OGS
VtkVisPipeline.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <QMap>
7#include <QVector>
8
10#include "GeoLib/GeoType.h"
11#include "GeoLib/Point.h"
12#include "MeshLib/MeshEnums.h"
13#include "Base/TreeModel.h"
14
15class vtkAlgorithm;
16class vtkDataSet;
17class vtkLight;
18class vtkPointSet;
19class vtkPolyDataAlgorithm;
20class vtkProp3D;
21class vtkRenderer;
22class vtkUnstructuredGridAlgorithm;
23
24class QModelIndex;
25class QString;
26
27class GeoTreeModel;
28class ProcessModel;
29class MeshModel;
31class TreeModel;
33
34namespace MeshLib
35{
37}
38
45{
46 Q_OBJECT
47
48public:
49 explicit VtkVisPipeline(vtkRenderer* renderer, QObject* parent = nullptr);
50
52 bool setData(const QModelIndex& index, const QVariant& value,
53 int role = Qt::EditRole) override;
54
56 void addLight(const GeoLib::Point &pos);
57
59 vtkLight* getLight(const GeoLib::Point &pos) const;
60
62 void removeLight(const GeoLib::Point &pos);
63
65 QColor getBGColor() const;
66
68 void setBGColor(const QColor &color);
69
72 QModelIndex getIndex(vtkProp3D* actor);
73
74 Qt::ItemFlags flags(const QModelIndex& index) const override;
75
77 void loadFromFile(QString filename);
78
81
84 void setGlobalSuperelevation(double factor) const;
85
87 void setGlobalBackfaceCulling(bool enable) const;
88
92 std::vector<double> const& quality);
93
94public slots:
96 void addPipelineItem(MeshModel* model, const QModelIndex &idx);
97 void addPipelineItem(GeoTreeModel* model, const std::string &name, GeoLib::GEOTYPE type);
98 void addPipelineItem(StationTreeModel* model, const std::string &name);
99 QModelIndex addPipelineItem(VtkVisPipelineItem* item, const QModelIndex &parent);
100
102 QModelIndex addPipelineItem(vtkAlgorithm* source, QModelIndex parent = QModelIndex());
103
105 void removeSourceItem(MeshModel* model, const QModelIndex &idx);
106 void removeSourceItem(GeoTreeModel* model, const std::string &name, GeoLib::GEOTYPE type);
107 void removeSourceItem(StationTreeModel* model, const std::string &name);
108
111 void removePipelineItem(QModelIndex index);
112
114 void highlightGeoObject(const vtkPolyDataAlgorithm* source, int index);
115
118
120 void highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const source, unsigned index, bool is_element);
121
124
125
126private:
127 void listArrays(vtkDataSet* dataSet);
128
129 vtkRenderer* _renderer;
130 QVector<vtkAlgorithm*> _sources;
131 std::list<vtkLight*> _lights;
132 QMap<vtkProp3D*, QModelIndex> _actorMap;
134
137
138signals:
141 void itemSelected(const QModelIndex&) const;
142};
A model for the GeoTreeView implementing a tree as a double-linked list.
VtkMappedMeshSource is a source class to transform OGS meshes into complete vtkUnstructuredGrids....
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:19
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition TreeModel.cpp:39
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:70
TreeModel(QObject *parent=nullptr)
Definition TreeModel.cpp:15
An item in the VtkVisPipeline containing a graphic object to be visualized.
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:12
MeshQualityType
Describes a mesh quality metric.
Definition MeshEnums.h:80