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

NurbsCurveDrawer Class Reference

Draws a Nurbs curve, also drawing in the control vertices and tangent vectors. More...

#include <nurbsCurveDrawer.h>

Inheritance diagram for NurbsCurveDrawer:

ParametricCurveDrawer TypedObject List of all members.

Public Member Functions

 NurbsCurveDrawer ()
virtual ~NurbsCurveDrawer ()
void set_cv_color (float r, float g, float b)
 Specifies the color of the CV's.

void set_hull_color (float r, float g, float b)
 Specifies the color of the convex hull.

void set_knot_color (float r, float g, float b)
 Specifies the color of the knots.

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

virtual bool recompute (float t1, float t2, ParametricCurve *curve=NULL)
void set_show_cvs (bool flag)
 Sets the flag that hides or shows the CV's.

bool get_show_cvs () const
 Returns the current state of the show-CV's flag.

void set_show_hull (bool flag)
 Sets the flag that hides or shows the convex hull.

bool get_show_hull () const
 Returns the current state of the show-hull flag.

void set_show_knots (bool flag)
 Sets the flag that hides or shows the knots.

bool get_show_knots () const
 Returns the current state of the show-knots flag.

bool hilight (int n)
 Hilights a particular CV by showing it and its knot in a different color.

bool hilight (int n, float hr, float hg, float hb)
 Hilights a particular CV by showing it and its knot in a different color.

bool unhilight (int n)
 Removes the hilight previously set on a CV.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
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.

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.

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

LVecBase3f _cv_color
LVecBase3f _hull_color
LVecBase3f _knot_color
int _num_cvs
int _num_hull
int _num_knots
LineSegs _hull
LineSegs _knots
LineSegs _cvs
pvector< int > _knotnums
bool _show_cvs
bool _show_hull
bool _show_knots
PointerTo< GeomNode_geom_node
PointerTo< ParametricCurveCollection_curves
bool _frame_accurate

Static Private Attributes

TypeHandle _type_handle

Detailed Description

Draws a Nurbs curve, also drawing in the control vertices and tangent vectors.

Definition at line 40 of file nurbsCurveDrawer.h.


Constructor & Destructor Documentation

NurbsCurveDrawer::NurbsCurveDrawer  ) 
 

Definition at line 38 of file nurbsCurveDrawer.cxx.

References _cvs, _hull, _knots, _show_cvs, _show_hull, and _show_knots.

NurbsCurveDrawer::~NurbsCurveDrawer  )  [virtual]
 

Definition at line 61 of file nurbsCurveDrawer.cxx.

References _cv_color, _cvs, ParametricCurveDrawer::redraw(), and LineSegs::set_color().


Member Function Documentation

void ParametricCurveDrawer::clear_curves  )  [inherited]
 

Empties the list of curves the drawer will update.

It will draw nothing.

Definition at line 125 of file parametricCurveDrawer.cxx.

References ParametricCurveDrawer::_geom_node.

PointerTo< GeomNode > ParametricCurveDrawer::detach_geom_node  )  [inherited]
 

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 ParametricCurveDrawer::_num_ticks, and ParametricCurveDrawer::redraw().

bool NurbsCurveDrawer::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 from ParametricCurveDrawer.

Definition at line 124 of file nurbsCurveDrawer.cxx.

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

Reimplemented from ParametricCurveDrawer.

Definition at line 84 of file nurbsCurveDrawer.h.

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

Reimplemented from ParametricCurveDrawer.

Definition at line 73 of file nurbsCurveDrawer.h.

ParametricCurveCollection * ParametricCurveDrawer::get_curves  )  [inherited]
 

Definition at line 137 of file parametricCurveDrawer.cxx.

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

bool ParametricCurveDrawer::get_frame_accurate  )  const [inherited]
 

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

Definition at line 350 of file parametricCurveDrawer.cxx.

References ParametricCurveDrawer::_ticks.

GeomNode * ParametricCurveDrawer::get_geom_node  )  [inherited]
 

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 ParametricCurveDrawer::_num_segs, and ParametricCurveDrawer::redraw().

float ParametricCurveDrawer::get_max_t  )  const [inline, inherited]
 

Definition at line 31 of file parametricCurveDrawer.I.

float ParametricCurveDrawer::get_num_segs  )  const [inherited]
 

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 ParametricCurveDrawer::_frame_accurate, and ParametricCurveDrawer::redraw().

float ParametricCurveDrawer::get_num_ticks  )  const [inherited]
 

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

Definition at line 277 of file parametricCurveDrawer.cxx.

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

bool NurbsCurveDrawer::get_show_cvs  )  const
 

Returns the current state of the show-CV's flag.

Definition at line 227 of file nurbsCurveDrawer.cxx.

References _show_knots, and ParametricCurveDrawer::redraw().

bool NurbsCurveDrawer::get_show_hull  )  const
 

Returns the current state of the show-hull flag.

Definition at line 254 of file nurbsCurveDrawer.cxx.

References _cvs, _knotnums, _knots, LineSegs::get_num_vertices(), nassertr, and LineSegs::set_vertex_color().

bool NurbsCurveDrawer::get_show_knots  )  const
 

Returns the current state of the show-knots flag.

Definition at line 281 of file nurbsCurveDrawer.cxx.

References _cvs.

float ParametricCurveDrawer::get_tick_scale  )  const [inherited]
 

Returns the size of the time tick marks or geometry.

Definition at line 497 of file parametricCurveDrawer.cxx.

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

Reimplemented from ParametricCurveDrawer.

Definition at line 81 of file nurbsCurveDrawer.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  )  [inherited]
 

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

Definition at line 465 of file parametricCurveDrawer.cxx.

Referenced by ParametricCurveDrawer::get_num_ticks().

bool NurbsCurveDrawer::hilight int  n,
float  hr,
float  hg,
float  hb
 

Hilights a particular CV by showing it and its knot in a different color.

Returns true if the CV exists and has been drawn, false otherwise.

Definition at line 299 of file nurbsCurveDrawer.cxx.

bool NurbsCurveDrawer::hilight int  n  )  [inline]
 

Hilights a particular CV by showing it and its knot in a different color.

Returns true if the CV exists and has been drawn, false otherwise.

Definition at line 36 of file nurbsCurveDrawer.I.

void NurbsCurveDrawer::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 ParametricCurveDrawer.

Definition at line 76 of file nurbsCurveDrawer.h.

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().

bool NurbsCurveDrawer::recompute float  t1,
float  t2,
ParametricCurve curve = NULL
[virtual]
 

Definition at line 199 of file nurbsCurveDrawer.cxx.

References _show_cvs.

void ParametricCurveDrawer::redraw  )  [inline, inherited]
 

Redraws the curve if it is currently visible.

Definition at line 48 of file parametricCurveDrawer.I.

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

void ParametricCurveDrawer::set_color float  r,
float  g,
float  b
[inherited]
 

Specifies the color of the curve when it is drawn.

The default is white.

Definition at line 294 of file parametricCurveDrawer.cxx.

References ParametricCurveDrawer::_curves, ParametricCurveDrawer::_num_segs, and t.

void ParametricCurveDrawer::set_curve ParametricCurve curve  )  [inherited]
 

Sets the drawer up to draw just the one curve.

Definition at line 73 of file parametricCurveDrawer.cxx.

References ParametricCurveDrawer::_curves, NULL, and ParametricCurveDrawer::redraw().

void ParametricCurveDrawer::set_curves ParametricCurveCollection curves  )  [inherited]
 

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::~ParametricCurveDrawer().

void NurbsCurveDrawer::set_cv_color float  r,
float  g,
float  b
 

Specifies the color of the CV's.

Definition at line 75 of file nurbsCurveDrawer.cxx.

References _knot_color, _knots, ParametricCurveDrawer::redraw(), and LineSegs::set_color().

void ParametricCurveDrawer::set_frame_accurate bool  frame_accurate  )  [inherited]
 

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 ParametricCurveDrawer::_curves, ParametricCurveDrawer::_tick_scale, ParametricCurveDrawer::_ticks, LineSegs::draw_to(), ParametricCurve::get_pt(), ParametricCurveDrawer::get_tick_marks(), LineSegs::move_to(), and t.

void NurbsCurveDrawer::set_hull_color float  r,
float  g,
float  b
 

Specifies the color of the convex hull.

Definition at line 107 of file nurbsCurveDrawer.cxx.

void NurbsCurveDrawer::set_knot_color float  r,
float  g,
float  b
 

Specifies the color of the knots.

Definition at line 91 of file nurbsCurveDrawer.cxx.

References _hull, _hull_color, ParametricCurveDrawer::redraw(), and LineSegs::set_color().

void ParametricCurveDrawer::set_num_segs float  num_segs  )  [inherited]
 

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 ParametricCurveDrawer::_lines, and LineSegs::set_color().

void ParametricCurveDrawer::set_num_ticks float  num_ticks  )  [inherited]
 

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 ParametricCurveDrawer::_frame_accurate.

void NurbsCurveDrawer::set_show_cvs bool  flag  ) 
 

Sets the flag that hides or shows the CV's.

Definition at line 213 of file nurbsCurveDrawer.cxx.

void NurbsCurveDrawer::set_show_hull bool  flag  ) 
 

Sets the flag that hides or shows the convex hull.

Definition at line 240 of file nurbsCurveDrawer.cxx.

References _show_knots.

void NurbsCurveDrawer::set_show_knots bool  flag  ) 
 

Sets the flag that hides or shows the knots.

Definition at line 267 of file nurbsCurveDrawer.cxx.

References _knots.

void ParametricCurveDrawer::set_tick_color float  r,
float  g,
float  b
[inherited]
 

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 ParametricCurveDrawer::_lines, LineSegs::draw_to(), ParametricCurve::get_point(), LineSegs::move_to(), and t.

void ParametricCurveDrawer::set_tick_scale float  scale  )  [inherited]
 

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

Definition at line 482 of file parametricCurveDrawer.cxx.

bool NurbsCurveDrawer::unhilight int  n  ) 
 

Removes the hilight previously set on a CV.

Definition at line 326 of file nurbsCurveDrawer.cxx.


Member Data Documentation

PointerTo< ParametricCurveCollection > ParametricCurveDrawer::_curves [protected, inherited]
 

Definition at line 81 of file parametricCurveDrawer.h.

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

LVecBase3f NurbsCurveDrawer::_cv_color [protected]
 

Definition at line 64 of file nurbsCurveDrawer.h.

Referenced by ~NurbsCurveDrawer().

LineSegs NurbsCurveDrawer::_cvs [protected]
 

Definition at line 66 of file nurbsCurveDrawer.h.

Referenced by get_show_hull(), get_show_knots(), NurbsCurveDrawer(), and ~NurbsCurveDrawer().

bool ParametricCurveDrawer::_frame_accurate [protected, inherited]
 

Definition at line 82 of file parametricCurveDrawer.h.

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

PointerTo< GeomNode > ParametricCurveDrawer::_geom_node [protected, inherited]
 

Definition at line 80 of file parametricCurveDrawer.h.

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

LineSegs NurbsCurveDrawer::_hull [protected]
 

Definition at line 66 of file nurbsCurveDrawer.h.

Referenced by NurbsCurveDrawer(), and set_knot_color().

LVecBase3f NurbsCurveDrawer::_hull_color [protected]
 

Definition at line 64 of file nurbsCurveDrawer.h.

Referenced by set_knot_color().

LVecBase3f NurbsCurveDrawer::_knot_color [protected]
 

Definition at line 64 of file nurbsCurveDrawer.h.

Referenced by set_cv_color().

pvector<int> NurbsCurveDrawer::_knotnums [protected]
 

Definition at line 67 of file nurbsCurveDrawer.h.

Referenced by get_show_hull().

LineSegs NurbsCurveDrawer::_knots [protected]
 

Definition at line 66 of file nurbsCurveDrawer.h.

Referenced by get_show_hull(), NurbsCurveDrawer(), set_cv_color(), and set_show_knots().

int NurbsCurveDrawer::_num_cvs [protected]
 

Definition at line 65 of file nurbsCurveDrawer.h.

int NurbsCurveDrawer::_num_hull [protected]
 

Definition at line 65 of file nurbsCurveDrawer.h.

int NurbsCurveDrawer::_num_knots [protected]
 

Definition at line 65 of file nurbsCurveDrawer.h.

bool NurbsCurveDrawer::_show_cvs [protected]
 

Definition at line 69 of file nurbsCurveDrawer.h.

Referenced by NurbsCurveDrawer(), and recompute().

bool NurbsCurveDrawer::_show_hull [protected]
 

Definition at line 69 of file nurbsCurveDrawer.h.

Referenced by NurbsCurveDrawer().

bool NurbsCurveDrawer::_show_knots [protected]
 

Definition at line 69 of file nurbsCurveDrawer.h.

Referenced by get_show_cvs(), NurbsCurveDrawer(), and set_show_hull().

TypeHandle NurbsCurveDrawer::_type_handle [static, private]
 

Reimplemented from ParametricCurveDrawer.

Definition at line 27 of file nurbsCurveDrawer.cxx.


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