#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 () |
void | enableHistory (bool history) |
enables or disables adding history to viewer history store by this tool | |
bool | isHistoryEnabled () const |
returns true if appending history to viewer history store is enabled in this tool | |
Protected Types | |
enum class | TransformMode { None , Translation , Rotation , UniformScale , NonUniformScale } |
Transformation mode. More... | |
Protected Member Functions | |
virtual MRVIEWER_API ObjAndPick | pickObjects_ (std::vector< std::shared_ptr< Object > > &objects, int modifiers) const |
virtual MRVIEWER_API TransformMode | modeFromPickModifiers_ (int modifiers) const |
Helper function to determine TransformMode based on modifiers. | |
virtual MRVIEWER_API TransformMode | modeFromPick_ (MouseButton button, int modifiers) const |
this function is called from onMouseDown to verify if pick should proceed, if None is returned - onMouseDown is canceled | |
virtual MRVIEWER_API void | setStartPoint_ (const ObjAndPick &pick, Vector3f &startPoint) const |
startPoint - a point under cursor for transform calculation, can be the picked point or else (world coordinates) | |
virtual MRVIEWER_API void | setCenterPoint_ (const std::vector< std::shared_ptr< Object > > &objects, Vector3f ¢erPoint) const |
centerPoint - a point that will be used as center of rotation/scaling in world space | |
MRVIEWER_API Box3f | getBbox_ (const std::vector< std::shared_ptr< Object > > &objects) const |
Protected Attributes | |
float | deadZonePixelRadius_ { 20.0f } |
AffineXf3f | currentXf_ |
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.
|
inline |
enables or disables adding history to viewer history store by this tool
|
protected |
Helper function to calculate world bounding box for several objects Note: can be invalid (feature objects give an invalid box etc.)
|
inline |
returns true if appending history to viewer history store is enabled in this tool
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)
|
protectedvirtual |
this function is called from onMouseDown
to verify if pick should proceed, if None is returned - onMouseDown
is canceled
|
protectedvirtual |
Helper function to determine TransformMode based on modifiers.
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 |
This function is called from onMouseMove
to update current active objects objects
- list of objects to be affected by transformation
|
protectedvirtual |
centerPoint
- a point that will be used as center of rotation/scaling in world space
|
inline |
|
protectedvirtual |
startPoint
- a point under cursor for transform calculation, can be the picked point or else (world coordinates)
|
protected |
|
protected |
if this value is > 0.0f, then Rotation and Scale will be blocked in this zone around xf center (this value IS automatically modified by menuScaling)