The area constrained manipulator. More...
#include <trackmode.h>
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< Point3f > | path |
Current action's object trace. | |
Plane3f | plane |
The polygon plane. | |
std::vector< Point3f > | points |
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. |
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.
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.
pts | the vertexes vector. |
Definition at line 876 of file trackmode.h.
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.
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.
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.
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.
point | The point to test. |
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.
Reimplemented from vcg::TrackMode.
Definition at line 763 of file trackmode.cpp.
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).
start | the starting point assumed inside. | |
end | the destination assumed in the plane. |
Definition at line 660 of file trackmode.cpp.
const char* vcg::AreaMode::Name | ( | ) | [inline, virtual] |
Return this manipulator's name.
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.
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.
p | the point wished for the start. |
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.
bool vcg::AreaMode::begin_action [private] |
True in time inteval between a call to SetAction () and a call to Apply().
Definition at line 985 of file trackmode.h.
Point3f vcg::AreaMode::delta_mouse [private] |
The screen space differenve between the object and the cursor during an action.
Definition at line 995 of file trackmode.h.
int vcg::AreaMode::first_coord_kept [private] |
One of the two dimensions used during the point in polygon test.
Definition at line 987 of file trackmode.h.
Point3f vcg::AreaMode::initial_status [private] |
The initial status.
Definition at line 999 of file trackmode.h.
float vcg::AreaMode::min_side_length [private] |
The length of the shortest border.
Definition at line 991 of file trackmode.h.
Point3f vcg::AreaMode::old_status [private] |
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.
Plane3f vcg::AreaMode::plane [private] |
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.
Point3f vcg::AreaMode::rubberband_handle [private] |
The rubberband handle (current destination in Move()).
Definition at line 1003 of file trackmode.h.
int vcg::AreaMode::second_coord_kept [private] |
One of the two dimensions used during the point in polygon test.
Definition at line 989 of file trackmode.h.
Point3f vcg::AreaMode::status [private] |
The current status.
Definition at line 993 of file trackmode.h.
bool vcg::AreaMode::undo_begin_action [private] |
begin_action after an Undo() call.
Definition at line 1007 of file trackmode.h.
Point3f vcg::AreaMode::undo_delta_mouse [private] |
delta_mouse after an Undo() call.
Definition at line 1011 of file trackmode.h.
Point3f vcg::AreaMode::undo_old_status [private] |
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.
Point3f vcg::AreaMode::undo_rubberband_handle [private] |
rubberband_handle after an Undo() call.
Definition at line 1015 of file trackmode.h.
Point3f vcg::AreaMode::undo_status [private] |
status after an Undo() call.
Definition at line 1009 of file trackmode.h.