diff --git a/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.cpp b/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.cpp index ad9171aae5..d2e20fde5b 100644 --- a/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.cpp +++ b/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.cpp @@ -1,213 +1,213 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //Blueberry #include #include //Qmitk #include "QmitkGeometryToolsView.h" //mitk #include #include //micro services #include #include const std::string QmitkGeometryToolsView::VIEW_ID = "org.mitk.views.geometrytools"; void QmitkGeometryToolsView::SetFocus() { m_Controls.m_AddInteractor->setFocus(); } void QmitkGeometryToolsView::CreateQtPartControl( QWidget *parent ) { m_Controls.setupUi( parent ); connect( m_Controls.m_AddInteractor, SIGNAL(clicked()), this, SLOT(AddInteractor()) ); connect( m_Controls.m_RemoveInteractor, SIGNAL(clicked()), this, SLOT(RemoveInteractor()) ); connect( m_Controls.m_TranslationStep, SIGNAL(valueChanged(double)), this, SLOT(OnTranslationSpinBoxChanged(double)) ); connect( m_Controls.m_RotationStep, SIGNAL(valueChanged(double)), this, SLOT(OnRotationSpinBoxChanged(double)) ); connect( m_Controls.m_ScaleFactor, SIGNAL(valueChanged(double)), this, SLOT(OnScaleSpinBoxChanged(double)) ); connect( m_Controls.m_AnchorPointX, SIGNAL(valueChanged(double)), this, SLOT(OnAnchorPointChanged(double)) ); connect( m_Controls.m_AnchorPointY, SIGNAL(valueChanged(double)), this, SLOT(OnAnchorPointChanged(double)) ); connect( m_Controls.m_AnchorPointZ, SIGNAL(valueChanged(double)), this, SLOT(OnAnchorPointChanged(double)) ); connect( m_Controls.m_UsageInfoCheckBox, SIGNAL(clicked(bool)), this, SLOT(OnUsageInfoBoxChanged(bool)) ); connect( m_Controls.m_CustomAnchorPointRadioButton, SIGNAL(toggled(bool)), this, SLOT(OnCustomPointRadioButtonToggled(bool)) ); connect( m_Controls.m_OriginPointRadioButton, SIGNAL(clicked(bool)), this, SLOT(OnOriginPointRadioButton(bool)) ); connect( m_Controls.m_CenterPointRadioButton, SIGNAL(clicked(bool)), this, SLOT(OnCenterPointRadioButton(bool)) ); m_Controls.m_UsageInfo->hide(); m_Controls.m_CustomAnchorPoint->hide(); } void QmitkGeometryToolsView::OnUsageInfoBoxChanged(bool flag) { m_Controls.m_UsageInfo->setVisible(flag); } void QmitkGeometryToolsView::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { - foreach( mitk::DataNode::Pointer node, nodes ) + for (mitk::DataNode::Pointer node: nodes) { if( node.IsNotNull() ) { m_Controls.m_AddInteractor->setEnabled( true ); return; } } m_Controls.m_AddInteractor->setEnabled( false ); } void QmitkGeometryToolsView::OnCustomPointRadioButtonToggled(bool status) { m_Controls.m_CustomAnchorPoint->setVisible(status); //change the anchor point to be the custom point OnAnchorPointChanged(0.0); } void QmitkGeometryToolsView::OnCenterPointRadioButton(bool) { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && (node->GetDataInteractor().IsNotNull()) ) { node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point X", node->GetData()->GetGeometry()->GetCenter()[0]); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Y", node->GetData()->GetGeometry()->GetCenter()[1]); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Z", node->GetData()->GetGeometry()->GetCenter()[2]); } } } void QmitkGeometryToolsView::OnOriginPointRadioButton(bool) { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && (node->GetDataInteractor().IsNotNull()) ) { node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point X", node->GetData()->GetGeometry()->GetOrigin()[0]); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Y", node->GetData()->GetGeometry()->GetOrigin()[1]); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Z", node->GetData()->GetGeometry()->GetOrigin()[2]); } } } void QmitkGeometryToolsView::AddInteractor() { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() ) { mitk::AffineBaseDataInteractor3D::Pointer affineDataInteractor = mitk::AffineBaseDataInteractor3D::New(); if (m_Controls.m_KeyboardMode->isChecked()) { affineDataInteractor->LoadStateMachine("AffineInteraction3D.xml", us::ModuleRegistry::GetModule("MitkDataTypesExt")); affineDataInteractor->SetEventConfig("AffineKeyConfig.xml", us::ModuleRegistry::GetModule("MitkDataTypesExt")); } else if(m_Controls.m_MouseMode->isChecked()) { affineDataInteractor->LoadStateMachine("AffineInteraction3D.xml", us::ModuleRegistry::GetModule("MitkDataTypesExt")); affineDataInteractor->SetEventConfig("AffineMouseConfig.xml", us::ModuleRegistry::GetModule("MitkDataTypesExt")); } affineDataInteractor->SetDataNode(node); node->SetBoolProperty("pickable", true); node->SetFloatProperty("AffineBaseDataInteractor3D.Translation Step Size", m_Controls.m_TranslationStep->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Rotation Step Size", m_Controls.m_RotationStep->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Scale Step Size", m_Controls.m_ScaleFactor->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point X", m_Controls.m_AnchorPointX->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Y", m_Controls.m_AnchorPointY->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Z", m_Controls.m_AnchorPointZ->value()); } } } void QmitkGeometryToolsView::RemoveInteractor() { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( (node.IsNotNull()) && (node->GetDataInteractor().IsNotNull()) ) { node->SetDataInteractor(nullptr); } } } void QmitkGeometryToolsView::OnTranslationSpinBoxChanged(double step) { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && (node->GetDataInteractor().IsNotNull()) ) { node->SetFloatProperty("AffineBaseDataInteractor3D.Translation Step Size", step); } } } void QmitkGeometryToolsView::OnRotationSpinBoxChanged(double step) { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && (node->GetDataInteractor().IsNotNull()) ) { node->SetFloatProperty("AffineBaseDataInteractor3D.Rotation Step Size", step); } } } void QmitkGeometryToolsView::OnScaleSpinBoxChanged(double factor) { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && (node->GetDataInteractor().IsNotNull()) ) { node->SetFloatProperty("AffineBaseDataInteractor3D.Scale Step Size", factor); } } } void QmitkGeometryToolsView::OnAnchorPointChanged(double /*value*/) { QList nodes = this->GetDataManagerSelection(); foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && (node->GetDataInteractor().IsNotNull()) ) { node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point X", m_Controls.m_AnchorPointX->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Y", m_Controls.m_AnchorPointY->value()); node->SetFloatProperty("AffineBaseDataInteractor3D.Anchor Point Z", m_Controls.m_AnchorPointZ->value()); } } } diff --git a/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.h b/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.h index 679945ca60..517618529a 100644 --- a/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.h +++ b/Plugins/org.mitk.gui.qt.geometrytools/src/internal/QmitkGeometryToolsView.h @@ -1,107 +1,107 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkGeometryToolsView_h #define QmitkGeometryToolsView_h #include #include #include #include "ui_QmitkGeometryToolsViewControls.h" /** \brief QmitkGeometryToolsView to modify geometry of mitkBaseData via interaction. \warning This is an experimental view to play with the geometry of all mitkBaseDatas. The current implementation allows to translate, rotate and scale objects with the keyboard. \warning Scaling is not supported for images, yet. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class QmitkGeometryToolsView : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; public slots: protected slots: /** * @brief Add/remove the affine interactor. */ void AddInteractor(); void RemoveInteractor(); /** * @brief Slots to adapt the step size for interaction. */ void OnRotationSpinBoxChanged(double step); void OnScaleSpinBoxChanged(double factor); void OnTranslationSpinBoxChanged(double step); /** * @brief OnUsageInfoBoxChanged show help. * @param flag yes/no. */ void OnUsageInfoBoxChanged(bool flag); /** * @brief OnCustomPointRadioButtonToggled hide/show custom anchor point * */ void OnCustomPointRadioButtonToggled(bool status); /** * @brief OnAnchorPointChanged sets the anchor point for rotation or translation. */ void OnAnchorPointChanged(double); /** * @brief OnOriginPointRadioButton sets the anchor point to the origin of the * mitk::DataNode mitk::BaseGeometry. */ void OnOriginPointRadioButton(bool); /** * @brief OnCenterPointRadioButton sets the anchor point to the center of the * mitk::DataNode mitk::BaseGeometry. */ void OnCenterPointRadioButton(bool); protected: virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed + /// \brief called by QmitkAbstractView when DataManager's selection has changed virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; Ui::QmitkGeometryToolsViewControls m_Controls; }; #endif // QmitkGeometryToolsView_h