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

LineSegs Class Reference

Encapsulates creation of a series of connected or disconnected line segments or points, for drawing paths or rays. More...

#include <lineSegs.h>

Inheritance diagram for LineSegs:

Namable List of all members.

Public Member Functions

 LineSegs (const string &name="lines")
 Constructs a LineSegs object, which can be used to create any number of disconnected lines or points of various thicknesses and colors through the visible scene.

 ~LineSegs ()
void reset ()
 Removes any lines in progress and resets to the initial empty state.

void set_color (float r, float g, float b, float a=1.0f)
 Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to().

void set_color (const Colorf &color)
 Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to().

void set_thickness (float thick)
 Establishes the line thickness or point size in pixels that will be assigned to all lines and points created by future calls to create().

void move_to (float x, float y, float z)
 Moves the pen to the given point without drawing a line.

void move_to (const LVecBase3f &v)
 Moves the pen to the given point without drawing a line.

void draw_to (float x, float y, float z)
 Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point.

void draw_to (const LVecBase3f &v)
 Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point.

const Vertexfget_current_position ()
 Returns the pen's current position.

bool is_empty ()
 Returns true if move_to() or draw_to() have not been called since the last reset() or create(), false otherwise.

GeomNodecreate (bool frame_accurate=false)
 Creates a new GeomNode that will render the series of line segments and points described via calls to move_to() and draw_to().

GeomNodecreate (GeomNode *previous, bool frame_accurate=false)
 Appends to an existing GeomNode a new Geom that will render the series of line segments and points described via calls to move_to() and draw_to().

int get_num_vertices () const
 Returns the total number of line segment and point vertices generated by the last call to create().

Vertexf get_vertex (int vertex) const
 Returns the nth point or vertex of the line segment sequence generated by the last call to create().

void set_vertex (int vertex, const Vertexf &vert)
 Moves the nth point or vertex of the line segment sequence generated by the last call to create().

void set_vertex (int vertex, float x, float y, float z)
 Moves the nth point or vertex of the line segment sequence generated by the last call to create().

Colorf get_vertex_color (int vertex) const
 Returns the color of the nth point or vertex/.

void set_vertex_color (int vertex, const Colorf &color)
 Changes the vertex color of the nth point or vertex.

void set_vertex_color (int vertex, float r, float g, float b, float a=1.0f)
 Changes the vertex color of the nth point or vertex.

void set_name (const string &name)
void clear_name ()
 Resets the Namable's name to empty.

bool has_name () const
 Returns true if the Namable has a nonempty name set, false if the name is empty.

const string & get_name () const
void output (ostream &out) const
 Outputs the Namable.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Private Types

typedef pvector< PointSegmentList
typedef pvector< SegmentListLineList

Private Attributes

LineList _list
Colorf _color
float _thick
PTA_Vertexf _created_verts
PTA_Colorf _created_colors

Detailed Description

Encapsulates creation of a series of connected or disconnected line segments or points, for drawing paths or rays.

This class doesn't attempt to be the smartest it could possibly be; it's intended primarily as a visualization and editing tool.

Definition at line 52 of file lineSegs.h.


Member Typedef Documentation

typedef pvector<SegmentList> LineSegs::LineList [private]
 

Definition at line 98 of file lineSegs.h.

typedef pvector<Point> LineSegs::SegmentList [private]
 

Definition at line 97 of file lineSegs.h.


Constructor & Destructor Documentation

LineSegs::LineSegs const string &  name = "lines"  ) 
 

Constructs a LineSegs object, which can be used to create any number of disconnected lines or points of various thicknesses and colors through the visible scene.

After creating the object, call move_to() and draw_to() repeatedly to describe the path, then call create() to create a GeomNode which will render the described path.

Definition at line 45 of file lineSegs.cxx.

LineSegs::~LineSegs  ) 
 

Definition at line 58 of file lineSegs.cxx.

References _color.


Member Function Documentation

void Namable::clear_name  )  [inline, inherited]
 

Resets the Namable's name to empty.

Definition at line 82 of file namable.I.

References Namable::_name, and INLINE.

GeomNode * LineSegs::create GeomNode previous,
bool  frame_accurate = false
 

Appends to an existing GeomNode a new Geom that will render the series of line segments and points described via calls to move_to() and draw_to().

The lines and points are created with the color and thickness established by calls to set_color() and set_thick().

If frame_accurate is true, the line segments will be created as a frame-accurate index, so that later calls to set_vertex or set_vertex_color will be visually correct.

Definition at line 200 of file lineSegs.cxx.

GeomNode * LineSegs::create bool  frame_accurate = false  )  [inline]
 

Creates a new GeomNode that will render the series of line segments and points described via calls to move_to() and draw_to().

The lines and points are created with the color and thickness established by calls to set_color() and set_thick().

If frame_accurate is true, the line segments will be created as a frame-accurate index, so that later calls to set_vertex or set_vertex_color will be visually correct.

Definition at line 193 of file lineSegs.I.

References INLINE, set_vertex(), Vertexf, x, and y.

Referenced by move_to().

void LineSegs::draw_to const LVecBase3f &  v  ) 
 

Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point.

move_to() and draw_to() only update tables; the actual drawing is performed when create() is called.

Definition at line 119 of file lineSegs.cxx.

References _list, move_to(), and Vertexf.

void LineSegs::draw_to float  x,
float  y,
float  z
[inline]
 

Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point.

move_to() and draw_to() only update tables; the actual drawing is performed when create() is called.

Definition at line 162 of file lineSegs.I.

References _created_verts, INLINE, nassertr, PointerToArray< Vertexf >::size(), and Vertexf.

Referenced by ParametricCurveDrawer::set_frame_accurate(), set_thickness(), and ParametricCurveDrawer::set_tick_color().

TypeHandle Namable::get_class_type void   )  [inline, static, inherited]
 

Reimplemented in AnimBundle, AnimBundleNode, AnimChannel< SwitchType >, AnimChannelBase, AnimChannelFixed< SwitchType >, AnimChannelMatrixXfmTable, AnimChannelScalarTable, AnimGroup, MovingPart< SwitchType >, MovingPartBase, MovingPartMatrix, MovingPartScalar, PartBundle, PartBundleNode, PartGroup, Character, CharacterJoint, CharacterJointBundle, CharacterSlider, CollisionNode, AnalogNode, ButtonNode, DialNode, MouseAndKeyboard, TrackerNode, VirtualMouse, DataNode, ProjectionScreen, EggAnimData, EggBin, EggComment, EggCoordinateSystem, EggCurve, EggData, EggExternalReference, EggFilenameNode, EggGroup, EggGroupNode, EggMaterial, EggNamedObject, EggNode, EggNurbsCurve, EggNurbsSurface, EggPoint, EggPolygon, EggPrimitive, EggSAnimData, EggSurface, EggTable, EggTexture, EggVertexPool, EggXfmAnimData, EggXfmSAnim, ImageBuffer, PixelBuffer, Texture, ClassicNurbsCurve, CubicCurveseg, HermiteCurve, NurbsPPCurve, ParametricCurve, PiecewiseCurve, RopeNode, AmbientLight, Camera, DirectionalLight, Fog, GeomNode, LensNode, LightLensNode, LightNode, LODNode, ModelNode, ModelRoot, PandaNode, PlaneNode, PointLight, SelectiveChildNode, SequenceNode, Spotlight, SwitchNode, PGButton, PGEntry, PGItem, PGMouseWatcherBackground, PGMouseWatcherRegion, PGTop, PGWaitBar, ActorNode, ForceNode, PhysicalNode, TextFont, TextNode, ButtonThrower, DriveInterface, MouseWatcher, MouseWatcherRegion, Trackball, Transform2SG, AnimChannel< ACScalarSwitchType >, AnimChannel< ACMatrixSwitchType >, MovingPart< ACScalarSwitchType >, and MovingPart< ACMatrixSwitchType >.

Definition at line 60 of file namable.h.

Referenced by MouseWatcherRegion::init_type().

const Vertexf & LineSegs::get_current_position  ) 
 

Returns the pen's current position.

The next call to draw_to() will draw a line segment from this point.

Definition at line 162 of file lineSegs.cxx.

References _list.

const string & Namable::get_name  )  const [inline, inherited]
 

Definition at line 109 of file namable.I.

Referenced by ComputedVerticesMaker::add_normal(), GLGraphicsStateGuardian::begin_bind_clip_planes(), GLGraphicsStateGuardian::begin_bind_lights(), BuilderBucket::BuilderBucket(), EggVertex::clear_grefs(), AnimBundleMaker::create_xfm_channel(), SceneGraphReducer::do_flatten_siblings(), BuilderBucket::done_geom(), DXTextureContext8::DXTextureContext8(), PartGroup::find_child(), EggLoader::find_collision_geometry(), EggGroupUniquifier::get_category(), PartBundle::get_control_effect(), PartGroup::get_num_children(), EggMorph< Parameter >::get_offset(), AnimChannelBase::has_changed(), Namable::has_name(), EggMaterial::is_equivalent_to(), Texture::load(), EggLoader::make_node(), AnimBundleMaker::make_node(), FindApproxPath::Component::matches(), move_to(), MovingPartBase::MovingPartBase(), NodeMap::NodeMap(), EggMorph< Parameter >::operator<(), operator<<(), MouseWatcherRegion::output(), AnimGroup::output(), EggXfmSAnim::r_transform(), Texture::read(), MouseWatcherGroup::remove_region(), EggLoader::reparent_decals(), CRGraphicsStateGuardian::set_blend_mode(), NodePath::set_color(), GLGraphicsStateGuardian::set_draw_buffer(), AnimChannelScalarTable::set_table(), NodePath::set_transparency(), NodePathComponent::uncollapse(), Texture::unprepare(), TextNode::wordwrap_to(), MovingPartBase::write(), CollisionNode::xform(), and EggVertex::~EggVertex().

int LineSegs::get_num_vertices  )  const [inline]
 

Returns the total number of line segment and point vertices generated by the last call to create().

The positions of these vertices may be read and adjusted through get_vertex() and set_vertex().

Definition at line 213 of file lineSegs.I.

References _created_colors.

Referenced by NurbsCurveDrawer::get_show_hull().

Vertexf LineSegs::get_vertex int  vertex  )  const [inline]
 

Returns the nth point or vertex of the line segment sequence generated by the last call to create().

The first move_to() generates vertex 0; subsequent move_to() and draw_to() calls generate consecutively higher vertex numbers.

Definition at line 234 of file lineSegs.I.

References Colorf, INLINE, and set_vertex_color().

Colorf LineSegs::get_vertex_color int  vertex  )  const [inline]
 

Returns the color of the nth point or vertex/.

Definition at line 292 of file lineSegs.I.

bool Namable::has_name  )  const [inline, inherited]
 

Returns true if the Namable has a nonempty name set, false if the name is empty.

Definition at line 97 of file namable.I.

References Namable::get_name(), and INLINE.

Referenced by EggGroupUniquifier::EggGroupUniquifier(), Texture::read(), and Texture::Texture().

void Namable::init_type void   )  [inline, static, inherited]
 

Reimplemented in AnimBundle, AnimBundleNode, AnimChannel< SwitchType >, AnimChannelBase, AnimChannelFixed< SwitchType >, AnimChannelMatrixXfmTable, AnimChannelScalarTable, AnimGroup, MovingPart< SwitchType >, MovingPartBase, MovingPartMatrix, MovingPartScalar, PartBundle, PartBundleNode, PartGroup, Character, CharacterJoint, CharacterJointBundle, CharacterSlider, CollisionNode, AnalogNode, ButtonNode, DialNode, MouseAndKeyboard, TrackerNode, VirtualMouse, DataNode, ProjectionScreen, EggAnimData, EggBin, EggComment, EggCoordinateSystem, EggCurve, EggData, EggExternalReference, EggFilenameNode, EggGroup, EggGroupNode, EggMaterial, EggNamedObject, EggNode, EggNurbsCurve, EggNurbsSurface, EggPoint, EggPolygon, EggPrimitive, EggSAnimData, EggSurface, EggTable, EggTexture, EggVertexPool, EggXfmAnimData, EggXfmSAnim, ImageBuffer, PixelBuffer, Texture, ClassicNurbsCurve, CubicCurveseg, HermiteCurve, NurbsPPCurve, ParametricCurve, PiecewiseCurve, RopeNode, AmbientLight, Camera, DirectionalLight, Fog, GeomNode, LensNode, LightLensNode, LightNode, LODNode, ModelNode, ModelRoot, PandaNode, PlaneNode, PointLight, SelectiveChildNode, SequenceNode, Spotlight, SwitchNode, PGButton, PGEntry, PGItem, PGMouseWatcherBackground, PGMouseWatcherRegion, PGTop, PGWaitBar, ActorNode, ForceNode, PhysicalNode, TextFont, TextNode, ButtonThrower, DriveInterface, MouseWatcher, MouseWatcherRegion, Trackball, Transform2SG, AnimChannel< ACScalarSwitchType >, AnimChannel< ACMatrixSwitchType >, MovingPart< ACScalarSwitchType >, and MovingPart< ACMatrixSwitchType >.

Definition at line 63 of file namable.h.

References INLINE.

bool LineSegs::is_empty  ) 
 

Returns true if move_to() or draw_to() have not been called since the last reset() or create(), false otherwise.

Definition at line 147 of file lineSegs.cxx.

References _created_colors, _created_verts, _list, PointerToArray< Colorf >::clear(), and PointerToArray< Vertexf >::clear().

void LineSegs::move_to const LVecBase3f &  v  ) 
 

Moves the pen to the given point without drawing a line.

When followed by draw_to(), this marks the first point of a line segment; when followed by move_to() or create(), this creates a single point.

Definition at line 93 of file lineSegs.cxx.

void LineSegs::move_to float  x,
float  y,
float  z
[inline]
 

Moves the pen to the given point without drawing a line.

When followed by draw_to(), this marks the first point of a line segment; when followed by move_to() or create(), this creates a single point.

Definition at line 141 of file lineSegs.I.

References create(), Namable::get_name(), and INLINE.

Referenced by draw_to(), set_color(), ParametricCurveDrawer::set_frame_accurate(), and ParametricCurveDrawer::set_tick_color().

void Namable::output ostream &  out  )  const [inline, inherited]
 

Outputs the Namable.

This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

Reimplemented in BuilderBucket, AnimBundle, AnimChannelBase, AnimChannelFixed< SwitchType >, AnimGroup, PartBundle, CollisionNode, ButtonNode, HermiteCurve, RopeNode, Fog, GeomNode, LensNode, LightLensNode, LightNode, LODNode, PandaNode, PlaneNode, MouseWatcher, and MouseWatcherRegion.

Definition at line 126 of file namable.I.

void LineSegs::reset  ) 
 

Removes any lines in progress and resets to the initial empty state.

Definition at line 73 of file lineSegs.cxx.

References _list.

void LineSegs::set_color const Colorf color  )  [inline]
 

Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to().

Definition at line 105 of file lineSegs.I.

References INLINE, move_to(), Vertexf, x, and y.

void LineSegs::set_color float  r,
float  g,
float  b,
float  a = 1.0f
[inline]
 

Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to().

Definition at line 88 of file lineSegs.I.

References _thick, and INLINE.

Referenced by NurbsCurveDrawer::set_cv_color(), NurbsCurveDrawer::set_knot_color(), ParametricCurveDrawer::set_num_segs(), and NurbsCurveDrawer::~NurbsCurveDrawer().

void Namable::set_name const string &  name  )  [inline, inherited]
 

Definition at line 69 of file namable.I.

References Namable::_name.

Referenced by BuilderBucket::BuilderBucket(), SceneGraphReducer::do_flatten_siblings(), Texture::read(), PandaNode::reparent(), and Texture::Texture().

void LineSegs::set_thickness float  thick  )  [inline]
 

Establishes the line thickness or point size in pixels that will be assigned to all lines and points created by future calls to create().

Definition at line 122 of file lineSegs.I.

References draw_to(), INLINE, Vertexf, x, and y.

void LineSegs::set_vertex int  vertex,
float  x,
float  y,
float  z
[inline]
 

Moves the nth point or vertex of the line segment sequence generated by the last call to create().

The first move_to() generates vertex 0; subsequent move_to() and draw_to() calls generate consecutively higher vertex numbers.

Definition at line 279 of file lineSegs.I.

void LineSegs::set_vertex int  vertex,
const Vertexf vert
[inline]
 

Moves the nth point or vertex of the line segment sequence generated by the last call to create().

The first move_to() generates vertex 0; subsequent move_to() and draw_to() calls generate consecutively higher vertex numbers.

Definition at line 257 of file lineSegs.I.

Referenced by create().

void LineSegs::set_vertex_color int  vertex,
float  r,
float  g,
float  b,
float  a = 1.0f
[inline]
 

Changes the vertex color of the nth point or vertex.

See set_vertex().

Definition at line 325 of file lineSegs.I.

void LineSegs::set_vertex_color int  vertex,
const Colorf color
[inline]
 

Changes the vertex color of the nth point or vertex.

See set_vertex().

Definition at line 309 of file lineSegs.I.

Referenced by NurbsCurveDrawer::get_show_hull(), and get_vertex().


Member Data Documentation

Colorf LineSegs::_color [private]
 

Definition at line 101 of file lineSegs.h.

Referenced by LineSegs::Point::Point(), and ~LineSegs().

PTA_Colorf LineSegs::_created_colors [private]
 

Definition at line 105 of file lineSegs.h.

Referenced by get_num_vertices(), and is_empty().

PTA_Vertexf LineSegs::_created_verts [private]
 

Definition at line 104 of file lineSegs.h.

Referenced by draw_to(), and is_empty().

LineList LineSegs::_list [private]
 

Definition at line 100 of file lineSegs.h.

Referenced by draw_to(), get_current_position(), is_empty(), and reset().

float LineSegs::_thick [private]
 

Definition at line 102 of file lineSegs.h.

Referenced by set_color().


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