AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
QtOSGUtils.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXQT_QTOSGUTILS_H
18#define AGXQT_QTOSGUTILS_H
19
20#include <agx/config/AGX_USE_KEYSHOT.h>
21#include <agxQt/export.h>
22
26#include <agxQt/CameraViewSet.h>
27#include <agx/Referenced.h>
32#include <agxOSG/ClipPlane.h>
35
36#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
37#include <osgViewer/ViewerEventHandlers>
38#include <osg/Group>
39#include <osgViewer/Renderer>
40#include <osgSim/ColorRange>
41#include <osgSim/ScalarsToColors>
42#include <agx/PopDisableWarnings.h> // End of disabled warnings.
43
44namespace agxOSG
45{
46 class SceneDecorator;
47 class Node;
48 class Group;
49}
50
51namespace agxQt
52{
53
76
77 class QtAgxWrapper;
78
84 {
85 public:
87
88 public:
91
92 void setPosition( agx::Vec3 position );
93
94 void setRotation(const agx::Quat& quat );
95
97
99
100 bool getEnable() const;
101
102 void setEnable(bool enable);
103
104 bool getEnableRendering() const;
105
106 void setEnableRendering(bool enable);
107
109
110 void setIncrement(agx::Real increment);
111
114
117
119
120 protected:
122
125
127 // Variables
129 protected:
134 };
135
141 {
142 public:
155 using AxesState = agx::BitState<State, agx::Int32>;
156
157 public:
160
161 void setPosition( agx::Vec3 position );
162
163 void setRotation( const agx::Quat& quat );
164
165 void setSize( const agx::Real size );
166
167 void setLineWidth( agx::Real lineWidth );
168
169 void setTickSize( const agx::Real tickSize );
170
171 void setNumTicks( const agx::UInt numTicks );
172
173 void setTickTextStride( const agx::UInt stride );
174
175 void setTickTextSize( agx::Real tickTextSize );
176
177 void setTickColor( const agxRender::Color& color );
178
180
182
184
186
188
190
192
194
196
198
200
201 bool getEnable() const;
202
203 void setEnable( bool enable );
204
205 bool getEnableTicks() const;
206
207 void setEnableTicks( bool enable );
208
209 bool getEnableTicksText() const;
210
211 void setEnableTicksText( bool enable );
212
213 void setEnableGrid( bool enable );
214
215 bool getEnableGrid() const;
216
218
219 void setEnableAxesSingleColor( bool enable );
220
221 void setShowXAxis( bool enable );
222 void setShowYAxis( bool enable );
223 void setShowZAxis( bool enable );
224
228
229 std::array<bool, 3> getShowAxesSettings() const;
230
231 protected:
232
235
237 // Variables
239 protected:
251 };
252
254
256 // ParticleTrajectoryRenderer
259 {
260 typedef agx::Vector < agx::Vec3 > Vec3List;
261
262 public:
264 osg::Group* root,
266
268
270
271 void setEnable( bool enable );
272
273 bool getEnable() const;
274
275 void setSampling( agx::Real enable );
276
278
279 void reSample();
280
282
284
286
287 protected:
289
291 // Variables
294 osg::observer_ptr<osg::Group> m_root;
295 osg::ref_ptr<osg::Geode> m_trajectoryGeode;
299
300 osg::ref_ptr < agxOSG::ParticleTrajectoriesDrawable > m_particleTrajectoryDrawable;
301 osg::ref_ptr < agxOSG::RigidBodyTrajectoryDrawable > m_RBTrajectorydrawable;
302 };
303
305
306
308 // ParticleContactGraphRenderer
311 {
312 public:
314
315 void setEnable(bool enable);
316
317 bool getEnable() const;
318
320
321 void setMinNetworkForce(agx::Real minForce);
322
324
325 void setMaxNetworkForce(agx::Real minForce);
326
327 protected:
329
331 // Variables
333 osg::observer_ptr<osg::Group> m_root;
336 };
337
339
341
343
345
347
349
354 {
355 public:
357 agxQt::QtAgxWrapper* qtagxViewer,
358 osg::Group* root,
360 agx::ParticleSystem* system);
361
363
365
367
368 agx::Real getAlphaValue() const;
369
370 virtual void pre(const agx::TimeStamp& t);
371
372 virtual void post(const agx::TimeStamp& t);
373
375
377
379
381
383
385
387
389
391
392 void setLimitColoringToAnalysisBound(bool enable);
393
395
396 void setShowColorLegend(bool enable, int width, int height);
397
398 void setShowColorLegend(bool enable);
399
400 void updateColorLegend(int width, int height);
401
403
404 bool getShowColorLegend() const;
405
406 void setEnableParticleRendering(bool enable);
407
408 bool getEnableParticleRendering() const;
409
411
413
415
417
419
420 bool hasOpenColorLegend() const;
421
423
424 void setEnableRenderOnNSSBodies(const agx::RigidBodyRefVector& bodies, bool enable);
425
427
429
430 void setLegendScaleFactor( agx::Real scaleFactor );
431
433
435
436 protected:
437
439
440 void preRender();
441
443
445
447
449 // Variables
451 protected:
453 osg::ref_ptr<agxOSG::ParticleSystemDrawable> m_psDrawable;
456
457 // color renderer
458 osg::ref_ptr<osg::Group> m_hudGroup;
459 osg::observer_ptr<osg::Group> m_root;
461
462
466
467 // Impacts drawable
468 osg::ref_ptr<agxQt::GranularImpactsDrawable> m_impactsDrawable;
470 };
471
473
474 /* Implementation */
475
477
479
481
483
485
487 {
489 return m_particleColorerManager->getMinScalar();
490 else
491 return 0;
492 }
493
495 {
497 return m_particleColorerManager->getMaxScalar();
498 else
499 return 0;
500 }
501
503
505
507
509
511
512 osg::Geode * createCube(const agx::Vec3& position, const agx::Vec3& boxhalfVec3);
513 osg::Geode * createCubeLines(const agx::AffineMatrix4x4& transform, const agx::Vec3& boxhalfVec3);
514 osg::Geode * createPlaneLines(const agx::Vec3& position, const agx::Vec3& normal, agx::Real size);
515 osg::Geode* createLine( const agx::Vec3& p1, const agx::Vec3& p2, agx::Real size, const agxRender::Color& color );
516
517#if AGX_USE_KEYSHOT()
521 class KeyShotParticleDumper
522 {
523 KeyShotParticleDumper();
524 public:
525
526 static void dumpParticlesInSimulationToKeyShotFile(agxSDK::Simulation * simulation, agx::String filename);
527
528 static void exportCurrentJournalFrameToBip(int frame,
529 const agx::String& journalFilename,
530 const agx::String& sessionName,
531 const agx::String& bipFile,
534
535 protected:
537 // Variables
539 };
540#endif
541}
542
543#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
This class wraps the ClipPlane functionality of osg together with a clip node and a clip plane.
Definition ClipPlane.h:44
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...
Class that describes an abstract camera and it's properties.
Class that is used to manipulate the clip plane in the scene.
Definition QtOSGUtils.h:84
void updateClipPlaneFromIncrement(agx::Real increment)
void decrementClipPlane()
Decrements the Near plane of the scene in the coupled agxViewer.
agxOSG::ClipPlane * m_clipPlane
Definition QtOSGUtils.h:130
void setIncrement(agx::Real increment)
void setEnableRendering(bool enable)
void setPosition(agx::Vec3 position)
void setRotation(const agx::Quat &quat)
agx::Real getIncrement() const
void incrementClipPlane()
Increments the Near plane of the scene in the coupled agxViewer.
agx::Quat getRotation() const
virtual ~ClipPlaneController()
Destructor.
bool getEnableRendering() const
const agx::Vec3 BASE_NORMAL
Definition QtOSGUtils.h:86
void setEnable(bool enable)
agx::Vec3 getPosition() const
ClipPlaneController(agxOSG::ClipPlane *clipPlane)
Constructor.
agxOSG::ClipPlane * getClipPlane() const
Class that is used to manipulate the axes in the scene.
Definition QtOSGUtils.h:141
void setNumTicks(const agx::UInt numTicks)
void setPosition(agx::Vec3 position)
void setTickColor(const agxRender::Color &color)
void setLineWidth(agx::Real lineWidth)
virtual ~MeasurementAxesController()
Destructor.
void setAxesSingleColor(const agxRender::Color &color)
std::array< bool, 3 > getShowAxesSettings() const
void setTickTextSize(agx::Real tickTextSize)
void setEnableAxesSingleColor(bool enable)
agx::UInt getTickTextStride() const
void setEnableTicks(bool enable)
agxRender::Color getTickColor() const
agx::Real getTickTextSize() const
void setRotation(const agx::Quat &quat)
void setTickSize(const agx::Real tickSize)
agxRender::Color getAxesSingleColor() const
void setSize(const agx::Real size)
agx::BitState< State, agx::Int32 > AxesState
Definition QtOSGUtils.h:155
void setTickTextStride(const agx::UInt stride)
void setEnableTicksText(bool enable)
agx::ParticleSystem * m_particleSystem
Definition QtOSGUtils.h:334
void setMinNetworkForce(agx::Real minForce)
Definition QtOSGUtils.h:344
agxOSG::ParticleContactGraphDrawable * m_graphDrawable
Definition QtOSGUtils.h:335
ParticleContactGraphRenderer(osg::Group *root, agx::ParticleSystem *ps)
void setMaxNetworkForce(agx::Real minForce)
Definition QtOSGUtils.h:342
osg::observer_ptr< osg::Group > m_root
Definition QtOSGUtils.h:333
This utility class is used for post processing of the particle system drawable representation,...
Definition QtOSGUtils.h:354
void setEnableRenderingOnTemplateBodies(const agx::RigidBodyRefVector &bodies, bool enable)
agx::Real getLegendScaleFactor() const
Definition QtOSGUtils.h:508
void updateColorLegend(int width, int height)
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 setShowColorLegend(bool enable, int width, int height)
agx::Real getMaxColorScalar() const
Definition QtOSGUtils.h:494
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...
ParticleColorMode getActiveParticleColorMode() const
Definition QtOSGUtils.h:478
osg::ref_ptr< agxQt::GranularImpactsDrawable > m_impactsDrawable
Definition QtOSGUtils.h:468
void setEnableRenderOnNSSBodies(const agx::RigidBodyRefVector &bodies, bool enable)
ParticleColorModeVector getAvailableColorModes() const
Definition QtOSGUtils.h:480
void setParticleColorModeFromName(const agx::String &mode)
osg::observer_ptr< osg::Group > m_root
Definition QtOSGUtils.h:459
agxOSG::ParticleSystemDrawable * getParticleSystemDrawable()
ParticleSystemRenderUtility(agxQt::QtAgxWrapper *qtagxViewer, osg::Group *root, agxOSG::ParticleSystemDrawable *psdraw, agx::ParticleSystem *system)
agx::Real getMinColorScalar() const
Definition QtOSGUtils.h:486
void setEnableParticleRendering(bool enable)
agx::ParticleSystem * m_system
Definition QtOSGUtils.h:454
void setShowColorLegend(bool enable)
ParticleRenderFilterManagerRef m_particleRenderFilterManager
Definition QtOSGUtils.h:465
void preRenderParticles(agx::ParticleSystem *system)
LegendSettings & getLegendSettings()
Definition QtOSGUtils.h:510
osg::ref_ptr< agxOSG::ParticleSystemDrawable > m_psDrawable
Definition QtOSGUtils.h:453
ParticleColorerManagerRef m_particleColorerManager
Definition QtOSGUtils.h:464
ParticleRenderFilterManager * getParticleRenderFilterManager()
void setParticleShaderMode(agxOSG::ParticleSystemDrawable::ParticleShaderMode mode)
void setAnalysisBox(const agx::AnalysisBox *box)
void setAlphaValue(agx::Real alpha)
void setLimitColoringToAnalysisBound(bool enable)
Definition QtOSGUtils.h:482
osg::ref_ptr< osg::Group > m_hudGroup
Definition QtOSGUtils.h:458
void setMinColorScalar(agx::Real minVel)
GranularImpactsDrawable * getGranularImpactsDrawable()
Definition QtOSGUtils.h:506
ParticleContactGraphRendererRef m_particleContactGraphRenderer
Definition QtOSGUtils.h:463
void setMaxColorScalar(agx::Real maxVel)
void setAlphaOnParticles(agx::Real alpha)
void setLegendScaleFactor(agx::Real scaleFactor)
ParticleContactGraphRendererRef getParticleContactGraphRenderer()
Definition QtOSGUtils.h:504
agxQt::QtAgxWrapper * m_qtAgxWrapper
Definition QtOSGUtils.h:452
agxOSG::ParticleSystemDrawable::ParticleShaderMode getParticleShaderMode() const
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
agx::UInt m_numTrajectoryPositions
Definition QtOSGUtils.h:296
agx::UInt getMaxPositionPoints()
void setMaxPositionPoints(agx::UInt posPoints)
osg::ref_ptr< agxOSG::ParticleTrajectoriesDrawable > m_particleTrajectoryDrawable
Definition QtOSGUtils.h:300
TrajectoryRenderer(agxSDK::Simulation *simulation, osg::Group *root, agx::ParticleSystem *ps)
agx::ParticleSystem * m_particleSystem
Definition QtOSGUtils.h:293
osg::ref_ptr< osg::Geode > m_trajectoryGeode
Definition QtOSGUtils.h:295
agxOSG::ScalarColorMap * getColorMap()
void setEnable(bool enable)
osg::ref_ptr< agxOSG::RigidBodyTrajectoryDrawable > m_RBTrajectorydrawable
Definition QtOSGUtils.h:301
void setSampling(agx::Real enable)
osg::observer_ptr< osg::Group > m_root
Definition QtOSGUtils.h:294
agx::Real getSampling() const
void setColorMap(agxOSG::ScalarColorMap *colorMap)
Utility color class with "common colors".
Definition Color.h:34
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Derive from this class to implement a listener for simulation step events.
Class that can be used to extract data from elements in a simulation within a specified bound.
Definition AnalysisBox.h:33
A basic particle system that contains all the storages and buffers required for basic operation and a...
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
#define AGX_FORCE_INLINE
Definition macros.h:58
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
Contains classes/utility functions for connecting AGX to QT with OSG.
osg::Geode * createCubeLines(const agx::AffineMatrix4x4 &transform, const agx::Vec3 &boxhalfVec3)
osg::Geode * createCube(const agx::Vec3 &position, const agx::Vec3 &boxhalfVec3)
osg::Geode * createPlaneLines(const agx::Vec3 &position, const agx::Vec3 &normal, agx::Real size)
osg::Geode * createLine(const agx::Vec3 &p1, const agx::Vec3 &p2, agx::Real size, const agxRender::Color &color)
int32_t Int32
Definition Integer.h:37
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition agx/Vec3.h:36
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42
agx::Real TimeStamp
Definition TimeStamp.h:26
agx::Real legendScaleFactor
Definition QtOSGUtils.h:63
Orientation orientation
Definition QtOSGUtils.h:64