Panda3D
lineSegs.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file lineSegs.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef LINESEGS_H
15 #define LINESEGS_H
16 
17 #include "pandabase.h"
18 
19 #include "luse.h"
20 #include "geom.h"
21 #include "geomNode.h"
22 #include "geomVertexData.h"
23 #include "namable.h"
24 
25 #include "pvector.h"
26 
27 /**
28  * Encapsulates creation of a series of connected or disconnected line
29  * segments or points, for drawing paths or rays. This class doesn't attempt
30  * to be the smartest it could possibly be; it's intended primarily as a
31  * visualization and editing tool.
32  */
33 class EXPCL_PANDA_GRUTIL LineSegs : public Namable {
34 PUBLISHED:
35  explicit LineSegs(const std::string &name = "lines");
36  ~LineSegs();
37 
38  void reset();
39  INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f);
40  INLINE void set_color(const LColor &color);
41  INLINE void set_thickness(PN_stdfloat thick);
42 
43  INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
44  void move_to(const LVecBase3 &v);
45 
46  INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
47  void draw_to(const LVecBase3 &v);
48 
49  const LVertex &get_current_position();
50  bool is_empty();
51 
52  INLINE GeomNode *create(bool dynamic = false);
53  GeomNode *create(GeomNode *previous, bool dynamic = false);
54 
55  // Functions to move the line vertices after they have been created.
56  INLINE int get_num_vertices() const;
57  LVertex get_vertex(int n) const;
58  MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
59  void set_vertex(int n, const LVertex &vert);
60  INLINE void set_vertex(int vertex, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
61 
62  LColor get_vertex_color(int vertex) const;
63  MAKE_SEQ(get_vertex_colors, get_num_vertices, get_vertex_color);
64  void set_vertex_color(int vertex, const LColor &c);
65  INLINE void set_vertex_color(int vertex, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f);
66 
67 private:
68  class Point {
69  public:
70  INLINE Point();
71  INLINE Point(const LVecBase3 &point, const LColor &color);
72  INLINE Point(const Point &copy);
73  INLINE void operator = (const Point &copy);
74 
75  LVertex _point;
76  UnalignedLVecBase4 _color;
77  };
78 
79  typedef pvector<Point> SegmentList;
80  typedef pvector<SegmentList> LineList;
81 
82  LineList _list;
83  LColor _color;
84  PN_stdfloat _thick;
85 
86  PT(GeomVertexData) _created_data;
87 };
88 
89 #include "lineSegs.I"
90 
91 #endif
geomVertexData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LineSegs
Encapsulates creation of a series of connected or disconnected line segments or points,...
Definition: lineSegs.h:33
lineSegs.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
GeomVertexData
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
Definition: geomVertexData.h:68
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
GeomNode
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:34
namable.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geom.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Namable
A base class for all things which can have a name.
Definition: namable.h:26
geomNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.