Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfColorMapper.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of Tissue Forge.
3 * Copyright (c) 2022-2024 T.J. Sego
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
25#ifndef _SOURCE_RENDERING_TFCOLORMAPPER_H_
26#define _SOURCE_RENDERING_TFCOLORMAPPER_H_
27
28#include <io/tf_io.h>
29#include <TissueForge_private.h>
30
31#include "tfColorMaps.h"
32
33#include <vector>
34
35
36namespace TissueForge {
37
38
39 struct ParticleType;
40
41 struct Angle;
42 struct Bond;
43 struct Dihedral;
44 struct Particle;
45
46
47 namespace rendering {
48
49
50 typedef float (*ParticleColorMapperFunc)(TissueForge::Particle* o, struct ColorMapper* mapper);
51 typedef float (*AngleColorMapperFunc)(TissueForge::Angle* o, struct ColorMapper* mapper);
52 typedef float (*BondColorMapperFunc)(TissueForge::Bond* o, struct ColorMapper* mapper);
53 typedef float (*DihedralColorMapperFunc)(TissueForge::Dihedral* o, struct ColorMapper* mapper);
54
55
59 struct CAPI_EXPORT ColorMapper
60 {
61 ColorMapperFunc map;
62 int species_index;
63
67 float min_val;
68
72 float max_val;
73
74 ColorMapper(const std::string &name, const float &min=0.f, const float &max=1.f);
76 ~ColorMapper() {};
77
81 fVector4 mapScalar(const float& val) const;
82
87
92
97
102
106 const bool hasMapParticle() const;
107
111 const bool hasMapAngle() const;
112
116 const bool hasMapBond() const;
117
121 const bool hasMapDihedral() const;
122
127
132
137
142
146 unsigned int getMapParticle() const { return map_enum_particle; }
147
151 unsigned int getMapAngle() const { return map_enum_angle; }
152
156 unsigned int getMapBond() const { return map_enum_bond; }
157
161 unsigned int getMapDihedral() const { return map_enum_dihedral; }
162
166 void setMapParticle(const unsigned int& label);
167
171 void setMapAngle(const unsigned int& label);
172
176 void setMapBond(const unsigned int& label);
177
181 void setMapDihedral(const unsigned int& label);
182
187
192
197
202
207
212
217
222
227
232
239 void setMapParticleSpecies(ParticleType* pType, const std::string& name);
240
245
250
255
260
265
270
279 bool set_colormap(const std::string& s);
280
284 static std::vector<std::string> getNames();
285
289 std::string getColorMapName() const;
290
291 private:
292
293 AngleColorMapperFunc mapper_angle;
294 BondColorMapperFunc mapper_bond;
295 DihedralColorMapperFunc mapper_dihedral;
296 ParticleColorMapperFunc mapper_particle;
297
298 unsigned int map_enum_angle;
299 unsigned int map_enum_bond;
300 unsigned int map_enum_dihedral;
301 unsigned int map_enum_particle;
302 };
303
304 }
305
306 namespace io {
307
308 template <>
309 HRESULT toFile(const rendering::ColorMapper &dataElement, const MetaData &metaData, IOElement &fileElement);
310
311 template <>
312 HRESULT fromFile(const IOElement &fileElement, const MetaData &metaData, rendering::ColorMapper *dataElement);
313
314 }
315
316};
317
318#endif // _SOURCE_RENDERING_TFCOLORMAPPER_H_
Definition tfVector4.h:33
HRESULT toFile(const T &dataElement, const MetaData &metaData, IOElement &fileElement)
Convert an object to an intermediate I/O object.
HRESULT fromFile(const IOElement &fileElement, const MetaData &metaData, T *dataElement)
Instantiate an object from an intermediate I/O object.
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
struct TissueForge::Dihedral Dihedral
struct TissueForge::Bond Bond
Bonds apply a potential to a particular set of particles.
struct TissueForge::Angle Angle
A bond concerning an angle.
A bond concerning an angle.
Definition tfAngle.h:60
Bonds apply a potential to a particular set of particles.
Definition tfBond.h:68
Definition tfDihedral.h:54
Definition tfParticle.h:101
Structure containing information on each particle type.
Definition tfParticle.h:768
The color mapping type.
Definition tfColorMapper.h:60
unsigned int getMapBond() const
Get the bond map label.
Definition tfColorMapper.h:156
void setMapDihedralAngleEq()
Set the dihedral map to angle from equilibrium.
const bool hasMapBond() const
Test whether the mapper has a bond map.
void clearMapBond()
Clear the bond map.
void setMapDihedralAngle()
Set the dihedral map to angle.
void setMapAngleAngle()
Set the angle map to angle.
void setMapParticleForceX()
Set the particle map to x-component of particle force.
fVector4 mapObj(Particle *o)
Map a particle to a color.
fVector4 mapObj(Dihedral *o)
Map a dihedral to a color.
void clearMapAngle()
Clear the angle map.
void setMapDihedral(const unsigned int &label)
Set the dihedral map by a label.
const bool hasMapAngle() const
Test whether the mapper has an angle map.
void setMapParticleSpeed()
Set the particle map to particle speed.
unsigned int getMapParticle() const
Get the particle map label.
Definition tfColorMapper.h:146
void setMapParticleVelocityX()
Set the particle map to x-component of particle velocity.
void setMapParticlePositionY()
Set the particle map to y-coordinate of particle position.
void setMapBond(const unsigned int &label)
Set the bond map by a label.
float min_val
minimum value of map
Definition tfColorMapper.h:67
void setMapParticle(const unsigned int &label)
Set the particle map by a label.
unsigned int getMapDihedral() const
Get the dihedral map label.
Definition tfColorMapper.h:161
void setMapBondLengthEq()
Set the bond map to length from equilibrium.
static std::vector< std::string > getNames()
Get all available color map names.
fVector4 mapScalar(const float &val) const
Map a scalar value to a color.
void setMapParticleVelocityZ()
Set the particle map to z-component of particle velocity.
void setMapParticlePositionX()
Set the particle map to x-coordinate of particle position.
void clearMapParticle()
Clear the particle map.
fVector4 mapObj(Angle *o)
Map an angle to a color.
void setMapParticleVelocityY()
Set the particle map to y-component of particle velocity.
std::string getColorMapName() const
Try to get the current color map name.
void setMapParticlePositionZ()
Set the particle map to z-coordinate of particle position.
bool set_colormap(const std::string &s)
Try to set the colormap.
void setMapParticleForceY()
Set the particle map to y-component of particle force.
fVector4 mapObj(Bond *o)
Map a bond to a color.
const bool hasMapDihedral() const
Test whether the mapper has a dihedral map.
unsigned int getMapAngle() const
Get the angle map label.
Definition tfColorMapper.h:151
void setMapParticleForceZ()
Set the particle map to z-component of particle force.
void setMapParticleSpecies(ParticleType *pType, const std::string &name)
Set the particle map to a species value.
void setMapAngleAngleEq()
Set the angle map to angle from equilibrium.
void clearMapDihedral()
Clear the dihedral map.
const bool hasMapParticle() const
Test whether the mapper has a particle map.
void setMapAngle(const unsigned int &label)
Set the angle map by a label.
float max_val
maximum value of map
Definition tfColorMapper.h:72
void setMapBondLength()
Set the bond map to length.
int32_t HRESULT
Definition tf_port.h:255