MeshLib
 
Loading...
Searching...
No Matches
MR::MoveObjectByMouseImpl Class Reference

#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 &centerPoint, Vector3f &startPoint)
 
MRVIEWER_API Box3f getBbox_ (const std::vector< std::shared_ptr< Object > > &objects)
 

Detailed Description

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

Member Enumeration Documentation

◆ TransformMode

enum class MR::MoveObjectByMouseImpl::TransformMode
strongprotected

Transformation mode.

Enumerator
None 
Translation 
Rotation 
Scale 

Constructor & Destructor Documentation

◆ MoveObjectByMouseImpl()

MR::MoveObjectByMouseImpl::MoveObjectByMouseImpl ( )
default

◆ ~MoveObjectByMouseImpl()

virtual MR::MoveObjectByMouseImpl::~MoveObjectByMouseImpl ( )
virtualdefault

Member Function Documentation

◆ cancel()

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.

◆ getBbox_()

MRVIEWER_API Box3f MR::MoveObjectByMouseImpl::getBbox_ ( const std::vector< std::shared_ptr< Object > > & objects)
protected

Helper function to calculate world bounding box for several objects Note: can be invalid (feature objects give an invalid box etc.)

◆ isMoving()

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

◆ minDistance()

int MR::MoveObjectByMouseImpl::minDistance ( ) const
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)

◆ onDrawDialog()

MRVIEWER_API void MR::MoveObjectByMouseImpl::onDrawDialog ( float menuScaling) const

Drawing callback to draw lines and tooltips Should be called from drawDialog

◆ onMouseDown()

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)

◆ onMouseMove()

MRVIEWER_API bool MR::MoveObjectByMouseImpl::onMouseMove ( int x,
int y )

◆ onMouseUp()

MRVIEWER_API bool MR::MoveObjectByMouseImpl::onMouseUp ( MouseButton button,
int modifiers )

◆ pick_()

virtual MRVIEWER_API TransformMode MR::MoveObjectByMouseImpl::pick_ ( MouseButton button,
int modifiers,
std::vector< std::shared_ptr< Object > > & objects,
Vector3f & centerPoint,
Vector3f & startPoint )
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

◆ setMinDistance()

void MR::MoveObjectByMouseImpl::setMinDistance ( int minDistance)
inline

The documentation for this class was generated from the following file: