diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp index 5573212a8610d0947d2d99b5587cb58a7b225460..79dc999b45be4020f39f979a269c6ca4483a7f69 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 120c65273a9a3af2d2693592028ae98376b744c3..e929d312466ef1d2933c9f9b0da2ba4a084d6153 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 12754b01ba0c61fccf9bf70f4383421052e6b133..ad5378d4ce9dcb53da97850b6df9ddd14c86c3a7 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 6410a63fb44f843af56e4f9a6f4c9e8d71d05740..dcc0a0fdf0cb7a0e326ba10617494dfdd507d336 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();