OGS
VtkVisPipeline Class Reference

Detailed Description

VtkVisPipeline manages the VTK visualization. It is a TreeModel and provides functions for adding and removing OGS Model or vtkAlgorithm objects.

Definition at line 55 of file VtkVisPipeline.h.

#include <VtkVisPipeline.h>

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

Public Slots

void addPipelineItem (MeshModel *model, const QModelIndex &idx)
 Adds the given Model to the pipeline.
 
void addPipelineItem (GeoTreeModel *model, const std::string &name, GeoLib::GEOTYPE type)
 
void addPipelineItem (StationTreeModel *model, const std::string &name)
 
QModelIndex addPipelineItem (VtkVisPipelineItem *item, const QModelIndex &parent)
 
QModelIndex addPipelineItem (vtkAlgorithm *source, QModelIndex parent=QModelIndex())
 Inserts the vtkAlgorithm as a child of the given QModelIndex to the pipeline.
 
void removeSourceItem (MeshModel *model, const QModelIndex &idx)
 Removes the given Model (and all attached vtkAlgorithms) from the pipeline.
 
void removeSourceItem (GeoTreeModel *model, const std::string &name, GeoLib::GEOTYPE type)
 
void removeSourceItem (StationTreeModel *model, const std::string &name)
 
void removePipelineItem (QModelIndex index)
 Removes the vtkAlgorithm at the given QModelIndex (and all attached vtkAlgorithms) from the pipeline.
 
void highlightGeoObject (const vtkPolyDataAlgorithm *source, int index)
 Applies a VtkCompositeGeoObjectFilter to add a specific index of the given geometry-source to the pipeline for highlighted display in the render window.
 
void removeHighlightedGeoObject ()
 Removes the currently highlighted geometry-object.
 
void highlightMeshComponent (vtkUnstructuredGridAlgorithm const *const source, unsigned index, bool is_element)
 Applies a VtkCompositeSelectionFilter to add a specific component of the given mesh-source to the pipeline for highlighted display in the render window.
 
void removeHighlightedMeshComponent ()
 Removes the currently highlighted mesh component.
 
- Public Slots inherited from TreeModel
void updateData ()
 

Signals

void vtkVisPipelineChanged () const
 Is emitted when a pipeline item was added or removed.
 
void itemSelected (const QModelIndex &) const
 

Public Member Functions

 VtkVisPipeline (vtkRenderer *renderer, QObject *parent=nullptr)
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 Emits vtkVisPipelineChanged() and calls base class method.
 
void addLight (const GeoLib::Point &pos)
 Adds a light to the scene at the given coordinates.
 
vtkLight * getLight (const GeoLib::Point &pos) const
 Returns a light (or nullptr) for the given coordinates.
 
void removeLight (const GeoLib::Point &pos)
 Removes a light at the given coordinates (if possible).
 
QColor getBGColor () const
 Returns the background-colour of the scene.
 
void setBGColor (const QColor &color)
 Sets the background-colour of the scene.
 
QModelIndex getIndex (vtkProp3D *actor)
 Returns the QModelIndex of VtkVisPipelineItem which actor is the given one.
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
void loadFromFile (QString filename)
 Loads a vtk object from the given file and adds it to the pipeline.
 
void resetCameraOnAddOrRemove (bool reset)
 Defaults to on.
 
void setGlobalSuperelevation (double factor) const
 Sets a global superelevation factor on all source items and resets the factor on other items to 1.
 
void setGlobalBackfaceCulling (bool enable) const
 Enables / disables backface culling on all actors.
 
void showMeshElementQuality (MeshLib::VtkMappedMeshSource *source, MeshLib::MeshQualityType t, std::vector< double > const &quality)
 Checks the quality of mesh elements and adds a filter to highlight deformed elements.
 
- Public Member Functions inherited from TreeModel
 TreeModel (QObject *parent=nullptr)
 
 ~TreeModel () override
 
QVariant data (const QModelIndex &index, int role) const override
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
TreeItemgetItem (const QModelIndex &index) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex parent (const QModelIndex &index) const override
 
bool removeRows (int position, int count, const QModelIndex &parent) override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
TreeItemrootItem () const
 

Private Member Functions

void listArrays (vtkDataSet *dataSet)
 

Private Attributes

vtkRenderer * _renderer
 
QVector< vtkAlgorithm * > _sources
 
std::list< vtkLight * > _lights
 
QMap< vtkProp3D *, QModelIndex > _actorMap
 
bool _resetCameraOnAddOrRemove
 
QModelIndex _highlighted_geo_index
 
QModelIndex _highlighted_mesh_component
 

Additional Inherited Members

- Protected Attributes inherited from TreeModel
TreeItem_rootItem
 

Constructor & Destructor Documentation

◆ VtkVisPipeline()

VtkVisPipeline::VtkVisPipeline ( vtkRenderer * renderer,
QObject * parent = nullptr )
explicit

Definition at line 64 of file VtkVisPipeline.cpp.

65 : TreeModel(parent), _renderer(renderer)
66{
67 QList<QVariant> rootData;
68 rootData << "Object name"
69 << "Visible";
70 delete _rootItem;
71 _rootItem = new TreeItem(rootData, nullptr);
72
73 QSettings settings;
74 QVariant backgroundColorVariant = settings.value("VtkBackgroundColor");
75 if (backgroundColorVariant != QVariant())
76 {
77 this->setBGColor(backgroundColorVariant.value<QColor>());
78 }
79
81 settings.value("resetViewOnLoad", true).toBool();
82}
Objects nodes for the TreeModel.
Definition TreeItem.h:28
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:81
TreeModel(QObject *parent=nullptr)
Definition TreeModel.cpp:26
TreeItem * _rootItem
Definition TreeModel.h:58
void setBGColor(const QColor &color)
Sets the background-colour of the scene.
bool _resetCameraOnAddOrRemove
vtkRenderer * _renderer

References _resetCameraOnAddOrRemove, TreeModel::_rootItem, and setBGColor().

Member Function Documentation

◆ addLight()

void VtkVisPipeline::addLight ( const GeoLib::Point & pos)

Adds a light to the scene at the given coordinates.

Definition at line 92 of file VtkVisPipeline.cpp.

93{
94 double lightPos[3];
95 for (auto& light : _lights)
96 {
97 light->GetPosition(lightPos);
98 if (pos[0] == lightPos[0] && pos[1] == lightPos[1] &&
99 pos[2] == lightPos[2])
100 {
101 return;
102 }
103 }
104 vtkLight* l = vtkLight::New();
105 l->SetPosition(pos[0], pos[1], pos[2]);
106 _renderer->AddLight(l);
107 _lights.push_back(l);
108}
std::list< vtkLight * > _lights

References _lights, and _renderer.

Referenced by VisPrefsDialog::on_lightAboveBox_clicked(), and VisPrefsDialog::on_lightBelowBox_clicked().

◆ addPipelineItem [1/5]

void VtkVisPipeline::addPipelineItem ( GeoTreeModel * model,
const std::string & name,
GeoLib::GEOTYPE type )
slot

Definition at line 286 of file VtkVisPipeline.cpp.

289{
290 addPipelineItem(model->vtkSource(name, type));
291}
vtkPolyDataAlgorithm * vtkSource(const std::string &name, GeoLib::GEOTYPE type) const
Returns the vtk-object indicated by type of the geometry indicated by name.
void addPipelineItem(MeshModel *model, const QModelIndex &idx)
Adds the given Model to the pipeline.

References addPipelineItem(), and GeoTreeModel::vtkSource().

◆ addPipelineItem [2/5]

void VtkVisPipeline::addPipelineItem ( MeshModel * model,
const QModelIndex & idx )
slot

Adds the given Model to the pipeline.

Definition at line 299 of file VtkVisPipeline.cpp.

300{
301 addPipelineItem(static_cast<MeshItem*>(model->getItem(idx))->vtkSource());
302}
A TreeItem containing a mesh and the associated vtk object used in the Mesh Model.
Definition MeshItem.h:30
MeshLib::VtkMappedMeshSource * vtkSource() const
Returns the VTK object.
Definition MeshItem.h:44
TreeItem * getItem(const QModelIndex &index) const

References addPipelineItem(), TreeModel::getItem(), and MeshItem::vtkSource().

Referenced by addPipelineItem(), addPipelineItem(), addPipelineItem(), addPipelineItem(), highlightGeoObject(), highlightMeshComponent(), loadFromFile(), VtkAddFilterDialog::on_buttonBox_accepted(), and showMeshElementQuality().

◆ addPipelineItem [3/5]

void VtkVisPipeline::addPipelineItem ( StationTreeModel * model,
const std::string & name )
slot

Definition at line 293 of file VtkVisPipeline.cpp.

295{
296 addPipelineItem(model->vtkSource(name));
297}
vtkPolyDataAlgorithm * vtkSource(const std::string &name) const

References addPipelineItem(), and StationTreeModel::vtkSource().

◆ addPipelineItem [4/5]

QModelIndex VtkVisPipeline::addPipelineItem ( vtkAlgorithm * source,
QModelIndex parent = QModelIndex() )
slot

Inserts the vtkAlgorithm as a child of the given QModelIndex to the pipeline.

Definition at line 346 of file VtkVisPipeline.cpp.

348{
349 std::string itemName;
350
351 if (!parent.isValid()) // if source object
352 {
353 auto* old_reader = dynamic_cast<vtkGenericDataObjectReader*>(source);
354 auto* new_reader = dynamic_cast<vtkXMLReader*>(source);
355 auto* image_reader = dynamic_cast<vtkImageReader2*>(source);
356 auto* props = dynamic_cast<VtkAlgorithmProperties*>(source);
357 auto* meshSource = dynamic_cast<MeshLib::VtkMappedMeshSource*>(source);
358 if (old_reader)
359 {
360 itemName = old_reader->GetFileName();
361 }
362 else if (new_reader)
363 {
364 itemName = new_reader->GetFileName();
365 }
366 else if (image_reader)
367 {
368 itemName = image_reader->GetFileName();
369 }
370 else if (props)
371 {
372 itemName = props->GetName().toStdString();
373 }
374 else if (meshSource)
375 {
376 itemName = meshSource->GetMesh()->getName();
377 }
378 }
379
380 if (itemName.length() == 0)
381 {
382 itemName = source->GetClassName();
383 }
384
385 QList<QVariant> itemData;
386 itemData << QString::fromStdString(itemName) << true;
387
388 VtkVisPipelineItem* item(nullptr);
389 if (dynamic_cast<vtkImageAlgorithm*>(source))
390 {
391 item = new VtkVisImageItem(source, getItem(parent), itemData);
392 }
393 else
394 {
395 item = new VtkVisPointSetItem(source, getItem(parent), itemData);
396 }
397 return this->addPipelineItem(item, parent);
398}
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:103
const MeshLib::Mesh * GetMesh() const
Returns the mesh.
Contains properties for the visualization of objects as VtkVisPipelineItems.
An item in the VtkVisPipeline containing an image to be visualized.
An item in the VtkVisPipeline containing a graphic object to be visualized.
An item in the VtkVisPipeline containing a point set object to be visualized.

References addPipelineItem(), TreeModel::getItem(), MeshLib::VtkMappedMeshSource::GetMesh(), MeshLib::Mesh::getName(), and TreeModel::parent().

◆ addPipelineItem [5/5]

QModelIndex VtkVisPipeline::addPipelineItem ( VtkVisPipelineItem * item,
const QModelIndex & parent )
slot

Definition at line 304 of file VtkVisPipeline.cpp.

306{
307 beginResetModel();
308
309 item->Initialize(_renderer);
310 TreeItem* parentItem = item->parentItem();
311 parentItem->appendChild(item);
312
313 if (!parent.isValid()) // Set global superelevation on source objects
314 {
315 QSettings settings;
316 if (dynamic_cast<vtkImageAlgorithm*>(item->algorithm()) == nullptr)
317 { // if not an image
318 item->setScale(
319 1.0, 1.0,
320 settings.value("globalSuperelevation", 1.0).toDouble());
321 }
322 }
323
324 int parentChildCount = parentItem->childCount();
325 QModelIndex newIndex = index(parentChildCount - 1, 0, parent);
326
328 {
329 _renderer->ResetCamera(_renderer->ComputeVisiblePropBounds());
330 }
331 _actorMap.insert(item->actor(), newIndex);
332
333 // Do not interpolate images
334 if (dynamic_cast<vtkImageAlgorithm*>(item->algorithm()))
335 {
336 static_cast<vtkImageActor*>(item->actor())->InterpolateOff();
337 }
338
339 endResetModel();
341 emit itemSelected(newIndex);
342
343 return newIndex;
344}
virtual int childCount() const
Definition TreeItem.cpp:65
void appendChild(TreeItem *item)
Definition TreeItem.cpp:42
TreeItem * parentItem() const
Definition TreeItem.cpp:115
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition TreeModel.cpp:50
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...
vtkProp3D * actor() const
Returns the actor as vtkProp3D.
vtkAlgorithm * algorithm() const
Returns the algorithm object.
virtual void Initialize(vtkRenderer *renderer)=0
Initializes vtkMapper and vtkActor necessary for visualization of the item and sets the item's proper...
void itemSelected(const QModelIndex &) const
void vtkVisPipelineChanged() const
Is emitted when a pipeline item was added or removed.
QMap< vtkProp3D *, QModelIndex > _actorMap

References _actorMap, _renderer, _resetCameraOnAddOrRemove, TreeModel::_rootItem, VtkVisPipelineItem::actor(), VtkVisPipelineItem::algorithm(), TreeItem::appendChild(), TreeItem::childCount(), TreeModel::index(), VtkVisPipelineItem::Initialize(), itemSelected(), TreeModel::parent(), TreeItem::parentItem(), VtkVisPipelineItem::setScale(), and vtkVisPipelineChanged().

◆ flags()

Qt::ItemFlags VtkVisPipeline::flags ( const QModelIndex & index) const
override

Definition at line 163 of file VtkVisPipeline.cpp.

164{
165 Qt::ItemFlags defaultFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
166
167 if (!index.isValid())
168 {
169 return Qt::ItemIsEnabled;
170 }
171
172 // if (index.column() == 1)
173 // defaultFlags |= Qt::ItemIsEditable;
174
175 return defaultFlags;
176}

References TreeModel::index().

◆ getBGColor()

QColor VtkVisPipeline::getBGColor ( ) const

Returns the background-colour of the scene.

Definition at line 142 of file VtkVisPipeline.cpp.

143{
144 double* color = _renderer->GetBackground();
145 QColor c(static_cast<int>(color[0] * 255),
146 static_cast<int>(color[1] * 255),
147 static_cast<int>(color[2] * 255));
148 return c;
149}

References _renderer.

Referenced by VisPrefsDialog::VisPrefsDialog().

◆ getIndex()

QModelIndex VtkVisPipeline::getIndex ( vtkProp3D * actor)

Returns the QModelIndex of VtkVisPipelineItem which actor is the given one.

Definition at line 158 of file VtkVisPipeline.cpp.

159{
160 return _actorMap.value(actor, QModelIndex());
161}

References _actorMap.

◆ getLight()

vtkLight * VtkVisPipeline::getLight ( const GeoLib::Point & pos) const

Returns a light (or nullptr) for the given coordinates.

Definition at line 110 of file VtkVisPipeline.cpp.

111{
112 double lightPos[3];
113 for (auto light : _lights)
114 {
115 light->GetPosition(lightPos);
116 if (pos[0] == lightPos[0] && pos[1] == lightPos[1] &&
117 pos[2] == lightPos[2])
118 {
119 return light;
120 }
121 }
122 return nullptr;
123}

References _lights.

Referenced by VisPrefsDialog::VisPrefsDialog().

◆ highlightGeoObject

void VtkVisPipeline::highlightGeoObject ( const vtkPolyDataAlgorithm * source,
int index )
slot

Applies a VtkCompositeGeoObjectFilter to add a specific index of the given geometry-source to the pipeline for highlighted display in the render window.

Definition at line 537 of file VtkVisPipeline.cpp.

539{
541 int nSources = this->_rootItem->childCount();
542 for (int i = 0; i < nSources; i++)
543 {
544 auto* parentItem =
545 static_cast<VtkVisPipelineItem*>(_rootItem->child(i));
546 if (parentItem->algorithm() == source)
547 {
548 QList<QVariant> itemData;
549 itemData << "Selected GeoObject" << true;
550
553 "VtkCompositeGeoObjectFilter",
554 parentItem->transformFilter());
555 static_cast<VtkCompositeGeoObjectFilter*>(filter)->SetIndex(index);
556 VtkVisPointSetItem* item =
557 new VtkVisPointSetItem(filter, parentItem, itemData);
558 QModelIndex parent_index =
559 static_cast<TreeModel*>(this)->index(i, 0, QModelIndex());
560 _highlighted_geo_index = this->addPipelineItem(item, parent_index);
561 break;
562 }
563 }
564}
TreeItem * child(int row) const
Definition TreeItem.cpp:52
A hierarchical model for a tree implemented as a double-linked list.
Definition TreeModel.h:30
Is used to combine several filter in one VtkVisPipelineItem. You can use vtk filter and custom filter...
Highlights a single GeoObject.
static VtkCompositeFilter * CreateCompositeFilter(QString type, vtkAlgorithm *inputAlgorithm)
Creates a composite filter by name.
void removeHighlightedGeoObject()
Removes the currently highlighted geometry-object.
QModelIndex _highlighted_geo_index
constexpr List filter(Pred, SomeListOfTypes<> *)
Definition TMP.h:49

References _highlighted_geo_index, TreeModel::_rootItem, addPipelineItem(), TreeItem::child(), TreeItem::childCount(), VtkFilterFactory::CreateCompositeFilter(), TreeModel::index(), and removeHighlightedGeoObject().

◆ highlightMeshComponent

void VtkVisPipeline::highlightMeshComponent ( vtkUnstructuredGridAlgorithm const *const source,
unsigned index,
bool is_element )
slot

Applies a VtkCompositeSelectionFilter to add a specific component of the given mesh-source to the pipeline for highlighted display in the render window.

Definition at line 575 of file VtkVisPipeline.cpp.

578{
579 int nSources = this->_rootItem->childCount();
580 for (int i = 0; i < nSources; i++)
581 {
582 auto* parentItem =
583 static_cast<VtkVisPipelineItem*>(_rootItem->child(i));
584 if (parentItem->algorithm() == source)
585 {
586 QList<QVariant> itemData;
587 itemData << "Selected Mesh Component" << true;
588 QList<QVariant> selected_index;
589 selected_index << index << index;
590
591 VtkCompositeFilter* filter(nullptr);
592 if (is_element)
593 {
595 "VtkCompositeElementSelectionFilter",
596 parentItem->transformFilter());
598 ->setSelectionArray("vtkIdFilter_Ids");
600 ->SetUserVectorProperty("Threshold Between",
601 selected_index);
602 }
603 else
604 {
606 "VtkCompositeNodeSelectionFilter",
607 parentItem->transformFilter());
608 std::vector<unsigned> indices(1);
609 indices[0] = index;
611 ->setSelectionArray(indices);
612 }
613 VtkVisPointSetItem* item =
614 new VtkVisPointSetItem(filter, parentItem, itemData);
615 QModelIndex parent_index =
616 static_cast<TreeModel*>(this)->index(i, 0, QModelIndex());
618 this->addPipelineItem(item, parent_index);
619 break;
620 }
621 }
622}
This filter selects/thresholds elements based on the selected array.
This filter displays the points/nodes given in the index field as spheres.
QModelIndex _highlighted_mesh_component

References _highlighted_mesh_component, TreeModel::_rootItem, addPipelineItem(), TreeItem::child(), TreeItem::childCount(), VtkFilterFactory::CreateCompositeFilter(), and TreeModel::index().

◆ itemSelected

void VtkVisPipeline::itemSelected ( const QModelIndex & ) const
signal

Referenced by addPipelineItem().

◆ listArrays()

void VtkVisPipeline::listArrays ( vtkDataSet * dataSet)
private

Definition at line 476 of file VtkVisPipeline.cpp.

477{
478 if (dataSet)
479 {
480 vtkPointData* pointData = dataSet->GetPointData();
481 INFO(" #point data arrays: {:d}", pointData->GetNumberOfArrays());
482 for (int i = 0; i < pointData->GetNumberOfArrays(); i++)
483 INFO(" Name: {:s}", pointData->GetArrayName(i));
484
485 vtkCellData* cellData = dataSet->GetCellData();
486 INFO(" #cell data arrays: {:d}", cellData->GetNumberOfArrays());
487 for (int i = 0; i < cellData->GetNumberOfArrays(); i++)
488 INFO(" Name: {:s}", cellData->GetArrayName(i));
489 }
490 else
491 ERR("VtkVisPipeline::listArrays(): not a valid vtkDataSet.");
492}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45

References ERR(), and INFO().

Referenced by loadFromFile().

◆ loadFromFile()

void VtkVisPipeline::loadFromFile ( QString filename)

Loads a vtk object from the given file and adds it to the pipeline.

Definition at line 178 of file VtkVisPipeline.cpp.

179{
180#ifndef NDEBUG
181 QElapsedTimer myTimer;
182 myTimer.start();
183 INFO("VTK Read: {:s}.", filename.toStdString());
184#endif
185
186 if (filename.size() > 0)
187 {
188 vtkSmartPointer<vtkXMLDataReader> reader;
189 if (filename.endsWith("vti"))
190 {
191 reader = vtkSmartPointer<vtkXMLImageDataReader>::New();
192 }
193 else if (filename.endsWith("vtr"))
194 {
195 reader = vtkSmartPointer<vtkXMLRectilinearGridReader>::New();
196 }
197 else if (filename.endsWith("vts"))
198 {
199 reader = vtkSmartPointer<vtkXMLStructuredGridReader>::New();
200 }
201 else if (filename.endsWith("vtp"))
202 {
203 reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
204 }
205 else if (filename.endsWith("vtu"))
206 {
207 reader = vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
208 }
209 else if (filename.endsWith("vtk"))
210 {
211 vtkGenericDataObjectReader* oldStyleReader =
212 vtkGenericDataObjectReader::New();
213 oldStyleReader->SetFileName(filename.toStdString().c_str());
214 oldStyleReader->ReadAllFieldsOn();
215 oldStyleReader->ReadAllScalarsOn();
216 oldStyleReader->Update();
217 vtkDataSet* dataSet =
218 vtkDataSet::SafeDownCast(oldStyleReader->GetOutput());
219 if (dataSet)
220 {
221 this->listArrays(dataSet);
222 addPipelineItem(oldStyleReader);
223 }
224 else
225 ERR("VtkVisPipeline::loadFromFile(): not a valid vtkDataSet.");
226 return;
227 }
228 else
229 {
230 return;
231 }
232
233 reader->SetFileName(filename.toStdString().c_str());
234 // TODO: insert ReadAllScalarsOn()-equivalent for xml-file-reader here,
235 // otherwise arrays are not available in GUI!
236 reader->Update();
237 // std::cout << "#cell scalars: " << reader->GetNumberOfCellArrays() <<
238 // std::endl; std::cout << "#point scalars: " <<
239 // reader->GetNumberOfPointArrays() << std::endl;
240
241 vtkSmartPointer<vtkDataSet> dataSet = reader->GetOutputAsDataSet();
242 if (dataSet)
243 {
244 this->listArrays(dataSet);
245 addPipelineItem(reader);
246 }
247 else
248 ERR("VtkVisPipeline::loadFromFile(): not a valid vtkDataSet.");
249 }
250
251#ifndef NDEBUG
252 INFO("{:d} ms", myTimer.elapsed());
253#endif
254}
void listArrays(vtkDataSet *dataSet)

References addPipelineItem(), ERR(), INFO(), and listArrays().

◆ removeHighlightedGeoObject

void VtkVisPipeline::removeHighlightedGeoObject ( )
slot

Removes the currently highlighted geometry-object.

Definition at line 566 of file VtkVisPipeline.cpp.

567{
568 if (_highlighted_geo_index != QModelIndex())
569 {
571 _highlighted_geo_index = QModelIndex();
572 }
573}
void removePipelineItem(QModelIndex index)
Removes the vtkAlgorithm at the given QModelIndex (and all attached vtkAlgorithms) from the pipeline.

References _highlighted_geo_index, and removePipelineItem().

Referenced by highlightGeoObject().

◆ removeHighlightedMeshComponent

void VtkVisPipeline::removeHighlightedMeshComponent ( )
slot

Removes the currently highlighted mesh component.

Definition at line 624 of file VtkVisPipeline.cpp.

625{
626 if (_highlighted_mesh_component != QModelIndex())
627 {
629 _highlighted_mesh_component = QModelIndex();
630 }
631}

References _highlighted_mesh_component, and removePipelineItem().

◆ removeLight()

void VtkVisPipeline::removeLight ( const GeoLib::Point & pos)

Removes a light at the given coordinates (if possible).

Definition at line 125 of file VtkVisPipeline.cpp.

126{
127 double lightPos[3];
128 for (auto it = _lights.begin(); it != _lights.end(); ++it)
129 {
130 (*it)->GetPosition(lightPos);
131 if (pos[0] == lightPos[0] && pos[1] == lightPos[1] &&
132 pos[2] == lightPos[2])
133 {
134 _renderer->RemoveLight(*it);
135 (*it)->Delete();
136 _lights.erase(it);
137 return;
138 }
139 }
140}

References _lights, and _renderer.

Referenced by VisPrefsDialog::on_lightAboveBox_clicked(), and VisPrefsDialog::on_lightBelowBox_clicked().

◆ removePipelineItem

void VtkVisPipeline::removePipelineItem ( QModelIndex index)
slot

Removes the vtkAlgorithm at the given QModelIndex (and all attached vtkAlgorithms) from the pipeline.

Definition at line 447 of file VtkVisPipeline.cpp.

448{
449 if (!index.isValid())
450 {
451 return;
452 }
453
454 QMap<vtkProp3D*, QModelIndex>::iterator it = _actorMap.begin();
455 while (it != _actorMap.end())
456 {
457 QModelIndex itIndex = it.value();
458 if (itIndex == index)
459 {
460 _actorMap.erase(it);
461 break;
462 }
463 ++it;
464 }
465
466 // TreeItem* item = getItem(index);
467 removeRows(index.row(), 1, index.parent());
468
470 {
471 _renderer->ResetCamera(_renderer->ComputeVisiblePropBounds());
472 }
474}
bool removeRows(int position, int count, const QModelIndex &parent) override

References _actorMap, _renderer, _resetCameraOnAddOrRemove, TreeModel::index(), TreeModel::removeRows(), and vtkVisPipelineChanged().

Referenced by removeHighlightedGeoObject(), removeHighlightedMeshComponent(), removeSourceItem(), removeSourceItem(), and removeSourceItem().

◆ removeSourceItem [1/3]

void VtkVisPipeline::removeSourceItem ( GeoTreeModel * model,
const std::string & name,
GeoLib::GEOTYPE type )
slot

Definition at line 400 of file VtkVisPipeline.cpp.

403{
404 for (int i = 0; i < _rootItem->childCount(); i++)
405 {
406 VtkVisPipelineItem* item =
407 static_cast<VtkVisPipelineItem*>(getItem(index(i, 0)));
408 if (item->algorithm() == model->vtkSource(name, type))
409 {
411 return;
412 }
413 }
414}

References TreeModel::_rootItem, VtkVisPipelineItem::algorithm(), TreeItem::childCount(), TreeModel::getItem(), TreeModel::index(), removePipelineItem(), and GeoTreeModel::vtkSource().

◆ removeSourceItem [2/3]

void VtkVisPipeline::removeSourceItem ( MeshModel * model,
const QModelIndex & idx )
slot

Removes the given Model (and all attached vtkAlgorithms) from the pipeline.

Definition at line 431 of file VtkVisPipeline.cpp.

432{
433 auto* sItem = static_cast<MeshItem*>(model->getItem(idx));
434
435 for (int i = 0; i < _rootItem->childCount(); i++)
436 {
437 VtkVisPipelineItem* item =
438 static_cast<VtkVisPipelineItem*>(getItem(index(i, 0)));
439 if (item->algorithm() == sItem->vtkSource())
440 {
442 return;
443 }
444 }
445}

References TreeModel::_rootItem, VtkVisPipelineItem::algorithm(), TreeItem::childCount(), TreeModel::getItem(), TreeModel::index(), and removePipelineItem().

◆ removeSourceItem [3/3]

void VtkVisPipeline::removeSourceItem ( StationTreeModel * model,
const std::string & name )
slot

Definition at line 416 of file VtkVisPipeline.cpp.

418{
419 for (int i = 0; i < _rootItem->childCount(); i++)
420 {
421 VtkVisPipelineItem* item =
422 static_cast<VtkVisPipelineItem*>(getItem(index(i, 0)));
423 if (item->algorithm() == model->vtkSource(name))
424 {
426 return;
427 }
428 }
429}

References TreeModel::_rootItem, VtkVisPipelineItem::algorithm(), TreeItem::childCount(), TreeModel::getItem(), TreeModel::index(), removePipelineItem(), and StationTreeModel::vtkSource().

◆ resetCameraOnAddOrRemove()

void VtkVisPipeline::resetCameraOnAddOrRemove ( bool reset)
inline

Defaults to on.

Definition at line 91 of file VtkVisPipeline.h.

References _resetCameraOnAddOrRemove.

Referenced by VisPrefsDialog::on_loadShowAllCheckBox_stateChanged().

◆ setBGColor()

void VtkVisPipeline::setBGColor ( const QColor & color)

Sets the background-colour of the scene.

Definition at line 151 of file VtkVisPipeline.cpp.

152{
153 QSettings settings;
154 settings.setValue("VtkBackgroundColor", color);
155 _renderer->SetBackground(color.redF(), color.greenF(), color.blueF());
156}

References _renderer.

Referenced by VtkVisPipeline(), and VisPrefsDialog::on_bgColorButton_colorPicked().

◆ setData()

bool VtkVisPipeline::setData ( const QModelIndex & index,
const QVariant & value,
int role = Qt::EditRole )
override

Emits vtkVisPipelineChanged() and calls base class method.

Definition at line 84 of file VtkVisPipeline.cpp.

86{
88
89 return TreeModel::setData(index, value, role);
90}
bool setData(const QModelIndex &index, const QVariant &value, int role) override

References TreeModel::index(), TreeModel::setData(), and vtkVisPipelineChanged().

◆ setGlobalBackfaceCulling()

void VtkVisPipeline::setGlobalBackfaceCulling ( bool enable) const

Enables / disables backface culling on all actors.

Definition at line 271 of file VtkVisPipeline.cpp.

272{
273 // iterate over all source items
274 for (int i = 0; i < _rootItem->childCount(); ++i)
275 {
276 auto* item = static_cast<VtkVisPipelineItem*>(_rootItem->child(i));
277 item->setBackfaceCulling(enable);
278
279 // recursively set on all child items
280 item->setBackfaceCullingOnChildren(enable);
281 }
282
284}
virtual void setBackfaceCulling(bool enable) const
Enables / disables backface culling.

References TreeModel::_rootItem, TreeItem::child(), TreeItem::childCount(), VtkVisPipelineItem::setBackfaceCulling(), and vtkVisPipelineChanged().

Referenced by VisPrefsDialog::on_cullBackfacesCheckBox_stateChanged().

◆ setGlobalSuperelevation()

void VtkVisPipeline::setGlobalSuperelevation ( double factor) const

Sets a global superelevation factor on all source items and resets the factor on other items to 1.

Definition at line 256 of file VtkVisPipeline.cpp.

257{
258 // iterate over all source items
259 for (int i = 0; i < _rootItem->childCount(); ++i)
260 {
261 auto* item = static_cast<VtkVisPipelineItem*>(_rootItem->child(i));
262 item->setScale(1.0, 1.0, factor);
263
264 // recursively set on all child items
265 item->setScaleOnChildren(1.0, 1.0, 1.0);
266 }
267
269}

References TreeModel::_rootItem, TreeItem::child(), TreeItem::childCount(), VtkVisPipelineItem::setScale(), and vtkVisPipelineChanged().

Referenced by VisPrefsDialog::on_superelevationPushButton_pressed().

◆ showMeshElementQuality()

void VtkVisPipeline::showMeshElementQuality ( MeshLib::VtkMappedMeshSource * source,
MeshLib::MeshQualityType t,
std::vector< double > const & quality )

Checks the quality of mesh elements and adds a filter to highlight deformed elements.

Definition at line 494 of file VtkVisPipeline.cpp.

497{
498 if (!source || quality.empty())
499 {
500 return;
501 }
502
503 int const nSources = this->_rootItem->childCount();
504 for (int i = 0; i < nSources; i++)
505 {
506 auto* parentItem =
507 static_cast<VtkVisPipelineItem*>(_rootItem->child(i));
508 if (parentItem->algorithm() != source)
509 {
510 continue;
511 }
512
513 QList<QVariant> itemData;
514 itemData << "MeshQuality: " +
515 QString::fromStdString(MeshQualityType2String(t))
516 << true;
517
519 "VtkCompositeElementSelectionFilter",
520 parentItem->transformFilter());
522 {
523 auto const range(
524 std::minmax_element(quality.cbegin(), quality.cend()));
525 static_cast<VtkCompositeElementSelectionFilter*>(filter)->setRange(
526 *range.first, *range.second);
527 }
529 ->setSelectionArray("Selection", quality);
530 VtkVisPointSetItem* item =
531 new VtkVisPointSetItem(filter, parentItem, itemData);
532 this->addPipelineItem(item, this->createIndex(i, 0, item));
533 break;
534 }
535}
std::string MeshQualityType2String(const MeshQualityType t)

References TreeModel::_rootItem, addPipelineItem(), TreeItem::child(), TreeItem::childCount(), VtkFilterFactory::CreateCompositeFilter(), and MeshLib::ELEMENTSIZE.

◆ vtkVisPipelineChanged

void VtkVisPipeline::vtkVisPipelineChanged ( ) const
signal

Is emitted when a pipeline item was added or removed.

Referenced by addPipelineItem(), removePipelineItem(), setData(), setGlobalBackfaceCulling(), and setGlobalSuperelevation().

Member Data Documentation

◆ _actorMap

QMap<vtkProp3D*, QModelIndex> VtkVisPipeline::_actorMap
private

Definition at line 143 of file VtkVisPipeline.h.

Referenced by addPipelineItem(), getIndex(), and removePipelineItem().

◆ _highlighted_geo_index

QModelIndex VtkVisPipeline::_highlighted_geo_index
private

Definition at line 146 of file VtkVisPipeline.h.

Referenced by highlightGeoObject(), and removeHighlightedGeoObject().

◆ _highlighted_mesh_component

QModelIndex VtkVisPipeline::_highlighted_mesh_component
private

Definition at line 147 of file VtkVisPipeline.h.

Referenced by highlightMeshComponent(), and removeHighlightedMeshComponent().

◆ _lights

std::list<vtkLight*> VtkVisPipeline::_lights
private

Definition at line 142 of file VtkVisPipeline.h.

Referenced by addLight(), getLight(), and removeLight().

◆ _renderer

vtkRenderer* VtkVisPipeline::_renderer
private

◆ _resetCameraOnAddOrRemove

bool VtkVisPipeline::_resetCameraOnAddOrRemove
private

◆ _sources

QVector<vtkAlgorithm*> VtkVisPipeline::_sources
private

Definition at line 141 of file VtkVisPipeline.h.


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