vcg::AreaMode Class Reference

The area constrained manipulator. More...

#include <trackmode.h>

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

List of all members.

Public Member Functions

void Apply (Trackball *trackball, Point3f new_point)
 Apply a translation, function of the user mouse drag action.
 AreaMode (const std::vector< Point3f > &pts)
 The constructor.
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.
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 Init (const std::vector< Point3f > &pts)
 The data initializer.
bool Inside (Point3f point)
 Point in Polygon test.
Point3f Move (Point3f start, Point3f end)
 Try to move the object inside the polygon.

Private Attributes

bool begin_action
 True in time inteval between a call to SetAction () and a call to Apply().
Point3f delta_mouse
 The screen space differenve between the object and the cursor during an action.
int first_coord_kept
 One of the two dimensions used during the point in polygon test.
Point3f initial_status
 The initial status.
float min_side_length
 The length of the shortest border.
Point3f old_status
 The old status.
std::vector< Point3fpath
 Current action's object trace.
Plane3f plane
 The polygon plane.
std::vector< Point3fpoints
 The vertexes vector.
Point3f rubberband_handle
 The rubberband handle (current destination in Move()).
int second_coord_kept
 One of the two dimensions used during the point in polygon test.
Point3f status
 The current status.
bool undo_begin_action
 begin_action after an Undo() call.
Point3f undo_delta_mouse
 delta_mouse after an Undo() call.
Point3f undo_old_status
 old_status after an Undo() call.
unsigned int undo_path_index
 path endpoint after an Undo() call.
Point3f undo_rubberband_handle
 rubberband_handle after an Undo() call.
Point3f undo_status
 status after an Undo() call.

Detailed Description

The area constrained manipulator.

This manipulator moves the object inside a poligonal area.

The user can drag the object inside a planar area, defined by a polygon. The polygon can be non convex, and is specified with a vector of vertexes.

If the object's trajectory intersects some poligon side, it tries to slide around it, in a "rubber band flavoured" way.

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

This is a stateful manipulator, result of the Apply function is determined by the objects's position inside the area and by the mouse coordinates.

Definition at line 861 of file trackmode.h.


Constructor & Destructor Documentation

vcg::AreaMode::AreaMode ( const std::vector< Point3f > &  pts  )  [inline]

The constructor.

From the given vector, is calculated the plane of the polygon, then every point in the vector is projected on this plane.

The vector passed to build the polygon is copied locally.

Warning:
The vector is assumed to be formed of non collinear points.
The polygon is not assumed to have 0-length sides, so please do not add a copy of the first point on the end of the vector.
Parameters:
pts the vertexes vector.

Definition at line 876 of file trackmode.h.


Member Function Documentation

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

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

The manipulated object is moved inside the poligon. This function implements an algorithm that makes the object try to slide around the polygon borders.

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

Reimplemented from vcg::TrackMode.

Definition at line 625 of file trackmode.cpp.

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

Render this manipulator.

Parameters:
trackball the manipulator manager.

Reimplemented from vcg::TrackMode.

Definition at line 777 of file trackmode.cpp.

void AreaMode::Init ( const std::vector< Point3f > &  pts  )  [private]

The data initializer.

Initialize the internal state and checks params validity.

Parameters:
pts The polygon vertexes.

Definition at line 571 of file trackmode.cpp.

bool AreaMode::Inside ( Point3f  point  )  [private]

Point in Polygon test.

Checks if a given point relies inside the poligon area, using the ray tracing algorithm, linear in the number of vertexes.

Parameters:
point The point to test.
Returns:
true if the point is inside the polygon, false otherwise.

Definition at line 719 of file trackmode.cpp.

bool AreaMode::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 763 of file trackmode.cpp.

Point3f AreaMode::Move ( Point3f  start,
Point3f  end 
) [private]

Try to move the object inside the polygon.

Given a point inside the area and a destination in the poligon plane, try to move the point toward the destination, sliding on any evenual border of the polygon. The object can be imagined tied with a rubber attached to destination, so it won't go back from it to slide around a border.

The algorithm is quadratic in the number of vertexes (worst case, really really unlikely).

Parameters:
start the starting point assumed inside.
end the destination assumed in the plane.
Returns:
the final move vector.

Definition at line 660 of file trackmode.cpp.

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

Return this manipulator's name.

Returns:
the constant string "AreaMode"

Reimplemented from vcg::TrackMode.

Definition at line 886 of file trackmode.h.

void AreaMode::Reset (  )  [virtual]

The reset function.

This function reset the object position to the initial point.

Reimplemented from vcg::TrackMode.

Definition at line 619 of file trackmode.cpp.

void AreaMode::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 650 of file trackmode.cpp.

Point3f AreaMode::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 in the area, the start is put in the closest point on it.

Parameters:
p the point wished for the start.
Returns:
the starting point in the area.

Definition at line 740 of file trackmode.cpp.

void AreaMode::Undo (  )  [virtual]

The undo function.

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

Reimplemented from vcg::TrackMode.

Definition at line 767 of file trackmode.cpp.


Member Data Documentation

True in time inteval between a call to SetAction () and a call to Apply().

Definition at line 985 of file trackmode.h.

The screen space differenve between the object and the cursor during an action.

Definition at line 995 of file trackmode.h.

One of the two dimensions used during the point in polygon test.

Definition at line 987 of file trackmode.h.

The initial status.

Definition at line 999 of file trackmode.h.

The length of the shortest border.

Definition at line 991 of file trackmode.h.

The old status.

Definition at line 997 of file trackmode.h.

std::vector< Point3f > vcg::AreaMode::path [private]

Current action's object trace.

Definition at line 1005 of file trackmode.h.

The polygon plane.

Definition at line 1001 of file trackmode.h.

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

The vertexes vector.

Definition at line 983 of file trackmode.h.

The rubberband handle (current destination in Move()).

Definition at line 1003 of file trackmode.h.

One of the two dimensions used during the point in polygon test.

Definition at line 989 of file trackmode.h.

The current status.

Definition at line 993 of file trackmode.h.

begin_action after an Undo() call.

Definition at line 1007 of file trackmode.h.

delta_mouse after an Undo() call.

Definition at line 1011 of file trackmode.h.

old_status after an Undo() call.

Definition at line 1013 of file trackmode.h.

unsigned int vcg::AreaMode::undo_path_index [private]

path endpoint after an Undo() call.

Definition at line 1017 of file trackmode.h.

rubberband_handle after an Undo() call.

Definition at line 1015 of file trackmode.h.

status after an Undo() call.

Definition at line 1009 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:22:57 2013