AGX Dynamics  2.35.0.1
CameraViewSet.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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);
70 
73 
76 
79 
82 
85 
88 
91 
94 
97 
100 
103 
105  bool renameCameraDescription(const agx::String& oldname, const agx::String& newName);
106 
109 
112 
113  protected:
115 
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 
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 
216 
219 
222 
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 
249 
250 
252  // Variables
254  protected:
256  };
257 
259 
260  /*Implementation*/
262 
263 }
264 
265 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXQT_EXPORT
CameraViewSet is a class that handles and manages a set of cameras that the user should be able to sw...
Definition: CameraViewSet.h:60
virtual ~CameraDescriptionSet()
Destructor.
agx::String toString()
Print the set.
CameraDescriptionSet()
Constructor.
CameraDescription * getActiveCameraDescription()
Returns the active camera description in the set.
bool removeCameraViewFromName(const agx::String &name)
Remove a loaded camera view given an string identifier. Returns false if not found,...
agx::UInt nextCameraDescription()
Increments the active camera index to the next one. If the active camera index is at max,...
agx::UInt getActiveCameraIndex()
Get the active camera index in the set.
void addCamera(CameraDescription *camera)
Add/Remove a camera to the camera set.
void removeCamera(CameraDescription *camera)
void setActiveCameraViewIndex(agx::UInt index)
Sets the active camera view index. If the index is out of bounds, nothing happens.
agx::Vector< agx::String > getCameraViewNames()
Get the names for all loaded views.
bool containsCameraDescription(const CameraDescription *camera)
Check if the camera is contained in the set.
CameraDescription * getCameraDescriptionFromName(const agx::String &name)
Returns a camera description given a name.
bool renameCameraDescription(const agx::String &oldname, const agx::String &newName)
Tries to rename a camera description given a name identifier. Returns false if no camera description ...
agx::UInt getNumberOfCameraDescriptions()
Returns the number of camera descriptions in the active set.
bool getIndexFromCamera(CameraDescription *camera, agx::UInt &index)
agx::UInt previousCameraDescription()
Decrements the active camera index to the previous one. If the active camera index is at 0,...
CameraDescriptionList m_cameraDescriptionContainer
CameraDescription * getCameraDescription(const agx::UInt &index)
Gets the camera description given an index.
bool setActiveViewFromName(const agx::String &name)
Set active view in manager from name. Returns false if not found, true if found and deleted.
Class that describes an abstract camera and it's properties.
const agx::String & getName() const
virtual ~CameraDescription()
Destructor.
const agx::Vec3 & getUp() const
Get up vector.
const agx::Vec3 & getEye() const
Get Eye vector.
const agx::String toString() const
Formats the description to a string.
CameraDescription()
Constructor.
const agx::Real getFov() const
Get Field of view.
agx::String m_name
Name of the camera description.
void setName(const agx::String &name)
Set name of the camera description.
const agx::Vec3 & getCenter() const
Get center.
bool isValid() const
Checks if the camera description is valid.
void setInformation(const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up, agx::Real fov)
Set Camera information.
Manager class that acts as a wrapper container for the CameravViewset class for OSG based view system...
CameraDescriptionSet * getCameraDescriptionSet()
Returns the internal structure of the camera view set.
CameraDescriptionSetRef m_cameraSet
bool removeCameraViewFromName(const agx::String &name)
Remove a loaded camera view given an string identifier. Returns false if not found,...
virtual ~OsgCameraViewManager()
Default destructor.
agx::Vector< agx::String > getCameraViewNames()
Get the names for all loaded views.
void setViewOnOSGViewer(CameraDescription *c, osgViewer::Viewer *viewer)
agx::String getActiveCameraViewName() const
Returns the active view name.
void storeCurrentView(osgViewer::Viewer *viewer)
Stores the current view in osg viewer.
void setNextView(osgViewer::Viewer *viewer)
Toggles the next view in stored views and sets it to an osgViewer.
OsgCameraViewManager()
Default constructor.
void setPreviousView(osgViewer::Viewer *viewer)
Toggles a previous view in stored views and sets it to an osgViewer.
bool parseCameraState(agxCFG::ConfigScript *cfg, CameraDescription *c)
Tries to parse a camera state from the current position in the config script.
static CameraDescription * getCameraDescriptionFromOsgViewer(osgViewer::Viewer *viewer)
Utility method for converting osgViewer views to CameraViewDescriptions.
bool storeCameraState(agxCFG::ConfigScript *cfg, CameraDescription *c)
Stores the camera description in the in the current place in the configure script.
bool setActiveViewFromName(const agx::String &name)
Set active view in manager from name. Returns false if not found, true if found and deleted.
void setActiveView(osgViewer::Viewer *viewer)
Sets the active view in the manager an osgViewer.
bool restoreViewsetFromCFGFile(const agx::String &filename)
Restores the a view set from a .cfg file. Will overwrite the current view set in the manager.
bool storeViewsetAsCFGFile(const agx::String &filename)
Store the active configuration to a file.
Base class providing referencing counted objects.
Definition: Referenced.h:114
Templated vector class.
Definition: agx/Vector.h:53
T * get() const
Definition: ref_ptr.h:256
#define AGX_FORCE_INLINE
Definition: macros.h:58
AGXMODEL_EXPORT agx::Vec3 getCenter(const agxCollide::Mesh::Triangle &triangle)
Contains classes/utility functions for connecting AGX to QT with OSG.
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42