Easy3D 2.5.3
|
A Frame that can be rotated and translated using the mouse. More...
#include <easy3d/renderer/manipulated_frame.h>
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 |
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():
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.
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).
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().
ManipulatedFrame | ( | ) |
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()).
|
overridedefault |
Virtual destructor. Empty.
ManipulatedFrame | ( | const ManipulatedFrame & | mf | ) |
Copy constructor. Performs a deep copy of all attributes using operator=().
|
virtual |
Stops the ManipulatedFrame mouse manipulation.
|
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.
|
virtual |
Initiates the ManipulatedFrame mouse manipulation.
ManipulatedFrame & operator= | ( | const ManipulatedFrame & | mf | ) |
Equal operator. Calls Frame::operator=() and then copy attributes.
|
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().
|
inline |
Defines the rotationSensitivity().
|
inline |
Defines the translationSensitivity().
|
inline |
Defines the wheelSensitivity().
|
inline |
Defines the zoomSensitivity().
|
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()).
See also setTranslationSensitivity(), rotationSensitivity(), spinningSensitivity() and wheelSensitivity().
|
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().
|
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().