MeVisLab Toolbox Reference
mlStylePalette.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_STYLE_PALETTE_H
14#define ML_STYLE_PALETTE_H
15
16
19
20// ML-includes
21
22#include "mlModuleIncludes.h"
23#include "mlTreeNode.h"
24
25
26#include "mlBaseInit.h"
27
28
29
30ML_START_NAMESPACE
31
32
34
35#define MKT_DASH (static_cast<int>(StylePalette::mktDash))
36
37
38//----------------------------------------------------------------------------------
39// Base object class StylePalette
40
43//----------------------------------------------------------------------------------
45{
46public:
47
51 StylePalette (const StylePalette &palette);
53
55 ~StylePalette () override;
56
58 StylePalette &operator = (const StylePalette &palette);
59
60
61 // --- Type definitions ---
62
64 typedef enum {
65 lstNone = 0,
69 lstNumLineStyles
70 } LineStyle;
71
73 typedef enum {
74 mktNone = 0,
83 mktDash = -1
84 } MarkerType;
85
86
87 // --- Constants ---
88
90 static const char *const lineStyleNames[lstNumLineStyles];
91
93 static const char *const markerTypeNames[mktNumMarkerTypes];
94
96 static const int defaultNumStyles;
97
98
99 // --- Access methods ---
100
102 MLssize_t getNumStyles () const { return _numStyles; }
103 void setNumStyles (MLssize_t newNumStyles);
105
108 void getColor (MLssize_t index, float &r, float &g, float &b) const;
109 void setColor (MLssize_t index, const Vector3 &color);
110 void setColor (MLssize_t index, float r, float g, float b) { setColor(index, Vector3(r, g, b)); }
112
116 int getLineWidth (MLssize_t index) const;
117 void setLineWidth (MLssize_t index, int lw);
119
123 int getMarkerSize (MLssize_t index) const;
124 void setMarkerSize (MLssize_t index, int ms);
126
128 bool getAntiAlias (MLssize_t index) const;
129 void setAntiAlias (MLssize_t index, bool aa);
131
133 std::string getName (MLssize_t index) const;
134 void setName (MLssize_t index, const std::string &n);
136
138 MLssize_t getReservedEntries () const { return _reservedEntries; }
141
145
147 void copyStylesFrom (const StylePalette &palette);
148
151
153 const char *getLineStyleName (LineStyle lst) const {
154 return lineStyleNames[static_cast<int>(lst)];
155 }
156
158 const char *getMarkerTypeName (MarkerType mkt) const {
159 return markerTypeNames[static_cast<int>(mkt)];
160 }
161
163 void dumpStyles ();
164
166 bool getStyleIndexForName(const std::string curveTitle, std::vector<MLssize_t> &indices);
167
168 // --- Persistence ---
169
171 void addStateToTree (TreeNode *parent) const override;
172
174 void readStateFromTree (TreeNode *parent) override;
175
178
180 virtual StylePalette* clone() const { return new StylePalette(*this); };
181 StylePalette* deepCopy() const override { return new StylePalette(*this); };
182protected:
183
184 // --- Methods ---
185
187 void clear ();
188
190 void init (MLssize_t numStyles);
191
192
193private:
194
195 // --- Data ---
196
198 Vector3 *_colors;
200 LineStyle *_lineStyles;
202 int *_lineWidths;
204 MarkerType *_markerTypes;
206 int *_markerSizes;
208 bool *_antiAlias;
210 std::string *_names;
211
213 MLssize_t _numStyles;
214
216 MLssize_t _reservedEntries;
217
218
219 // Runtime type system initialization
221
222};
223
224
225ML_END_NAMESPACE
226
227
228#endif
229// __mlStylePalette_H
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Definition mlBase.h:59
Base object class StylePalette for providing a collection of colors, line styles and marker types.
static const int defaultNumStyles
Default number of styles (=12)
Vector3 getColor(MLssize_t index) const
~StylePalette() override
Destructor.
void copyStylesFrom(const StylePalette &palette)
Copy style palette from palette.
virtual StylePalette * clone() const
Create a clone of the StylePalette.
const char * getLineStyleName(LineStyle lst) const
Get name of line style lst.
std::string getName(MLssize_t index) const
void setColorDefaults()
Set color default values.
StylePalette * deepCopy() const override
Creates a deep copy of the given object.
int getMarkerSize(MLssize_t index) const
void setAntiAlias(MLssize_t index, bool aa)
void setLineWidth(MLssize_t index, int lw)
MarkerType
Marker type constants.
void setLineStyle(MLssize_t index, LineStyle lst)
void addStateToTree(TreeNode *parent) const override
Attach the object state as children of the given parent node.
LineStyle
Line style constants.
int getLineWidth(MLssize_t index) const
ML_SET_ADDSTATE_VERSION(0)
Sets addState version number.
bool getStyleIndexForName(const std::string curveTitle, std::vector< MLssize_t > &indices)
Get style indices using name, writes all matching indices into vector, returns true if at least one w...
MLssize_t getNumStyles() const
void dumpStyles()
Dump current style definitions to cout.
void setName(MLssize_t index, const std::string &n)
void setColor(MLssize_t index, const Vector3 &color)
StylePalette(MLssize_t numStyles)
void readStateFromTree(TreeNode *parent) override
Read the object state from the children of the given parent node.
const char * getMarkerTypeName(MarkerType mkt) const
Get name of marker type mkt.
void setColor(MLssize_t index, float r, float g, float b)
void clear()
Deallocate style definition arrays.
MarkerType getMarkerType(MLssize_t index) const
LineStyle getLineStyle(MLssize_t index) const
bool getAntiAlias(MLssize_t index) const
void setMarkerType(MLssize_t index, MarkerType mkt)
MLssize_t getAutoStyleIndex(MLssize_t n)
Get index for automatic style n (>= 1).
MLssize_t getReservedEntries() const
void setReservedEntries(MLssize_t reserved)
void getColor(MLssize_t index, float &r, float &g, float &b) const
void setMarkerSize(MLssize_t index, int ms)
void setNumStyles(MLssize_t newNumStyles)
StylePalette(const StylePalette &palette)
void init(MLssize_t numStyles)
Allocate style definition arrays.
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition mlTreeNode.h:154
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition mlBaseInit.h:22
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non-existing export symbol.
SSIZE_T MLssize_t
The signed ML size type that is a signed 32-bit size_t on 32-bit platforms and 64-bit one on 64-bit p...
Definition mlTypeDefs.h:565
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:286