AGXDynamics  2.35.0.2
ParticlePostProcessColorer.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_PARTICLEPOSTPROCESSCOLORER_H
18 #define AGXQT_PARTICLEPOSTPROCESSCOLORER_H
19 
20 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
21 #include <osg/ref_ptr>
22 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
23 
24 #include <functional>
25 #include <agxQt/export.h>
26 #include <agx/Referenced.h>
27 #include <agx/Bound.h>
28 #include <agx/ParticleSystem.h>
29 #include <agx/AnalysisBox.h>
30 #include <agxOSG/ScalarColorMap.h>
31 
32 namespace agx
33 {
34  class ParticleSystem;
35 }
36 
37 namespace agxQt
38 {
39  // Forward declaration
41 
45  typedef std::function<ParticleColorer*()> ColorerConstructor;
47  {
51 
52  bool operator==(const ParticleColorMode& rhs) { return m_id == rhs.m_id; }
53  };
55 
61  {
62  public:
64  static const char* const COLORMODE_NONE_NAME;
65 
66  public:
67  ParticleColorer(const agx::Name& name);
68 
69  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) = 0;
70 
71  virtual void initColorRange(agx::Real minScalar, agx::Real maxScalar);
72 
73  agxOSG::ScalarColorMap* getColorMap() const;
74 
75  agx::Name getName() const;
76 
77  protected:
78  void applyColorFromMap( agx::Vec4f& targetColorData, agx::Real scalar, bool modifyAlpha );
79 
80  protected:
81  virtual ~ParticleColorer() {};
82 
84  // Variables
86  protected:
87  agxOSG::ScalarColorMapRef m_colorMap;
89  };
90 
92 
94 
96  {
97  return ParticleColorMode{ ParticleColorer::COLORMODE_NONE_NAME, []{ return nullptr; }, "" };
98  }
99 
105  {
106  public:
108  public:
110 
111  void setMaxScalar(agx::Real maxScalar);
112 
113  void setMinScalar(agx::Real minScalar);
114 
115  agx::Real getMaxScalar() const;
116 
117  agx::Real getMinScalar() const;
118 
119  void setAnalysisBox(const agx::AnalysisBox* analysisBox);
120 
121  void setParticleColorModeFromName(const agx::String& name);
122 
123  bool particleColorModeExists(const agx::String& name);
124 
125  void addCustomColorMode(const agx::String& name, ParticleColorer::GetParticleRealFunc getRealFunc, const agx::String& unitString);
126 
127  ParticleColorMode getActiveParticleColorMode() const;
128 
129  ParticleColorModeVector getAvailableParticleColorModes();
130 
131  void colorParticles(agx::ParticleSystem * system);
132 
133  agxOSG::ScalarColorMap* getColorMap() const;
134 
135  void setEnableModifyScalarFromAlpha(bool enable);
136 
137  void setLimitInBound(bool limitInBound);
138 
139  bool getLimitInBound() const;
140 
141  protected:
142  void setParticleColorMode(ParticleColorMode mode);
143 
144  void initParticleModes();
145 
147 
148  void initColorRange();
149 
150  bool shouldLimitColorToBound() const;
151 
153  // Variables
155  protected:
163  };
164 
166 
168 
170 
172 
174 
175  AGX_FORCE_INLINE void ParticleColorerManager::setLimitInBound(bool limitInBound) { m_limitInBound = limitInBound; }
176 
178 
180 
185  {
186  public:
188 
189  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
190 
191  protected:
193  };
194 
199  {
200  public:
202 
203  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
204 
205  protected:
207  };
208 
213  {
214  public:
215  ParticlePostPorcessColorerHeight(const agx::Name& name, const agx::Vec3& heightAxis = agx::Vec3::Z_AXIS());
216 
217  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
218 
219  protected:
221  agx::Vec3 m_heightAxis;
222  };
223 
228  {
229  public:
231 
232  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
233 
234  protected:
236  };
237 
242  {
243  public:
245 
246  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
247 
248  protected:
250 
252  // Variables
254  protected:
255  bool m_shouldResetPostions;
257  };
258 
263  {
264  public:
266 
267  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
268 
269  protected:
271 
273  // Variables
275  protected:
276  };
277 
282  {
283  public:
285 
286  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
287 
288  protected:
290 
292  // Variables
294  protected:
295  GetParticleRealFunc m_getRealFunc;
296  };
297 }
298 
299 #endif
agxQt::ParticlePostPorcessColorerVelocity::~ParticlePostPorcessColorerVelocity
virtual ~ParticlePostPorcessColorerVelocity()
Definition: ParticlePostProcessColorer.h:192
Referenced.h
agxQt::ParticlePostPorcessColorerContactForce
Implements the particle post processor colorer for contact force.
Definition: ParticlePostProcessColorer.h:198
agxQt::ParticleColorerManager::getMaxScalar
agx::Real getMaxScalar() const
Definition: ParticlePostProcessColorer.h:165
agx::Real
double Real
Definition: Real.h:42
agxQt::ParticlePostPorcessColorerRadius
Implements the particle post processor colorer for contact force.
Definition: ParticlePostProcessColorer.h:227
agxQt::ParticleColorMode::m_unit
agx::Name m_unit
Definition: ParticlePostProcessColorer.h:50
AGXQT_EXPORT
#define AGXQT_EXPORT
agxQt
Contains classes/utility functions for connecting AGX to QT with OSG.
Definition: AnalysisBoundWidget.h:33
agxQt::ParticleColorerManager::initColorRange
void initColorRange()
agxQt::ParticleColorer::getName
agx::Name getName() const
Definition: ParticlePostProcessColorer.h:93
agx::Vector< ParticleColorMode >
agxQt::ParticlePostPorcessColorerHeight
Implements the particle post processor colorer for contact force.
Definition: ParticlePostProcessColorer.h:212
agxQt::ParticleColorerManager::m_modifyAlphaFromScalar
bool m_modifyAlphaFromScalar
Definition: ParticlePostProcessColorer.h:160
agxQt::ParticleColorerManager::m_maxScalar
agx::Real m_maxScalar
Definition: ParticlePostProcessColorer.h:156
agxQt::ColorerConstructor
std::function< ParticleColorer *()> ColorerConstructor
ParticleColorMode.
Definition: ParticlePostProcessColorer.h:40
agxQt::ParticlePostPorcessColorerHeight::~ParticlePostPorcessColorerHeight
virtual ~ParticlePostPorcessColorerHeight()
Definition: ParticlePostProcessColorer.h:220
agxOSG::ScalarColorMap
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...
Definition: ScalarColorMap.h:37
agxQt::ParticlePostPorcessColorerLambda
Implements the particle post processor colorer for velocities.
Definition: ParticlePostProcessColorer.h:281
agxQt::ParticleColorMode
Definition: ParticlePostProcessColorer.h:46
agxQt::ParticlePostPorcessKineticEnergy
Implements the particle post processor colorer for velocities.
Definition: ParticlePostProcessColorer.h:262
agx::Vec3T< Real >::Z_AXIS
static Vec3T Z_AXIS()
Definition: Vec3Template.h:789
agxQt::ParticleColorerManager::m_particleColorModeTable
ParticleColorModeTable m_particleColorModeTable
Definition: ParticlePostProcessColorer.h:161
ScalarColorMap.h
agxQt::ParticleColorerManager::~ParticleColorerManager
virtual ~ParticleColorerManager()
Definition: ParticlePostProcessColorer.h:146
agx::AnalysisBox
Class that can be used to extract data from elements in a simulation within a specified bound.
Definition: AnalysisBox.h:31
agxQt::ParticlePostPorcessColorerVelocity
Implements the particle post processor colorer for velocities.
Definition: ParticlePostProcessColorer.h:184
agxQt::ParticleColorerManager::m_limitInBound
bool m_limitInBound
Definition: ParticlePostProcessColorer.h:159
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
agxQt::ParticlePostPorcessColorerDisplacement::~ParticlePostPorcessColorerDisplacement
virtual ~ParticlePostPorcessColorerDisplacement()
Definition: ParticlePostProcessColorer.h:249
ParticleSystem.h
export.h
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agxQt::ParticleColorerManager::setEnableModifyScalarFromAlpha
void setEnableModifyScalarFromAlpha(bool enable)
Definition: ParticlePostProcessColorer.h:179
agx::BoundT< Vec3 >
agxQt::ParticleColorer::GetParticleRealFunc
std::function< agx::Real(agx::ParticleSystem *, agx::Physics::ParticlePtr)> GetParticleRealFunc
Definition: ParticlePostProcessColorer.h:63
agxQt::ParticlePostPorcessColorerDisplacement::m_particleIdToPosition
agx::HashTable< agx::Index, agx::Vec3 > m_particleIdToPosition
Definition: ParticlePostProcessColorer.h:256
agxQt::ParticlePostPorcessColorerContactForce::~ParticlePostPorcessColorerContactForce
virtual ~ParticlePostPorcessColorerContactForce()
Definition: ParticlePostProcessColorer.h:206
agx::Physics::ParticlePtr
Pointer to a entity instance of type Physics.Particle.
Definition: ParticleEntity.h:292
agxQt::ParticleColorer::COLORMODE_NONE_NAME
static const char *const COLORMODE_NONE_NAME
Definition: ParticlePostProcessColorer.h:64
agxQt::ParticlePostPorcessColorerRadius::~ParticlePostPorcessColorerRadius
virtual ~ParticlePostPorcessColorerRadius()
Definition: ParticlePostProcessColorer.h:235
agx::ParticleSystem
A basic particle system that contains all the storages and buffers required for basic operation and a...
Definition: ParticleSystem.h:67
agx::ref_ptr< ScalarColorMap >
agxQt::ParticleColorer::getColorMap
agxOSG::ScalarColorMap * getColorMap() const
Definition: ParticlePostProcessColorer.h:91
PushDisableWarnings.h
agxQt::ParticleColorerManager::getMinScalar
agx::Real getMinScalar() const
Definition: ParticlePostProcessColorer.h:167
agxQt::ParticleColorerManager::setMinScalar
void setMinScalar(agx::Real minScalar)
Definition: ParticlePostProcessColorer.h:171
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:871
Bound.h
agxQt::ParticleColorModeVector
agx::Vector< ParticleColorMode > ParticleColorModeVector
Definition: ParticlePostProcessColorer.h:54
agx::Name
Representation of a name string.
Definition: Name.h:32
agxQt::ParticleColorerManager::m_activeParticleColorer
ParticleColorerRef m_activeParticleColorer
Definition: ParticlePostProcessColorer.h:162
agxQt::ParticleColorerManager::setLimitInBound
void setLimitInBound(bool limitInBound)
Definition: ParticlePostProcessColorer.h:175
agxQt::ParticleColorerManager
Definition: ParticlePostProcessColorer.h:104
agxQt::ParticleColorerManager::m_minScalar
agx::Real m_minScalar
Definition: ParticlePostProcessColorer.h:157
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxQt::ParticleColorerManager::getLimitInBound
bool getLimitInBound() const
Definition: ParticlePostProcessColorer.h:177
agxQt::ParticleColorMode::operator==
bool operator==(const ParticleColorMode &rhs)
Definition: ParticlePostProcessColorer.h:52
agxQt::ParticleColorerManager::setMaxScalar
void setMaxScalar(agx::Real maxScalar)
Definition: ParticlePostProcessColorer.h:169
AnalysisBox.h
agxQt::createNoneParticleColorMode
ParticleColorMode AGXQT_EXPORT createNoneParticleColorMode()
Definition: ParticlePostProcessColorer.h:95
agxQt::ParticlePostPorcessKineticEnergy::~ParticlePostPorcessKineticEnergy
virtual ~ParticlePostPorcessKineticEnergy()
Definition: ParticlePostProcessColorer.h:270
agxQt::ParticleColorer::m_colorMap
agxOSG::ScalarColorMapRef m_colorMap
Definition: ParticlePostProcessColorer.h:81
agx::AgXString< std::string >
agx::Vec3T< Real >
agxQt::ParticleColorer::~ParticleColorer
virtual ~ParticleColorer()
Definition: ParticlePostProcessColorer.h:81
agxQt::ParticleColorMode::m_id
agx::Name m_id
Definition: ParticlePostProcessColorer.h:48
agxQt::ParticleColorMode::m_constructor
ColorerConstructor m_constructor
Definition: ParticlePostProcessColorer.h:49
agxQt::ParticleColorerManager::setAnalysisBox
void setAnalysisBox(const agx::AnalysisBox *analysisBox)
Definition: ParticlePostProcessColorer.h:173
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxQt::ParticleColorerManager::ParticleColorModeTable
agx::HashTable< agx::Name, ParticleColorMode > ParticleColorModeTable
Definition: ParticlePostProcessColorer.h:107
agxQt::ParticlePostPorcessColorerLambda::~ParticlePostPorcessColorerLambda
virtual ~ParticlePostPorcessColorerLambda()
Definition: ParticlePostProcessColorer.h:289
agxQt::ParticleColorer
Definition: ParticlePostProcessColorer.h:60
agxQt::ParticleColorerManager::m_analysisBox
const agx::AnalysisBox * m_analysisBox
Definition: ParticlePostProcessColorer.h:158
agxQt::ParticlePostPorcessColorerDisplacement
Implements the particle post processor colorer for velocities.
Definition: ParticlePostProcessColorer.h:241
PopDisableWarnings.h
agxQt::ParticleColorer::m_name
agx::Name m_name
Definition: ParticlePostProcessColorer.h:88