diff --git a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp index 3f642e17f8..94538a89c3 100644 --- a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp +++ b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp @@ -1,143 +1,147 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkSurfaceRegistration.h" - #include #include #include #include #include #include #include // Includes for image casting between ITK and MITK: added after using Plugin Generator #include // added for surface dynamic cast #include #include const std::string QmitkSurfaceRegistration::VIEW_ID = "org.mitk.views.qmitksurfaceregistration"; QmitkSurfaceRegistration::QmitkSurfaceRegistration(QObject *parent) : m_ParentWidget(0), m_movingSurfaceNode(nullptr), m_targetSurfaceNode(nullptr) { } QmitkSurfaceRegistration::~QmitkSurfaceRegistration() { // delete pointer objects m_movingSurfaceNode = nullptr; m_targetSurfaceNode = nullptr; } // void QmitkSurfaceRegistration::SetFocus(){ - } void QmitkSurfaceRegistration::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); connect(m_Controls.pushButtonExecute, SIGNAL(clicked()), this, SLOT(doExecute())); m_ParentWidget = parent; } void QmitkSurfaceRegistration::doExecute() { MITK_INFO << "pushButtonExecute clicked"; } void QmitkSurfaceRegistration::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList &nodes) { MITK_INFO << "On Selection Changed"; bool rotationEnabled = false; if (nodes.empty()) { MITK_INFO << "Nothing selected yet"; m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(255, 0, 0) }"); m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(255, 0, 0) }"); m_Controls.labelMovingSurfaceName->setText(QString::fromStdString("No moving surface selected")); m_Controls.labelTargetSurfaceName->setText(QString::fromStdString("No target surface selected")); m_Controls.groupBoxMappedData->setEnabled(false); m_Controls.pushButtonExecute->setEnabled(false); return; } else { - foreach(mitk::DataNode::Pointer dataNode, nodes) + if (nodes.size() == 1) { - MITK_INFO << dynamic_cast(dataNode->GetData()) - << " in selection changed and nodes available..."; - if (dataNode.IsNotNull() && dynamic_cast(dataNode->GetData())) + if (nodes[0].IsNotNull() && dynamic_cast(nodes[0]->GetData())) + { + MITK_INFO << "There is exactly one image selected"; + m_movingSurfaceNode = nodes[0]; + m_Controls.labelSelectMovingSurface->setText("Selected moving surface:"); + m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); + m_Controls.labelMovingSurfaceName->setText( + QString::fromStdString("File name: " + m_movingSurfaceNode->GetName())); + } + else { - if (nodes.size() == 1) - { - MITK_INFO << "There is exactly one Image selected"; - m_movingSurfaceNode = nodes[0]; - m_Controls.labelSelectMovingSurface->setText("Selected moving surface:"); - m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); - m_Controls.labelMovingSurfaceName->setText( - QString::fromStdString("File name: " + m_movingSurfaceNode->GetName())); - } - else - { - MITK_INFO << "There is more than one Image selected"; - m_targetSurfaceNode = nodes[1]; - m_Controls.labelSelectTargetSurface->setText("Selected target surface:"); - m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); - m_Controls.labelTargetSurfaceName->setText( - QString::fromStdString("File name: " + m_targetSurfaceNode->GetName())); - m_Controls.groupBoxMappedData->setEnabled(true); - m_Controls.textMappedDataName->setEnabled(true); - m_Controls.pushButtonExecute->setEnabled(true); - } + QMessageBox::information(nullptr, "Warning", "Are you sure? - I dont think this is a Surface!"); } } + else if (nodes.size() == 2) + { + if (nodes[1].IsNotNull() && dynamic_cast(nodes[1]->GetData())) + { + MITK_INFO << "There is two images selected"; + m_targetSurfaceNode = nodes[1]; + m_Controls.labelSelectTargetSurface->setText("Selected target su rface:"); + m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); + m_Controls.labelTargetSurfaceName->setText( + QString::fromStdString("File name: " + m_targetSurfaceNode->GetName())); + m_Controls.groupBoxMappedData->setEnabled(true); + m_Controls.textMappedDataName->setEnabled(true); + m_Controls.pushButtonExecute->setEnabled(true); + } + else + { + QMessageBox::information(nullptr, "Warning", "Are you sure? - I dont think this is a Surface!"); + } + } + else + { + QMessageBox::information(nullptr, "Warning", "You do know that it only works with two surfaces, right? If you continue to click execute, this might crash one day!"); + //wie kann ich die Auswahl zurueck setzen? + } } // mitk::Image::Pointer image = dynamic_cast(m_ImageNode->GetData()); // if (image != nullptr) // { // vtkSmartPointer imageMat = image->GetGeometry()->GetVtkMatrix(); // // check whether the image geometry is rotated, if so, no pixel aligned cropping or masking can be performed // if ((imageMat->GetElement(1, 0) == 0.0) && (imageMat->GetElement(0, 1) == 0.0) && // (imageMat->GetElement(1, 2) == 0.0) && (imageMat->GetElement(2, 1) == 0.0) && // (imageMat->GetElement(2, 0) == 0.0) && (imageMat->GetElement(0, 2) == 0.0)) // { // rotationEnabled = false; // m_Controls.labelWarningRotation->setVisible(false); // } // else // { // rotationEnabled = true; // m_Controls.labelWarningRotation->setStyleSheet(" QLabel { color: rgb(255, 0, 0) }"); // m_Controls.labelWarningRotation->setVisible(true); // } -} -// else -// { -// QMessageBox::information(nullptr, "Warning", "Please load and select an image before starting image processing."); -// } -//} \ No newline at end of file +} \ No newline at end of file