OGS
VtkBGImageSource Class Reference

Detailed Description

Uses an image source to create a plane in the 3D with the given image texture mapped on it.

Definition at line 28 of file VtkBGImageSource.h.

#include <VtkBGImageSource.h>

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

Public Member Functions

 vtkTypeMacro (VtkBGImageSource, vtkTextureMapToPlane)
 
void SetRaster (vtkImageAlgorithm *img, double x0, double y0, double scalingFactor)
 Sets the raster/image to be used as a texture map.
 
void SetUserProperty (QString name, QVariant value) override
 Sets a user property. This should be implemented by subclasses.
 
- 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.
 

Static Public Member Functions

static VtkBGImageSourceNew ()
 Create new objects with New() because of VTKs object reference counting.
 

Protected Member Functions

 VtkBGImageSource ()
 
 ~VtkBGImageSource () override
 

Private Attributes

std::pair< double, double > _origin {0, 0}
 
double _cellsize {1}
 

Additional Inherited Members

- Signals inherited from VtkAlgorithmProperties
void ScalarVisibilityChanged (bool on)
 
- 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

◆ VtkBGImageSource()

VtkBGImageSource::VtkBGImageSource ( )
protecteddefault

◆ ~VtkBGImageSource()

VtkBGImageSource::~VtkBGImageSource ( )
overrideprotecteddefault

Member Function Documentation

◆ New()

static VtkBGImageSource * VtkBGImageSource::New ( )
static

Create new objects with New() because of VTKs object reference counting.

Referenced by MainWindow::loadFile().

◆ SetRaster()

void VtkBGImageSource::SetRaster ( vtkImageAlgorithm * img,
double x0,
double y0,
double scalingFactor )

Sets the raster/image to be used as a texture map.

Definition at line 37 of file VtkBGImageSource.cpp.

39{
40 double range[2];
41 img->Update();
42 img->GetOutput()->GetPointData()->GetScalars()->GetRange(range);
43 vtkSmartPointer<vtkImageShiftScale> scale =
44 vtkSmartPointer<vtkImageShiftScale>::New();
45 scale->SetInputConnection(img->GetOutputPort());
46 scale->SetShift(-range[0]);
47 scale->SetScale(255.0 / (range[1] - range[0]));
48 scale->SetOutputScalarTypeToUnsignedChar();
49 scale->Update();
50
51 vtkImageData* imageData = scale->GetOutput();
52 int dims[3];
53 imageData->GetDimensions(dims);
54 vtkTexture* texture = vtkTexture::New();
55 texture->InterpolateOff();
56 texture->RepeatOff();
57 // texture->EdgeClampOn(); // does not work
58 texture->SetInputData(imageData);
59 this->SetTexture(texture);
60
61 _origin =
62 std::pair<float, float>(static_cast<float>(x0), static_cast<float>(y0));
63 _cellsize = scalingFactor;
64
65 vtkSmartPointer<vtkPlaneSource> plane =
66 vtkSmartPointer<vtkPlaneSource>::New();
67 plane->SetOrigin(_origin.first, _origin.second, -1);
68 plane->SetPoint1(_origin.first + dims[0] * _cellsize, _origin.second, -1);
69 plane->SetPoint2(_origin.first, _origin.second + dims[1] * _cellsize, -1);
70
71 this->SetInputConnection(0, plane->GetOutputPort(0));
72 this->SetTexture(texture);
73}
void SetTexture(vtkTexture *t)
Sets a texture for the VtkVisPipelineItem.
std::pair< double, double > _origin
void scale(PETScVector &x, PetscScalar const a)
Definition LinAlg.cpp:44

References _cellsize, _origin, and VtkAlgorithmProperties::SetTexture().

Referenced by MainWindow::loadFile().

◆ SetUserProperty()

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

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

Reimplemented from VtkAlgorithmProperties.

Definition at line 75 of file VtkBGImageSource.cpp.

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

References VtkAlgorithmProperties::SetUserProperty().

◆ vtkTypeMacro()

VtkBGImageSource::vtkTypeMacro ( VtkBGImageSource ,
vtkTextureMapToPlane  )

Member Data Documentation

◆ _cellsize

double VtkBGImageSource::_cellsize {1}
private

Definition at line 47 of file VtkBGImageSource.h.

47{1};

Referenced by SetRaster().

◆ _origin

std::pair<double, double> VtkBGImageSource::_origin {0, 0}
private

Definition at line 46 of file VtkBGImageSource.h.

46{0, 0};

Referenced by SetRaster().


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