Easy3D 2.5.3
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 ()
 
 ~ManipulatedFrame () override=default
 
 ManipulatedFrame (const ManipulatedFrame &mf)
 
ManipulatedFrameoperator= (const ManipulatedFrame &mf)
 
Manipulation sensitivity
void setRotationSensitivity (float sensitivity)
 
void setTranslationSensitivity (float sensitivity)
 
void setWheelSensitivity (float sensitivity)
 
void setZoomSensitivity (float sensitivity)
 
float rotationSensitivity () const
 
float translationSensitivity () const
 
float zoomSensitivity () const
 
float wheelSensitivity () const
 
- Public Member Functions inherited from Frame
 Frame ()
 
virtual ~Frame ()
 
 Frame (const Frame &frame)
 
Frameoperator= (const Frame &frame)
 
 Frame (const vec3 &position, const quat &orientation)
 
void setPosition (const vec3 &position)
 
void setPositionWithConstraint (vec3 &position)
 
void setOrientation (const quat &orientation)
 
void setOrientationWithConstraint (quat &orientation)
 
void setPositionAndOrientation (const vec3 &position, const quat &orientation)
 
void setPositionAndOrientationWithConstraint (vec3 &position, quat &orientation)
 
vec3 position () const
 
quat orientation () const
 
void setTranslation (const vec3 &translation)
 
void setTranslationWithConstraint (vec3 &translation)
 
void setRotation (const quat &rotation)
 
void setRotationWithConstraint (quat &rotation)
 
void setTranslationAndRotation (const vec3 &translation, const quat &rotation)
 
void setTranslationAndRotationWithConstraint (vec3 &translation, quat &rotation)
 
vec3 translation () const
 
quat rotation () const
 
const FramereferenceFrame () const
 
void setReferenceFrame (const Frame *const refFrame)
 
bool settingAsReferenceFrameWillCreateALoop (const Frame *const frame)
 
void translate (vec3 &t)
 
void translate (const vec3 &t)
 
void rotate (quat &q)
 
void rotate (const quat &q)
 
void rotateAroundPoint (quat &rotation, const vec3 &point)
 
void rotateAroundPoint (const quat &rotation, const vec3 &point)
 
void alignWithFrame (const Frame *const frame, bool move=false, float threshold=0.0f)
 
void projectOnLine (const vec3 &origin, const vec3 &direction)
 
vec3 coordinatesOf (const vec3 &src) const
 
vec3 inverseCoordinatesOf (const vec3 &src) const
 
vec3 localCoordinatesOf (const vec3 &src) const
 
vec3 localInverseCoordinatesOf (const vec3 &src) const
 
vec3 coordinatesOfIn (const vec3 &src, const Frame *const in) const
 
vec3 coordinatesOfFrom (const vec3 &src, const Frame *const from) const
 
vec3 transformOf (const vec3 &src) const
 
vec3 inverseTransformOf (const vec3 &src) const
 
vec3 localTransformOf (const vec3 &src) const
 
vec3 localInverseTransformOf (const vec3 &src) const
 
vec3 transformOfIn (const vec3 &src, const Frame *const in) const
 
vec3 transformOfFrom (const vec3 &src, const Frame *const from) const
 
Constraintconstraint () const
 
void setConstraint (Constraint *const constraint)
 
mat4 matrix () const
 
mat4 worldMatrix () const
 
void setFromMatrix (const mat4 &m)
 
Frame inverse () const
 
Frame worldInverse () const
 

Frame manipulation

enum  ScreenAxis { NONE , HORIZONTAL , VERTICAL , ORTHOGONAL }
 
class Viewer
 
virtual void action_start ()
 
virtual void action_end ()
 
virtual void action_rotate (int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis)
 
virtual void action_translate (int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis)
 
virtual void action_zoom (int dy_wheel, Camera *camera)
 

Additional Inherited Members

- Public Attributes inherited from Frame
Signal modified
 

Detailed Description

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

A ManipulatedFrame converts the mouse motion into a translation and an 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 a great reactivity in your applications.

A ManipulatedFrame is attached to a QGLViewer using QGLViewer::setManipulatedFrame():

init() { setManipulatedFrame( new
draw()
{
glPushMatrix();
glMultMatrixd(manipulatedFrame()->matrix());
// draw the manipulated object here
glPopMatrix();
}
mat4 matrix() const
Definition: frame.cpp:141
ManipulatedFrame()
Definition: manipulated_frame.cpp:54

See the manipulatedFrame example for a complete application.

Mouse events are normally sent to the QGLViewer::camera(). You have to press the QGLViewer::FRAME state key (default is Control) to move the QGLViewer::manipulatedFrame() instead. See the mouse page for a description of mouse button bindings.

Inherited functionalities

A ManipulatedFrame is an overloaded instance of a Frame. The powerful coordinate system transformation functions (Frame::coordinatesOf(), Frame::transformOf(), ...) can hence be applied to a ManipulatedFrame.

A ManipulatedFrame is also a MouseGrabber. If the mouse cursor gets within a distance of 10 pixels from the projected position of the ManipulatedFrame, the ManipulatedFrame becomes the new QGLViewer::mouseGrabber(). It can then be manipulated directly, without any specific state key, object selection or GUI intervention. This is very convenient to directly move some objects in the scene (typically a light). See the mouseGrabber example as an illustration. Note that QWidget::setMouseTracking() needs to be enabled in order to use this feature (see the MouseGrabber documentation).

Advanced functionalities

A QGLViewer can handle at most one ManipulatedFrame at a time. If you want to move several objects in the scene, you simply have to keep a list of the different ManipulatedFrames, and to activate the right one (using QGLViewer::setManipulatedFrame()) when needed. This can for instance be done according to an object selection: see the luxo example for an illustration.

When the ManipulatedFrame is being manipulated using the mouse (mouse pressed and not yet released), isManipulated() returns true. This might be used to trigger a specific action or display (as is done with QGLViewer::fastDraw()).

The ManipulatedFrame also emits a manipulated() signal each time its state is modified by the mouse. This signal is automatically connected to the QGLViewer::update() slot when the ManipulatedFrame is attached to a viewer using QGLViewer::setManipulatedFrame().

Examples
Tutorial_405_ObjectManipulation.

Constructor & Destructor Documentation

◆ ManipulatedFrame() [1/2]

Default constructor.

The translation is set to (0,0,0), with an identity rotation (0,0,0,1) (see Frame constructor for details).

The different sensitivities are set to their default values (see rotationSensitivity(), translationSensitivity(), spinningSensitivity() and wheelSensitivity()).

◆ ~ManipulatedFrame()

~ManipulatedFrame ( )
overridedefault

Virtual destructor. Empty.

◆ ManipulatedFrame() [2/2]

Copy constructor. Performs a deep copy of all attributes using operator=().

Member Function Documentation

◆ action_end()

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.
Examples
Tutorial_203_Viewer_wxWidgets, and Tutorial_204_Viewer_Qt.

◆ action_rotate()

void action_rotate ( int  x,
int  y,
int  dx,
int  dy,
Camera camera,
ScreenAxis  axis 
)
virtual

Modifies the ManipulatedFrame according to the mouse motion.

Actual behavior depends on mouse bindings. See the QGLViewer::MouseAction enum and the QGLViewer mouse page for details.

The camera is used to fit the mouse motion with the display parameters (see Camera::screenWidth(), Camera::screenHeight(), Camera::fieldOfView()).

Emits the manipulated() signal.

Reimplemented in ManipulatedCameraFrame.

Examples
Tutorial_405_ObjectManipulation, and visualization_cross_section.

◆ action_start()

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.
Examples
Tutorial_203_Viewer_wxWidgets, and Tutorial_204_Viewer_Qt.

◆ operator=()

ManipulatedFrame & operator= ( const ManipulatedFrame mf)

Equal operator. Calls Frame::operator=() and then copy attributes.

◆ rotationSensitivity()

float rotationSensitivity ( ) const
inline

Returns 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()).

See also setRotationSensitivity(), translationSensitivity(), spinningSensitivity() and wheelSensitivity().

◆ setRotationSensitivity()

void setRotationSensitivity ( float  sensitivity)
inline

Defines the rotationSensitivity().

◆ setTranslationSensitivity()

void setTranslationSensitivity ( float  sensitivity)
inline

◆ setWheelSensitivity()

void setWheelSensitivity ( float  sensitivity)
inline

Defines the wheelSensitivity().

◆ setZoomSensitivity()

void setZoomSensitivity ( float  sensitivity)
inline

Defines the zoomSensitivity().

◆ translationSensitivity()

float translationSensitivity ( ) const
inline

Returns 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()).

Note
When the ManipulatedFrame is used to move a Camera (see the ManipulatedCameraFrame class documentation), after zooming on a small region of your scene, the camera may translate too fast. For a camera, it is the Camera::pivotPoint() that exactly matches the mouse displacement. Hence, instead of changing the translationSensitivity(), solve the problem by (temporarily) setting the Camera::pivotPoint() to a point on the zoomed region (see the QGLViewer::RAP_FROM_PIXEL mouse binding in the mouse page).

See also setTranslationSensitivity(), rotationSensitivity(), spinningSensitivity() and wheelSensitivity().

◆ wheelSensitivity()

float wheelSensitivity ( ) const
inline

Returns the mouse 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.

See also setWheelSensitivity(), translationSensitivity(), rotationSensitivity() zoomSensitivity() and spinningSensitivity().

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

See also setZoomSensitivity(), translationSensitivity(), rotationSensitivity() wheelSensitivity() and spinningSensitivity().


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