Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ParametricCurveDrawer Class Reference

Draws a 3-d parametric curve in the scene by creating a series of line segments to approximate the curve. More...

#include <parametricCurveDrawer.h>

Inheritance diagram for ParametricCurveDrawer:

TypedObject NurbsCurveDrawer List of all members.

Public Member Functions

 ParametricCurveDrawer ()
virtual ~ParametricCurveDrawer ()
void set_curve (ParametricCurve *curve)
 Sets the drawer up to draw just the one curve.

void set_curves (ParametricCurveCollection *curves)
 Sets the drawer up to draw the curves in the indicated collection.

void clear_curves ()
 Empties the list of curves the drawer will update.

ParametricCurveCollectionget_curves ()
GeomNodeget_geom_node ()
 Returns a pointer to the drawer's GeomNode.

PointerTo< GeomNodedetach_geom_node ()
 Detaches the GeomNode from the drawer so that the drawing will remain after the death of the drawer.

void set_num_segs (float num_segs)
 Specifies the number of line segments used to approximate the curve for each parametric unit.

float get_num_segs () const
 Returns the number of line segments used to approximate the curve for each parametric unit.

void set_num_ticks (float num_ticks)
 Specifies the number of time tick marks drawn for each unit of time.

float get_num_ticks () const
 Returns the number of time tick marks per unit of time drawn.

void set_color (float r, float g, float b)
 Specifies the color of the curve when it is drawn.

void set_tick_color (float r, float g, float b)
 Specifies the color of the time tick marks drawn on the curve.

void set_frame_accurate (bool frame_accurate)
 Specifies whether the curve drawn is to be frame-accurate.

bool get_frame_accurate () const
 Returns whether the curve is drawn in frame-accurate mode.

virtual bool draw ()
 Creates a series of line segments that approximates the curve.

void hide ()
 Removes the lines that were created by a previous call to draw().

void set_tick_scale (float scale)
 Sets the visible size of the time tick marks or geometry.

float get_tick_scale () const
 Returns the size of the time tick marks or geometry.

float get_max_t () const
void redraw ()
 Redraws the curve if it is currently visible.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.


Protected Attributes

PointerTo< GeomNode_geom_node
PointerTo< ParametricCurveCollection_curves
bool _frame_accurate

Static Private Member Functions

void get_tick_marks (const LVecBase3f &tangent, LVecBase3f &t1, LVecBase3f &t2)
 Given a tangent vector, computes two vectors at right angles to the tangent and to each other, suitable for drawing as tick marks.


Private Attributes

float _num_segs
LineSegs _lines
LineSegs _ticks
bool _drawn
float _num_ticks
float _tick_scale

Static Private Attributes

TypeHandle _type_handle

Detailed Description

Draws a 3-d parametric curve in the scene by creating a series of line segments to approximate the curve.

Definition at line 41 of file parametricCurveDrawer.h.


Constructor & Destructor Documentation

ParametricCurveDrawer::ParametricCurveDrawer  ) 
 

Definition at line 37 of file parametricCurveDrawer.cxx.

References _drawn, _frame_accurate, _geom_node, and _num_ticks.

ParametricCurveDrawer::~ParametricCurveDrawer  )  [virtual]
 

Definition at line 56 of file parametricCurveDrawer.cxx.

References PT, and set_curves().


Member Function Documentation

void ParametricCurveDrawer::clear_curves  ) 
 

Empties the list of curves the drawer will update.

It will draw nothing.

Definition at line 125 of file parametricCurveDrawer.cxx.

References _geom_node.

PointerTo< GeomNode > ParametricCurveDrawer::detach_geom_node  ) 
 

Detaches the GeomNode from the drawer so that the drawing will remain after the death of the drawer.

Returns the now-static GeomNode. A new, dynamic GeomNode is created for the drawer's future use; get_geom_node() will return this new GeomNode which will be empty until the next call to draw().

Definition at line 189 of file parametricCurveDrawer.cxx.

References _num_ticks, and redraw().

bool ParametricCurveDrawer::draw  )  [virtual]
 

Creates a series of line segments that approximates the curve.

These line segments may be made visible by parenting the node returned by get_geom_node() into the scene graph.

Reimplemented in NurbsCurveDrawer.

Definition at line 371 of file parametricCurveDrawer.cxx.

References _drawn.

Referenced by get_curves().

virtual TypeHandle ParametricCurveDrawer::force_init_type void   )  [inline, virtual]
 

Implements TypedObject.

Reimplemented in NurbsCurveDrawer.

Definition at line 102 of file parametricCurveDrawer.h.

TypeHandle ParametricCurveDrawer::get_class_type void   )  [inline, static]
 

Reimplemented from TypedObject.

Reimplemented in NurbsCurveDrawer.

Definition at line 92 of file parametricCurveDrawer.h.

References TypedObject::get_class_type().

ParametricCurveCollection * ParametricCurveDrawer::get_curves  ) 
 

Definition at line 137 of file parametricCurveDrawer.cxx.

References _drawn, _geom_node, draw(), and PT.

bool ParametricCurveDrawer::get_frame_accurate  )  const
 

Returns whether the curve is drawn in frame-accurate mode.

Definition at line 350 of file parametricCurveDrawer.cxx.

References _ticks.

GeomNode * ParametricCurveDrawer::get_geom_node  ) 
 

Returns a pointer to the drawer's GeomNode.

This is where the drawer will build the visible representation of the curve. This GeomNode must be inserted into the scene graph to make the curve visible. The GeomNode remains connected to the drawer, so that future updates to the drawer will reflect in the GeomNode, and the GeomNode will be emptied when the drawer destructs. Also see detach_geom_node().

Definition at line 165 of file parametricCurveDrawer.cxx.

References _num_segs, and redraw().

float ParametricCurveDrawer::get_max_t  )  const [inline]
 

Definition at line 31 of file parametricCurveDrawer.I.

float ParametricCurveDrawer::get_num_segs  )  const
 

Returns the number of line segments used to approximate the curve for each parametric unit.

This just affects the visual appearance of the curve as it is drawn. The total number of segments drawn for the curve will be get_max_t() * get_num_segs().

Definition at line 239 of file parametricCurveDrawer.cxx.

References _frame_accurate, and redraw().

float ParametricCurveDrawer::get_num_ticks  )  const
 

Returns the number of time tick marks per unit of time drawn.

Definition at line 277 of file parametricCurveDrawer.cxx.

References _curves, _drawn, hide(), and NULL.

void ParametricCurveDrawer::get_tick_marks const LVecBase3f &  tangent,
LVecBase3f &  t1,
LVecBase3f &  t2
[static, private]
 

Given a tangent vector, computes two vectors at right angles to the tangent and to each other, suitable for drawing as tick marks.

Definition at line 514 of file parametricCurveDrawer.cxx.

Referenced by set_frame_accurate().

float ParametricCurveDrawer::get_tick_scale  )  const
 

Returns the size of the time tick marks or geometry.

Definition at line 497 of file parametricCurveDrawer.cxx.

virtual TypeHandle ParametricCurveDrawer::get_type void   )  const [inline, virtual]
 

Implements TypedObject.

Reimplemented in NurbsCurveDrawer.

Definition at line 99 of file parametricCurveDrawer.h.

int TypedObject::get_type_index  )  const [inline, inherited]
 

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

void ParametricCurveDrawer::hide  ) 
 

Removes the lines that were created by a previous call to draw().

Definition at line 465 of file parametricCurveDrawer.cxx.

Referenced by get_num_ticks().

void ParametricCurveDrawer::init_type void   )  [inline, static]
 

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from TypedObject.

Reimplemented in NurbsCurveDrawer.

Definition at line 95 of file parametricCurveDrawer.h.

References TypedObject::get_class_type(), and TypedObject::init_type().

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

void ParametricCurveDrawer::redraw  )  [inline]
 

Redraws the curve if it is currently visible.

Definition at line 48 of file parametricCurveDrawer.I.

Referenced by detach_geom_node(), get_geom_node(), get_num_segs(), NurbsCurveDrawer::get_show_cvs(), set_curve(), NurbsCurveDrawer::set_cv_color(), NurbsCurveDrawer::set_knot_color(), and NurbsCurveDrawer::~NurbsCurveDrawer().

void ParametricCurveDrawer::set_color float  r,
float  g,
float  b
 

Specifies the color of the curve when it is drawn.

The default is white.

Definition at line 294 of file parametricCurveDrawer.cxx.

References _curves, _num_segs, and t.

void ParametricCurveDrawer::set_curve ParametricCurve curve  ) 
 

Sets the drawer up to draw just the one curve.

Definition at line 73 of file parametricCurveDrawer.cxx.

References _curves, NULL, and redraw().

void ParametricCurveDrawer::set_curves ParametricCurveCollection curves  ) 
 

Sets the drawer up to draw the curves in the indicated collection.

The drawer will actually draw just the first XYZ curve in the collection, but if one or more timewarps are present, this will affect the placement of tick marks.

Definition at line 96 of file parametricCurveDrawer.cxx.

References NULL.

Referenced by ~ParametricCurveDrawer().

void ParametricCurveDrawer::set_frame_accurate bool  frame_accurate  ) 
 

Specifies whether the curve drawn is to be frame-accurate.

If true, then changes made to the curve dynamically after it has been drawn will be reflected correctly in the render window. If false, dynamic updates may be drawn before the rest of the scene has updated.

Definition at line 334 of file parametricCurveDrawer.cxx.

References _curves, _tick_scale, _ticks, LineSegs::draw_to(), ParametricCurve::get_pt(), get_tick_marks(), LineSegs::move_to(), and t.

void ParametricCurveDrawer::set_num_segs float  num_segs  ) 
 

Specifies the number of line segments used to approximate the curve for each parametric unit.

This just affects the visual appearance of the curve as it is drawn. The total number of segments drawn for the curve will be get_max_t() * get_num_segs().

Definition at line 217 of file parametricCurveDrawer.cxx.

References _lines, and LineSegs::set_color().

void ParametricCurveDrawer::set_num_ticks float  num_ticks  ) 
 

Specifies the number of time tick marks drawn for each unit of time.

These tick marks are drawn at equal increments in time to give a visual approximation of speed. Specify 0 to disable drawing of tick marks.

Definition at line 261 of file parametricCurveDrawer.cxx.

References _frame_accurate.

void ParametricCurveDrawer::set_tick_color float  r,
float  g,
float  b
 

Specifies the color of the time tick marks drawn on the curve.

The default is red.

Definition at line 310 of file parametricCurveDrawer.cxx.

References _lines, LineSegs::draw_to(), ParametricCurve::get_point(), LineSegs::move_to(), and t.

void ParametricCurveDrawer::set_tick_scale float  scale  ) 
 

Sets the visible size of the time tick marks or geometry.

Definition at line 482 of file parametricCurveDrawer.cxx.


Member Data Documentation

PointerTo< ParametricCurveCollection > ParametricCurveDrawer::_curves [protected]
 

Definition at line 81 of file parametricCurveDrawer.h.

Referenced by get_num_ticks(), set_color(), set_curve(), and set_frame_accurate().

bool ParametricCurveDrawer::_drawn [private]
 

Definition at line 87 of file parametricCurveDrawer.h.

Referenced by draw(), get_curves(), get_num_ticks(), and ParametricCurveDrawer().

bool ParametricCurveDrawer::_frame_accurate [protected]
 

Definition at line 82 of file parametricCurveDrawer.h.

Referenced by get_num_segs(), ParametricCurveDrawer(), and set_num_ticks().

PointerTo< GeomNode > ParametricCurveDrawer::_geom_node [protected]
 

Definition at line 80 of file parametricCurveDrawer.h.

Referenced by clear_curves(), get_curves(), and ParametricCurveDrawer().

LineSegs ParametricCurveDrawer::_lines [private]
 

Definition at line 86 of file parametricCurveDrawer.h.

Referenced by set_num_segs(), and set_tick_color().

float ParametricCurveDrawer::_num_segs [private]
 

Definition at line 85 of file parametricCurveDrawer.h.

Referenced by get_geom_node(), and set_color().

float ParametricCurveDrawer::_num_ticks [private]
 

Definition at line 88 of file parametricCurveDrawer.h.

Referenced by detach_geom_node(), and ParametricCurveDrawer().

float ParametricCurveDrawer::_tick_scale [private]
 

Definition at line 89 of file parametricCurveDrawer.h.

Referenced by set_frame_accurate().

LineSegs ParametricCurveDrawer::_ticks [private]
 

Definition at line 86 of file parametricCurveDrawer.h.

Referenced by get_frame_accurate(), and set_frame_accurate().

TypeHandle ParametricCurveDrawer::_type_handle [static, private]
 

Reimplemented from TypedObject.

Reimplemented in NurbsCurveDrawer.

Definition at line 27 of file parametricCurveDrawer.cxx.


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:53:08 2003 for Panda by doxygen1.3