7#include <vtkDataSetMapper.h>
10#include <QAbstractItemModel>
11#include <QContextMenuEvent>
29#include <vtkDataObject.h>
30#include <vtkGenericDataObjectReader.h>
31#include <vtkImageData.h>
32#include <vtkSmartPointer.h>
33#include <vtkTransformFilter.h>
34#include <vtkUnstructuredGrid.h>
35#include <vtkUnstructuredGridAlgorithm.h>
36#include <vtkXMLUnstructuredGridReader.h>
44 this->setItemsExpandable(
false);
46 this->setItemDelegateForColumn(1, checkboxDelegate);
47 this->header()->setStretchLastSection(
true);
48 this->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
53 QTreeView::setModel(model);
57 this->header()->moveSection(1, 0);
62 QModelIndex index = selectionModel()->currentIndex();
68 ->
getItem(this->selectionModel()->currentIndex()));
70 item->
algorithm()->GetOutputDataObject(0)->GetDataObjectType();
73 !(this->selectionModel()->currentIndex().parent().isValid());
76 QAction* addFilterAction = menu.addAction(
"Add filter...");
78 if (objectType == VTK_IMAGE_DATA)
83 QAction* saveRasterAction = menu.addAction(
"Save Raster...");
84 connect(saveRasterAction, SIGNAL(triggered()),
this,
86 QAction* addMeshingAction =
87 menu.addAction(
"Convert Raster to Mesh...");
88 connect(addMeshingAction, SIGNAL(triggered()),
this,
93 QAction* addLUTAction = menu.addAction(
"Add color table...");
94 connect(addLUTAction, SIGNAL(triggered()),
this,
98 if (objectType == VTK_UNSTRUCTURED_GRID)
100 QAction* addConvertToMeshAction =
101 menu.addAction(
"Convert to Mesh...");
102 connect(addConvertToMeshAction, SIGNAL(triggered()),
this,
106 QAction* exportVtkAction = menu.addAction(
"Export as VTK");
111 QAction* removeAction = menu.addAction(
"Remove");
112 connect(removeAction, SIGNAL(triggered()),
this,
116 connect(addFilterAction, SIGNAL(triggered()),
this,
118 connect(exportVtkAction, SIGNAL(triggered()),
this,
121 menu.exec(event->globalPos());
128 QModelIndex idx = this->selectionModel()->currentIndex();
129 QString filename = QFileDialog::getSaveFileName(
130 this,
"Export object to vtk-file",
131 settings.value(
"lastExportedFileDirectory").toString(),
133 if (!filename.isEmpty())
138 QDir dir = QDir(filename);
139 settings.setValue(
"lastExportedFileDirectory", dir.absolutePath());
156 if (dlg.exec() != QDialog::Accepted)
161 vtkSmartPointer<vtkAlgorithm> algorithm =
164 ->
getItem(this->selectionModel()->currentIndex()))
167 vtkSmartPointer<VtkGeoImageSource> imageSource =
168 VtkGeoImageSource::SafeDownCast(algorithm);
193 QModelIndex
const index = this->selectionModel()->currentIndex();
203 ->
getItem(this->selectionModel()->currentIndex()));
204 vtkSmartPointer<vtkAlgorithm> algorithm = item->
algorithm();
206 vtkUnstructuredGrid* grid(
nullptr);
207 vtkUnstructuredGridAlgorithm* ugAlg =
208 vtkUnstructuredGridAlgorithm::SafeDownCast(algorithm);
211 grid = ugAlg->GetOutput();
216 vtkGenericDataObjectReader* dataReader =
217 vtkGenericDataObjectReader::SafeDownCast(algorithm);
220 grid = vtkUnstructuredGrid::SafeDownCast(dataReader->GetOutput());
225 vtkXMLUnstructuredGridReader* xmlReader =
226 vtkXMLUnstructuredGridReader::SafeDownCast(algorithm);
227 grid = vtkUnstructuredGrid::SafeDownCast(xmlReader->GetOutput());
232 mesh->
setName(item->
data(0).toString().toStdString());
237 const QItemSelection& deselected)
239 QTreeView::selectionChanged(selected, deselected);
241 if (selected.empty())
246 QModelIndex index = *selected.indexes().begin();
252 if (item->transformFilter())
255 item->transformFilter()->GetOutputDataObject(0)));
274 if (!index.isValid())
279 QItemSelectionModel* selectionModel = this->selectionModel();
280 selectionModel->clearSelection();
281 selectionModel->select(index, QItemSelectionModel::Select);
288 ->getItem(this->selectionModel()->currentIndex())));
292 QString filename = QFileDialog::getOpenFileName(
293 this,
"Select color table",
294 settings.value(
"lastOpenedLutFileDirectory").toString(),
295 "Color table files (*.xml);;");
296 QFileInfo fi(filename);
298 if (fi.suffix().toLower() ==
"xml")
313 QMessageBox::warning(
nullptr,
314 "Color lookup table could not be applied.",
315 "Color lookup tables can only be applied to "
316 "VtkVisPointSetItem.");
318 QDir dir = QDir(filename);
319 settings.setValue(
"lastOpenedLutFileDirectory", dir.absolutePath());
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.