18#include <vtkDataSetMapper.h>
21#include <QAbstractItemModel>
22#include <QContextMenuEvent>
40#include <vtkDataObject.h>
41#include <vtkGenericDataObjectReader.h>
42#include <vtkImageData.h>
43#include <vtkSmartPointer.h>
44#include <vtkTransformFilter.h>
45#include <vtkUnstructuredGrid.h>
46#include <vtkUnstructuredGridAlgorithm.h>
47#include <vtkXMLUnstructuredGridReader.h>
55 this->setItemsExpandable(
false);
57 this->setItemDelegateForColumn(1, checkboxDelegate);
58 this->header()->setStretchLastSection(
true);
59 this->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
64 QTreeView::setModel(model);
68 this->header()->moveSection(1, 0);
73 QModelIndex index = selectionModel()->currentIndex();
79 ->
getItem(this->selectionModel()->currentIndex()));
81 item->
algorithm()->GetOutputDataObject(0)->GetDataObjectType();
84 !(this->selectionModel()->currentIndex().parent().isValid());
87 QAction* addFilterAction = menu.addAction(
"Add filter...");
89 if (objectType == VTK_IMAGE_DATA)
94 QAction* saveRasterAction = menu.addAction(
"Save Raster...");
95 connect(saveRasterAction, SIGNAL(triggered()),
this,
97 QAction* addMeshingAction =
98 menu.addAction(
"Convert Raster to Mesh...");
99 connect(addMeshingAction, SIGNAL(triggered()),
this,
104 QAction* addLUTAction = menu.addAction(
"Add color table...");
105 connect(addLUTAction, SIGNAL(triggered()),
this,
109 if (objectType == VTK_UNSTRUCTURED_GRID)
111 QAction* addConvertToMeshAction =
112 menu.addAction(
"Convert to Mesh...");
113 connect(addConvertToMeshAction, SIGNAL(triggered()),
this,
117 QAction* exportVtkAction = menu.addAction(
"Export as VTK");
122 QAction* removeAction = menu.addAction(
"Remove");
123 connect(removeAction, SIGNAL(triggered()),
this,
127 connect(addFilterAction, SIGNAL(triggered()),
this,
129 connect(exportVtkAction, SIGNAL(triggered()),
this,
132 menu.exec(event->globalPos());
139 QModelIndex idx = this->selectionModel()->currentIndex();
140 QString filename = QFileDialog::getSaveFileName(
141 this,
"Export object to vtk-file",
142 settings.value(
"lastExportedFileDirectory").toString(),
144 if (!filename.isEmpty())
149 QDir dir = QDir(filename);
150 settings.setValue(
"lastExportedFileDirectory", dir.absolutePath());
167 if (dlg.exec() != QDialog::Accepted)
172 vtkSmartPointer<vtkAlgorithm> algorithm =
175 ->
getItem(this->selectionModel()->currentIndex()))
178 vtkSmartPointer<VtkGeoImageSource> imageSource =
179 VtkGeoImageSource::SafeDownCast(algorithm);
204 QModelIndex
const index = this->selectionModel()->currentIndex();
214 ->
getItem(this->selectionModel()->currentIndex()));
215 vtkSmartPointer<vtkAlgorithm> algorithm = item->
algorithm();
217 vtkUnstructuredGrid* grid(
nullptr);
218 vtkUnstructuredGridAlgorithm* ugAlg =
219 vtkUnstructuredGridAlgorithm::SafeDownCast(algorithm);
222 grid = ugAlg->GetOutput();
227 vtkGenericDataObjectReader* dataReader =
228 vtkGenericDataObjectReader::SafeDownCast(algorithm);
231 grid = vtkUnstructuredGrid::SafeDownCast(dataReader->GetOutput());
236 vtkXMLUnstructuredGridReader* xmlReader =
237 vtkXMLUnstructuredGridReader::SafeDownCast(algorithm);
238 grid = vtkUnstructuredGrid::SafeDownCast(xmlReader->GetOutput());
243 mesh->
setName(item->
data(0).toString().toStdString());
248 const QItemSelection& deselected)
250 QTreeView::selectionChanged(selected, deselected);
252 if (selected.empty())
257 QModelIndex index = *selected.indexes().begin();
263 if (item->transformFilter())
266 item->transformFilter()->GetOutputDataObject(0)));
285 if (!index.isValid())
290 QItemSelectionModel* selectionModel = this->selectionModel();
291 selectionModel->clearSelection();
292 selectionModel->select(index, QItemSelectionModel::Select);
299 ->getItem(this->selectionModel()->currentIndex())));
303 QString filename = QFileDialog::getOpenFileName(
304 this,
"Select color table",
305 settings.value(
"lastOpenedLutFileDirectory").toString(),
306 "Color table files (*.xml);;");
307 QFileInfo fi(filename);
309 if (fi.suffix().toLower() ==
"xml")
324 QMessageBox::warning(
nullptr,
325 "Color lookup table could not be applied.",
326 "Color lookup tables can only be applied to "
327 "VtkVisPointSetItem.");
329 QDir dir = QDir(filename);
330 settings.setValue(
"lastOpenedLutFileDirectory", dir.absolutePath());
Definition of the CheckboxDelegate class.
Definition of the MeshFromRasterDialog class.
Definition of the Mesh class.
Definition of the OGSError class.
Definition of the VtkGeoImageSource class.
Definition of the VtkMeshConverter class.
Definition of the VtkVisImageItem class.
Definition of the VtkVisPipelineItem class.
Definition of the VtkVisPipelineView class.
Definition of the VtkVisPipeline class.
Definition of the VtkVisPointSetItem class.
CheckboxDelegate modifies a model view to display boolean values as checkboxes.
A dialog for specifying the parameters to construct a mesh based on a raster.
std::string getMeshName() const
MeshLib::MeshElemType getElementSelection() const
std::string getArrayName() const
MeshLib::UseIntensityAs getIntensitySelection() const
void setName(const std::string &name)
Changes the name of the mesh.
static MeshLib::Mesh * convertUnstructuredGrid(vtkUnstructuredGrid *grid, bool const compute_element_neighbors=false, std::string const &mesh_name="vtkUnstructuredGrid")
Converts a vtkUnstructuredGrid object to a Mesh.
static void box(const QString &e)
TreeItem * getItem(const QModelIndex &index) const
Contains properties for the visualization of objects as VtkVisPipelineItems.
void SetLookUpTable(const QString &array_name, vtkLookupTable *lut)
Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
bool IsRemovable() const
Is this algorithm removable from the pipeline (view).
static std::optional< GeoLib::Raster > convertToRaster(VtkGeoImageSource *const source)
An item in the VtkVisPipeline containing an image to be visualized.
bool writeAsRaster()
Allows writing this item's source object as an ASCII raster file.
An item in the VtkVisPipeline containing a graphic object to be visualized.
vtkAlgorithm * algorithm() const
Returns the algorithm object.
VtkAlgorithmProperties * getVtkProperties() const
Returns the VtkAlgorithmProperties.
virtual QString GetActiveAttribute() const
int writeToFile(const std::string &filename) const
Writes this algorithm's vtkDataSet (i.e. vtkPolyData or vtkUnstructuredGrid) to a vtk-file.
QVariant data(int column) const override
virtual void SetActiveAttribute(const QString &str)
void setModel(QAbstractItemModel *model) override
Overridden to set model specific header properties.
VtkVisPipelineView(QWidget *parent=nullptr)
Constructor.
void requestRemovePipelineItem(QModelIndex)
void meshAdded(MeshLib::Mesh *)
void dataObjectSelected(vtkDataObject *)
void requestAddPipelineFilterItem(QModelIndex)
void exportSelectedPipelineItemAsVtk()
Exports the currently selected item as a VTK file.
void convertVTKToOGSMesh()
Calls the conversion method for making a vtk grid an ogs mesh.
void actorSelected(vtkProp3D *)
void selectItem(vtkProp3D *actor)
void addColorTable()
Adds a color lookup table to the current scalar array of the selected pipeline item.
void itemSelected(VtkVisPipelineItem *)
void contextMenuEvent(QContextMenuEvent *event) override
Creates a menu on right-clicking on an item.
void showImageToMeshConversionDialog()
Calls the dialog to.
void writeRaster()
Calls the conversion method for saving this as an *.asc-file.
void addPipelineFilterItem()
Sends a requestAddPipelineFilterItem() signal to add a filter.
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
Emits itemSelected() signals when an items was selected.
void removeSelectedPipelineItem()
VtkVisPipeline manages the VTK visualization. It is a TreeModel and provides functions for adding and...
An item in the VtkVisPipeline containing a point set object to be visualized.