OGS
VtkAlgorithmProperties.h
Go to the documentation of this file.
1
15#pragma once
16
17// ** INCLUDES **
18#include <QList>
19#include <QMap>
20#include <QObject>
21#include <QString>
22#include <QVariant>
23
24class vtkProperty;
25class vtkTexture;
26class vtkLookupTable;
27
28
29#define ogsUserPropertyMacro(name,type) \
30 virtual void Set ## name (type _arg) \
31 { \
32 vtkDebugMacro( \
33 << this->GetClassName() << " (" << this << "): setting " # name " to " << \
34 _arg); \
35 if (this->name != _arg) \
36 { \
37 this->name = _arg; \
38 this->Modified(); \
39 (*(this->_algorithmUserProperties))[QString(# name)] = QVariant(_arg); \
40 } \
41 } \
42\
43 type name;
44// End of ogsUserPropertyMacro
45
46#define ogsUserVec2PropertyMacro(name,type) \
47 virtual void Set ## name (type _arg1, type _arg2) \
48 { \
49 vtkDebugMacro( \
50 << this->GetClassName() << " (" << this << "): setting " << \
51 # name " to (" << \
52 _arg1 << "," << _arg2 << ")"); \
53 if ((this->name[0] != _arg1) || (this->name[1] != _arg2)) \
54 { \
55 this->name[0] = _arg1; \
56 this->name[1] = _arg2; \
57 this->Modified(); \
58 QList<QVariant> list; \
59 list.push_back(QVariant(_arg1)); \
60 list.push_back(QVariant(_arg2)); \
61 (*(this->_algorithmUserVectorProperties))[QString(# name)] = list; \
62 } \
63 } \
64\
65 virtual void Set ## name (type _arg[2]) \
66 { \
67 this->Set ## name (_arg[0], _arg[1]); \
68 } \
69\
70 type name[2];
71// End of ogsUserVec2PropertyMacro
72
73#define ogsUserVec3PropertyMacro(name,type) \
74 virtual void Set ## name (type _arg1, type _arg2, type _arg3) \
75 { \
76 vtkDebugMacro( \
77 << this->GetClassName() << " (" << this << "): setting " << \
78 # name " to (" << \
79 _arg1 << "," << _arg2 << "," << _arg3 << ")"); \
80 if ((this->name[0] != _arg1) || (this->name[1] != _arg2) || (this->name[2] != _arg3)) \
81 { \
82 this->name[0] = _arg1; \
83 this->name[1] = _arg2; \
84 this->name[2] = _arg3; \
85 this->Modified(); \
86 QList<QVariant> list; \
87 list.push_back(QVariant(_arg1)); \
88 list.push_back(QVariant(_arg2)); \
89 list.push_back(QVariant(_arg3)); \
90 (*(this->_algorithmUserVectorProperties))[QString(# name)] = list; \
91 } \
92 } \
93\
94 virtual void Set ## name (type _arg[3]) \
95 { \
96 this->Set ## name (_arg[0], _arg[1], _arg[2]); \
97 } \
98\
99 type name[3];
100// End of ogsUserVec3PropertyMacro
101
102#define ogsUserVec4PropertyMacro(name,type) \
103 virtual void Set ## name (type _arg1, type _arg2, type _arg3, type _arg4) \
104 { \
105 vtkDebugMacro( \
106 << this->GetClassName() << " (" << this << "): setting " << \
107 # name " to (" << \
108 _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << ")"); \
109 if ((this->name[0] != _arg1) || (this->name[1] != _arg2) || \
110 (this->name[2] != _arg3) || (this->name[3] != _arg4)) \
111 { \
112 this->name[0] = _arg1; \
113 this->name[1] = _arg2; \
114 this->name[2] = _arg3; \
115 this->name[3] = _arg4; \
116 this->Modified(); \
117 QList<QVariant> list; \
118 list.push_back(QVariant(_arg1)); \
119 list.push_back(QVariant(_arg2)); \
120 list.push_back(QVariant(_arg3)); \
121 list.push_back(QVariant(_arg4)); \
122 (*(this->_algorithmUserVectorProperties))[QString(# name)] = list; \
123 } \
124 } \
125\
126 virtual void Set ## name (type _arg[4]) \
127 { \
128 this->Set ## name (_arg[0], _arg[1], _arg[2], _arg[3]); \
129 } \
130\
131 type name[4];
132// End of ogsUserVec4PropertyMacro
133
137class VtkAlgorithmProperties : public QObject
138{
139 Q_OBJECT
140
141public:
143 explicit VtkAlgorithmProperties(QObject* parent = nullptr);
144
145 ~VtkAlgorithmProperties() override;
146
148 vtkProperty* GetProperties() const { return _property; }
149
151 vtkTexture* GetTexture() { return _texture; }
152
154 void SetTexture(vtkTexture* t) { _texture = t; }
155
157 vtkLookupTable* GetLookupTable(const QString& array_name);
158
160 void RemoveLookupTable(const QString& array_name);
161
163 void SetLookUpTable(const QString &array_name, vtkLookupTable* lut);
164
166 void SetLookUpTable(const QString &array_name, const QString &filename);
167
169 bool GetScalarVisibility() const { return _scalarVisibility; }
170
172 void SetScalarVisibility(bool on);
173
175 QString GetName() const { return _name; }
176
178 void SetName(QString name) { _name = name; }
179
181 bool IsRemovable() const { return _removable; }
182
184 QMap<QString, QVariant>* GetAlgorithmUserProperties() const {
186 }
187
189 QMap<QString, QList<QVariant> >* GetAlgorithmUserVectorProperties() const {
191 }
192
194 virtual void SetUserProperty(QString name, QVariant value)
195 {
196 (*_algorithmUserProperties)[name] = value;
197 }
198
200 QVariant GetUserProperty(QString name) const;
201
203 virtual void SetUserVectorProperty(QString name, QList<QVariant> values)
204 {
205 (*_algorithmUserVectorProperties)[name] = values;
206 }
207
209 QList<QVariant> GetUserVectorProperty(QString name) const;
210
212 void SetActiveAttribute(QString name);
213
215 QString GetActiveAttribute() const { return _activeAttributeName; }
216
217
218protected:
219
220 // Properties set on vtkActor
221 vtkProperty* _property;
222 vtkTexture* _texture;
223
224 // Properties set on vtkMapper
226 std::map<QString, vtkLookupTable*> _lut;
227
228 // Properties used in the GUI
229 QString _name;
232
233 QMap<QString, QVariant>* _algorithmUserProperties;
234 QMap<QString, QList<QVariant> >* _algorithmUserVectorProperties;
235
236signals:
238};
Contains properties for the visualization of objects as VtkVisPipelineItems.
vtkLookupTable * GetLookupTable(const QString &array_name)
Returns the colour lookup table (if one has been assigned).
QMap< QString, QList< QVariant > > * _algorithmUserVectorProperties
void ScalarVisibilityChanged(bool on)
void SetActiveAttribute(QString name)
Set the active attribute.
virtual void SetUserVectorProperty(QString name, QList< QVariant > values)
Sets a vector user property. This should be implemented by subclasses.
bool GetScalarVisibility() const
Returns the scalar visibility.
void SetScalarVisibility(bool on)
Sets the scalar visibility.
vtkTexture * GetTexture()
Returns a texture (if one has been assigned).
QMap< QString, QVariant > * GetAlgorithmUserProperties() const
Returns a map of user properties.
QString GetActiveAttribute() const
Returns the desired active attribute.
void SetLookUpTable(const QString &array_name, vtkLookupTable *lut)
Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
std::map< QString, vtkLookupTable * > _lut
QVariant GetUserProperty(QString name) const
Returns the value of a user property.
void SetName(QString name)
Sets the name.
void RemoveLookupTable(const QString &array_name)
Removes the lookup table for the given scalar.
QList< QVariant > GetUserVectorProperty(QString name) const
Returns a list of values of a vector user property.
VtkAlgorithmProperties(QObject *parent=nullptr)
Constructor (sets default values)
QMap< QString, QVariant > * _algorithmUserProperties
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties() const
Returns a map of vector user properties.
void SetTexture(vtkTexture *t)
Sets a texture for the VtkVisPipelineItem.
QString GetName() const
Returns the name. This is set to the file path if it is a source algorithm.
vtkProperty * GetProperties() const
Returns the vtk properties.
bool IsRemovable() const
Is this algorithm removable from the pipeline (view).
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.