MeshLib Documentation
Loading...
Searching...
No Matches
MRMoveObjectByMouseImpl.h
Go to the documentation of this file.
1#pragma once
2#include "MRMesh/MRPlane3.h"
5#include "MRViewer/MRMouse.h"
6#include "imgui.h"
7
8namespace MR
9{
10
15class MRVIEWER_CLASS MoveObjectByMouseImpl
16{
17public:
19 virtual ~MoveObjectByMouseImpl() = default;
20
24 int minDistance() const { return minDistance_; }
25 void setMinDistance( int minDistance ) { minDistance_ = minDistance; }
26
29 MRVIEWER_API void onDrawDialog( float menuScaling ) const;
30
37 MRVIEWER_API bool onMouseDown( MouseButton button, int modifiers );
38 MRVIEWER_API bool onMouseMove( int x, int y );
39 MRVIEWER_API bool onMouseUp( MouseButton button, int modifiers );
40
43 MRVIEWER_API bool isMoving() const;
44
48 MRVIEWER_API void cancel();
49
50protected:
52 enum class TransformMode
53 {
54 None,
57 Scale
58 };
59
66 MRVIEWER_API virtual TransformMode pick_( MouseButton button, int modifiers,
67 std::vector<std::shared_ptr<Object>>& objects, Vector3f& centerPoint, Vector3f& startPoint );
68
71 MRVIEWER_API Box3f getBbox_( const std::vector<std::shared_ptr<Object>>& objects );
72
73private:
74 int minDistance_ = 0;
75
76 void clear_();
77
78 void applyCurrentXf_( bool history );
79 void resetXfs_();
80
81 void setVisualizeVectors_( std::vector<Vector3f> worldPoints );
82
83 std::vector<std::shared_ptr<Object>> objects_;
84 std::vector<AffineXf3f> initialXfs_;
85
86 TransformMode transformMode_ = TransformMode::None;
87 Vector2i screenStartPoint_; // cNoPoint when moving actually started, {} when inactive
88 AffineXf3f currentXf_; // Transform currently applied to objects
89 MouseButton currentButton_ = MouseButton::NoButton;
90
91 // Data used to calculate transform
92 Vector3f worldStartPoint_; // World point corresponding to cursor, for transform calculation
93 Vector3f xfCenterPoint_;
94 float viewportStartPointZ_;
95 Plane3f referencePlane_;
96 float angle_ = 0.f;
97 float shift_ = 0.f;
98 float scale_ = 1.f;
99
100 std::vector<ImVec2> visualizeVectors_;
101};
102
103}
Definition MRMoveObjectByMouseImpl.h:16
virtual ~MoveObjectByMouseImpl()=default
MRVIEWER_API void onDrawDialog(float menuScaling) const
MRVIEWER_API bool onMouseMove(int x, int y)
MRVIEWER_API Box3f getBbox_(const std::vector< std::shared_ptr< Object > > &objects)
MRVIEWER_API bool onMouseUp(MouseButton button, int modifiers)
TransformMode
Transformation mode.
Definition MRMoveObjectByMouseImpl.h:53
MRVIEWER_API bool onMouseDown(MouseButton button, int modifiers)
MRVIEWER_API bool isMoving() const
int minDistance() const
Definition MRMoveObjectByMouseImpl.h:24
void setMinDistance(int minDistance)
Definition MRMoveObjectByMouseImpl.h:25
MRVIEWER_API void cancel()
virtual MRVIEWER_API TransformMode pick_(MouseButton button, int modifiers, std::vector< std::shared_ptr< Object > > &objects, Vector3f &centerPoint, Vector3f &startPoint)
@ None
special value not to limit path in one slice
Definition MRVoxelPath.h:33
Definition MRCameraOrientationPlugin.h:8
MouseButton
Definition MRMouse.h:9