OGS
VtkVisPipeline.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <QMap>
18#include <QVector>
19
21#include "GeoLib/GeoType.h"
22#include "GeoLib/Point.h"
23#include "MeshLib/MeshEnums.h"
24#include "Base/TreeModel.h"
25
26class vtkAlgorithm;
27class vtkDataSet;
28class vtkLight;
29class vtkPointSet;
30class vtkPolyDataAlgorithm;
31class vtkProp3D;
32class vtkRenderer;
33class vtkUnstructuredGridAlgorithm;
34
35class QModelIndex;
36class QString;
37
38class GeoTreeModel;
39class ProcessModel;
40class MeshModel;
42class TreeModel;
44
45namespace MeshLib
46{
47 class VtkMappedMeshSource;
48}
49
56{
57 Q_OBJECT
58
59public:
60 explicit VtkVisPipeline(vtkRenderer* renderer, QObject* parent = nullptr);
61
63 bool setData(const QModelIndex& index, const QVariant& value,
64 int role = Qt::EditRole) override;
65
67 void addLight(const GeoLib::Point &pos);
68
70 vtkLight* getLight(const GeoLib::Point &pos) const;
71
73 void removeLight(const GeoLib::Point &pos);
74
76 QColor getBGColor() const;
77
79 void setBGColor(const QColor &color);
80
83 QModelIndex getIndex(vtkProp3D* actor);
84
85 Qt::ItemFlags flags(const QModelIndex& index) const override;
86
88 void loadFromFile(QString filename);
89
92
95 void setGlobalSuperelevation(double factor) const;
96
98 void setGlobalBackfaceCulling(bool enable) const;
99
103 std::vector<double> const& quality);
104
105public slots:
107 void addPipelineItem(MeshModel* model, const QModelIndex &idx);
108 void addPipelineItem(GeoTreeModel* model, const std::string &name, GeoLib::GEOTYPE type);
109 void addPipelineItem(StationTreeModel* model, const std::string &name);
110 QModelIndex addPipelineItem(VtkVisPipelineItem* item, const QModelIndex &parent);
111
113 QModelIndex addPipelineItem(vtkAlgorithm* source, QModelIndex parent = QModelIndex());
114
116 void removeSourceItem(MeshModel* model, const QModelIndex &idx);
117 void removeSourceItem(GeoTreeModel* model, const std::string &name, GeoLib::GEOTYPE type);
118 void removeSourceItem(StationTreeModel* model, const std::string &name);
119
122 void removePipelineItem(QModelIndex index);
123
125 void highlightGeoObject(const vtkPolyDataAlgorithm* source, int index);
126
129
131 void highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const source, unsigned index, bool is_element);
132
135
136
137private:
138 void listArrays(vtkDataSet* dataSet);
139
140 vtkRenderer* _renderer;
141 QVector<vtkAlgorithm*> _sources;
142 std::list<vtkLight*> _lights;
143 QMap<vtkProp3D*, QModelIndex> _actorMap;
145
148
149signals:
152 void itemSelected(const QModelIndex&) const;
153};
Definition of the Color class.
Definition of the Point class.
Definition of the GEOTYPE enumeration.
Definition of mesh-related Enumerations.
Definition of the TreeModel class.
A model for the GeoTreeView implementing a tree as a double-linked list.
A model implementing a tree structure for process-relevant information such as process types,...
A model for the StationTreeView implementing a tree as a double-linked list.
A hierarchical model for a tree implemented as a double-linked list.
Definition TreeModel.h:30
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition TreeModel.cpp:50
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:81
An item in the VtkVisPipeline containing a graphic object to be visualized.
VtkVisPipeline manages the VTK visualization. It is a TreeModel and provides functions for adding and...
void setGlobalBackfaceCulling(bool enable) const
Enables / disables backface culling on all actors.
QModelIndex _highlighted_mesh_component
void itemSelected(const QModelIndex &) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Emits vtkVisPipelineChanged() and calls base class method.
std::list< vtkLight * > _lights
void addLight(const GeoLib::Point &pos)
Adds a light to the scene at the given coordinates.
void resetCameraOnAddOrRemove(bool reset)
Defaults to on.
void removeLight(const GeoLib::Point &pos)
Removes a light at the given coordinates (if possible).
void vtkVisPipelineChanged() const
Is emitted when a pipeline item was added or removed.
void addPipelineItem(MeshModel *model, const QModelIndex &idx)
Adds the given Model to the pipeline.
void removePipelineItem(QModelIndex index)
Removes the vtkAlgorithm at the given QModelIndex (and all attached vtkAlgorithms) from the pipeline.
VtkVisPipeline(vtkRenderer *renderer, QObject *parent=nullptr)
void removeHighlightedGeoObject()
Removes the currently highlighted geometry-object.
void setBGColor(const QColor &color)
Sets the background-colour of the scene.
void setGlobalSuperelevation(double factor) const
Sets a global superelevation factor on all source items and resets the factor on other items to 1.
void removeHighlightedMeshComponent()
Removes the currently highlighted mesh component.
Qt::ItemFlags flags(const QModelIndex &index) const override
vtkLight * getLight(const GeoLib::Point &pos) const
Returns a light (or nullptr) for the given coordinates.
void loadFromFile(QString filename)
Loads a vtk object from the given file and adds it to the pipeline.
QVector< vtkAlgorithm * > _sources
void highlightGeoObject(const vtkPolyDataAlgorithm *source, int index)
Applies a VtkCompositeGeoObjectFilter to add a specific index of the given geometry-source to the pip...
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 pip...
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.
void removeSourceItem(MeshModel *model, const QModelIndex &idx)
Removes the given Model (and all attached vtkAlgorithms) from the pipeline.
QModelIndex getIndex(vtkProp3D *actor)
Returns the QModelIndex of VtkVisPipelineItem which actor is the given one.
bool _resetCameraOnAddOrRemove
QMap< vtkProp3D *, QModelIndex > _actorMap
QModelIndex _highlighted_geo_index
QColor getBGColor() const
Returns the background-colour of the scene.
void listArrays(vtkDataSet *dataSet)
vtkRenderer * _renderer
GEOTYPE
Definition GeoType.h:23
MeshQualityType
Describes a mesh quality metric.
Definition MeshEnums.h:70