AGX Dynamics  2.35.0.1
EmbeddedGLWindow.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 AGXOSG_EMBEDDEDGLWINDOW_H
18 #define AGXOSG_EMBEDDEDGLWINDOW_H
19 
20 
21 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
22 
23 #if defined(_MSC_VER)
24 #include <Winsock2.h>
25 #include <agx/Windows.h>
26 #endif
27 
28 
29 #include <osgViewer/Viewer>
30 #include <osg/Version>
31 
32 #include <osgGA/TrackballManipulator>
33 #include <osgViewer/GraphicsWindow>
34 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
35 
36 #include <agxOSG/export.h>
37 #include <agx/Integer.h>
38 #include <agxSDK/Simulation.h>
39 #include <agxOSG/RenderProxy.h>
40 
41 namespace agxOSG
42 {
47  {
48  public:
49 
52 
59  bool init(int x, int y, int width, int height);
60 
66  void resize(int x, int y, int width, int height);
67  osgGA::EventQueue* getEventQueue() const;
68 
73  void mouseMoveEvent(int x, int y);
74 
80  void mousePressEvent(int x, int y, int button);
81 
87  void mouseReleaseEvent(int x, int y, int button);
88 
94  void keyPressEvent(int key, int mod_mask);
95 
101  void keyReleaseEvent(int key, int mod_mask);
102 
107  void wheelEvent(int motion);
108 
112  void frame();
113 
117  osg::Camera *getCamera();
118 
122  const osg::Camera *getCamera() const;
123 
128  void setSimulation( agxSDK::Simulation *simulation );
129 
134 
139 
143  osg::Group* getRoot();
144 
148  const osg::Group* getRoot() const;
149 
154 
159 
162 
167  void clear();
168 
169  private:
170 
171  osg::ref_ptr<osgViewer::Viewer> m_viewer;
172  agxSDK::SimulationRef m_simulation;
173  osg::ref_ptr<osg::Group> m_root;
174  osg::ref_ptr<agxOSG::SceneDecorator> m_decorator;
175  osgGA::StandardManipulator *m_manipulator;
176 
177  osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> m_embeddedWindow;
178  };
179 }
180 
181 #endif
#define AGXOSG_EXPORT
This class is for embedding an OSG based window inside another OpenGL contex, for example in QT.
void fitSceneIntoView()
Will move the camera so that the whole scene is visible.
osg::Group * getRoot()
void mouseMoveEvent(int x, int y)
Called upon mouse event.
void frame()
Should be called to update the rendering frame.
const osg::Camera * getCamera() const
void mousePressEvent(int x, int y, int button)
Called upon pressing a mouse button.
agxSDK::Simulation * getSimulation() const
const osg::Group * getRoot() const
void resize(int x, int y, int width, int height)
Called at resize of the window.
bool init(int x, int y, int width, int height)
Will initialize the scenegraph, camera, viewer A valid OpenGL context should be initialized and activ...
EmbeddedGLWindow()
Constructor.
void keyPressEvent(int key, int mod_mask)
Called upon a keypress event.
agxOSG::SceneDecorator * getSceneDecorator()
osgGA::EventQueue * getEventQueue() const
void mouseReleaseEvent(int x, int y, int button)
Called upon releasing a mouse button.
void clear()
Will remove simulation, deallocate all scene graph elements After call to this method,...
void setSimulation(agxSDK::Simulation *simulation)
Associate a Simulation to this window.
osg::Camera * getCamera()
void removeSimulation()
Deassociates any registered simulation.
void wheelEvent(int motion)
Called when the mouse wheel is used.
void keyReleaseEvent(int key, int mod_mask)
Called upon a keyrelease event.
~EmbeddedGLWindow()
Destructor.
Decorates a scene with a specific AGX Rendering Style.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.