OGS
VtkCompositeColormapToImageFilter Class Reference

Detailed Description

Applies a user adjustable color map to an image.

Definition at line 20 of file VtkCompositeColormapToImageFilter.h.

#include <VtkCompositeColormapToImageFilter.h>

Inheritance diagram for VtkCompositeColormapToImageFilter:
[legend]
Collaboration diagram for VtkCompositeColormapToImageFilter:
[legend]

Public Member Functions

 VtkCompositeColormapToImageFilter (vtkAlgorithm *inputAlgorithm)
 
 ~VtkCompositeColormapToImageFilter () override
 
void init () override
 
void SetUserProperty (QString name, QVariant value) override
 Sets a user property. This should be implemented by subclasses.
 
void SetUserVectorProperty (QString name, QList< QVariant > values) override
 Sets a vector user property. This should be implemented by subclasses.
 
- Public Member Functions inherited from VtkCompositeFilter
 VtkCompositeFilter (vtkAlgorithm *inputAlgorithm)
 Constructor.
 
 ~VtkCompositeFilter () override
 Destructor.
 
int GetInputDataObjectType () const
 
int GetOutputDataObjectType () const
 
vtkAlgorithm * GetOutputAlgorithm () const
 
- Public Member Functions inherited from VtkAlgorithmProperties
 VtkAlgorithmProperties (QObject *parent=nullptr)
 Constructor (sets default values)
 
 ~VtkAlgorithmProperties () override
 
vtkProperty * GetProperties () const
 Returns the vtk properties.
 
vtkTexture * GetTexture ()
 Returns a texture (if one has been assigned).
 
void SetTexture (vtkTexture *t)
 Sets a texture for the VtkVisPipelineItem.
 
vtkLookupTable * GetLookupTable (const QString &array_name)
 Returns the colour lookup table (if one has been assigned).
 
void RemoveLookupTable (const QString &array_name)
 Removes the lookup table for the given scalar.
 
void SetLookUpTable (const QString &array_name, vtkLookupTable *lut)
 Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
 
void SetLookUpTable (const QString &array_name, const QString &filename)
 Loads a predefined color lookup table from a file for the specified scalar array.
 
bool GetScalarVisibility () const
 Returns the scalar visibility.
 
void SetScalarVisibility (bool on)
 Sets the scalar visibility.
 
QString GetName () const
 Returns the name. This is set to the file path if it is a source algorithm.
 
void SetName (QString name)
 Sets the name.
 
bool IsRemovable () const
 Is this algorithm removable from the pipeline (view).
 
QMap< QString, QVariant > * GetAlgorithmUserProperties () const
 Returns a map of user properties.
 
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties () const
 Returns a map of vector user properties.
 
QVariant GetUserProperty (QString name) const
 Returns the value of a user property.
 
QList< QVariant > GetUserVectorProperty (QString name) const
 Returns a list of values of a vector user property.
 
void SetActiveAttribute (QString name)
 Set the active attribute.
 
QString GetActiveAttribute () const
 Returns the desired active attribute.
 

Additional Inherited Members

- Signals inherited from VtkAlgorithmProperties
void ScalarVisibilityChanged (bool on)
 
- Protected Member Functions inherited from VtkCompositeFilter
double GetInitialRadius () const
 Calculates a 1/200th of the largest extension of the bounding box (this is used as default radius for various filters)
 
- Protected Attributes inherited from VtkCompositeFilter
int _inputDataObjectType
 
int _outputDataObjectType
 
vtkAlgorithm * _inputAlgorithm
 
vtkAlgorithm * _outputAlgorithm
 
- Protected Attributes inherited from VtkAlgorithmProperties
vtkProperty * _property
 
vtkTexture * _texture
 
bool _scalarVisibility
 
std::map< QString, vtkLookupTable * > _lut
 
QString _name
 
QString _activeAttributeName
 
bool _removable
 
QMap< QString, QVariant > * _algorithmUserProperties
 
QMap< QString, QList< QVariant > > * _algorithmUserVectorProperties
 

Constructor & Destructor Documentation

◆ VtkCompositeColormapToImageFilter()

VtkCompositeColormapToImageFilter::VtkCompositeColormapToImageFilter ( vtkAlgorithm * inputAlgorithm)
explicit

Definition at line 30 of file VtkCompositeColormapToImageFilter.cpp.

32 : VtkCompositeFilter(inputAlgorithm)
33{
34 this->init();
35}
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

References init().

◆ ~VtkCompositeColormapToImageFilter()

VtkCompositeColormapToImageFilter::~VtkCompositeColormapToImageFilter ( )
overridedefault

Member Function Documentation

◆ init()

void VtkCompositeColormapToImageFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 40 of file VtkCompositeColormapToImageFilter.cpp.

41{
42 this->_inputDataObjectType = VTK_IMAGE_DATA;
43 this->_outputDataObjectType = VTK_IMAGE_DATA;
44
45 vtkSmartPointer<VtkColorLookupTable> colormap =
46 vtkSmartPointer<VtkColorLookupTable>::New();
47
48 QWidget* parent = nullptr;
49 QSettings settings;
50 QString fileName = QFileDialog::getOpenFileName(
51 parent, "Select color lookup table",
52 settings.value("lastOpenedLookupTableFileDirectory").toString(),
53 "Lookup table XML files (*.xml);;");
54 double range[2];
55 dynamic_cast<vtkImageAlgorithm*>(_inputAlgorithm)
56 ->GetOutput()
57 ->GetPointData()
58 ->GetScalars()
59 ->GetRange(range);
60
62 if (FileIO::XmlLutReader::readFromFile(fileName, lut))
63 {
64 colormap->setLookupTable(lut);
65 settings.setValue("lastOpenedLookupTableFileDirectory", fileName);
66 }
67 else
68 {
69 colormap->SetTableRange(range[0], range[1]);
70 colormap->SetHueRange(0.0, 0.666);
71 }
72 colormap->SetNumberOfTableValues(256);
73 colormap->Build();
74
75 colormap->GetTableRange(range);
76 QList<QVariant> tableRangeList;
77 tableRangeList.push_back(range[0]);
78 tableRangeList.push_back(range[1]);
79 QList<QVariant> hueRangeList;
80 hueRangeList.push_back(0.0);
81 hueRangeList.push_back(0.666);
82 (*_algorithmUserVectorProperties)["TableRange"] = tableRangeList;
83 (*_algorithmUserVectorProperties)["HueRange"] = hueRangeList;
84
85 vtkImageMapToColors* map = vtkImageMapToColors::New();
86 map->SetInputConnection(0, _inputAlgorithm->GetOutputPort());
87 map->SetLookupTable(colormap);
88 map->SetPassAlphaToOutput(1);
89 (*_algorithmUserProperties)["PassAlphaToOutput"] = true;
90 (*_algorithmUserProperties)["NumberOfColors"] = 256;
91
92 _outputAlgorithm = map;
93}
static bool readFromFile(const QString &fileName, DataHolderLib::ColorLookupTable &lut)
vtkAlgorithm * _outputAlgorithm
vtkAlgorithm * _inputAlgorithm

References VtkCompositeFilter::_inputAlgorithm, VtkCompositeFilter::_inputDataObjectType, VtkCompositeFilter::_outputAlgorithm, VtkCompositeFilter::_outputDataObjectType, and FileIO::XmlLutReader::readFromFile().

Referenced by VtkCompositeColormapToImageFilter().

◆ SetUserProperty()

void VtkCompositeColormapToImageFilter::SetUserProperty ( QString name,
QVariant value )
overridevirtual

Sets a user property. This should be implemented by subclasses.

Reimplemented from VtkAlgorithmProperties.

Definition at line 95 of file VtkCompositeColormapToImageFilter.cpp.

97{
99
100 auto* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm);
101 if (name.compare("PassAlphaToOutput") == 0)
102 {
103 map->SetPassAlphaToOutput(value.toBool());
104 }
105 else if (name.compare("NumberOfColors") == 0)
106 {
107 static_cast<vtkLookupTable*>(map->GetLookupTable())
108 ->SetNumberOfTableValues(value.toInt());
109 }
110}
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.

References VtkCompositeFilter::_outputAlgorithm, and VtkAlgorithmProperties::SetUserProperty().

◆ SetUserVectorProperty()

void VtkCompositeColormapToImageFilter::SetUserVectorProperty ( QString name,
QList< QVariant > values )
overridevirtual

Sets a vector user property. This should be implemented by subclasses.

Reimplemented from VtkAlgorithmProperties.

Definition at line 112 of file VtkCompositeColormapToImageFilter.cpp.

114{
116
117 auto* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm);
118 if (name.compare("TableRange") == 0)
119 {
120 static_cast<vtkLookupTable*>(map->GetLookupTable())
121 ->SetTableRange(values[0].toInt(), values[1].toInt());
122 }
123 else if (name.compare("HueRange") == 0)
124 {
125 static_cast<vtkLookupTable*>(map->GetLookupTable())
126 ->SetHueRange(values[0].toDouble(), values[1].toDouble());
127 }
128}
virtual void SetUserVectorProperty(QString name, QList< QVariant > values)
Sets a vector user property. This should be implemented by subclasses.

References VtkCompositeFilter::_outputAlgorithm, and VtkAlgorithmProperties::SetUserVectorProperty().


The documentation for this class was generated from the following files: