vcg::Trackball Class Reference

The manipulator manager system. More...

#include <trackball.h>

Inheritance diagram for vcg::Trackball:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Button {
  BUTTON_NONE = 0x0000, BUTTON_LEFT = 0x0001, BUTTON_MIDDLE = 0x0002, BUTTON_RIGHT = 0x0004,
  WHEEL = 0x0008, KEY_SHIFT = 0x0010, KEY_CTRL = 0x0020, KEY_ALT = 0x0040,
  HANDLE = 0x0080, MODIFIER_MASK = 0x00FF, KEY_UP = 0x0100, KEY_DOWN = 0x0200,
  KEY_LEFT = 0x0400, KEY_RIGHT = 0x0800, KEY_PGUP = 0x1000, KEY_PGDOWN = 0x2000
}
 

The componibile states of the manipulator system.

More...

Public Member Functions

void Animate (unsigned int msec=0)
void Apply ()
 Old application of the transformation.
void Apply (bool Draw)
 Apply the current transformation on the OpenGL modelview matrix.
void ApplyInverse ()
 Apply the inverse of current transformation on the OpenGL modelview matrix.
void Back ()
 Currently not in use.
void ButtonDown (Button button, unsigned int msec=0)
 Interface function relative to key up event in QT/SDL.
void ButtonUp (Button button)
 Interface function relative to key down event in QT/SDL.
void ClearModes ()
 clear the modes map. Taking the right care of not doubledeleting anything.
void DrawPostApply ()
 Draw the current manipulator.
void Forward ()
 Currently not in use.
void GetView ()
 Initialize the camera instance.
void HistorySize (int lenght)
 Currently not in use.
void Home ()
 Currently not in use.
Matrix44f InverseMatrix () const
bool IsAnimating (unsigned int msec=0)
bool IsSpinnable ()
 Currently not in use.
bool IsSpinning ()
 Currently not in use.
Matrix44f Matrix () const
void MouseDown (int x, int y, int button)
 Interface function relative to mouse down event in QT/SDL.
void MouseDown (int button)
 Interface function relative to mouse down event in QT/SDL.
void MouseMove (int x, int y)
 Interface function relative to mouse down event in QT/SDL.
void MouseUp (int x, int y, int button)
 Interface function relative to mouse down event in QT/SDL.
void MouseWheel (float notch, int button)
 Interface function relative to mouse down event in QT/SDL.
void MouseWheel (float notch)
 Old interface function relative to mouse down event in QT/SDL.
void Reset ()
 Reset the transformation and every mapped manipulator.
void Scale (const float f)
 Apply a scaling on the current transformation.
void SetCurrentAction ()
 Prepare Trackball and every mapped TrackMode for an user action.
void setDefaultMapping ()
 Reset modes to default mapping.
void SetFixedTimesteps (bool mode)
bool SetFromAscii (const char *st)
 Loads current status from an ascii stings.
void SetIdentity ()
 Reset the trackball.
void SetPosition (const Point3f &c, int millisec=0)
 Set the position of the trackball.
void SetScale (const float s)
 Currently not in use.
void SetSensitivity (float s)
 Currently not in use.
void SetSpinnable (bool on)
void SetSpinning (Quaternionf &spin)
 Currently not in use.
void SetTransform (const Transform &transform, int millisec=0)
 Currently not in use.
void StopSpinning ()
 Currently not in use.
void Store ()
 Currently not in use.
void ToAscii (char *st)
 Stores current status into an ascii stings.
 Trackball ()
 The constructor.
void Translate (Point3f tr)
 Apply a translation on the current transformation.
void Undo ()
 Undo function for manipulator system.
 ~Trackball ()
 The destructor.

Public Attributes

int button_mask
 Currently not in use.
View< float > camera
 The reference for point projection and unprojection from screen space to modelspace.
int current_button
 Current state composition. Note: mask with MODIFIERS to get modifier buttons only.
TrackModecurrent_mode
 The selected manipulator.
bool dragging
 Currently not in use.
std::list< Transformhistory
 Currently not in use.
int history_size
 Currently not in use.
std::vector< Point3fHits
 Currently not in use.
TrackModeidle_and_keys_mode
TrackModeinactive_mode
 The inactive manipulator. It is drawn when Trackball is inactive.
Point3f last_point
 Mouse cursor coordinates before current action.
unsigned int last_time
Similarityf last_track
 Transformation before current user action.
Similarityf last_view
 Currently not in use.
std::map< int, TrackMode * > modes
 The manipulator mapping. Needs to be explicitally managed for custom mappings.
Quaternionf spin
 Currently not in use.
bool spinnable
 Currently not in use.
bool spinning
 Currently not in use.
Similarityf undo_track
 track after an Undo() call.

Private Member Functions

Trackball operator= (const Trackball &)
void Sync (unsigned int msec)

Private Attributes

bool fixedTimestepMode

Friends

class TrackMode
 Manipulators needs full access to this class.

Detailed Description

The manipulator manager system.

Short usage note:

When you specify a translation with the trackball the trackball center remain unchanged, in other words it means that the object move out of the trackball icon. Similarly when you apply a scaling the size of the manipulator icon do not change.

Typical use:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, float(width())/float(height()), 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,3,   0,0,0,   0,1,0)
trackball.center=Point3f(0, 0, 0);
trackball.radius= 1;
trackball.GetView();
trackball.Apply(true); //false if you want an invisible trackball
float d=1.0f/mesh.bbox.Diag();
glScale(d);
glTranslate(-mesh.bbox.Center());
mesh->Render();

Note on the typical use:

Definition at line 167 of file gui/trackball.h.


Member Enumeration Documentation

The componibile states of the manipulator system.

Enumerator:
BUTTON_NONE 

No button or key pressed.

BUTTON_LEFT 

Left mouse button pressed.

BUTTON_MIDDLE 

Middle mouse button pressed.

BUTTON_RIGHT 

Right mouse button pressed.

WHEEL 

Mouse wheel activated.

KEY_SHIFT 

Shift key pressed.

KEY_CTRL 

Ctrl key pressed.

KEY_ALT 

Alt key pressed.

HANDLE 

Application-defined state activated.

MODIFIER_MASK 

(mask to get modifiers only)

KEY_UP 

Up directional key.

KEY_DOWN 

Down directional key.

KEY_LEFT 

Left directional key.

KEY_RIGHT 

Right directional key.

KEY_PGUP 

PageUp directional key.

KEY_PGDOWN 

PageDown directional key.

Definition at line 171 of file gui/trackball.h.


Constructor & Destructor Documentation

Trackball::Trackball (  ) 

The constructor.

Initialize the internal state with default values and call setDefaultMapping().

Definition at line 127 of file trackball.cpp.

Trackball::~Trackball (  ) 

The destructor.

Warning:
The destructor does not deallocate the memory allocated by setDefaultMapping(), because the application can change the modes map. This can lead to small memory leaks, so please explicitally delete any manipulator in the modes map if you are going to repeatly allocate and deallocate Trackball instances.

Definition at line 133 of file trackball.cpp.


Member Function Documentation

void Trackball::Animate ( unsigned int  msec = 0  ) 

Definition at line 414 of file trackball.cpp.

void Trackball::Apply (  ) 

Old application of the transformation.

Warning:
This function does not call DrawPostApply() after the application.

Definition at line 197 of file trackball.cpp.

void Trackball::Apply ( bool  Draw  ) 

Apply the current transformation on the OpenGL modelview matrix.

Parameters:
Draw true if has to call DrawPostApply() after the application.

Definition at line 203 of file trackball.cpp.

void Trackball::ApplyInverse (  ) 

Apply the inverse of current transformation on the OpenGL modelview matrix.

Definition at line 211 of file trackball.cpp.

void Trackball::Back (  ) 

Currently not in use.

Definition at line 517 of file trackball.cpp.

void Trackball::ButtonDown ( Trackball::Button  button,
unsigned int  msec = 0 
)

Interface function relative to key up event in QT/SDL.

Parameters:
button the new state.

Definition at line 468 of file trackball.cpp.

void Trackball::ButtonUp ( Trackball::Button  button  ) 

Interface function relative to key down event in QT/SDL.

Parameters:
button the new state.

Definition at line 484 of file trackball.cpp.

void Trackball::ClearModes (  ) 

clear the modes map. Taking the right care of not doubledeleting anything.

Definition at line 139 of file trackball.cpp.

void Trackball::DrawPostApply (  ) 

Draw the current manipulator.

Call the draw function of the current manipulator. If no manipulator is selected call the draw function of the manipulator associated to inactive_mode.

Warning:
This function assumes that the OpenGL modelview matrix has been initialized with Apply ().

Definition at line 189 of file trackball.cpp.

void Trackball::Forward (  ) 

Currently not in use.

Definition at line 518 of file trackball.cpp.

void Trackball::GetView (  ) 

Initialize the camera instance.

Definition at line 184 of file trackball.cpp.

void Trackball::HistorySize ( int  lenght  ) 

Currently not in use.

Definition at line 520 of file trackball.cpp.

void Trackball::Home (  ) 

Currently not in use.

Definition at line 519 of file trackball.cpp.

Matrix44f Trackball::InverseMatrix (  )  const

Definition at line 233 of file trackball.cpp.

bool Trackball::IsAnimating ( unsigned int  msec = 0  ) 

Definition at line 397 of file trackball.cpp.

bool Trackball::IsSpinnable (  ) 

Currently not in use.

Returns:
A meaningless boolean value.

Definition at line 507 of file trackball.cpp.

bool Trackball::IsSpinning (  ) 

Currently not in use.

Returns:
A meaningless boolean value.

Definition at line 512 of file trackball.cpp.

Matrix44f Trackball::Matrix (  )  const

Definition at line 218 of file trackball.cpp.

void Trackball::MouseDown ( int  x,
int  y,
int  button 
)

Interface function relative to mouse down event in QT/SDL.

Parameters:
x The horizontal coordinate of the mouse pointer.
y The vertical coordinate of the mouse pointer.
button The new state.

Definition at line 379 of file trackball.cpp.

void Trackball::MouseDown ( int  button  ) 

Interface function relative to mouse down event in QT/SDL.

Parameters:
button The new state.

Definition at line 373 of file trackball.cpp.

void Trackball::MouseMove ( int  x,
int  y 
)

Interface function relative to mouse down event in QT/SDL.

Parameters:
x The horizontal coordinate of the mouse pointer.
y The vertical coordinate of the mouse pointer.

Definition at line 387 of file trackball.cpp.

void Trackball::MouseUp ( int  x,
int  y,
int  button 
)

Interface function relative to mouse down event in QT/SDL.

Parameters:
x The horizontal coordinate of the mouse pointer.
y The vertical coordinate of the mouse pointer.
button The new state.

Definition at line 426 of file trackball.cpp.

void Trackball::MouseWheel ( float  notch,
int  button 
)

Interface function relative to mouse down event in QT/SDL.

Parameters:
notch The mouse wheel notch (1: one forward step, -1: one backward step).
button The new state.

Definition at line 453 of file trackball.cpp.

void Trackball::MouseWheel ( float  notch  ) 

Old interface function relative to mouse down event in QT/SDL.

Parameters:
notch The mouse wheel notch (1: one forward step, -1: one backward step).

Definition at line 434 of file trackball.cpp.

Trackball vcg::Trackball::operator= ( const Trackball  )  [inline, private]

Definition at line 205 of file gui/trackball.h.

void Trackball::Reset (  ) 

Reset the transformation and every mapped manipulator.

Definition at line 360 of file trackball.cpp.

void Trackball::Scale ( const float  f  ) 

Apply a scaling on the current transformation.

Parameters:
f The scale factor.

Definition at line 237 of file trackball.cpp.

void Trackball::SetCurrentAction (  ) 

Prepare Trackball and every mapped TrackMode for an user action.

This function is called automatically when an user action begins.

Definition at line 522 of file trackball.cpp.

void Trackball::setDefaultMapping (  ) 

Reset modes to default mapping.

Set the default modes mapping. The default mapping is:

Warning:
The memory allocated by this function is not automatically deallocated. see ~Trackball().

Definition at line 155 of file trackball.cpp.

void vcg::Trackball::SetFixedTimesteps ( bool  mode  )  [inline]

Definition at line 525 of file gui/trackball.h.

bool Trackball::SetFromAscii ( const char *  st  ) 

Loads current status from an ascii stings.

Loads current status from an ascii stings. This is useful for example to implement cut-and-paste operations of trackball status, or to embed used trackball into a comment inside a screenshot, etc.

Parameters:
st The string where to read from (must be allocated). Use ToAscii() method to set it.
Returns:
True iff the trackball was successfully recovered.

Definition at line 287 of file trackball.cpp.

void Trackball::SetIdentity (  ) 

Reset the trackball.

Equivalent to Reset().

Definition at line 176 of file trackball.cpp.

void Trackball::SetPosition ( const Point3f c,
int  millisec = 0 
)

Set the position of the trackball.

Parameters:
c The new position of the trackball.
millisec Currently not in use.

Definition at line 180 of file trackball.cpp.

void vcg::Trackball::SetScale ( const float  s  )  [inline]

Currently not in use.

Parameters:
s Currently not in use.

Definition at line 225 of file gui/trackball.h.

void vcg::Trackball::SetSensitivity ( float  s  ) 

Currently not in use.

Parameters:
s Currently not in use.
void Trackball::SetSpinnable ( bool  on  ) 

Definition at line 506 of file trackball.cpp.

void Trackball::SetSpinning ( Quaternionf spin  ) 

Currently not in use.

Parameters:
spin Currently not in use.

Definition at line 510 of file trackball.cpp.

void vcg::Trackball::SetTransform ( const Transform transform,
int  millisec = 0 
)

Currently not in use.

Parameters:
transform Currently not in use.
millisec Currently not in use.
void Trackball::StopSpinning (  ) 

Currently not in use.

Definition at line 511 of file trackball.cpp.

void vcg::Trackball::Store (  ) 

Currently not in use.

void Trackball::Sync ( unsigned int  msec  )  [private]

Definition at line 410 of file trackball.cpp.

void Trackball::ToAscii ( char *  st  ) 

Stores current status into an ascii stings.

Stores current status into an ascii stings. This is useful for example to implement cut-and-paste operations of trackball status, or to embed used trackball into a comment inside a screenshot, etc.

Parameters:
st The string where to export (must be allocated).

Definition at line 281 of file trackball.cpp.

void Trackball::Translate ( Point3f  tr  ) 

Apply a translation on the current transformation.

Parameters:
tr The translation vector.

Definition at line 242 of file trackball.cpp.

void Trackball::Undo (  ) 

Undo function for manipulator system.

A call of this function restores the state before last user action. This function calls Undo() on every mapped manipulator.

Definition at line 498 of file trackball.cpp.


Friends And Related Function Documentation

friend class TrackMode [friend]

Manipulators needs full access to this class.

Definition at line 530 of file gui/trackball.h.


Member Data Documentation

Currently not in use.

Definition at line 508 of file gui/trackball.h.

The reference for point projection and unprojection from screen space to modelspace.

Definition at line 460 of file gui/trackball.h.

Current state composition. Note: mask with MODIFIERS to get modifier buttons only.

Definition at line 468 of file gui/trackball.h.

The selected manipulator.

Definition at line 470 of file gui/trackball.h.

Currently not in use.

Definition at line 506 of file gui/trackball.h.

Definition at line 533 of file gui/trackball.h.

Currently not in use.

Definition at line 520 of file gui/trackball.h.

Currently not in use.

Definition at line 522 of file gui/trackball.h.

Currently not in use.

Definition at line 504 of file gui/trackball.h.

Definition at line 476 of file gui/trackball.h.

The inactive manipulator. It is drawn when Trackball is inactive.

Definition at line 473 of file gui/trackball.h.

Mouse cursor coordinates before current action.

Definition at line 502 of file gui/trackball.h.

Definition at line 510 of file gui/trackball.h.

Transformation before current user action.

Definition at line 496 of file gui/trackball.h.

Currently not in use.

Definition at line 500 of file gui/trackball.h.

std::map<int, TrackMode *> vcg::Trackball::modes

The manipulator mapping. Needs to be explicitally managed for custom mappings.

Definition at line 492 of file gui/trackball.h.

Currently not in use.

Definition at line 513 of file gui/trackball.h.

Currently not in use.

Definition at line 515 of file gui/trackball.h.

Currently not in use.

Definition at line 517 of file gui/trackball.h.

track after an Undo() call.

Definition at line 498 of file gui/trackball.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


vcglib
Author(s): Christian Bersch
autogenerated on Fri Jan 11 09:23:07 2013