AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParticlePostProcessColorer.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_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:
63  typedef std::function<agx::Real(agx::ParticleSystem*, agx::Physics::ParticlePtr)> GetParticleRealFunc;
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
void setMinScalar(agx::Real minScalar)
Implements the particle post processor colorer for contact force.
#define AGXQT_EXPORT
Implements the particle post processor colorer for contact force.
std::function< agx::Real(agx::ParticleSystem *, agx::Physics::ParticlePtr)> GetParticleRealFunc
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
Implements the particle post processor colorer for velocities.
void setMaxScalar(agx::Real maxScalar)
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
bool operator==(const ParticleColorMode &rhs)
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:62
ParticleColorMode AGXQT_EXPORT createNoneParticleColorMode()
Base class providing referencing counted objects.
Definition: Referenced.h:113
static Vec3T Z_AXIS()
Implements the particle post processor colorer for contact force.
agxOSG::ScalarColorMap * getColorMap() const
A basic particle system that contains all the storages and buffers required for basic operation and a...
std::function< ParticleColorer *()> ColorerConstructor
ParticleColorMode.
Implements the particle post processor colorer for velocities.
agx::HashTable< agx::Index, agx::Vec3 > m_particleIdToPosition
void setAnalysisBox(const agx::AnalysisBox *analysisBox)
agxOSG::ScalarColorMapRef m_colorMap
static const char *const COLORMODE_NONE_NAME
Class that can be used to extract data from elements in a simulation within a specified bound...
Definition: AnalysisBox.h:31
Implements the particle post processor colorer for velocities.
ParticleColorModeTable m_particleColorModeTable
Implements the particle post processor colorer for velocities.
agx::HashTable< agx::Name, ParticleColorMode > ParticleColorModeTable
double Real
Definition: Real.h:42
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...
agx::Vector< ParticleColorMode > ParticleColorModeVector
Inheritance with partial specialization due to bug with ref_ptr containers.