#include <MRMoveObjectByMouseImpl.h>
Public Member Functions | |
MoveObjectByMouseImpl ()=default | |
virtual | ~MoveObjectByMouseImpl ()=default |
int | minDistance () const |
void | setMinDistance (int minDistance) |
MRVIEWER_API void | onDrawDialog (float menuScaling) const |
MRVIEWER_API bool | onMouseDown (MouseButton button, int modifiers) |
MRVIEWER_API bool | onMouseMove (int x, int y) |
MRVIEWER_API bool | onMouseUp (MouseButton button, int modifiers) |
MRVIEWER_API bool | isMoving () const |
MRVIEWER_API void | cancel () |
Protected Types | |
enum class | TransformMode { None , Translation , Rotation , Scale } |
Transformation mode. More... | |
Protected Member Functions | |
virtual MRVIEWER_API TransformMode | pick_ (MouseButton button, int modifiers, std::vector< std::shared_ptr< Object > > &objects, Vector3f ¢erPoint, Vector3f &startPoint) |
MRVIEWER_API Box3f | getBbox_ (const std::vector< std::shared_ptr< Object > > &objects) |
Helper class to incorporate basic object transformation feature into plugins User can move objects by dragging them, rotate by dragging with Ctrl key; scaling is disabled by default To use, create class instance and call its event handlers For extra features, override the pick_
method
|
strongprotected |
|
default |
|
virtualdefault |
MRVIEWER_API void MR::MoveObjectByMouseImpl::cancel | ( | ) |
Reset transformation and stop moving the object(s). Does nothing if not moving anything Calling onMouseUp
is not necessary after this Should be called when closing plugin etc.
|
protected |
Helper function to calculate world bounding box for several objects Note: can be invalid (feature objects give an invalid box etc.)
MRVIEWER_API bool MR::MoveObjectByMouseImpl::isMoving | ( | ) | const |
Returns true if currently moving object(s) Return false if not active, or object picked but minDistance
has not yet reached
|
inline |
Minimum drag distance in screen pixels If cursor moved less than this value, no transform is done Default value 0 (set transformation even if mouse did not move)
MRVIEWER_API void MR::MoveObjectByMouseImpl::onDrawDialog | ( | float | menuScaling | ) | const |
Drawing callback to draw lines and tooltips Should be called from drawDialog
MRVIEWER_API bool MR::MoveObjectByMouseImpl::onMouseDown | ( | MouseButton | button, |
int | modifiers ) |
These functions should be called from corresponding mouse handlers Or mouse drag handlers, making it work together with mouseClick signal Return true if handled (picked/moved/released) It is recommended to call viewer->select_hovered_viewport()
before onMouseDown
The object is transformed temporarily in onMouseMove
onMouseUp
finalizes the transformation and writes to undo/redo history (unless cancelled)
MRVIEWER_API bool MR::MoveObjectByMouseImpl::onMouseMove | ( | int | x, |
int | y ) |
MRVIEWER_API bool MR::MoveObjectByMouseImpl::onMouseUp | ( | MouseButton | button, |
int | modifiers ) |
|
protectedvirtual |
Called from onMouseDown
Returns chosen TransformMode
to start transformation, None
to skip; fills the output parameters: objects
- list of objects to be affected by transformation centerPoint
- center point for rotation (world coordinates) startPoint
- a point under cursor for transform calculation, can be the picked point or else (world coordinates) Default implementation can be used as a reference for custom implementations
|
inline |