AGX Dynamics  2.38.0.2
CameraViewSet.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXQT_CAMERAVIEWSET_H
18 #define AGXQT_CAMERAVIEWSET_H
19 
20 #include <agxQt/export.h>
21 #include <agx/Referenced.h>
22 #include <agx/List.h>
23 #include <agx/Vec3.h>
24 #include <agx/Vector.h>
25 
26 #define DEFAULT_CAMERADESCRIPTION_FOV 30.0
27 
28 // Forward declaration
29 namespace osg
30 {
31  class Camera;
32 }
33 
34 namespace osgViewer
35 {
36  class Viewer;
37 }
38 
39 namespace agxCFG
40 {
41  class ConfigScript;
42 }
43 
44 namespace agxQt
45 {
46 
47  class CameraDescription;
48  class CameraDescriptionSet;
51 
60  {
62 
63  public:
66 
68  void addCamera(CameraDescription * camera);
69  void removeCamera(CameraDescription * camera);
70 
72  agx::UInt getActiveCameraIndex();
73 
75  agx::UInt nextCameraDescription();
76 
78  agx::UInt previousCameraDescription();
79 
81  CameraDescription* getCameraDescription(const agx::UInt& index);
82 
84  CameraDescription* getActiveCameraDescription();
85 
87  CameraDescription* getCameraDescriptionFromName(const agx::String& name);
88 
90  void setActiveCameraViewIndex(agx::UInt index);
91 
93  bool containsCameraDescription(const CameraDescription* camera);
94 
96  agx::UInt getNumberOfCameraDescriptions();
97 
99  bool setActiveViewFromName(const agx::String& name);
100 
102  bool removeCameraViewFromName(const agx::String& name);
103 
105  bool renameCameraDescription(const agx::String& oldname, const agx::String& newName);
106 
108  agx::Vector<agx::String> getCameraViewNames();
109 
111  agx::String toString();
112 
113  protected:
114  bool getIndexFromCamera(CameraDescription * camera, agx::UInt& index);
115 
117  virtual ~CameraDescriptionSet();
118 
119 
121  // Variables
123  protected:
126  };
127 
132  {
133  public:
136 
138  void setInformation(const agx::Vec3 &eye, const agx::Vec3& center, const agx::Vec3& up, agx::Real fov);
139 
141  void setName(const agx::String& name);
142  const agx::String& getName() const;
143 
145  bool isValid() const;
146 
148  const agx::Vec3& getCenter() const;
149 
151  const agx::Vec3& getUp() const;
152 
154  const agx::Vec3& getEye() const;
155 
157  const agx::Real getFov() const;
158 
160  const agx::String toString() const;
161 
162  protected:
163 
165  virtual ~CameraDescription();
166 
168  // Variables
170  protected:
175 
178  };
179 
180  /* Implementation */
182 
184 
186 
188 
190 
192 
197  {
198  public:
201 
203  void storeCurrentView(osgViewer::Viewer *viewer);
204 
206  void setActiveView(osgViewer::Viewer * viewer);
207 
209  void setNextView(osgViewer::Viewer * viewer);
210 
212  void setPreviousView(osgViewer::Viewer * viewer);
213 
215  bool setActiveViewFromName(const agx::String& name);
216 
218  bool removeCameraViewFromName(const agx::String& name);
219 
221  agx::String getActiveCameraViewName() const;
222 
224  agx::Vector<agx::String> getCameraViewNames();
225 
227  bool storeViewsetAsCFGFile(const agx::String& filename);
228 
230  bool restoreViewsetFromCFGFile(const agx::String& filename);
231 
233  CameraDescriptionSet* getCameraDescriptionSet();
234 
236  static CameraDescription* getCameraDescriptionFromOsgViewer(osgViewer::Viewer * viewer);
237 
238  protected:
239  void setViewOnOSGViewer(CameraDescription* c, osgViewer::Viewer* viewer);
240 
242  bool parseCameraState(agxCFG::ConfigScript * cfg, CameraDescription *c);
243 
245  bool storeCameraState(agxCFG::ConfigScript * cfg, CameraDescription *c);
246 
248  virtual ~OsgCameraViewManager();
249 
250 
252  // Variables
254  protected:
256  };
257 
259 
260  /*Implementation*/
262 
263 }
264 
265 #endif
agxQt::CameraDescription::m_name
agx::String m_name
Name of the camera description.
Definition: CameraViewSet.h:177
agxQt::CameraDescription::m_eye
agx::Vec3 m_eye
Definition: CameraViewSet.h:172
agx::UInt
uint64_t UInt
Definition: Integer.h:27
Referenced.h
agx::Real
double Real
Definition: Real.h:42
agxQt::CameraDescription::getName
const agx::String & getName() const
Definition: CameraViewSet.h:191
agx::List< CameraDescriptionRef >
AGXQT_EXPORT
#define AGXQT_EXPORT
Vector.h
agxQt
Contains classes/utility functions for connecting AGX to QT with OSG.
Definition: AnalysisBoundWidget.h:30
agxQt::OsgCameraViewManager
Manager class that acts as a wrapper container for the CameravViewset class for OSG based view system...
Definition: CameraViewSet.h:196
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxQt::CameraDescription::getUp
const agx::Vec3 & getUp() const
Get up vector.
Definition: CameraViewSet.h:183
export.h
agxQt::OsgCameraViewManager::getCameraDescriptionSet
CameraDescriptionSet * getCameraDescriptionSet()
Returns the internal structure of the camera view set.
Definition: CameraViewSet.h:261
agxQt::CameraDescriptionSet::m_activeCameraIndex
agx::UInt m_activeCameraIndex
Definition: CameraViewSet.h:125
agxQt::CameraDescription::getFov
const agx::Real getFov() const
Get Field of view.
Definition: CameraViewSet.h:187
agxQt::OsgCameraViewManager::m_cameraSet
CameraDescriptionSetRef m_cameraSet
Definition: CameraViewSet.h:255
agxQt::CameraDescription::m_fov
agx::Real m_fov
Definition: CameraViewSet.h:174
Vec3.h
agx::ref_ptr< CameraDescriptionSet >
agxModel::getCenter
AGXMODEL_EXPORT agx::Vec3 getCenter(const agxCollide::Mesh::Triangle &triangle)
agxQt::CameraDescriptionSet::m_cameraDescriptionContainer
CameraDescriptionList m_cameraDescriptionContainer
Definition: CameraViewSet.h:124
agxQt::CameraDescription::setName
void setName(const agx::String &name)
Set name of the camera description.
Definition: CameraViewSet.h:189
agxQt::CameraDescription::m_up
agx::Vec3 m_up
Definition: CameraViewSet.h:173
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agxQt::CameraDescription::getEye
const agx::Vec3 & getEye() const
Get Eye vector.
Definition: CameraViewSet.h:185
agx::AgXString< std::string >
agx::Vec3T< Real >
agxQt::CameraDescription::getCenter
const agx::Vec3 & getCenter() const
Get center.
Definition: CameraViewSet.h:181
agxQt::CameraDescriptionSet
CameraViewSet is a class that handles and manages a set of cameras that the user should be able to sw...
Definition: CameraViewSet.h:59
agxQt::CameraDescription
Class that describes an abstract camera and it's properties.
Definition: CameraViewSet.h:131
agxQt::CameraDescription::m_center
agx::Vec3 m_center
Definition: CameraViewSet.h:171
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::ref_ptr::get
T * get() const
Definition: ref_ptr.h:256
List.h