OGS
VtkAlgorithmProperties.cpp
Go to the documentation of this file.
1
15// ** INCLUDES **
17
18#include <vtkProperty.h>
19#include <vtkTexture.h>
20
23#include "BaseLib/Logging.h"
24#include "VtkColorLookupTable.h"
25
27 : QObject(parent)
28{
29 _property = vtkProperty::New();
30 _texture = nullptr;
31 _scalarVisibility = true;
32 _algorithmUserProperties = new QMap<QString, QVariant>;
33 _algorithmUserVectorProperties = new QMap<QString, QList<QVariant>>;
35 _removable = true;
36}
37
39{
40 _property->Delete();
41 if (_texture != nullptr)
42 {
43 _texture->Delete();
44 }
45
46 for (auto& row : _lut)
47 {
48 row.second->Delete();
49 }
52}
53
55 const QString& array_name)
56{
57 auto it = _lut.find(array_name);
58 if (it != _lut.end())
59 {
60 return it->second;
61 }
62
63 return nullptr;
64}
65
66void VtkAlgorithmProperties::RemoveLookupTable(const QString& array_name)
67{
68 auto it = _lut.find(array_name);
69 if (it != _lut.end())
70 {
71 it->second->Delete();
72 _lut.erase(it);
73 }
74}
75
76void VtkAlgorithmProperties::SetLookUpTable(const QString& array_name,
77 vtkLookupTable* lut)
78{
79 lut->Build();
80
81 if (array_name.length() > 0)
82 {
83 this->RemoveLookupTable(array_name);
84 _lut.insert(std::pair<QString, vtkLookupTable*>(array_name, lut));
85 _activeAttributeName = array_name;
86 }
87}
88
89void VtkAlgorithmProperties::SetLookUpTable(const QString& array_name,
90 const QString& filename)
91{
93 if (FileIO::XmlLutReader::readFromFile(filename, lut))
94 {
96 colorLookupTable->setLookupTable(lut);
97 SetLookUpTable(array_name, colorLookupTable);
98 }
99 else
100 ERR("Error reading color look-up table.");
101}
102
108
109QVariant VtkAlgorithmProperties::GetUserProperty(QString name) const
110{
111 if (this->_algorithmUserProperties->contains(name))
112 {
113 return this->_algorithmUserProperties->value(name);
114 }
115
116 ERR("Not a valid property: {:s}", name.toStdString());
117 return QVariant();
118}
119
121 QString name) const
122{
123 if (this->_algorithmUserVectorProperties->contains(name))
124 {
125 return this->_algorithmUserVectorProperties->value(name);
126 }
127
128 ERR("Not a valid property: {:s}", name.toStdString());
129 return QList<QVariant>();
130}
131
133{
134 if (name.contains("Solid Color") || name.contains("P-TextureCoordinates"))
135 {
136 SetScalarVisibility(false);
137 }
138 else
139 {
141 }
143}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
Definition of the VtkAlgorithmProperties class.
Definition of the VtkColorLookupTable class.
Definition of the XmlLutReader class.
static bool readFromFile(const QString &fileName, DataHolderLib::ColorLookupTable &lut)
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.
void SetScalarVisibility(bool on)
Sets the scalar visibility.
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 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
Calculates and stores a colour lookup table.
void setLookupTable(DataHolderLib::ColorLookupTable const &lut)
Imports settings of OGS lookup table class.
static VtkColorLookupTable * New()
Create new objects with New() because of VTKs object reference counting.