OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coVRLabel.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_VR_LABEL
9 #define CO_VR_LABEL
10 
24 // label always faces viewer
25 // line is z axis
26 //
27 // | TEXT
28 // |
29 // |
30 
31 #include <osg/Vec3>
32 #include <osg/Vec4>
33 #include <osg/Array>
34 
35 namespace osg
36 {
37 class MatrixTransform;
38 class Geode;
39 class Geometry;
40 };
41 
42 namespace osgText
43 {
44 class Text;
45 };
46 
47 #include "coBillboard.h"
48 #include <util/coExport.h>
49 namespace opencover
50 {
51 class COVEREXPORT coVRLabel
52 {
53 
54 private:
55  osg::MatrixTransform *posTransform;
56  osg::ref_ptr<coBillboard> billboard;
57  osg::Geode *geode;
58  osgText::Text *text;
59  float offset;
60  osg::Vec3Array *lc, *qc;
61  osg::Geometry *lineGeoset, *quadGeoset;
62  osg::Geode *label;
63  osg::Vec3 position;
64  bool keepPositionInScene;
65  float distanceFromCamera;
66  bool moveToCam;
67 
68  osg::Vec3f moveToCamera(const osg::Vec3f &point, float distance);
69 
70 public:
71  // creates scene graph
72  //
73  // scene
74  // |
75  // posTransform
76  // |
77  // coBillboard
78  // | |
79  // coText lineGeode
80  // | |
81  // lineGeoset quadGeoset
82  coVRLabel(const char *name, float fontsize, float lineLen, osg::Vec4 fgcolor, osg::Vec4 bgcolor);
83  ~coVRLabel();
84 
85  // after construction you may decide to attach posTransform to
86  // a given osg::Group *anchor instead of cover->getScene()
87  // but manipulate the position of the label as if
88  // it were attached to the scene
89 
91  // Does not work correctly!!!!!
93 
94  void reAttachTo(osg::Group *anchor);
95 
96  // position in world coordinates
97  void setPosition(const osg::Vec3 &pos);
98  void setPositionInScene(const osg::Vec3 &pos);
99 
100  // move label towards camera to keep above geometry
101  void keepDistanceFromCamera(bool enable, float distanceFromCamera = 50.0f);
102 
103  // rotation mode
104  /* enum RotationMode
105  {
106  STOP_ROT = 0,
107  AXIAL_ROT,
108  POINT_ROT_EYE,
109  POINT_ROT_WORLD
110  };*/
111 
112  void setRotMode(coBillboard::RotationMode mode);
113  //RotationMode getMode() const;
114 
115  // update the linelen
116  void setLineLen(float lineLen);
117 
118  // update the label string
119  void setString(const char *name);
120 
121  void setFGColor(osg::Vec4 fgc);
122 
123  // show label
124  void show();
125 
126  // hide label
127  void hide();
128 
129  // show line
130  void showLine();
131 
132  // hide line
133  void hideLine();
134  // RotationMode _mode;
135 
136  void update();
137 };
138 }
139 #endif
osg billboard group node
RotationMode
Definition: coBillboard.h:107
Definition: coVRLabel.h:51