MeshLib C++ Docs
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 ()
 
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 &centerPoint) 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_
 

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 
UniformScale 
NonUniformScale 

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.

◆ enableHistory()

void MR::MoveObjectByMouseImpl::enableHistory ( bool history)
inline

enables or disables adding history to viewer history store by this tool

◆ getBbox_()

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

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

◆ isHistoryEnabled()

bool MR::MoveObjectByMouseImpl::isHistoryEnabled ( ) const
inline

returns true if appending history to viewer history store is enabled in this tool

◆ 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)

◆ modeFromPick_()

virtual MRVIEWER_API TransformMode MR::MoveObjectByMouseImpl::modeFromPick_ ( MouseButton button,
int modifiers ) const
protectedvirtual

this function is called from onMouseDown to verify if pick should proceed, if None is returned - onMouseDown is canceled

◆ modeFromPickModifiers_()

virtual MRVIEWER_API TransformMode MR::MoveObjectByMouseImpl::modeFromPickModifiers_ ( int modifiers) const
protectedvirtual

Helper function to determine TransformMode based on modifiers.

◆ 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 )

◆ pickObjects_()

virtual MRVIEWER_API ObjAndPick MR::MoveObjectByMouseImpl::pickObjects_ ( std::vector< std::shared_ptr< Object > > & objects,
int modifiers ) const
protectedvirtual

This function is called from onMouseMove to update current active objects objects - list of objects to be affected by transformation

◆ setCenterPoint_()

virtual MRVIEWER_API void MR::MoveObjectByMouseImpl::setCenterPoint_ ( const std::vector< std::shared_ptr< Object > > & objects,
Vector3f & centerPoint ) const
protectedvirtual

centerPoint - a point that will be used as center of rotation/scaling in world space

◆ setMinDistance()

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

◆ setStartPoint_()

virtual MRVIEWER_API void MR::MoveObjectByMouseImpl::setStartPoint_ ( const ObjAndPick & pick,
Vector3f & startPoint ) const
protectedvirtual

startPoint - a point under cursor for transform calculation, can be the picked point or else (world coordinates)

Member Data Documentation

◆ currentXf_

AffineXf3f MR::MoveObjectByMouseImpl::currentXf_
protected

◆ deadZonePixelRadius_

float MR::MoveObjectByMouseImpl::deadZonePixelRadius_ { 20.0f }
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)


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