OGS
VtkCompositeColorByHeightFilter Class Reference

Detailed Description

This filter colors the input by the points z-value.

Definition at line 22 of file VtkCompositeColorByHeightFilter.h.

#include <VtkCompositeColorByHeightFilter.h>

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

Public Member Functions

 VtkCompositeColorByHeightFilter (vtkAlgorithm *inputAlgorithm)
 
 ~VtkCompositeColorByHeightFilter () override=default
 
void init () override
 
void SetUserProperty (QString name, QVariant value) override
 Sets a 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.
 
virtual void SetUserVectorProperty (QString name, QList< QVariant > values)
 Sets a vector user property. This should be implemented by subclasses.
 
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

◆ VtkCompositeColorByHeightFilter()

VtkCompositeColorByHeightFilter::VtkCompositeColorByHeightFilter ( vtkAlgorithm * inputAlgorithm)
explicit

Definition at line 25 of file VtkCompositeColorByHeightFilter.cpp.

27 : VtkCompositeFilter(inputAlgorithm)
28{
29 this->init();
30}
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

References init().

◆ ~VtkCompositeColorByHeightFilter()

VtkCompositeColorByHeightFilter::~VtkCompositeColorByHeightFilter ( )
overridedefault

Member Function Documentation

◆ init()

void VtkCompositeColorByHeightFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 32 of file VtkCompositeColorByHeightFilter.cpp.

33{
34 this->_inputDataObjectType = VTK_DATA_SET;
35 this->_outputDataObjectType = VTK_POLY_DATA;
36
37 vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter;
39
40 if (dynamic_cast<vtkUnstructuredGrid*>(
41 _inputAlgorithm->GetOutputDataObject(0)))
42 {
43 surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
44 surfaceFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
45 heightFilter->SetInputConnection(surfaceFilter->GetOutputPort());
46 }
47 else
48 {
49 heightFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
50 }
51
52 DataHolderLib::Color a{{0, 0, 255, 255}}; // blue
53 DataHolderLib::Color b{{0, 255, 0, 255}}; // green
54 DataHolderLib::Color c{{255, 255, 0, 255}}; // yellow
55 DataHolderLib::Color d{{155, 100, 50, 255}}; // brown
56 DataHolderLib::Color e{{255, 0, 0, 255}}; // red
57 VtkColorLookupTable* ColorLookupTable = heightFilter->GetColorLookupTable();
59 ColorLookupTable->setColor(-50, a);
60 ColorLookupTable->setColor(0, a);
61 ColorLookupTable->setColor(1, b); // instant change at 0m a.s.l.
62 ColorLookupTable->setColor(200, b); // green at about 200m a.s.l.
63 ColorLookupTable->setColor(
64 500, c); // yellow at about 500m and changing to red from then on
65 ColorLookupTable->setColor(1000, d);
66 ColorLookupTable->setColor(2000, e);
67 ColorLookupTable->SetTableRange(-35, 2000);
68 ColorLookupTable->Build();
69
70 // This passes ownership of the ColorLookupTable to VtkVisPointSetItem
71 heightFilter->SetLookUpTable("P-Colors", ColorLookupTable);
72 heightFilter->Update();
73
74 _outputAlgorithm = heightFilter;
76}
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.
VTK filter object for colouring vtkPolyData objects based on z-coordinates.
static VtkColorByHeightFilter * New()
Create new objects with New() because of VTKs object reference counting.
Calculates and stores a colour lookup table.
void setColor(double pos, DataHolderLib::Color const &color)
void Build() override
Builds the colour table based on the previously set parameters. This method should only be called aft...
void setInterpolationType(DataHolderLib::LUTType type)
Sets the type of interpolation.
vtkAlgorithm * _outputAlgorithm
vtkAlgorithm * _inputAlgorithm
std::array< unsigned char, 4 > Color
Definition Color.h:24

References VtkAlgorithmProperties::_activeAttributeName, VtkCompositeFilter::_inputAlgorithm, VtkCompositeFilter::_inputDataObjectType, VtkCompositeFilter::_outputAlgorithm, VtkCompositeFilter::_outputDataObjectType, VtkColorLookupTable::Build(), VtkAlgorithmProperties::GetActiveAttribute(), DataHolderLib::LINEAR, VtkColorByHeightFilter::New(), VtkColorLookupTable::setColor(), VtkColorLookupTable::setInterpolationType(), and VtkAlgorithmProperties::SetLookUpTable().

Referenced by VtkCompositeColorByHeightFilter().

◆ SetUserProperty()

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

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

Reimplemented from VtkAlgorithmProperties.

Definition at line 78 of file VtkCompositeColorByHeightFilter.cpp.

80{
81 Q_UNUSED(name);
82 Q_UNUSED(value);
83}

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