AGX Dynamics  2.35.0.1
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
40  class ParticleColorer;
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:
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 
122 
124 
125  void addCustomColorMode(const agx::String& name, ParticleColorer::GetParticleRealFunc getRealFunc, const agx::String& unitString);
126 
128 
130 
132 
134 
135  void setEnableModifyScalarFromAlpha(bool enable);
136 
137  void setLimitInBound(bool limitInBound);
138 
139  bool getLimitInBound() const;
140 
141  protected:
143 
145 
147 
149 
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:
216 
217  virtual void colorParticles(agx::ParticleSystem * system, bool limitBound, const agx::Bound3& bound, bool modifyAlpha) override;
218 
219  protected:
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:
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:
296  };
297 }
298 
299 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXQT_EXPORT
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...
ParticleColorMode getActiveParticleColorMode() const
void addCustomColorMode(const agx::String &name, ParticleColorer::GetParticleRealFunc getRealFunc, const agx::String &unitString)
agx::HashTable< agx::Name, ParticleColorMode > ParticleColorModeTable
void colorParticles(agx::ParticleSystem *system)
void setParticleColorModeFromName(const agx::String &name)
void setAnalysisBox(const agx::AnalysisBox *analysisBox)
bool shouldLimitColorToBound() const
bool particleColorModeExists(const agx::String &name)
void setMaxScalar(agx::Real maxScalar)
ParticleColorModeTable m_particleColorModeTable
void setParticleColorMode(ParticleColorMode mode)
ParticleColorModeVector getAvailableParticleColorModes()
agxOSG::ScalarColorMap * getColorMap() const
void setMinScalar(agx::Real minScalar)
agxOSG::ScalarColorMapRef m_colorMap
static const char *const COLORMODE_NONE_NAME
ParticleColorer(const agx::Name &name)
void applyColorFromMap(agx::Vec4f &targetColorData, agx::Real scalar, bool modifyAlpha)
std::function< agx::Real(agx::ParticleSystem *, agx::Physics::ParticlePtr)> GetParticleRealFunc
agxOSG::ScalarColorMap * getColorMap() const
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha)=0
virtual void initColorRange(agx::Real minScalar, agx::Real maxScalar)
Implements the particle post processor colorer for contact force.
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Implements the particle post processor colorer for velocities.
agx::HashTable< agx::Index, agx::Vec3 > m_particleIdToPosition
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Implements the particle post processor colorer for contact force.
ParticlePostPorcessColorerHeight(const agx::Name &name, const agx::Vec3 &heightAxis=agx::Vec3::Z_AXIS())
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Implements the particle post processor colorer for velocities.
ParticlePostPorcessColorerLambda(const agx::Name &name, ParticleColorer::GetParticleRealFunc getRealFunc)
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Implements the particle post processor colorer for contact force.
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Implements the particle post processor colorer for velocities.
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Implements the particle post processor colorer for velocities.
virtual void colorParticles(agx::ParticleSystem *system, bool limitBound, const agx::Bound3 &bound, bool modifyAlpha) override
Class that can be used to extract data from elements in a simulation within a specified bound.
Definition: AnalysisBox.h:32
Inheritance with partial specialization due to bug with ref_ptr containers.
Representation of a name string.
Definition: Name.h:33
A basic particle system that contains all the storages and buffers required for basic operation and a...
Pointer to a entity instance of type Physics.Particle.
Base class providing referencing counted objects.
Definition: Referenced.h:114
static Vec3T Z_AXIS()
Definition: Vec3Template.h:789
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes/utility functions for connecting AGX to QT with OSG.
agx::Vector< ParticleColorMode > ParticleColorModeVector
std::function< ParticleColorer *()> ColorerConstructor
ParticleColorMode.
ParticleColorMode AGXQT_EXPORT createNoneParticleColorMode()
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42
bool operator==(const ParticleColorMode &rhs)