OGS
VtkCompositeTextureOnSurfaceFilter Class Reference

Detailed Description

Puts a texture on an object (and converts it into a vtkPolyData if necessary).

Definition at line 22 of file VtkCompositeTextureOnSurfaceFilter.h.

#include <VtkCompositeTextureOnSurfaceFilter.h>

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

Public Member Functions

 VtkCompositeTextureOnSurfaceFilter (vtkAlgorithm *inputAlgorithm)
 
 ~VtkCompositeTextureOnSurfaceFilter () override
 
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

◆ VtkCompositeTextureOnSurfaceFilter()

VtkCompositeTextureOnSurfaceFilter::VtkCompositeTextureOnSurfaceFilter ( vtkAlgorithm * inputAlgorithm)
explicit

Definition at line 33 of file VtkCompositeTextureOnSurfaceFilter.cpp.

35 : VtkCompositeFilter(inputAlgorithm)
36{
37 this->init();
38}
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

References init().

◆ ~VtkCompositeTextureOnSurfaceFilter()

VtkCompositeTextureOnSurfaceFilter::~VtkCompositeTextureOnSurfaceFilter ( )
overridedefault

Member Function Documentation

◆ init()

void VtkCompositeTextureOnSurfaceFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 43 of file VtkCompositeTextureOnSurfaceFilter.cpp.

44{
45 this->_inputDataObjectType = VTK_DATA_SET;
46 this->_outputDataObjectType = VTK_POLY_DATA;
47
48 vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter;
50
51 if (dynamic_cast<vtkUnstructuredGrid*>(
52 _inputAlgorithm->GetOutputDataObject(0)))
53 {
54 surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
55 surfaceFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
56 surface->SetInputConnection(surfaceFilter->GetOutputPort());
57 }
58 else
59 {
60 surface->SetInputConnection(_inputAlgorithm->GetOutputPort());
61 }
62
63 QWidget* parent = nullptr;
64 QSettings settings;
65 QString fileName = QFileDialog::getOpenFileName(
66 parent, "Select raster file to apply as texture",
67 settings.value("lastOpenedTextureFileDirectory").toString(),
68 "Raster files (*.asc *.grd *.bmp *.jpg *.png *.tif);;"
69#ifdef OGS_USE_NETCDF
70 "NetCDF files (*.nc);;"
71#endif // OGS_USE_NETCDF
72 );
73 QFileInfo fi(fileName);
74
75 if ((fi.suffix().toLower() == "asc") || (fi.suffix().toLower() == "tif") ||
76 (fi.suffix().toLower() == "png") || (fi.suffix().toLower() == "grd") ||
77 (fi.suffix().toLower() == "jpg") || (fi.suffix().toLower() == "bmp"))
78 {
79 std::string name = fileName.toStdString();
80 vtkImageAlgorithm* image = VtkRaster::loadImage(name);
81 surface->SetRaster(image);
82 surface->Update();
83
84 QDir dir = QDir(fileName);
85 settings.setValue("lastOpenedTextureFileDirectory", dir.absolutePath());
86 }
87#ifdef OGS_USE_NETCDF
88 else if (fi.suffix().toLower() == "nc")
89 {
90 NetCdfConfigureDialog dlg(fileName.toStdString().c_str());
91 dlg.exec();
92 if (dlg.getRaster() != nullptr)
93 {
94 VtkGeoImageSource* image = dlg.getRaster();
95 surface->SetRaster(image);
96 surface->Update();
97 }
98 }
99#endif // OGS_USE_NETCDF
100 else
101 ERR("VtkCompositeTextureOnSurfaceFilter::init(): Error reading texture "
102 "file.");
103
104 _outputAlgorithm = surface;
105}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
The dialog for converting data from NetCDF-files into OGS data structures. While NetCDF files can inc...
vtkAlgorithm * _outputAlgorithm
vtkAlgorithm * _inputAlgorithm
The VtkVisPipeline source object of a geo-referenced image (file).
static vtkImageAlgorithm * loadImage(const std::string &fileName)
Loads an image- or raster-file into an vtkImageAlgorithm-Object.
Definition VtkRaster.cpp:43
Filter class for assigning a texture to a surface.
static VtkTextureOnSurfaceFilter * New()
Create new objects with New() because of VTKs object reference counting.
void SetRaster(vtkImageAlgorithm *img)
Sets the raster/image to be used as a texture map.

References VtkCompositeFilter::_inputAlgorithm, VtkCompositeFilter::_inputDataObjectType, VtkCompositeFilter::_outputAlgorithm, VtkCompositeFilter::_outputDataObjectType, ERR(), NetCdfConfigureDialog::getRaster(), VtkRaster::loadImage(), VtkTextureOnSurfaceFilter::New(), and VtkTextureOnSurfaceFilter::SetRaster().

Referenced by VtkCompositeTextureOnSurfaceFilter().

◆ SetUserProperty()

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

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

Reimplemented from VtkAlgorithmProperties.

Definition at line 107 of file VtkCompositeTextureOnSurfaceFilter.cpp.

109{
111}
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.

References VtkAlgorithmProperties::SetUserProperty().


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