18 #include <vtkDataSetMapper.h>
19 #include <vtkProp3D.h>
21 #include <QAbstractItemModel>
22 #include <QContextMenuEvent>
23 #include <QFileDialog>
24 #include <QHeaderView>
26 #include <QMessageBox>
39 #include <vtkDataObject.h>
40 #include <vtkGenericDataObjectReader.h>
41 #include <vtkImageData.h>
42 #include <vtkSmartPointer.h>
43 #include <vtkTransformFilter.h>
44 #include <vtkUnstructuredGrid.h>
45 #include <vtkUnstructuredGridAlgorithm.h>
46 #include <vtkXMLUnstructuredGridReader.h>
54 this->setItemsExpandable(
false);
56 this->setItemDelegateForColumn(1, checkboxDelegate);
57 this->header()->setStretchLastSection(
true);
58 this->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
63 QTreeView::setModel(model);
67 this->header()->moveSection(1, 0);
72 QModelIndex index = selectionModel()->currentIndex();
78 ->getItem(this->selectionModel()->currentIndex()));
80 item->
algorithm()->GetOutputDataObject(0)->GetDataObjectType();
83 !(this->selectionModel()->currentIndex().parent().isValid());
86 QAction* addFilterAction = menu.addAction(
"Add filter...");
88 if (objectType == VTK_IMAGE_DATA)
93 QAction* addMeshingAction =
94 menu.addAction(
"Convert Image to Mesh...");
95 connect(addMeshingAction, SIGNAL(triggered()),
this,
100 QAction* addLUTAction = menu.addAction(
"Add color table...");
101 connect(addLUTAction, SIGNAL(triggered()),
this,
105 if (objectType == VTK_UNSTRUCTURED_GRID)
107 QAction* addConvertToMeshAction =
108 menu.addAction(
"Convert to Mesh...");
109 connect(addConvertToMeshAction, SIGNAL(triggered()),
this,
113 QAction* exportVtkAction = menu.addAction(
"Export as VTK");
118 QAction* removeAction = menu.addAction(
"Remove");
119 connect(removeAction, SIGNAL(triggered()),
this,
123 connect(addFilterAction, SIGNAL(triggered()),
this,
125 connect(exportVtkAction, SIGNAL(triggered()),
this,
128 menu.exec(event->globalPos());
135 QModelIndex idx = this->selectionModel()->currentIndex();
136 QString filename = QFileDialog::getSaveFileName(
137 this,
"Export object to vtk-file",
138 settings.value(
"lastExportedFileDirectory").toString(),
140 if (!filename.isEmpty())
145 QDir dir = QDir(filename);
146 settings.setValue(
"lastExportedFileDirectory", dir.absolutePath());
163 if (dlg.exec() != QDialog::Accepted)
168 vtkSmartPointer<vtkAlgorithm> algorithm =
171 ->getItem(this->selectionModel()->currentIndex()))
174 vtkSmartPointer<VtkGeoImageSource> imageSource =
175 VtkGeoImageSource::SafeDownCast(algorithm);
177 imageSource->GetOutput()->GetOrigin(origin);
179 imageSource->GetOutput()->GetSpacing(spacing);
199 ->getItem(this->selectionModel()->currentIndex()));
200 vtkSmartPointer<vtkAlgorithm> algorithm = item->
algorithm();
202 vtkUnstructuredGrid* grid(
nullptr);
203 vtkUnstructuredGridAlgorithm* ugAlg =
204 vtkUnstructuredGridAlgorithm::SafeDownCast(algorithm);
207 grid = ugAlg->GetOutput();
212 vtkGenericDataObjectReader* dataReader =
213 vtkGenericDataObjectReader::SafeDownCast(algorithm);
216 grid = vtkUnstructuredGrid::SafeDownCast(dataReader->GetOutput());
221 vtkXMLUnstructuredGridReader* xmlReader =
222 vtkXMLUnstructuredGridReader::SafeDownCast(algorithm);
223 grid = vtkUnstructuredGrid::SafeDownCast(xmlReader->GetOutput());
228 mesh->
setName(item->
data(0).toString().toStdString());
233 const QItemSelection& deselected)
235 QTreeView::selectionChanged(selected, deselected);
237 if (selected.empty())
242 QModelIndex index = *selected.indexes().begin();
248 if (item->transformFilter())
251 item->transformFilter()->GetOutputDataObject(0)));
270 if (!index.isValid())
275 QItemSelectionModel* selectionModel = this->selectionModel();
276 selectionModel->clearSelection();
277 selectionModel->select(index, QItemSelectionModel::Select);
284 ->getItem(this->selectionModel()->currentIndex())));
288 QString filename = QFileDialog::getOpenFileName(
289 this,
"Select color table",
290 settings.value(
"lastOpenedLutFileDirectory").toString(),
291 "Color table files (*.xml);;");
292 QFileInfo fi(filename);
294 if (fi.suffix().toLower() ==
"xml")
309 QMessageBox::warning(
nullptr,
310 "Color lookup table could not be applied.",
311 "Color lookup tables can only be applied to "
312 "VtkVisPointSetItem.");
314 QDir dir = QDir(filename);
315 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 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 std::unique_ptr< MeshLib::Mesh > convert(GeoLib::Raster const &raster, MeshElemType elem_type, UseIntensityAs intensity_type, std::string const &array_name="Colour")
static MeshLib::Mesh * convertUnstructuredGrid(vtkUnstructuredGrid *grid, std::string const &mesh_name="vtkUnstructuredGrid")
Converts a vtkUnstructuredGrid object to a Mesh.
static void box(const QString &e)
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).
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
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 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.
void writeToFile(std::string const &id_area_fname, std::string const &csv_fname, std::vector< std::pair< std::size_t, double >> const &ids_and_areas, std::vector< MeshLib::Node * > const &mesh_nodes)