AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QtOSGUtils.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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_QTOSGUTILS_H
18 #define AGXQT_QTOSGUTILS_H
19 
21 #include <agxQt/export.h>
22 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
23 #include <agxQt/ui_RenderController.h>
24 #include <QWidget>
25 #include <osgViewer/ViewerEventHandlers>
26 #include <osg/Group>
27 #include <osgViewer/Renderer>
28 #include <osgSim/ColorRange>
29 #include <osgSim/ScalarsToColors>
30 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
31 
34 #include <agxQt/ParticleFilters.h>
35 #include <agxQt/CameraViewSet.h>
36 #include <agx/Referenced.h>
41 #include <agxOSG/ClipPlane.h>
44 
45 namespace agxOSG
46 {
47  class SceneDecorator;
48  class Node;
49  class Group;
50 }
51 
52 namespace agxQt
53 {
54  class QtAgxWrapper;
55 
61  {
62  public:
63  const agx::Vec3 BASE_NORMAL = agx::Vec3(0, 1, 0);
64 
65  public:
68 
69  void setPosition( agx::Vec3 position );
70 
71  void setRotation(const agx::Quat& quat );
72 
73  agx::Vec3 getPosition() const;
74 
75  agx::Quat getRotation() const;
76 
77  bool getEnable() const;
78 
79  void setEnable(bool enable);
80 
81  bool getEnableRendering() const;
82 
83  void setEnableRendering(bool enable);
84 
85  agx::Real getIncrement() const;
86 
87  void setIncrement(agx::Real increment);
88 
90  void incrementClipPlane();
91 
93  void decrementClipPlane();
94 
95  protected:
96  void updateClipPlaneFromIncrement( agx::Real increment );
97 
99  virtual ~ClipPlaneController();
100 
102  // Variables
104  protected:
109  };
110 
112 
114  // ParticleTrajectoryRenderer
117  {
119 
120  public:
122  osg::Group* root,
123  agx::ParticleSystem* ps );
124 
125  void setMaxPositionPoints( agx::UInt posPoints );
126 
128 
129  void setEnable( bool enable );
130 
131  bool getEnable() const;
132 
133  void setSampling( agx::Real enable );
134 
135  agx::Real getSampling() const;
136 
137  void reSample();
138 
139  void resetTrajectoires();
140 
141  protected:
142  virtual ~TrajectoryRenderer();
143 
145  // Variables
148  osg::observer_ptr<osg::Group> m_root;
149  osg::ref_ptr<osg::Geode> m_trajectoryGeode;
152  bool m_enable;
153 
154  osg::ref_ptr < agxOSG::ParticleTrajectoriesDrawable > m_particleTrajectoryDrawable;
155  osg::ref_ptr < agxOSG::RigidBodyTrajectoryDrawable > m_RBTrajectorydrawable;
156  };
157 
159 
160 
162  // ParticleContactGraphRenderer
165  {
166  public:
168 
169  void setEnable(bool enable);
170 
171  bool getEnable() const;
172 
174 
175  void setMinNetworkForce(agx::Real minForce);
176 
178 
179  void setMaxNetworkForce(agx::Real minForce);
180 
181  protected:
183 
185  // Variables
187  osg::observer_ptr<osg::Group> m_root;
190  };
191 
193 
195 
197 
199 
201 
203 
208  {
209  public:
211  agxQt::QtAgxWrapper* qtagxViewer,
212  osg::Group* root,
214  agx::ParticleSystem* system);
215 
217 
219 
220  void setAlphaValue(agx::Real alpha);
221 
222  agx::Real getAlphaValue() const;
223 
224  virtual void pre(const agx::TimeStamp& t);
225 
226  virtual void post(const agx::TimeStamp& t);
227 
228  void setParticleColorModeFromName(const agx::String& mode);
229 
231 
233 
235 
236  void setMaxColorScalar(agx::Real maxVel);
237 
238  void setMinColorScalar(agx::Real minVel);
239 
241 
243 
244  void setAnalysisBox(const agx::AnalysisBox* box);
245 
246  void setLimitColoringToAnalysisBound(bool enable);
247 
248  bool getLimitColoringToAnalysisBound() const;
249 
250  void setShowColorLegend(bool enable, int width, int height);
251 
252  void setShowColorLegend(bool enable);
253 
254  void updateColorLegend(int width, int height);
255 
256  void refreshColorLegend();
257 
258  bool getShowColorLegend() const;
259 
260  void setEnableParticleRendering(bool enable);
261 
262  bool getEnableParticleRendering() const;
263 
265 
267 
269 
270  void addCustomColorers();
271 
272  bool hasOpenColorLegend() const;
273 
275 
276  protected:
277 
279 
280  void preRender();
281 
282  void resetAlphaOnColors();
283 
284  void setAlphaOnParticles(agx::Real alpha);
285 
286  void removeColorLegend();
287 
289  // Variables
291  protected:
296 
297  // color renderer
298  osg::ref_ptr<osg::Group> m_hudGroup;
299  osg::observer_ptr<osg::Group> m_root;
300 
304 
305  // Impacts drawable
306  osg::ref_ptr<agxQt::GranularImpactsDrawable> m_impactsDrawable;
307  };
308 
310 
311  /* Implementation */
312 
314 
316 
318 
320 
322 
324  {
326  return m_particleColorerManager->getMinScalar();
327  else
328  return 0;
329  }
330 
332  {
334  return m_particleColorerManager->getMaxScalar();
335  else
336  return 0;
337  }
338 
340 
342 
344 
346 
347  osg::Geode * createCube(const agx::Vec3& position, const agx::Vec3& boxhalfVec3);
348  osg::Geode * createCubeLines(const agx::Vec3& position, const agx::Vec3& boxhalfVec3);
349  osg::Geode * createPlaneLines(const agx::Vec3& position, const agx::Vec3& normal, agx::Real size);
350 
351 #if AGX_USE_KEYSHOT()
352 
355  class KeyShotParticleDumper
356  {
357  KeyShotParticleDumper();
358  public:
359 
360  static void dumpParticlesInSimulationToKeyShotFile(agxSDK::Simulation * simulation, agx::String filename);
361 
362  static void exportCurrentJournalFrameToBip(int frame,
363  const agx::String& journalFilename,
364  const agx::String& sessionName,
365  const agx::String& bipFile,
366  agxQt::CameraDescription* camera,
368 
369  protected:
371  // Variables
373  };
374 #endif
375 }
376 
377 #endif
agx::UInt m_numTrajectoryPositions
Definition: QtOSGUtils.h:150
agxOSG::ParticleContactGraphDrawable * m_graphDrawable
Definition: QtOSGUtils.h:189
ParticleColorModeVector getAvailableColorModes() const
Definition: QtOSGUtils.h:317
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
osg::Geode * createCubeLines(const agx::Vec3 &position, const agx::Vec3 &boxhalfVec3)
TrajectoryRenderer(agxSDK::Simulation *simulation, osg::Group *root, agx::ParticleSystem *ps)
agxOSG::ParticleSystemDrawable::ParticleShaderMode getParticleShaderMode() const
agx::ParticleSystem * m_system
Definition: QtOSGUtils.h:294
Derive from this class to implement a listener for simulation Step events.
ParticleContactGraphRenderer(osg::Group *root, agx::ParticleSystem *ps)
void setParticleColorModeFromName(const agx::String &mode)
void setPosition(agx::Vec3 position)
This utility class is used for post processing of the particle system drawable representation, such as alpha rendering and velocity color.
Definition: QtOSGUtils.h:207
ParticleRenderFilterManager * getParticleRenderFilterManager()
virtual ~ClipPlaneController()
Destructor.
agxQt::QtAgxWrapper * m_qtAgxWrapper
Definition: QtOSGUtils.h:292
void setEnable(bool enable)
osg::ref_ptr< agxOSG::ParticleTrajectoriesDrawable > m_particleTrajectoryDrawable
Definition: QtOSGUtils.h:154
void setParticleShaderMode(agxOSG::ParticleSystemDrawable::ParticleShaderMode mode)
agx::ParticleSystem * m_particleSystem
Definition: QtOSGUtils.h:188
osg::ref_ptr< agxQt::GranularImpactsDrawable > m_impactsDrawable
Definition: QtOSGUtils.h:306
void setShowColorLegend(bool enable, int width, int height)
agx::Real getSampling() const
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agx::Real getIncrement() const
#define AGX_FORCE_INLINE
Definition: Object.h:62
This class wraps the ClipPlane functionality of osg together with a clip node and a clip plane...
Definition: ClipPlane.h:43
agx::Real TimeStamp
Definition: TimeStamp.h:26
ParticleContactGraphRendererRef getParticleContactGraphRenderer()
Definition: QtOSGUtils.h:343
void setMinNetworkForce(agx::Real minForce)
Definition: QtOSGUtils.h:198
agx::ParticleSystem * m_particleSystem
Definition: QtOSGUtils.h:147
osg::observer_ptr< osg::Group > m_root
Definition: QtOSGUtils.h:187
ClipPlaneController(agxOSG::ClipPlane *clipPlane)
Constructor.
Base class providing referencing counted objects.
Definition: Referenced.h:113
void setMaxColorScalar(agx::Real maxVel)
osg::observer_ptr< osg::Group > m_root
Definition: QtOSGUtils.h:148
void setEnableParticleRendering(bool enable)
Definition: QtOSGUtils.h:341
agxOSG::ParticleSystemDrawable * m_psDrawable
Definition: QtOSGUtils.h:293
A basic particle system that contains all the storages and buffers required for basic operation and a...
uint32_t UInt
Definition: Integer.h:34
agx::Real getMaxColorScalar() const
Definition: QtOSGUtils.h:331
osg::Geode * createPlaneLines(const agx::Vec3 &position, const agx::Vec3 &normal, agx::Real size)
void updateColorLegend(int width, int height)
bool getEnableParticleRendering() const
Definition: QtOSGUtils.h:339
agx::Quat getRotation() const
agx::Vec3 getPosition() const
void setSampling(agx::Real enable)
GranularImpactsDrawable * getGranularImpactsDrawable()
Definition: QtOSGUtils.h:345
void setAlphaValue(agx::Real alpha)
void setMinColorScalar(agx::Real minVel)
void setRotation(const agx::Quat &quat)
osg::ref_ptr< osg::Geode > m_trajectoryGeode
Definition: QtOSGUtils.h:149
void setEnableRendering(bool enable)
Class that can be used to extract data from elements in a simulation within a specified bound...
Definition: AnalysisBox.h:31
void incrementClipPlane()
Increments the Near plane of the scene in the coupled agxViewer.
ParticleColorerManagerRef m_particleColorerManager
Definition: QtOSGUtils.h:302
bool getLimitColoringToAnalysisBound() const
Definition: QtOSGUtils.h:321
agx::Real getAlphaValue() const
Definition: QtOSGUtils.h:313
void setAlphaOnParticles(agx::Real alpha)
virtual void post(const agx::TimeStamp &t)
Called after a step is taken in the simulation Implement this method in the derived class to get call...
void setAnalysisBox(const agx::AnalysisBox *box)
void setIncrement(agx::Real increment)
osg::ref_ptr< agxOSG::RigidBodyTrajectoryDrawable > m_RBTrajectorydrawable
Definition: QtOSGUtils.h:155
ParticleRenderFilterManagerRef m_particleRenderFilterManager
Definition: QtOSGUtils.h:303
void decrementClipPlane()
Decrements the Near plane of the scene in the coupled agxViewer.
Class that describes an abstract camera and it&#39;s properties.
void setMaxPositionPoints(agx::UInt posPoints)
agx::Real getMinColorScalar() const
Definition: QtOSGUtils.h:323
ParticleColorMode getActiveParticleColorMode() const
Definition: QtOSGUtils.h:315
agx::UInt getMaxPositionPoints()
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:121
void colorParticlesWithActivePostProcess(agx::ParticleSystem *system)
Class that is used to manipulate the clip plane in the scene.
Definition: QtOSGUtils.h:60
agx::Real getMinNetworkForce() const
Definition: QtOSGUtils.h:200
void updateClipPlaneFromIncrement(agx::Real increment)
ParticleContactGraphRendererRef m_particleContactGraphRenderer
Definition: QtOSGUtils.h:301
ParticleSystemRenderUtility(agxQt::QtAgxWrapper *qtagxViewer, osg::Group *root, agxOSG::ParticleSystemDrawable *psdraw, agx::ParticleSystem *system)
const agx::Vec3 BASE_NORMAL
Definition: QtOSGUtils.h:63
double Real
Definition: Real.h:42
void setEnable(bool enable)
AGXCORE_EXPORT Component * root()
void setLimitColoringToAnalysisBound(bool enable)
Definition: QtOSGUtils.h:319
virtual void pre(const agx::TimeStamp &t)
Called before a step is taken in the simulation Implement this method in the derived class to get cal...
void setMaxNetworkForce(agx::Real minForce)
Definition: QtOSGUtils.h:196
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
Definition: QtAgxWrapper.h:71
osg::Geode * createCube(const agx::Vec3 &position, const agx::Vec3 &boxhalfVec3)
agx::Real getMaxNetworkForce() const
Definition: QtOSGUtils.h:202
osg::ref_ptr< osg::Group > m_hudGroup
Definition: QtOSGUtils.h:298
osg::observer_ptr< osg::Group > m_root
Definition: QtOSGUtils.h:299
agxOSG::ClipPlane * m_clipPlane
Definition: QtOSGUtils.h:105
bool getEnableRendering() const