ADTF_DISPLAY_TOOLBOX  3.8.0 (ADTF 3.14.3)
baseobject.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <osg/Array>
10 #include <osg/ShapeDrawable>
11 #include <osg/Switch>
12 
13 #include <a_utils/a_utils.h>
14 #include <memory>
15 
16 namespace adtf
17 {
18 
19 namespace disptb
20 {
21 
22 namespace mixinlib
23 {
24 
25 namespace endor
26 {
27 
28 
39 class cBaseObject : public osg::Switch
40 {
41 protected:
43  tUInt32 m_nId;
44 
45  // object
47  osg::ref_ptr<osg::PositionAttitudeTransform> m_pTransform;
49  osg::ref_ptr<osg::ShapeDrawable> m_pDrawable;
51  osg::ref_ptr<osg::Box> m_pBox;
52 
53  // history
55  osg::ref_ptr<osg::Geometry> m_pHistoryGeom;
57  osg::ref_ptr<osg::DrawArrays> m_pHistoryArray;
58 
59  // motion vector
61  osg::ref_ptr<osg::Geometry> m_pMotionGeom;
63  osg::ref_ptr<osg::DrawArrays> m_pMotionArray;
64 
65  // payload data
67  osg::Vec3d m_vPos;
68 
69  // position history
71  osg::ref_ptr<osg::Vec3Array> m_pPositionHistory;
73  tUInt32 m_nHistorySize;
74 
75  // motion vector data
77  osg::ref_ptr<osg::Vec3Array> m_pMotionVector;
78 
79  // color array for both history an motion vector
81  osg::ref_ptr<osg::Vec4Array> m_pColorArray;
82 
84  osg::ref_ptr<osg::Switch> m_pSelectionSwitch;
85  osg::ref_ptr<osg::Geode> m_pSelectionGeode;
86  osg::ref_ptr<osg::ShapeDrawable> m_pSelectionDrawable;
87  osg::ref_ptr<osg::Box> m_pSelectionBox;
89 
90  // state data
92  tBool m_bHistory;
96  tBool m_bSelected;
98  tBool m_bUpdated;
99 
100 public:
105  cBaseObject(tUInt32 nId);
106 
110  virtual ~cBaseObject();
111 
116  tUInt32 GetId();
117 
123  tResult Update();
124 
129  tBool IsUpdated();
130 
135  tResult Reset();
136 
148  virtual tResult SetHistory(tBool bEnabled, tUInt32 nCount = 0);
149 
155  virtual tResult SetMotionVector(tBool bEnabled);
156 
162  virtual tResult SetPosition(tFloat64 fPosX,
163  tFloat64 fPosY,
164  tFloat64 fPosZ);
165 
170  osg::Vec3d GetPosition();
171 
177  virtual tResult SetRotation(tFloat64 fRotX,
178  tFloat64 fRotY,
179  tFloat64 fRotZ);
180 
185  osg::Vec3d GetRotation();
186 
192  virtual tResult SetSize(tFloat64 fSizeX,
193  tFloat64 fSizeY,
194  tFloat64 fSizeZ);
195 
200  osg::Vec3d GetSize();
201 
208  virtual tResult SetColor(tFloat64 fRed,
209  tFloat64 fGreen,
210  tFloat64 fBlue,
211  tFloat64 fAlpha);
212 
219  virtual tResult SetMotion(tFloat64 fMotionX,
220  tFloat64 fMotionY,
221  tFloat64 fMotionZ);
222 
227  osg::Vec3d GetMotion();
228 
234  virtual tResult SetSelected(tBool bSelected);
235 
240  virtual tBool IsSelected();
241 
242 protected:
243 
248  virtual tResult UpdateSelection();
249 
250 protected:
251  class cImplementation;
255  std::unique_ptr<cImplementation> m_pImplementation;
256 };
257 
258 } // chewbacca
259 
261 using endor::cBaseObject;
262 
263 } // mixinlib
264 
265 } // disptb
266 
267 } // adtf
Base class for objects that can be managed with cBaseObjectScene.
Definition: baseobject.h:40
tBool IsUpdated()
Returns whether or not this object has been updated since the last Reset call.
virtual tResult SetHistory(tBool bEnabled, tUInt32 nCount=0)
Enables or disable the history trail of this object.
osg::Vec3d GetMotion()
Returns the current motion vector.
tResult Reset()
Resets the updated property to false.
virtual tResult SetRotation(tFloat64 fRotX, tFloat64 fRotY, tFloat64 fRotZ)
Sets the rotation (attitude) of the object.
osg::ref_ptr< osg::ShapeDrawable > m_pDrawable
The drawable for the box.
Definition: baseobject.h:49
tBool m_bUpdated
Whether or not this object has been updated.
Definition: baseobject.h:98
virtual tResult SetMotionVector(tBool bEnabled)
Enables or disables the motion vector.
tBool m_bSelected
Whether or not this object is selected.
Definition: baseobject.h:96
virtual tResult SetMotion(tFloat64 fMotionX, tFloat64 fMotionY, tFloat64 fMotionZ)
Sets the motion vector of the object.
osg::ref_ptr< osg::Vec3Array > m_pMotionVector
The start and end point of the motion vector.
Definition: baseobject.h:77
osg::ref_ptr< osg::DrawArrays > m_pMotionArray
This will do the actual drawing of the motion vector.
Definition: baseobject.h:63
osg::Vec3d GetRotation()
Returns the current rotation.
virtual tBool IsSelected()
Returns the selected property of the object.
osg::ref_ptr< osg::Geometry > m_pHistoryGeom
Geometry object used for rendering the history trail.
Definition: baseobject.h:55
tUInt32 GetId()
Returns the id of the object.
osg::Vec3d GetSize()
Returns the current size.
osg::ref_ptr< osg::Vec3Array > m_pPositionHistory
This will store old positions for drawing the history trail.
Definition: baseobject.h:71
osg::ref_ptr< osg::DrawArrays > m_pHistoryArray
This will do the actual drawing of the history trail.
Definition: baseobject.h:57
std::unique_ptr< cImplementation > m_pImplementation
D-Pointer implementation.
Definition: baseobject.h:251
tResult Update()
Base Implementation sets the updated property to true.
osg::Vec3d m_vPos
The current position of the object.
Definition: baseobject.h:67
virtual tResult SetSelected(tBool bSelected)
Gives the object a chance to change its appearance when being selected or unselected.
virtual tResult SetSize(tFloat64 fSizeX, tFloat64 fSizeY, tFloat64 fSizeZ)
Sets the dimensions of the object.
virtual tResult SetColor(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue, tFloat64 fAlpha)
Sets the color of the object.
virtual tResult UpdateSelection()
Used to update the selection sphere.
osg::ref_ptr< osg::PositionAttitudeTransform > m_pTransform
The transform that applies the translation and rotation to the box.
Definition: baseobject.h:47
virtual tResult SetPosition(tFloat64 fPosX, tFloat64 fPosY, tFloat64 fPosZ)
Sets the position of the object.
tBool m_bHistory
Whether or not to show the history trail.
Definition: baseobject.h:92
osg::Vec3d GetPosition()
Returns the current position.
osg::ref_ptr< osg::Geometry > m_pMotionGeom
Geometry object used for rendering the motion vector.
Definition: baseobject.h:61
tBool m_bMotionVector
Whether or not to show the motion vector.
Definition: baseobject.h:94
osg::ref_ptr< osg::Vec4Array > m_pColorArray
The color array used for drawing the history trail and the motion vector.
Definition: baseobject.h:81
osg::ref_ptr< osg::Box > m_pBox
The box that represents the object.
Definition: baseobject.h:51
tUInt32 m_nHistorySize
The maximum amount of positions in the m_pPositionHistory array.
Definition: baseobject.h:73
Main namespace.