Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfStyle.h
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
20#ifndef _SOURCE_RENDERING_TFSTYLE_H_
21#define _SOURCE_RENDERING_TFSTYLE_H_
22
23#include <io/tf_io.h>
24#include <TissueForge_private.h>
25
26#include <string>
27
28
29namespace TissueForge {
30
31
32 struct Particle;
33 struct Angle;
34 struct Bond;
35 struct Dihedral;
36
37 struct ParticleType;
38
39
40 namespace rendering {
41
45 struct CAPI_EXPORT Style
46 {
48 fVector3 color;
49
51 uint32_t flags;
52
56 struct ColorMapper *mapper = NULL;
57
58 Style(const fVector3 *color=NULL, const bool &visible=true, uint32_t flags=STYLE_VISIBLE, ColorMapper *cmap=NULL);
59
68 Style(const std::string &color, const bool &visible=true, uint32_t flags=STYLE_VISIBLE, ColorMapper *cmap=NULL);
69 Style(const Style &other);
70
71 int init(const fVector3 *color=NULL, const bool &visible=true, uint32_t flags=STYLE_VISIBLE, ColorMapper *cmap=NULL);
72
79 HRESULT setColor(const std::string &colorName);
80
84 HRESULT setFlag(StyleFlags flag, bool value);
85
89 fVector4 map_color(struct Particle *p);
90
94 fVector4 map_color(struct Angle* a);
95
99 fVector4 map_color(struct Bond* b);
100
104 fVector4 map_color(struct Dihedral* d);
105
109 const bool getVisible() const;
110
114 void setVisible(const bool &visible);
115
119 std::string getColorMap() const;
120
125
129 void setColorMap(const std::string &colorMap);
130
135
141 std::string toString();
142
149 static Style *fromString(const std::string &str);
150
151 };
152
153 }
154
155
156 namespace io {
157
158 template <>
159 HRESULT toFile(const rendering::Style &dataElement, const MetaData &metaData, IOElement &fileElement);
160
161 template <>
162 HRESULT fromFile(const IOElement &fileElement, const MetaData &metaData, rendering::Style *dataElement);
163
164 };
165
166}
167
168#endif // _SOURCE_RENDERING_TFSTYLE_H_
Tissue Forge I/O.
Definition tfThreeDFAngleMeshGenerator.h:28
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.
Tissue Forge rendering and visualization.
Definition tfAngle.h:38
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
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
The Tissue Forge style type.
Definition tfStyle.h:46
void setVisible(const bool &visible)
Set whether visible.
HRESULT setColor(const std::string &colorName)
Set the color by name.
static Style * fromString(const std::string &str)
Create from a JSON string representation.
HRESULT setFlag(StyleFlags flag, bool value)
Set a style flag.
fVector4 map_color(struct Dihedral *d)
Map a dihedral to a color.
void setColorMapper(ColorMapper *cmap)
Set the color mapper.
std::string toString()
Get a JSON string representation.
fVector4 map_color(struct Angle *a)
Map an angle to a color.
struct ColorMapper * mapper
Color mapper of this style.
Definition tfStyle.h:56
fVector4 map_color(struct Particle *p)
Map a particle to a color.
fVector3 color
Definition tfStyle.h:48
Style(const std::string &color, const bool &visible=true, uint32_t flags=STYLE_VISIBLE, ColorMapper *cmap=NULL)
Construct a new style.
uint32_t flags
Definition tfStyle.h:51
void setColorMap(const std::string &colorMap)
Create a color mapper by name.
ColorMapper * getColorMapper() const
Get the color mapper, if any.
std::string getColorMap() const
Get the name of the color map, if any.
fVector4 map_color(struct Bond *b)
Map a bond to a color.
const bool getVisible() const
Test whether visible.
int32_t HRESULT
Definition tf_port.h:255