diff --git a/Gui/DataView/MshView.cpp b/Gui/DataView/MshView.cpp index 8315d52c0574bf860e8d8e2d0eb7e6f1d31ddda6..6b712ca3988d5b052d0429269369160627327f74 100644 --- a/Gui/DataView/MshView.cpp +++ b/Gui/DataView/MshView.cpp @@ -76,7 +76,7 @@ void MshView::selectionChanged( const QItemSelection &selected, const QItemSelec { emit enableSaveButton(false); emit enableRemoveButton(false); - emit elementSelected(dynamic_cast<const MshItem*>(tree_item->parentItem())->vtkSource(), tree_item->row()); + emit elementSelected(dynamic_cast<const MshItem*>(tree_item->parentItem())->vtkSource(), true, tree_item->row()); } } //emit itemSelectionChanged(selected, deselected); diff --git a/Gui/DataView/MshView.h b/Gui/DataView/MshView.h index c187ad6d1bcbbb0baf5cd8003b3089b410b8deb6..1b4a7a64ecfe8f997a05a310dd211fc68b5fe70c 100644 --- a/Gui/DataView/MshView.h +++ b/Gui/DataView/MshView.h @@ -87,7 +87,7 @@ private slots: void checkMeshQuality(); signals: - void elementSelected(const vtkUnstructuredGridAlgorithm*, int); + void elementSelected(const vtkUnstructuredGridAlgorithm*, bool, int); void enableSaveButton(bool); void enableRemoveButton(bool); void openMeshFile(int); diff --git a/Gui/VtkVis/VtkCompositeFilter.cpp b/Gui/VtkVis/VtkCompositeFilter.cpp index 9341f0bc61ab6eb17e45c96ee4bcfe4d7d8e111b..13e186bc346d422faa86f88f21127cadfa48b9d6 100644 --- a/Gui/VtkVis/VtkCompositeFilter.cpp +++ b/Gui/VtkVis/VtkCompositeFilter.cpp @@ -16,6 +16,7 @@ #include "VtkCompositeFilter.h" #include <vtkAlgorithm.h> +#include <vtkPolyData.h> #include <QMapIterator> #include <QString> @@ -31,3 +32,19 @@ VtkCompositeFilter::~VtkCompositeFilter() { _outputAlgorithm->Delete(); } + + +float VtkCompositeFilter::GetInitialRadius() const +{ + double bounding_box[6]; + static_cast<vtkPolyData*>(this->_inputAlgorithm->GetOutputDataObject(0))->GetBounds(bounding_box); + double x_diff = fabs(bounding_box[0]-bounding_box[1]); + double y_diff = fabs(bounding_box[2]-bounding_box[3]); + double z_diff = fabs(bounding_box[4]-bounding_box[5]); + + double max = (x_diff == 0) ? 1 : x_diff; + max = (max > y_diff) ? max : y_diff; + max = (max > z_diff) ? max : z_diff; + + return max/200.0; +} diff --git a/Gui/VtkVis/VtkCompositeFilter.h b/Gui/VtkVis/VtkCompositeFilter.h index 8220b80e1cd9476df73af03431aa6ceaaf7dbe42..7f73d82c631a74f55bbbc5660beec9c1b81ba60e 100644 --- a/Gui/VtkVis/VtkCompositeFilter.h +++ b/Gui/VtkVis/VtkCompositeFilter.h @@ -67,6 +67,9 @@ public: vtkAlgorithm* GetOutputAlgorithm() const { return _outputAlgorithm; } protected: + /// Calculates a 1/200th of the largest extension of the bounding box (this is used as default radius for various filters) + float GetInitialRadius() const; + /// See [vtkSetGet.h](https://github.com/Kitware/VTK/blob/master/Common/Core/vtkSetGet.h) /// for the defines int _inputDataObjectType; diff --git a/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp b/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp index f88c4bd389daaa741cc9b1d53e6e1e09eb7c3323..0e454970c4e1ceac1b35ac981c735be622c91afa 100644 --- a/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp +++ b/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp @@ -93,16 +93,4 @@ void VtkCompositeGeoObjectFilter::SetIndex(size_t idx) _threshold->ThresholdBetween(idx, idx); } -float VtkCompositeGeoObjectFilter::GetInitialRadius() const -{ - double bounding_box[6]; - static_cast<vtkPolyData*>(this->_inputAlgorithm->GetOutputDataObject(0))->GetBounds(bounding_box); - double x_diff = fabs(bounding_box[0]-bounding_box[1]); - double y_diff = fabs(bounding_box[2]-bounding_box[3]); - double z_diff = fabs(bounding_box[4]-bounding_box[5]); - - double max = (x_diff > y_diff) ? x_diff : y_diff; - max = (max > z_diff) ? max : z_diff; - return max/150.0; -} diff --git a/Gui/VtkVis/VtkCompositeGeoObjectFilter.h b/Gui/VtkVis/VtkCompositeGeoObjectFilter.h index 15306b117aeded38b7089e04b566f9681a53bba9..cb1bea548dc349d481212c4e8ba6b17cfd9cb609 100644 --- a/Gui/VtkVis/VtkCompositeGeoObjectFilter.h +++ b/Gui/VtkVis/VtkCompositeGeoObjectFilter.h @@ -39,8 +39,6 @@ public: void SetIndex(std::size_t idx); private: - float GetInitialRadius() const; - GeoLib::GEOTYPE _type; vtkThreshold* _threshold; }; diff --git a/Gui/VtkVis/VtkCompositeLineToTubeFilter.cpp b/Gui/VtkVis/VtkCompositeLineToTubeFilter.cpp index 1e29038339e7d80c751d34ab9c62552594e89fa2..ea473f27741455ce7c79a66cb2c6f2fc863d81cf 100644 --- a/Gui/VtkVis/VtkCompositeLineToTubeFilter.cpp +++ b/Gui/VtkVis/VtkCompositeLineToTubeFilter.cpp @@ -71,17 +71,3 @@ void VtkCompositeLineToTubeFilter::SetUserProperty( QString name, QVariant value else if (name.compare("Capping") == 0) static_cast<vtkTubeFilter*>(_outputAlgorithm)->SetCapping(value.toBool()); } - -float VtkCompositeLineToTubeFilter::GetInitialRadius() const -{ - double bounding_box[6]; - static_cast<vtkPolyData*>(this->_inputAlgorithm->GetOutputDataObject(0))->GetBounds(bounding_box); - double x_diff = fabs(bounding_box[0]-bounding_box[1]); - double y_diff = fabs(bounding_box[2]-bounding_box[3]); - double z_diff = fabs(bounding_box[4]-bounding_box[5]); - - double max = (x_diff > y_diff) ? x_diff : y_diff; - max = (max > z_diff) ? max : z_diff; - - return max/200.0; -} diff --git a/Gui/VtkVis/VtkCompositeLineToTubeFilter.h b/Gui/VtkVis/VtkCompositeLineToTubeFilter.h index 83540c58caa15ccd92e1e2d911c55699a962c95f..3a23c8c1ec54000326bbc62a0a7b92801d5821e5 100644 --- a/Gui/VtkVis/VtkCompositeLineToTubeFilter.h +++ b/Gui/VtkVis/VtkCompositeLineToTubeFilter.h @@ -29,7 +29,7 @@ public: virtual void SetUserProperty(QString name, QVariant value); private: - float GetInitialRadius() const; + }; #endif // VTKCOMPOSITELINETOTUBEFILTER_H diff --git a/Gui/VtkVis/VtkCompositePointToGlyphFilter.cpp b/Gui/VtkVis/VtkCompositePointToGlyphFilter.cpp index 58e61815840c343a3f3c90568efce5336dcb3da2..77a777bd7e41520d9a3d71dd08690012152373c9 100644 --- a/Gui/VtkVis/VtkCompositePointToGlyphFilter.cpp +++ b/Gui/VtkVis/VtkCompositePointToGlyphFilter.cpp @@ -93,18 +93,3 @@ void VtkCompositePointToGlyphFilter::SetUserProperty( QString name, QVariant val else if (name.compare("Orient") == 0) static_cast<vtkGlyph3D*>(_outputAlgorithm)->SetOrient(value.toBool()); } - -float VtkCompositePointToGlyphFilter::GetInitialRadius() const -{ - double bounding_box[6]; - static_cast<vtkPolyData*>(this->_inputAlgorithm->GetOutputDataObject(0))->GetBounds(bounding_box); - double x_diff = fabs(bounding_box[0]-bounding_box[1]); - double y_diff = fabs(bounding_box[2]-bounding_box[3]); - double z_diff = fabs(bounding_box[4]-bounding_box[5]); - - double max = (x_diff == 0) ? 1 : x_diff; - max = (max > y_diff) ? max : y_diff; - max = (max > z_diff) ? max : z_diff; - - return max/150.0; -} diff --git a/Gui/VtkVis/VtkCompositePointToGlyphFilter.h b/Gui/VtkVis/VtkCompositePointToGlyphFilter.h index aca27c35fa00a2a5f3ddd09fb5d5723d6b98a96d..2750583bd574be717f59d3cf9e2b0300a0cfbc96 100644 --- a/Gui/VtkVis/VtkCompositePointToGlyphFilter.h +++ b/Gui/VtkVis/VtkCompositePointToGlyphFilter.h @@ -31,8 +31,6 @@ public: virtual void SetUserProperty(QString name, QVariant value); private: - float GetInitialRadius() const; - vtkSphereSource* _glyphSource; }; diff --git a/Gui/VtkVis/VtkCompositeSelectionFilter.cpp b/Gui/VtkVis/VtkCompositeSelectionFilter.cpp index e6b009af7cf290234463b280028bdb5cf929a5be..3f1981e57318b665a9d7db1b14e3375a837a889b 100644 --- a/Gui/VtkVis/VtkCompositeSelectionFilter.cpp +++ b/Gui/VtkVis/VtkCompositeSelectionFilter.cpp @@ -15,6 +15,7 @@ // ** INCLUDES ** #include "VtkCompositeSelectionFilter.h" #include "VtkAppendArrayFilter.h" +#include "VtkCompositePointToGlyphFilter.h" #include "VtkColorLookupTable.h" #include <vtkDataSetSurfaceFilter.h> @@ -24,7 +25,7 @@ #include <vtkUnstructuredGrid.h> VtkCompositeSelectionFilter::VtkCompositeSelectionFilter( vtkAlgorithm* inputAlgorithm ) - : VtkCompositeFilter(inputAlgorithm), _selection_name("Selection") + : VtkCompositeFilter(inputAlgorithm), _selection_name("Selection"), _is_element_array(true) { //this->init(); } @@ -57,23 +58,34 @@ void VtkCompositeSelectionFilter::init() idFilter->Update(); vtkThreshold* threshold = vtkThreshold::New(); - threshold->SetInputConnection(idFilter->GetOutputPort()); - threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS, _selection_name.c_str()); - threshold->SetSelectedComponent(0); - threshold->ThresholdBetween(thresholdLower, thresholdUpper); - threshold->Update(); + threshold->SetInputConnection(idFilter->GetOutputPort()); + if (_is_element_array) + threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS, _selection_name.c_str()); + else + threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, _selection_name.c_str()); + threshold->SetSelectedComponent(0); + threshold->ThresholdBetween(thresholdLower, thresholdUpper); + threshold->Update(); QList<QVariant> thresholdRangeList; thresholdRangeList.push_back(0.0); thresholdRangeList.push_back(1.0); (*_algorithmUserVectorProperties)["Threshold Between"] = thresholdRangeList; - _outputAlgorithm = threshold; + if (!_is_element_array) + { + VtkCompositeFilter* composite = new VtkCompositePointToGlyphFilter(threshold); + composite->SetUserProperty("Radius", this->GetInitialRadius()); + _outputAlgorithm = composite->GetOutputAlgorithm(); + } + else + _outputAlgorithm = threshold; } -void VtkCompositeSelectionFilter::setSelectionArray(const std::string &selection_name, const std::vector<double> &selection) +void VtkCompositeSelectionFilter::setSelectionArray(const std::string &selection_name, bool is_element_array, const std::vector<double> &selection) { _selection_name = selection_name; + _is_element_array = is_element_array; _selection = selection; init(); } diff --git a/Gui/VtkVis/VtkCompositeSelectionFilter.h b/Gui/VtkVis/VtkCompositeSelectionFilter.h index b11d55167639859243b70fd386199de65767ef64..d0a868ebf25036c3f8f2a18c8ef429e49ee060e3 100644 --- a/Gui/VtkVis/VtkCompositeSelectionFilter.h +++ b/Gui/VtkVis/VtkCompositeSelectionFilter.h @@ -30,7 +30,7 @@ public: virtual void init(); - void setSelectionArray(const std::string &selection_name, const std::vector<double> &selection = std::vector<double>()); + void setSelectionArray(const std::string &selection_name, bool is_element_array = true, const std::vector<double> &selection = std::vector<double>()); virtual void SetUserVectorProperty(QString name, QList<QVariant> values); @@ -40,6 +40,7 @@ private: std::string _selection_name; std::vector<double> _selection; + bool _is_element_array; }; #endif // VTKCOMPOSITESELECTIONFILTER_H diff --git a/Gui/VtkVis/VtkVisPipeline.cpp b/Gui/VtkVis/VtkVisPipeline.cpp index b40ec7256058d92b26642ff9ad4105a92606e01c..cd9092c6285a36c712f4ca63cf328ff74ca76a59 100644 --- a/Gui/VtkVis/VtkVisPipeline.cpp +++ b/Gui/VtkVis/VtkVisPipeline.cpp @@ -513,7 +513,7 @@ void VtkVisPipeline::checkMeshQuality(VtkMeshSource* source, MshQualityType::typ "VtkCompositeSelectionFilter", parentItem->transformFilter()); static_cast<VtkCompositeSelectionFilter*>(filter)-> - setSelectionArray("Selection", quality); + setSelectionArray("Selection", true, quality); VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData); @@ -592,7 +592,7 @@ void VtkVisPipeline::removeHighlightedGeoObject() } } -void VtkVisPipeline::highlightMeshComponent(const vtkUnstructuredGridAlgorithm* source, int index) +void VtkVisPipeline::highlightMeshComponent(const vtkUnstructuredGridAlgorithm* source, bool is_element, int index) { int nSources = this->_rootItem->childCount(); for (int i = 0; i < nSources; i++) @@ -608,7 +608,7 @@ void VtkVisPipeline::highlightMeshComponent(const vtkUnstructuredGridAlgorithm* VtkCompositeFilter* filter = VtkFilterFactory::CreateCompositeFilter( "VtkCompositeSelectionFilter", parentItem->transformFilter()); - static_cast<VtkCompositeSelectionFilter*>(filter)->setSelectionArray("vtkIdFilter_Ids"); + static_cast<VtkCompositeSelectionFilter*>(filter)->setSelectionArray("vtkIdFilter_Ids", is_element); static_cast<VtkCompositeSelectionFilter*>(filter)->SetUserVectorProperty("Threshold Between", selected_index); VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData); diff --git a/Gui/VtkVis/VtkVisPipeline.h b/Gui/VtkVis/VtkVisPipeline.h index b48ee88019a96c453dc60ab162359a5f6dce79de..2d6debb5c4d0c47e13525f47c0a11a0cbe5f7360 100644 --- a/Gui/VtkVis/VtkVisPipeline.h +++ b/Gui/VtkVis/VtkVisPipeline.h @@ -126,7 +126,7 @@ public slots: void removeHighlightedGeoObject(); /// Applies a VtkCompositeSelectionFilter to add a specific component of the given mesh-source to the pipeline for highlighted display in the render window. - void highlightMeshComponent(const vtkUnstructuredGridAlgorithm* source, int index); + void highlightMeshComponent(const vtkUnstructuredGridAlgorithm* source, bool is_element, int index); /// Removes the currently highlighted mesh component void removeHighlightedMeshComponent(); diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index 1c6664f49625b6d5e910dad4c354e1ac39929c8c..d29de28553c87b46703070f69969bd101b6ceca8 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -201,8 +201,8 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) this, SLOT(showMshQualitySelectionDialog(VtkMeshSource*))); connect(mshTabWidget->treeView, SIGNAL(requestCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool)), this, SLOT(showCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool))); - connect(mshTabWidget->treeView, SIGNAL(elementSelected(const vtkUnstructuredGridAlgorithm*, int)), - _vtkVisPipeline, SLOT(highlightMeshComponent(const vtkUnstructuredGridAlgorithm*, int))); + connect(mshTabWidget->treeView, SIGNAL(elementSelected(const vtkUnstructuredGridAlgorithm*, bool, int)), + _vtkVisPipeline, SLOT(highlightMeshComponent(const vtkUnstructuredGridAlgorithm*, bool, int))); connect(mshTabWidget->treeView, SIGNAL(removeSelectedMeshComponent()), _vtkVisPipeline, SLOT(removeHighlightedMeshComponent()));