vcg::PathMode Class Reference

The path constrained manipulator. More...

#include <trackmode.h>

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

List of all members.

Public Member Functions

void Apply (Trackball *trackball, float WheelNotch)
 Apply a translation, function of the user mouse wheel action.
void Apply (Trackball *trackball, Point3f new_point)
 Apply a translation, function of the user mouse drag action.
void Draw (Trackball *trackball)
 Render this manipulator.
bool isSticky ()
 The (non) avaibility to manipulator changes inside an action.
const char * Name ()
 Return this manipulator's name.
 PathMode (const Point3f &start, const Point3f &end)
 The segment constructor.
 PathMode (const std::vector< Point3f > &pts, bool w=false)
 The vector-boolean constructor.
void Reset ()
 The reset function.
void SetAction ()
 The begin action function.
Point3f SetStartNear (Point3f p)
 Try to set the inital point.
void Undo ()
 The undo function.

Private Member Functions

void GetPoints (float state, Point3f &point, Point3f &prev_point, Point3f &next_point)
 The state interpreter.
float HitPoint (float state, Ray3fN ray, Point3f &hit_point)
 Compute the new point and the $\Delta$-state.
void Init (const std::vector< Point3f > &points)
 The data initializer.
float Normalize (float state)
 The state normalizer.
int Verse (Point3f reference_point, Point3f current_point, Point3f prev_point, Point3f next_point)
 Compute the verse to follow for slide nearer to a given point.

Private Attributes

float current_state
 The current state.
float initial_state
 The initial state.
float min_seg_length
 The length of the shostest path segment.
Point3f old_hitpoint
 The point relative to the old state.
float path_length
 The path length.
std::vector< Point3fpoints
 The node vector.
float undo_current_state
 current_state after an Undo() call.
Point3f undo_old_hitpoint
 old_hitpoint after an Undo() call.
bool wrap
 True if the path is closed, false otherwise.

Detailed Description

The path constrained manipulator.

This manipulator moves the object along an eventually closed path.

The user can either drag the mouse or scroll the wheel, when the user drags the mouse, the object tries to slide toward it.

The object is assumed to initially be on the same position of the first point on the path.

This is a stateful manipulator, result of the Apply functions is determined by the objects's position along the path and by either the mouse coordinates or the mouse wheel notch.

Definition at line 649 of file trackmode.h.


Constructor & Destructor Documentation

vcg::PathMode::PathMode ( const std::vector< Point3f > &  pts,
bool  w = false 
) [inline]

The vector-boolean constructor.

The vector passed to build the path is copied locally. The boolean value specifies if the path is to be closed. If the boolean value is not specified, the path is not closed.

Warning:
the path is not assumed to have 0-length segments, so, if you want to close the path, please do not add a copy of the first point on the end of the vector.
Parameters:
pts the path nodes.
w a boolean value that closes the path.

Definition at line 663 of file trackmode.h.

vcg::PathMode::PathMode ( const Point3f start,
const Point3f end 
) [inline]

The segment constructor.

If the path is a simple segment, it can be specified just with the endpoints.

Parameters:
start the starting point.
end the ending point.

Definition at line 677 of file trackmode.h.


Member Function Documentation

void PathMode::Apply ( Trackball trackball,
float  WheelNotch 
) [virtual]

Apply a translation, function of the user mouse wheel action.

The manipulated object is moved along the path. A step of the mouse wheel makes the object slide by a distance equal to the half of the shortest segment on the path.

Parameters:
trackball the manipulator manager.
WheelNotch the mouse wheel notch.

Reimplemented from vcg::TrackMode.

Definition at line 449 of file trackmode.cpp.

void PathMode::Apply ( Trackball trackball,
Point3f  new_point 
) [virtual]

Apply a translation, function of the user mouse drag action.

The manipulated object is moved along the path. This function implements an algorithm that makes the object try to slide on the path towards the mouse pointer.

Parameters:
trackball the manipulator manager.
new_point the new mouse pointer coordinate.

Reimplemented from vcg::TrackMode.

Definition at line 541 of file trackmode.cpp.

void PathMode::Draw ( Trackball trackball  )  [virtual]

Render this manipulator.

Parameters:
trackball the manipulator manager.

Reimplemented from vcg::TrackMode.

Definition at line 562 of file trackmode.cpp.

void PathMode::GetPoints ( float  state,
Point3f point,
Point3f prev_point,
Point3f next_point 
) [private]

The state interpreter.

Given the state, return the current point, the previous node and the next node on the path. The algoritm is linear in the node paths.

Parameters:
state the given state.
point is set to the current point.
prev_point is set to the point of current point's previous node.
next_point is set to the point of current point's next node.

Definition at line 389 of file trackmode.cpp.

float PathMode::HitPoint ( float  state,
Ray3fN  ray,
Point3f hit_point 
) [private]

Compute the new point and the $\Delta$-state.

Given a state and the mouse coords ray, computes the new state point and return the $\Delta$-state. The algoritm is linear in the node paths.

Parameters:
state the given state.
ray the ray relative to mouse coords.
hit_point is set to the new state point.
Returns:
the $\Delta$-state.

Definition at line 511 of file trackmode.cpp.

void PathMode::Init ( const std::vector< Point3f > &  points  )  [private]

The data initializer.

Initialize the internal state and checks params validity.

Parameters:
points the path nodes.

Definition at line 322 of file trackmode.cpp.

bool PathMode::isSticky (  )  [virtual]

The (non) avaibility to manipulator changes inside an action.

This manipulator has an internal state and does not allow a switch in the middle of a function.

Returns:
the costant boolean true.

Reimplemented from vcg::TrackMode.

Definition at line 553 of file trackmode.cpp.

const char* vcg::PathMode::Name (  )  [inline, virtual]

Return this manipulator's name.

Returns:
the constant string "PathMode"

Reimplemented from vcg::TrackMode.

Definition at line 691 of file trackmode.h.

float PathMode::Normalize ( float  state  )  [private]

The state normalizer.

Normalize a given state in the right interval:

  • $ [0 \ldots 1] $ if the path is open.
  • $ [0 \ldots 1) $ if the path is closed (because it wraps).
Parameters:
state the given state.

Definition at line 463 of file trackmode.cpp.

void PathMode::Reset (  )  [virtual]

The reset function.

This function reset the object position to the initial point.

Reimplemented from vcg::TrackMode.

Definition at line 345 of file trackmode.cpp.

void PathMode::SetAction (  )  [virtual]

The begin action function.

This function is to be called at the begin of an user action.

Reimplemented from vcg::TrackMode.

Definition at line 536 of file trackmode.cpp.

Point3f PathMode::SetStartNear ( Point3f  p  ) 

Try to set the inital point.

This function try to set the starting point in the point passed as parameter, if the point passed does not reside on the path, the start is put on the closest point on it.

Parameters:
p the point wished for the start.
Returns:
the starting point on the path.

Definition at line 350 of file trackmode.cpp.

void PathMode::Undo (  )  [virtual]

The undo function.

This function recreates the state present before the last Apply() call.

Reimplemented from vcg::TrackMode.

Definition at line 557 of file trackmode.cpp.

int PathMode::Verse ( Point3f  reference_point,
Point3f  current_point,
Point3f  prev_point,
Point3f  next_point 
) [private]

Compute the verse to follow for slide nearer to a given point.

Given the current state point, the point of previus and next node and a reference point, compute the verse to follow for the object to come closer to the reference point.

Parameters:
reference_point 
current_point 
prev_point 
next_point 
Returns:
-1, 0 or 1 if the verse is respectively towars the startpoint, null or towards the endpoint.

Definition at line 480 of file trackmode.cpp.


Member Data Documentation

The current state.

Definition at line 827 of file trackmode.h.

The initial state.

Definition at line 829 of file trackmode.h.

The length of the shostest path segment.

Definition at line 833 of file trackmode.h.

The point relative to the old state.

Definition at line 835 of file trackmode.h.

float vcg::PathMode::path_length [private]

The path length.

Definition at line 831 of file trackmode.h.

std::vector< Point3f > vcg::PathMode::points [private]

The node vector.

Definition at line 823 of file trackmode.h.

current_state after an Undo() call.

Definition at line 837 of file trackmode.h.

old_hitpoint after an Undo() call.

Definition at line 839 of file trackmode.h.

bool vcg::PathMode::wrap [private]

True if the path is closed, false otherwise.

Definition at line 825 of file trackmode.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:03 2013