From eee1d44ef8fc716c83c669e4abfa1233122e1b37 Mon Sep 17 00:00:00 2001 From: rinkk <karsten.rink@ufz.de> Date: Thu, 28 Jan 2016 14:09:32 +0100 Subject: [PATCH] restructured dialog call to work without connect --- .../VtkVis/MeshFromRasterDialog.cpp | 21 ++++++++++++------- .../VtkVis/MeshFromRasterDialog.h | 12 ++++++++--- .../VtkVis/VtkVisPipelineView.cpp | 14 +++++++------ .../DataExplorer/VtkVis/VtkVisPipelineView.h | 10 ++++++--- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp index 5573212a861..79dc999b45b 100644 --- a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp +++ b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp @@ -34,15 +34,22 @@ MeshFromRasterDialog::~MeshFromRasterDialog() void MeshFromRasterDialog::accept() { - MeshLib::UseIntensityAs i_type(MeshLib::UseIntensityAs::ELEVATION); - if (this->materialButton->isChecked()) i_type = MeshLib::UseIntensityAs::DATAVECTOR; - else if (this->ignoreButton->isChecked()) i_type = MeshLib::UseIntensityAs::NONE; + if (this->mshNameEdit->text().isEmpty()) + { + OGSError::box("Please specify a name for the resulting mesh."); + return; + } - MeshLib::MeshElemType e_type(MeshLib::MeshElemType::TRIANGLE); - if (this->quadButton->isChecked()) e_type = MeshLib::MeshElemType::QUAD; - else if (this->hexButton->isChecked()) e_type = MeshLib::MeshElemType::HEXAHEDRON; + _new_mesh_name = this->mshNameEdit->text().toStdString(); + + _intensity_selection = MeshLib::UseIntensityAs::ELEVATION; + if (this->materialButton->isChecked()) _intensity_selection = MeshLib::UseIntensityAs::DATAVECTOR; + else if (this->ignoreButton->isChecked()) _intensity_selection = MeshLib::UseIntensityAs::NONE; + + _element_selection = MeshLib::MeshElemType::TRIANGLE; + if (this->quadButton->isChecked()) _element_selection = MeshLib::MeshElemType::QUAD; + else if (this->hexButton->isChecked()) _element_selection = MeshLib::MeshElemType::HEXAHEDRON; - emit setMeshParameters(this->mshNameEdit->text(), e_type, i_type); this->done(QDialog::Accepted); } diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h index 120c65273a9..e929d312466 100644 --- a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h +++ b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h @@ -17,6 +17,7 @@ #include "ui_MeshFromRaster.h" +#include <string> #include <QDialog> namespace MeshLib { @@ -35,9 +36,12 @@ class MeshFromRasterDialog : public QDialog, private Ui_MeshFromRaster public: /// Constructor MeshFromRasterDialog(QDialog* parent = 0); - ~MeshFromRasterDialog(void); + std::string getNewMeshName() const { return _new_mesh_name; } + MeshLib::MeshElemType getElementSelection() const { return _element_selection; } + MeshLib::UseIntensityAs getIntensitySelection() const { return _intensity_selection; } + private slots: /// Instructions if the OK-Button has been pressed. void accept(); @@ -45,8 +49,10 @@ private slots: /// Instructions if the Cancel-Button has been pressed. void reject(); -signals: - void setMeshParameters(QString, MeshLib::MeshElemType, MeshLib::UseIntensityAs); +private: + std::string _new_mesh_name; + MeshLib::MeshElemType _element_selection; + MeshLib::UseIntensityAs _intensity_selection; }; diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp index 12754b01ba0..ad5378d4ce9 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp @@ -196,13 +196,15 @@ void VtkVisPipelineView::addPipelineFilterItem() void VtkVisPipelineView::showImageToMeshConversionDialog() { - MeshFromRasterDialog* dlg = new MeshFromRasterDialog; - connect(dlg, SIGNAL(setMeshParameters(QString, MeshLib::MeshElemType, MeshLib::UseIntensityAs)), - this, SLOT(constructMeshFromImage(QString, MeshLib::MeshElemType, MeshLib::UseIntensityAs))); - dlg->exec(); + MeshFromRasterDialog dlg; + if (dlg.exec() != QDialog::Accepted) + return; + + MeshLib::MeshElemType t (dlg.getElementSelection()); + constructMeshFromImage(dlg.getNewMeshName(), dlg.getElementSelection(), dlg.getIntensitySelection()); } -void VtkVisPipelineView::constructMeshFromImage(QString msh_name, MeshLib::MeshElemType element_type, MeshLib::UseIntensityAs intensity_type) +void VtkVisPipelineView::constructMeshFromImage(std::string msh_name, MeshLib::MeshElemType element_type, MeshLib::UseIntensityAs intensity_type) { vtkSmartPointer<vtkAlgorithm> algorithm = static_cast<VtkVisPipelineItem*>(static_cast<VtkVisPipeline*>(this->model())-> @@ -217,7 +219,7 @@ void VtkVisPipelineView::constructMeshFromImage(QString msh_name, MeshLib::MeshE MeshLib::Mesh* mesh = MeshLib::VtkMeshConverter::convertImgToMesh(imageSource->GetOutput(), origin, spacing[0], element_type, intensity_type); if (mesh) { - mesh->setName(msh_name.toStdString()); + mesh->setName(msh_name); emit meshAdded(mesh); } else diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h index 6410a63fb44..dcc0a0fdf0c 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h @@ -56,6 +56,13 @@ private: /// Creates a menu on right-clicking on an item. void contextMenuEvent(QContextMenuEvent* event); + /// Calls the conversion method for creating an OGS Mesh from a vtkImageData object. + void constructMeshFromImage( + std::string msh_name, + MeshLib::MeshElemType element_type, + MeshLib::UseIntensityAs intensity_type); + + private slots: /// Adds a color lookup table to the current scalar array of the selected pipeline item. void addColorTable(); @@ -76,9 +83,6 @@ private slots: /// Sends a requestAddPipelineFilterItem() signal to add a filter. void addPipelineFilterItem(); - /// Calls the conversion method for creating an OGS Mesh from a vtkImageData object. - void constructMeshFromImage(QString msh_name, MeshLib::MeshElemType element_type, MeshLib::UseIntensityAs intensity_type); - /// Calls the dialog to void showImageToMeshConversionDialog(); -- GitLab