OGS
VtkVisPipelineItem Class Referenceabstract

Detailed Description

An item in the VtkVisPipeline containing a graphic object to be visualized.

Any VTK-object (source-items, filter-items, etc.) need to be put into a VtkPipelineItem to be assigned a mapper, an actor and its visualization properties (colour, etc.).

Definition at line 42 of file VtkVisPipelineItem.h.

#include <VtkVisPipelineItem.h>

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

Public Member Functions

 VtkVisPipelineItem (vtkAlgorithm *algorithm, TreeItem *parentItem, const QList< QVariant > data=QList< QVariant >())
 Constructor for a source/filter object.
 
 VtkVisPipelineItem (VtkCompositeFilter *compositeFilter, TreeItem *parentItem, const QList< QVariant > data=QList< QVariant >())
 Constructor for composite filter.
 
 ~VtkVisPipelineItem () override
 
VtkVisPipelineItemchild (int row) const
 Returns a VtkVisPipelineItem.
 
virtual void Initialize (vtkRenderer *renderer)=0
 Initializes vtkMapper and vtkActor necessary for visualization of the item and sets the item's properties.
 
QVariant data (int column) const override
 
bool setData (int column, const QVariant &value) override
 
vtkAlgorithm * algorithm () const
 Returns the algorithm object.
 
vtkProp3D * actor () const
 Returns the actor as vtkProp3D.
 
virtual QString GetActiveAttribute () const
 
virtual void SetActiveAttribute (const QString &str)
 
VtkCompositeFiltercompositeFilter () const
 Returns the composite filter.
 
bool isVisible () const
 Returns if the VTK object is visible in the visualization.
 
void setVisible (bool visible)
 Sets the visibility of the VTK object in the visualization.
 
int writeToFile (const std::string &filename) const
 Writes this algorithm's vtkDataSet (i.e. vtkPolyData or vtkUnstructuredGrid) to a vtk-file.
 
virtual void setScale (double x, double y, double z) const
 Scales the data in visualisation-space. This function is empty and needs to be implemented by derived classes.
 
void setScaleOnChildren (double x, double y, double z) const
 Sets the geometry and date scaling recursively on all children of this item.
 
virtual void setTranslation (double x, double y, double z) const
 Translates the item in visualisation-space. This function is empty and needs to be implemented by derived classes.
 
virtual vtkAlgorithm * transformFilter () const =0
 
virtual void setBackfaceCulling (bool enable) const
 Enables / disables backface culling.
 
void setBackfaceCullingOnChildren (bool enable) const
 Enables / disables backface culling on all children.
 
QStringList getScalarArrayNames () const
 Returns a list of array names prefixed with P- or C- for point and cell data.
 
VtkAlgorithmPropertiesgetVtkProperties () const
 Returns the VtkAlgorithmProperties.
 
- Public Member Functions inherited from TreeItem
 TreeItem (QList< QVariant > data, TreeItem *parent)
 
virtual ~TreeItem ()
 
void appendChild (TreeItem *item)
 
TreeItemchild (int row) const
 
virtual int childCount () const
 
virtual int columnCount () const
 
virtual QVariant data (int column) const
 
virtual bool setData (int column, const QVariant &value)
 
int row () const
 
TreeItemparentItem () const
 
bool removeChildren (int position, int count)
 

Protected Member Functions

virtual int callVTKWriter (vtkAlgorithm *algorithm, const std::string &filename) const
 

Protected Attributes

vtkProp3D * _actor
 
vtkAlgorithm * _algorithm
 
vtkRenderer * _renderer
 
VtkCompositeFilter_compositeFilter
 
VtkAlgorithmProperties_vtkProps
 The active VtkAlgorithmProperties. From algorithm, compositeFilter, or copied from parent.
 

Constructor & Destructor Documentation

◆ VtkVisPipelineItem() [1/2]

VtkVisPipelineItem::VtkVisPipelineItem ( vtkAlgorithm *  algorithm,
TreeItem parentItem,
const QList< QVariant >  data = QList<QVariant>() 
)

Constructor for a source/filter object.

Definition at line 38 of file VtkVisPipelineItem.cpp.

42 _actor(nullptr),
44 _renderer(nullptr),
45 _compositeFilter(nullptr),
46 _vtkProps(nullptr)
47{
48 auto* visParentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem);
50 {
51 _algorithm->SetInputConnection(
52 visParentItem->algorithm()->GetOutputPort());
53 }
54}
Objects nodes for the TreeModel.
Definition: TreeItem.h:28
TreeItem * parentItem() const
Definition: TreeItem.cpp:115
An item in the VtkVisPipeline containing a graphic object to be visualized.
vtkAlgorithm * algorithm() const
Returns the algorithm object.
VtkAlgorithmProperties * _vtkProps
The active VtkAlgorithmProperties. From algorithm, compositeFilter, or copied from parent.
vtkAlgorithm * _algorithm
VtkCompositeFilter * _compositeFilter
QVariant data(int column) const override

References _algorithm, and TreeItem::parentItem().

◆ VtkVisPipelineItem() [2/2]

VtkVisPipelineItem::VtkVisPipelineItem ( VtkCompositeFilter compositeFilter,
TreeItem parentItem,
const QList< QVariant >  data = QList<QVariant>() 
)

Constructor for composite filter.

Definition at line 56 of file VtkVisPipelineItem.cpp.

60 _actor(nullptr),
61 _renderer(nullptr),
63 _vtkProps(nullptr)
64{
66}
vtkAlgorithm * GetOutputAlgorithm() const
VtkCompositeFilter * compositeFilter() const
Returns the composite filter.

References _algorithm, _compositeFilter, and VtkCompositeFilter::GetOutputAlgorithm().

◆ ~VtkVisPipelineItem()

VtkVisPipelineItem::~VtkVisPipelineItem ( )
override

Definition at line 68 of file VtkVisPipelineItem.cpp.

69{
70 _renderer->RemoveActor(_actor);
71 _actor->Delete();
72 delete _compositeFilter;
73}

References _actor, _compositeFilter, and _renderer.

Member Function Documentation

◆ actor()

◆ algorithm()

◆ callVTKWriter()

int VtkVisPipelineItem::callVTKWriter ( vtkAlgorithm *  algorithm,
const std::string &  filename 
) const
protectedvirtual

Selects the appropriate VTK-Writer object and writes the object to a file with the given name. This function is empty and needs to be implemented by derived classes.

Reimplemented in VtkVisImageItem, and VtkVisPointSetItem.

Definition at line 127 of file VtkVisPipelineItem.cpp.

129{
130 // needs to be implemented in derived classes!
131 (void)algorithm;
132 (void)filename;
133 return 0;
134}

References algorithm().

Referenced by writeToFile().

◆ child()

VtkVisPipelineItem * VtkVisPipelineItem::child ( int  row) const

Returns a VtkVisPipelineItem.

Definition at line 75 of file VtkVisPipelineItem.cpp.

76{
77 TreeItem* treeItem = TreeItem::child(row);
78 if (treeItem)
79 {
80 return dynamic_cast<VtkVisPipelineItem*>(treeItem);
81 }
82
83 return nullptr;
84}
TreeItem * child(int row) const
Definition: TreeItem.cpp:52
int row() const
Definition: TreeItem.cpp:73

References TreeItem::child(), and TreeItem::row().

Referenced by VtkVisTabWidget::on_scaleZ_textChanged(), setBackfaceCullingOnChildren(), and setScaleOnChildren().

◆ compositeFilter()

VtkCompositeFilter * VtkVisPipelineItem::compositeFilter ( ) const
inline

Returns the composite filter.

Definition at line 81 of file VtkVisPipelineItem.h.

81{ return _compositeFilter; }

References _compositeFilter.

Referenced by VtkVisTabWidget::buildProportiesDialog(), and VtkVisTabWidget::on_scaleZ_textChanged().

◆ data()

QVariant VtkVisPipelineItem::data ( int  column) const
overridevirtual

Returns the data from all the columns.

Reimplemented from TreeItem.

Definition at line 86 of file VtkVisPipelineItem.cpp.

87{
88 if (column == 1)
89 {
90 return isVisible();
91 }
92
93 return TreeItem::data(column);
94}
virtual QVariant data(int column) const
Definition: TreeItem.cpp:94
bool isVisible() const
Returns if the VTK object is visible in the visualization.

References TreeItem::data(), and isVisible().

Referenced by VtkVisPointSetItem::activeAttributeExists(), and VtkVisPipelineView::convertVTKToOGSMesh().

◆ GetActiveAttribute()

virtual QString VtkVisPipelineItem::GetActiveAttribute ( ) const
inlinevirtual

Reimplemented in VtkVisPointSetItem.

Definition at line 75 of file VtkVisPipelineItem.h.

75{ return QString(""); }

Referenced by VtkVisPipelineView::addColorTable(), VtkVisTabWidget::buildScalarArrayComboBox(), and VtkVisTabWidget::setActiveItem().

◆ getScalarArrayNames()

QStringList VtkVisPipelineItem::getScalarArrayNames ( ) const

Returns a list of array names prefixed with P- or C- for point and cell data.

Definition at line 178 of file VtkVisPipelineItem.cpp.

179{
180 this->algorithm()->Update();
181 vtkDataSet* dataSet =
182 vtkDataSet::SafeDownCast(this->algorithm()->GetOutputDataObject(0));
183 QStringList dataSetAttributesList;
184 if (dataSet)
185 {
186 vtkPointData* pointData = dataSet->GetPointData();
187 // std::cout << " #point data arrays: " <<
188 // pointData->GetNumberOfArrays() << std::endl;
189 for (int i = 0; i < pointData->GetNumberOfArrays(); i++)
190 {
191 // std::cout << " Name: " << pointData->GetArrayName(i) <<
192 // std::endl;
193 dataSetAttributesList.push_back(QString("P-") +
194 pointData->GetArrayName(i));
195 }
196
197 vtkCellData* cellData = dataSet->GetCellData();
198 // std::cout << " #cell data arrays: " << cellData->GetNumberOfArrays()
199 // << std::endl;
200 for (int i = 0; i < cellData->GetNumberOfArrays(); i++)
201 {
202 // std::cout << " Name: " << cellData->GetArrayName(i) <<
203 // std::endl;
204 dataSetAttributesList.push_back(QString("C-") +
205 cellData->GetArrayName(i));
206 }
207 }
208 return dataSetAttributesList;
209}

References algorithm().

Referenced by VtkVisTabWidget::buildScalarArrayComboBox(), and VtkVisPointSetItem::Initialize().

◆ getVtkProperties()

◆ Initialize()

virtual void VtkVisPipelineItem::Initialize ( vtkRenderer *  renderer)
pure virtual

Initializes vtkMapper and vtkActor necessary for visualization of the item and sets the item's properties.

Implemented in VtkVisImageItem, and VtkVisPointSetItem.

Referenced by VtkVisPipeline::addPipelineItem().

◆ isVisible()

bool VtkVisPipelineItem::isVisible ( ) const

Returns if the VTK object is visible in the visualization.

Definition at line 106 of file VtkVisPipelineItem.cpp.

107{
108 return static_cast<bool>(_actor->GetVisibility());
109}

References _actor.

Referenced by data().

◆ SetActiveAttribute()

virtual void VtkVisPipelineItem::SetActiveAttribute ( const QString &  str)
inlinevirtual

◆ setBackfaceCulling()

void VtkVisPipelineItem::setBackfaceCulling ( bool  enable) const
virtual

Enables / disables backface culling.

Reimplemented in VtkVisPointSetItem.

Definition at line 162 of file VtkVisPipelineItem.cpp.

163{
164 // Reimplemented in subclass
165 (void)enable;
166}

Referenced by setBackfaceCullingOnChildren(), and VtkVisPipeline::setGlobalBackfaceCulling().

◆ setBackfaceCullingOnChildren()

void VtkVisPipelineItem::setBackfaceCullingOnChildren ( bool  enable) const

Enables / disables backface culling on all children.

Definition at line 168 of file VtkVisPipelineItem.cpp.

169{
170 for (int i = 0; i < this->childCount(); ++i)
171 {
172 VtkVisPipelineItem* child = this->child(i);
173 child->setBackfaceCulling(static_cast<int>(enable));
174 child->setBackfaceCullingOnChildren(static_cast<int>(enable));
175 }
176}
virtual int childCount() const
Definition: TreeItem.cpp:65
virtual void setBackfaceCulling(bool enable) const
Enables / disables backface culling.
void setBackfaceCullingOnChildren(bool enable) const
Enables / disables backface culling on all children.
VtkVisPipelineItem * child(int row) const
Returns a VtkVisPipelineItem.

References child(), TreeItem::childCount(), setBackfaceCulling(), and setBackfaceCullingOnChildren().

Referenced by setBackfaceCullingOnChildren().

◆ setData()

bool VtkVisPipelineItem::setData ( int  column,
const QVariant &  value 
)
overridevirtual

Sets the data at a given column.

Reimplemented from TreeItem.

Definition at line 96 of file VtkVisPipelineItem.cpp.

97{
98 if (column == 1)
99 {
100 setVisible(value.toBool());
101 return true;
102 }
103
104 return TreeItem::setData(column, value);
105}
virtual bool setData(int column, const QVariant &value)
Definition: TreeItem.cpp:102
void setVisible(bool visible)
Sets the visibility of the VTK object in the visualization.

References TreeItem::setData(), and setVisible().

◆ setScale()

void VtkVisPipelineItem::setScale ( double  x,
double  y,
double  z 
) const
virtual

Scales the data in visualisation-space. This function is empty and needs to be implemented by derived classes.

Reimplemented in VtkVisPointSetItem.

Definition at line 141 of file VtkVisPipelineItem.cpp.

142{
143 (void)x;
144 (void)y, (void)z;
145}

Referenced by VtkVisPipeline::addPipelineItem(), VtkVisTabWidget::on_scaleZ_textChanged(), VtkVisPipeline::setGlobalSuperelevation(), and setScaleOnChildren().

◆ setScaleOnChildren()

void VtkVisPipelineItem::setScaleOnChildren ( double  x,
double  y,
double  z 
) const

Sets the geometry and date scaling recursively on all children of this item.

Definition at line 153 of file VtkVisPipelineItem.cpp.

154{
155 for (int i = 0; i < this->childCount(); ++i)
156 {
157 VtkVisPipelineItem* child = this->child(i);
158 child->setScale(x, y, z);
159 }
160}
virtual void setScale(double x, double y, double z) const
Scales the data in visualisation-space. This function is empty and needs to be implemented by derived...

References child(), TreeItem::childCount(), and setScale().

◆ setTranslation()

void VtkVisPipelineItem::setTranslation ( double  x,
double  y,
double  z 
) const
virtual

Translates the item in visualisation-space. This function is empty and needs to be implemented by derived classes.

Reimplemented in VtkVisImageItem, and VtkVisPointSetItem.

Definition at line 147 of file VtkVisPipelineItem.cpp.

148{
149 (void)x;
150 (void)y, (void)z;
151}

Referenced by VtkVisTabWidget::translateItem().

◆ setVisible()

void VtkVisPipelineItem::setVisible ( bool  visible)

Sets the visibility of the VTK object in the visualization.

Definition at line 111 of file VtkVisPipelineItem.cpp.

112{
113 _actor->SetVisibility(static_cast<int>(visible));
114 _actor->Modified();
115 _renderer->Render();
116}

References _actor, and _renderer.

Referenced by setData().

◆ transformFilter()

virtual vtkAlgorithm * VtkVisPipelineItem::transformFilter ( ) const
pure virtual

Returns the transform filter for the object. This function needs to be implemented by derived classes.

Implemented in VtkVisImageItem, and VtkVisPointSetItem.

Referenced by VtkVisTabWidget::setActiveItem().

◆ writeToFile()

int VtkVisPipelineItem::writeToFile ( const std::string &  filename) const

Writes this algorithm's vtkDataSet (i.e. vtkPolyData or vtkUnstructuredGrid) to a vtk-file.

Definition at line 118 of file VtkVisPipelineItem.cpp.

119{
120 if (!filename.empty())
121 {
122 return callVTKWriter(this->algorithm(), filename);
123 }
124 return 0;
125}
virtual int callVTKWriter(vtkAlgorithm *algorithm, const std::string &filename) const

References algorithm(), and callVTKWriter().

Referenced by MainWindow::on_actionExportVTK_triggered().

Member Data Documentation

◆ _actor

◆ _algorithm

◆ _compositeFilter

VtkCompositeFilter* VtkVisPipelineItem::_compositeFilter
protected

◆ _renderer

vtkRenderer* VtkVisPipelineItem::_renderer
protected

◆ _vtkProps

VtkAlgorithmProperties* VtkVisPipelineItem::_vtkProps
protected

The active VtkAlgorithmProperties. From algorithm, compositeFilter, or copied from parent.

Definition at line 136 of file VtkVisPipelineItem.h.

Referenced by VtkVisPointSetItem::GetActiveAttribute(), getVtkProperties(), VtkVisPointSetItem::Initialize(), and VtkVisPointSetItem::SetActiveAttribute().


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