diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp index c3cc16f76e..7f084beb61 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp @@ -1,110 +1,110 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkRemeshingView.h" #include <ui_QmitkRemeshingViewControls.h> #include <berryQtStyleManager.h> #include <mitkNodePredicateAnd.h> #include <mitkNodePredicateDataType.h> #include <mitkNodePredicateNot.h> #include <mitkNodePredicateOr.h> #include <mitkNodePredicateProperty.h> #include <mitkRemeshing.h> const std::string QmitkRemeshingView::VIEW_ID = "org.mitk.views.remeshing"; QmitkRemeshingView::QmitkRemeshingView() : m_Controls(new Ui::QmitkRemeshingViewControls) { } QmitkRemeshingView::~QmitkRemeshingView() { } void QmitkRemeshingView::CreateQtPartControl(QWidget* parent) { m_Controls->setupUi(parent); m_Controls->decimatePushButton->setIcon(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/Remeshing/RemeshingIcon.svg"))); m_Controls->selectionWidget->SetDataStorage(this->GetDataStorage()); m_Controls->selectionWidget->SetSelectionIsOptional(true); - m_Controls->selectionWidget->SetEmptyInfo(QStringLiteral("Select a mesh")); + m_Controls->selectionWidget->SetEmptyInfo(QStringLiteral("Select a surface")); m_Controls->selectionWidget->SetAutoSelectNewNodes(true); m_Controls->selectionWidget->SetNodePredicate(mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType<mitk::Surface>::New(), mitk::NodePredicateNot::New(mitk::NodePredicateOr::New( mitk::NodePredicateProperty::New("helper object"), mitk::NodePredicateProperty::New("hidden object"))))); - connect(m_Controls->selectionWidget, &QmitkSingleNodeSelectionWidget::CurrentSelectionChanged, this, &QmitkRemeshingView::OnSelectedMeshChanged); + connect(m_Controls->selectionWidget, &QmitkSingleNodeSelectionWidget::CurrentSelectionChanged, this, &QmitkRemeshingView::OnSurfaceChanged); connect(m_Controls->polygonCountSlider, SIGNAL(valueChanged(int)), this, SLOT(OnPolygonCountChanged(int))); connect(m_Controls->polygonCountSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnPolygonCountChanged(int))); connect(m_Controls->decimatePushButton, SIGNAL(clicked()), this, SLOT(OnDecimateButtonClicked())); - this->OnSelectedMeshChanged(m_Controls->selectionWidget->GetSelectedNodes()); + this->OnSurfaceChanged(m_Controls->selectionWidget->GetSelectedNodes()); } -void QmitkRemeshingView::OnSelectedMeshChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes) +void QmitkRemeshingView::OnSurfaceChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes) { this->EnableWidgets(!nodes.empty() && nodes.front().IsNotNull()); } void QmitkRemeshingView::OnPolygonCountChanged(int polygonCount) { if (polygonCount != m_Controls->polygonCountSlider->value()) m_Controls->polygonCountSlider->setValue(polygonCount); if (polygonCount != m_Controls->polygonCountSpinBox->value()) m_Controls->polygonCountSpinBox->setValue(polygonCount); } void QmitkRemeshingView::OnDecimateButtonClicked() { mitk::DataNode::Pointer selectedNode = m_Controls->selectionWidget->GetSelectedNode(); mitk::Surface::ConstPointer input = static_cast<mitk::Surface*>(selectedNode->GetData()); mitk::Surface::Pointer output; try { output = mitk::Remeshing::Decimate(input); } catch(const mitk::Exception& exception) { MITK_ERROR << exception.GetDescription(); return; } auto newNode = mitk::DataNode::New(); newNode->SetName(QString("%1 (%2%)").arg(selectedNode->GetName().c_str()).arg(m_Controls->polygonCountSpinBox->value()).toStdString()); newNode->SetData(output); this->GetDataStorage()->Add(newNode, selectedNode); } void QmitkRemeshingView::EnableWidgets(bool enable) { m_Controls->polygonCountSlider->setEnabled(enable); m_Controls->polygonCountSpinBox->setEnabled(enable); m_Controls->polygonDistributionComboBox->setEnabled(enable); m_Controls->decimatePushButton->setEnabled(enable); } void QmitkRemeshingView::SetFocus() { m_Controls->selectionWidget->setFocus(); } diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h index f8564df290..a2cc446cd7 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h @@ -1,48 +1,48 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QmitkRemeshingView_h #define QmitkRemeshingView_h #include <QmitkAbstractView.h> #include <QmitkSingleNodeSelectionWidget.h> namespace Ui { class QmitkRemeshingViewControls; } class QmitkRemeshingView : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; QmitkRemeshingView(); ~QmitkRemeshingView() override; void CreateQtPartControl(QWidget* parent) override; void SetFocus() override; private slots: - void OnSelectedMeshChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes); + void OnSurfaceChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes); void OnPolygonCountChanged(int polygonCount); void OnDecimateButtonClicked(); private: void EnableWidgets(bool enable); Ui::QmitkRemeshingViewControls* m_Controls; }; #endif diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui index fcc3ab7ab2..bca912609c 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui @@ -1,182 +1,182 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>QmitkRemeshingViewControls</class> <widget class="QWidget" name="QmitkRemeshingViewControls"> <property name="enabled"> <bool>true</bool> </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>253</width> <height>573</height> </rect> </property> <property name="windowTitle"> <string>Remeshing</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> <layout class="QGridLayout" name="gridLayout"> <item row="1" column="1"> <widget class="QSlider" name="polygonCountSlider"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimum"> <number>1</number> </property> <property name="maximum"> <number>100</number> </property> <property name="pageStep"> <number>10</number> </property> <property name="value"> <number>100</number> </property> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> <item row="1" column="2"> <widget class="QSpinBox" name="polygonCountSpinBox"> <property name="suffix"> <string>%</string> </property> <property name="minimum"> <number>1</number> </property> <property name="maximum"> <number>100</number> </property> <property name="singleStep"> <number>1</number> </property> <property name="value"> <number>100</number> </property> </widget> </item> <item row="2" column="0"> <widget class="QLabel" name="polygonDistributionLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="text"> <string>Polygon distribution</string> </property> </widget> </item> <item row="0" column="0"> - <widget class="QLabel" name="meshLabel"> + <widget class="QLabel" name="surfaceLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="text"> - <string>Mesh</string> + <string>Surface</string> </property> </widget> </item> <item row="0" column="1" colspan="2"> <widget class="QmitkSingleNodeSelectionWidget" name="selectionWidget" native="true"> <property name="minimumSize"> <size> <width>0</width> <height>40</height> </size> </property> </widget> </item> <item row="1" column="0"> <widget class="QLabel" name="polygonCountLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="text"> <string>Polygon count</string> </property> </widget> </item> <item row="2" column="1" colspan="2"> <widget class="QComboBox" name="polygonDistributionComboBox"> <item> <property name="text"> <string>Adaptive</string> </property> </item> <item> <property name="text"> <string>Uniform</string> </property> </item> </widget> </item> </layout> </item> <item> <widget class="QPushButton" name="decimatePushButton"> <property name="enabled"> <bool>true</bool> </property> <property name="text"> <string>Decimate</string> </property> <property name="icon"> <iconset resource="../../resources/Remeshing.qrc"> <normaloff>:/Remeshing/RemeshingIcon.svg</normaloff>:/Remeshing/RemeshingIcon.svg</iconset> </property> <property name="iconSize"> <size> <width>24</width> <height>24</height> </size> </property> </widget> </item> <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> </size> </property> </spacer> </item> </layout> </widget> <customwidgets> <customwidget> <class>QmitkSingleNodeSelectionWidget</class> <extends>QWidget</extends> <header location="global">QmitkSingleNodeSelectionWidget.h</header> <container>1</container> </customwidget> </customwidgets> <tabstops> <tabstop>polygonCountSpinBox</tabstop> <tabstop>decimatePushButton</tabstop> </tabstops> <resources> <include location="../../resources/Remeshing.qrc"/> </resources> <connections/> </ui>