Easy3D 2.6.1
Loading...
Searching...
No Matches
ManipulatedFrame Class Reference

A Frame that can be rotated and translated using the mouse. More...

#include <easy3d/renderer/manipulated_frame.h>

Inheritance diagram for ManipulatedFrame:
Frame ManipulatedCameraFrame

Public Member Functions

 ManipulatedFrame ()
 Default constructor.
 
 ~ManipulatedFrame () override=default
 
 ManipulatedFrame (const ManipulatedFrame &mf)
 Copy constructor.
 
ManipulatedFrameoperator= (const ManipulatedFrame &mf)
 Copy assignment operator.
 
Manipulation sensitivity
void setRotationSensitivity (float sensitivity)
 Sets the rotation sensitivity.
 
void setTranslationSensitivity (float sensitivity)
 Sets the translation sensitivity.
 
void setWheelSensitivity (float sensitivity)
 Sets the wheel sensitivity.
 
void setZoomSensitivity (float sensitivity)
 Sets the zoom sensitivity.
 
float rotationSensitivity () const
 Returns the rotation sensitivity.
 
float translationSensitivity () const
 Returns the translation sensitivity.
 
float zoomSensitivity () const
 Returns the zoom sensitivity.
 
float wheelSensitivity () const
 Returns the wheel sensitivity.
 
- Public Member Functions inherited from Frame
 Frame ()
 Default constructor.
 
virtual ~Frame ()
 
 Frame (const Frame &frame)
 Copy constructor.
 
Frameoperator= (const Frame &frame)
 Assignment operator.
 
 Frame (const vec3 &position, const quat &orientation)
 Constructor with position and orientation.
 
void setPosition (const vec3 &position)
 Sets the position of the Frame.
 
void setPositionWithConstraint (vec3 &position)
 Sets the position of the Frame with constraint.
 
void setOrientation (const quat &orientation)
 Sets the orientation of the Frame.
 
void setOrientationWithConstraint (quat &orientation)
 Sets the orientation of the Frame with constraint.
 
void setPositionAndOrientation (const vec3 &position, const quat &orientation)
 Sets the position and orientation of the Frame.
 
void setPositionAndOrientationWithConstraint (vec3 &position, quat &orientation)
 Sets the position and orientation of the Frame with constraint.
 
vec3 position () const
 Returns the position of the Frame.
 
quat orientation () const
 Returns the orientation of the Frame.
 
void setTranslation (const vec3 &translation)
 Sets the translation of the Frame.
 
void setTranslationWithConstraint (vec3 &translation)
 Sets the translation of the Frame with constraint.
 
void setRotation (const quat &rotation)
 Sets the rotation of the Frame.
 
void setRotationWithConstraint (quat &rotation)
 Sets the rotation of the Frame with constraint.
 
void setTranslationAndRotation (const vec3 &translation, const quat &rotation)
 Sets the translation and rotation of the Frame.
 
void setTranslationAndRotationWithConstraint (vec3 &translation, quat &rotation)
 Sets the translation and rotation of the Frame with constraint.
 
vec3 translation () const
 Returns the translation of the Frame.
 
quat rotation () const
 Returns the rotation of the Frame.
 
const FramereferenceFrame () const
 Returns the reference Frame.
 
void setReferenceFrame (const Frame *refFrame)
 Sets the reference Frame.
 
bool settingAsReferenceFrameWillCreateALoop (const Frame *const frame) const
 Checks if setting the reference Frame will create a loop.
 
void translate (vec3 &t)
 Translates the Frame.
 
void translate (const vec3 &t)
 Translates the Frame.
 
void rotate (quat &q)
 Rotates the Frame.
 
void rotate (const quat &q)
 Rotates the Frame.
 
void rotateAroundPoint (quat &rotation, const vec3 &point)
 Rotates the Frame around a point.
 
void rotateAroundPoint (const quat &rotation, const vec3 &point)
 Rotates the Frame around a point.
 
void alignWithFrame (const Frame *const frame, bool move=false, float threshold=0.0f)
 Aligns the Frame with another Frame.
 
void projectOnLine (const vec3 &origin, const vec3 &direction)
 Projects the Frame on a line.
 
vec3 coordinatesOf (const vec3 &src) const
 Transforms a 3D point to the Frame's coordinate system.
 
vec3 inverseCoordinatesOf (const vec3 &src) const
 Transforms a 3D point from the Frame's coordinate system to the world coordinate system.
 
vec3 localCoordinatesOf (const vec3 &src) const
 Transforms a 3D point to the Frame's local coordinate system.
 
vec3 localInverseCoordinatesOf (const vec3 &src) const
 Transforms a 3D point from the Frame's local coordinate system to the world coordinate system.
 
vec3 coordinatesOfIn (const vec3 &src, const Frame *const in) const
 Transforms a 3D point to another Frame's coordinate system.
 
vec3 coordinatesOfFrom (const vec3 &src, const Frame *const from) const
 Transforms a 3D point from another Frame's coordinate system to the Frame's coordinate system.
 
vec3 transformOf (const vec3 &src) const
 Transforms a 3D vector to the Frame's coordinate system.
 
vec3 inverseTransformOf (const vec3 &src) const
 Transforms a 3D vector from the Frame's coordinate system to the world coordinate system.
 
vec3 localTransformOf (const vec3 &src) const
 Transforms a 3D vector to the Frame's local coordinate system.
 
vec3 localInverseTransformOf (const vec3 &src) const
 Transforms a 3D vector from the Frame's local coordinate system to the world coordinate system.
 
vec3 transformOfIn (const vec3 &src, const Frame *const in) const
 Transforms a 3D vector to another Frame's coordinate system.
 
vec3 transformOfFrom (const vec3 &src, const Frame *const from) const
 Transforms a 3D vector from another Frame's coordinate system to the Frame's coordinate system.
 
Constraintconstraint () const
 Returns the current constraint applied to the Frame.
 
void setConstraint (Constraint *const constraint)
 Sets the constraint attached to the Frame.
 
mat4 matrix () const
 Returns the transformation matrix of the Frame.
 
mat4 worldMatrix () const
 Returns the world transformation matrix of the Frame.
 
void setFromMatrix (const mat4 &m)
 Sets the Frame from a transformation matrix.
 
Frame inverse () const
 Returns the inverse of the Frame.
 
Frame worldInverse () const
 Returns the inverse of the Frame's world transformation.
 

Frame manipulation

enum  ScreenAxis { NONE , HORIZONTAL , VERTICAL , ORTHOGONAL }
 ScreenAxis constrains rotation or translation around/along the axis. More...
 
class Viewer
 
virtual void action_start ()
 Initiates the ManipulatedFrame mouse manipulation.
 
virtual void action_end ()
 Stops the ManipulatedFrame mouse manipulation.
 
virtual void action_rotate (int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis)
 Rotates the frame based on mouse movement.
 
virtual void action_translate (int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis)
 Translates the frame based on mouse movement.
 
virtual void action_zoom (int dy_wheel, Camera *camera)
 Zooms the frame based on mouse wheel movement.
 

Additional Inherited Members

Signal modified
 Signal emitted when the Frame is modified.
 

Detailed Description

A Frame that can be rotated and translated using the mouse.

A ManipulatedFrame converts the mouse motion into translation and orientation updates. A ManipulatedFrame is used to move an object in the scene. Combined with object selection, its MouseGrabber properties and a dynamic update of the scene, the ManipulatedFrame introduces great reactivity in your applications.

Examples
Tutorial_405_ObjectManipulation/main.cpp.

Member Enumeration Documentation

◆ ScreenAxis

enum ScreenAxis

ScreenAxis constrains rotation or translation around/along the axis.

Enumerator
NONE 

No constraint.

HORIZONTAL 

Horizontal constraint.

VERTICAL 

Vertical constraint.

ORTHOGONAL 

Orthogonal constraint.

Constructor & Destructor Documentation

◆ ~ManipulatedFrame()

~ManipulatedFrame ( )
overridedefault

Virtual destructor. Empty.

◆ ManipulatedFrame()

Copy constructor.

Parameters
mfThe ManipulatedFrame to copy from.

Member Function Documentation

◆ action_end()

virtual void action_end ( )
virtual

Stops the ManipulatedFrame mouse manipulation.

Note
This function should be called when an action (e.g., drag) ends, e.g., mouse released.

◆ action_rotate()

virtual void action_rotate ( int mouse_x,
int mouse_y,
int mouse_dx,
int mouse_dy,
Camera * camera,
ScreenAxis axis )
virtual

Rotates the frame based on mouse movement.

Parameters
mouse_xThe current x position of the mouse.
mouse_yThe current y position of the mouse.
mouse_dxThe change in x position of the mouse.
mouse_dyThe change in y position of the mouse.
cameraThe camera associated with the frame.
axisThe axis of rotation.

Reimplemented in ManipulatedCameraFrame.

Examples
Tutorial_307_CrossSection/main.cpp, and Tutorial_405_ObjectManipulation/main.cpp.

◆ action_start()

virtual void action_start ( )
virtual

Initiates the ManipulatedFrame mouse manipulation.

Note
This function should be called when an action (e.g., drag) starts, e.g., mouse pressed.

◆ action_translate()

virtual void action_translate ( int mouse_x,
int mouse_y,
int mouse_dx,
int mouse_dy,
Camera * camera,
ScreenAxis axis )
virtual

Translates the frame based on mouse movement.

Parameters
mouse_xThe current x position of the mouse.
mouse_yThe current y position of the mouse.
mouse_dxThe change in x position of the mouse.
mouse_dyThe change in y position of the mouse.
cameraThe camera associated with the frame.
axisThe axis of translation.

Reimplemented in ManipulatedCameraFrame.

Examples
Tutorial_405_ObjectManipulation/main.cpp.

◆ action_zoom()

virtual void action_zoom ( int dy_wheel,
Camera * camera )
virtual

Zooms the frame based on mouse wheel movement.

Parameters
dy_wheelThe change in the mouse wheel position.
cameraThe camera associated with the frame.

Reimplemented in ManipulatedCameraFrame.

◆ operator=()

ManipulatedFrame & operator= ( const ManipulatedFrame & mf)

Copy assignment operator.

Parameters
mfThe ManipulatedFrame to assign from.
Returns
A reference to this ManipulatedFrame.

◆ rotationSensitivity()

float rotationSensitivity ( ) const
inline

Returns the rotation sensitivity.

The rotation sensitivity is the influence of a mouse displacement on the ManipulatedFrame rotation. Default value is 1.0. With an identical mouse displacement, a higher value will generate a larger rotation (and inversely for lower values). A 0.0 value will forbid ManipulatedFrame mouse rotation (see also constraint()).

Returns
The rotation sensitivity.
See also
setRotationSensitivity(), translationSensitivity(), zoomSensitivity(), and wheelSensitivity().

◆ setRotationSensitivity()

void setRotationSensitivity ( float sensitivity)
inline

Sets the rotation sensitivity.

Parameters
sensitivityThe new rotation sensitivity.

◆ setTranslationSensitivity()

void setTranslationSensitivity ( float sensitivity)
inline

Sets the translation sensitivity.

Parameters
sensitivityThe new translation sensitivity.

◆ setWheelSensitivity()

void setWheelSensitivity ( float sensitivity)
inline

Sets the wheel sensitivity.

Parameters
sensitivityThe new wheel sensitivity.

◆ setZoomSensitivity()

void setZoomSensitivity ( float sensitivity)
inline

Sets the zoom sensitivity.

Parameters
sensitivityThe new zoom sensitivity.

◆ translationSensitivity()

float translationSensitivity ( ) const
inline

Returns the translation sensitivity.

The translation sensitivity is the influence of a mouse displacement on the ManipulatedFrame translation. Default value is 1.0. You should not have to modify this value, since with 1.0 the ManipulatedFrame precisely stays under the mouse cursor. With an identical mouse displacement, a higher value will generate a larger translation (and inversely for lower values). A 0.0 value will forbid ManipulatedFrame mouse translation (see also constraint()).

Returns
The translation sensitivity.
See also
setTranslationSensitivity(), rotationSensitivity(), zoomSensitivity(), and wheelSensitivity().

◆ wheelSensitivity()

float wheelSensitivity ( ) const
inline

Returns the wheel sensitivity.

Default value is 1.0. A higher value will make the wheel action more efficient (usually meaning a faster zoom). Use a negative value to invert the zoom in and out directions.

Returns
The wheel sensitivity.
See also
setWheelSensitivity(), translationSensitivity(), rotationSensitivity(), and zoomSensitivity().

◆ zoomSensitivity()

float zoomSensitivity ( ) const
inline

Returns the zoom sensitivity.

Default value is 1.0. A higher value will make the zoom faster. Use a negative value to invert the zoom in and out directions.

Returns
The zoom sensitivity.
See also
setZoomSensitivity(), translationSensitivity(), rotationSensitivity(), and wheelSensitivity().

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