diff --git a/Modules/SurfaceRegistration/include/MitkShapeComparisonManager.h b/Modules/SurfaceRegistration/include/MitkShapeComparisonManager.h index 8d5b6e3a3a..0cf7163c14 100644 --- a/Modules/SurfaceRegistration/include/MitkShapeComparisonManager.h +++ b/Modules/SurfaceRegistration/include/MitkShapeComparisonManager.h @@ -1,69 +1,75 @@ /*=================================================================== 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 ShapeComparisonManager_h #define ShapeComparisonManager_h #include "mitkSurface.h" #include #include "mitkDataNode.h" #include #include #include +#include +#include +#include +#include + //#include "mitkSurfaceRegistrationICP.h" #include namespace mitk { class MITKSURFACEREGISTRATION_EXPORT ShapeComparisonManager { public: ShapeComparisonManager(mitk::Surface::Pointer moving, mitk::Surface::Pointer target); ~ShapeComparisonManager(); - mitk::Surface::Pointer getRegisteredSurface(); void execute(); vtkSmartPointer getTable(); + mitk::DataNode::Pointer getColourTransformedDataNode(); + private: void manageICPCalculation(); void manageCalculateDistances(); void createLookUpTable(); void printPoints();//for test purposes mitk::Surface::Pointer m_MovingSurface; mitk::Surface::Pointer m_TargetSurface; mitk::Surface::Pointer m_registeredSurface; vtkSmartPointer m_distances; vtkSmartPointer m_LookupTable; }; } #endif diff --git a/Modules/SurfaceRegistration/src/DataManagement/MitkShortestDistanceCalculator.cpp b/Modules/SurfaceRegistration/src/DataManagement/MitkShortestDistanceCalculator.cpp index daade90ded..9b049cfc60 100644 --- a/Modules/SurfaceRegistration/src/DataManagement/MitkShortestDistanceCalculator.cpp +++ b/Modules/SurfaceRegistration/src/DataManagement/MitkShortestDistanceCalculator.cpp @@ -1,59 +1,72 @@ /*=================================================================== 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. ===================================================================*/ #include "mitkShortestDistanceCalculator.h" #include "vtkCellLocator.h" #include "vtkPointData.h" #include "vtkImplicitPolyDataDistance.h" #include "vtkDoubleArray.h" #include // std::abs mitk::ShortestDistanceCalculator::ShortestDistanceCalculator() { } mitk::ShortestDistanceCalculator::~ShortestDistanceCalculator() { } vtkSmartPointer mitk::ShortestDistanceCalculator::calculateShortestDistance(vtkSmartPointer moving, vtkSmartPointer target) { MITK_INFO << "calculate shortest distance ..."; vtkSmartPointer distances = vtkSmartPointer::New(); double fromPoint[3] = { 0, 0, 0 }; int pointNumber = moving->GetPoints()->GetNumberOfPoints(); vtkSmartPointer implicitPolyDataDistance = vtkSmartPointer::New(); implicitPolyDataDistance->SetInput(target); //test double mean = 0; + double min = 0; + double max = 0; for (int i = 0; i < pointNumber; ++i) { moving->GetPoints()->GetPoint(i, fromPoint); double distance = implicitPolyDataDistance->FunctionValue(fromPoint[0], fromPoint[1], fromPoint[2]); // MITK_INFO << distance; - distances->InsertNextValue(distance); + //+4 for correct LookUpTable value + distances->InsertNextValue(distance + 4); mean += std::abs(distance); + if (distance < min) + { + min = distance; + } + else if (distance > max) + { + max = distance; + } } mean = mean / pointNumber; MITK_INFO << "The mean is: " << mean; + MITK_INFO << "Min Value is: " << min; + MITK_INFO << "Max Value is: " << max; return distances; } \ No newline at end of file diff --git a/Modules/SurfaceRegistration/src/mitkShapeComparisonManager.cpp b/Modules/SurfaceRegistration/src/mitkShapeComparisonManager.cpp index 024d527c90..1e75c3f902 100644 --- a/Modules/SurfaceRegistration/src/mitkShapeComparisonManager.cpp +++ b/Modules/SurfaceRegistration/src/mitkShapeComparisonManager.cpp @@ -1,135 +1,194 @@ /*=================================================================== 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. ===================================================================*/ #include + #include #include +#include +#include +#include #include #include - +#include +#include +#include +#include +#include #include #include mitk::ShapeComparisonManager::ShapeComparisonManager(mitk::Surface::Pointer moving, mitk::Surface::Pointer target) { this->m_MovingSurface = moving; this->m_TargetSurface = target; + createLookUpTable(); } mitk::ShapeComparisonManager::~ShapeComparisonManager() { m_MovingSurface->Delete(); m_TargetSurface->Delete(); - createLookUpTable(); - } mitk::Surface::Pointer mitk::ShapeComparisonManager::getRegisteredSurface() { return m_registeredSurface; } void mitk::ShapeComparisonManager::execute() { - // printPoints(); + // printPoints(); manageICPCalculation(); manageCalculateDistances(); } vtkSmartPointer mitk::ShapeComparisonManager::getTable() { return m_LookupTable; } +mitk::DataNode::Pointer mitk::ShapeComparisonManager::getColourTransformedDataNode() +{ + mitk::Surface::Pointer currentSurface; + if (m_registeredSurface == nullptr) + { + currentSurface = m_MovingSurface; + } + else + { + currentSurface = m_registeredSurface; + } + currentSurface->GetVtkPolyData()->GetPointData()->SetScalars(m_distances); + currentSurface->GetVtkPolyData()->GetPointData()->Update(); + + mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); + lut->SetVtkLookupTable(m_LookupTable); + //lut->SetType(mitk::LookupTable::JET); + mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(lut); + currentSurface->GetVtkPolyData()->GetPointData()->Update(); + mitk::DataNode::Pointer planeNodeTrans = mitk::DataNode::New(); + + planeNodeTrans->SetProperty("LookupTable", prop); + planeNodeTrans->SetBoolProperty("scalar visibility", true); + planeNodeTrans->SetBoolProperty("color mode", true); + planeNodeTrans->SetFloatProperty("ScalarsRangeMinimum", 0.0); + planeNodeTrans->SetFloatProperty("ScalarsRangeMaximum", 8.0); + // Configure material so that only scalar colors are shown + planeNodeTrans->SetColor(0.0f, 0.0f, 0.0f); + planeNodeTrans->SetOpacity(1.0f); + planeNodeTrans->SetFloatProperty("material.wireframeLineWidth", 2.0f); + //Set view of plane to VTK_SURFACE + planeNodeTrans->SetProperty("material.representation", mitk::VtkRepresentationProperty::New());//VTK_SURFACE currently default + // save colored surface node + planeNodeTrans->SetData(currentSurface); + planeNodeTrans->SetName("ColouredNode"); + + return planeNodeTrans; +} + + void mitk::ShapeComparisonManager::manageICPCalculation() { m_registeredSurface = mitk::Surface::New(); mitk::SurfaceRegistrationICP *registrationHelper = new SurfaceRegistrationICP(); m_registeredSurface = registrationHelper->CalculateICP(m_MovingSurface, m_TargetSurface); } void mitk::ShapeComparisonManager::manageCalculateDistances() { mitk::ShortestDistanceCalculator *distanceCalculator = new ShortestDistanceCalculator(); - m_distances = distanceCalculator->calculateShortestDistance(m_registeredSurface->GetVtkPolyData(), m_TargetSurface->GetVtkPolyData()); - //TODO - // m_TargetSurface->GetVtkPolyData()->GetCellData()->setScalars(m_distances); - //data - //aPlane->Update(); // Force an update so we can set cell data - //aPlane->GetOutput()->GetCellData()->SetScalars(cellData); - - - - //// Setup actor and mapper - //vtkSmartPointer mapper = - // vtkSmartPointer::New(); - //mapper->SetInputConnection(aPlane->GetOutputPort()); - //mapper->SetScalarRange(0, tableSize - 1); - //mapper->SetLookupTable(lut); - - //vtkSmartPointer actor = - // vtkSmartPointer::New(); - //actor->SetMapper(mapper) + if (m_registeredSurface) + { + m_distances = distanceCalculator->calculateShortestDistance(m_registeredSurface->GetVtkPolyData(), + m_TargetSurface->GetVtkPolyData()); + } + else + { + m_distances = distanceCalculator->calculateShortestDistance(m_MovingSurface->GetVtkPolyData(), + m_TargetSurface->GetVtkPolyData()); + } } void mitk::ShapeComparisonManager::createLookUpTable() { m_LookupTable = vtkSmartPointer::New(); - int tableSize = 10; + int tableSize = 3; m_LookupTable->SetNumberOfTableValues(tableSize); m_LookupTable->Build(); - // Fill in a few known colors, the rest will be generated if needed - m_LookupTable->SetTableValue(0, 0, 0, 0, 1); //Black - m_LookupTable->SetTableValue(1, 0.8900, 0.8100, 0.3400, 1); // Banana - m_LookupTable->SetTableValue(2, 1.0000, 0.3882, 0.2784, 1); // Tomato - m_LookupTable->SetTableValue(3, 0.9608, 0.8706, 0.7020, 1); // Wheat - m_LookupTable->SetTableValue(4, 0.9020, 0.9020, 0.9804, 1); // Lavender - m_LookupTable->SetTableValue(5, 1.0000, 0.4900, 0.2500, 1); // Flesh - m_LookupTable->SetTableValue(6, 0.5300, 0.1500, 0.3400, 1); // Raspberry - m_LookupTable->SetTableValue(7, 0.9804, 0.5020, 0.4471, 1); // Salmon - m_LookupTable->SetTableValue(8, 0.7400, 0.9900, 0.7900, 1); // Mint - m_LookupTable->SetTableValue(9, 0.2000, 0.6300, 0.7900, 1); // Peacock + m_LookupTable->SetNumberOfTableValues(9); + vtkSmartPointer valArray = vtkSmartPointer::New(); + vtkSmartPointer strgArray = vtkSmartPointer::New(); + strgArray->InsertNextValue("-4"); + valArray->InsertNextValue(vtkVariant(0.45)); + m_LookupTable->SetTableValue(0, 0.0, 0.0, 1.0); // blue = -4 mm + strgArray->InsertNextValue("-3"); + valArray->InsertNextValue(vtkVariant(1.35)); + m_LookupTable->SetTableValue(1, 0.0, 0.5, 1.0); // + strgArray->InsertNextValue("-2"); + valArray->InsertNextValue(vtkVariant(2.25)); + m_LookupTable->SetTableValue(2, 0.0, 1.0, 1.0); // turquoise = -2 mm + strgArray->InsertNextValue("-1"); + valArray->InsertNextValue(vtkVariant(3.15)); + m_LookupTable->SetTableValue(3, 0.0, 1.0, 0.5); // + strgArray->InsertNextValue("0"); + valArray->InsertNextValue(vtkVariant(4.05)); + m_LookupTable->SetTableValue(4, 0.0, 1.0, 0.0); // green = 0 mm + strgArray->InsertNextValue("1"); + valArray->InsertNextValue(vtkVariant(4.95)); + m_LookupTable->SetTableValue(5, 0.5, 1.0, 0.0); // + strgArray->InsertNextValue("2"); + valArray->InsertNextValue(vtkVariant(5.85)); + m_LookupTable->SetTableValue(6, 1.0, 1.0, 0.0); // yellow = 2 mm + strgArray->InsertNextValue("3"); + valArray->InsertNextValue(vtkVariant(6.75)); + m_LookupTable->SetTableValue(7, 1.0, 0.5, 0.0); // + strgArray->InsertNextValue("4"); + valArray->InsertNextValue(vtkVariant(7.65)); + m_LookupTable->SetTableValue(8, 1.0, 0.0, 0.0); // red = 4 mm + m_LookupTable->SetAnnotations(valArray, strgArray); + m_LookupTable->SetTableRange(0.0, 8.0); } void mitk::ShapeComparisonManager::printPoints() { MITK_INFO << "printing"; std::ofstream OutputFileMoving; OutputFileMoving.open("movingPoints.txt"); int pointNumber = m_MovingSurface->GetVtkPolyData()->GetPoints()->GetNumberOfPoints(); double printPoint[3] = { 0,0,0 }; for (int i = 0; i < pointNumber; ++i) { m_MovingSurface->GetVtkPolyData()->GetPoints()->GetPoint(i, printPoint); OutputFileMoving << printPoint[0]<<" " << printPoint[1] << " " << printPoint[2] <GetVtkPolyData()->GetPoints()->GetNumberOfPoints(); double printPoint2[3] = { 0,0,0 }; for (int i = 0; i < pointNumber2; ++i) { m_TargetSurface->GetVtkPolyData()->GetPoints()->GetPoint(i, printPoint2); OutputFileTarget << printPoint2[0] << " " << printPoint2[1] << " " << printPoint2[2] << std::endl; } OutputFileTarget.close(); } 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 9caebb2798..398b1ef491 100644 --- a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp +++ b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp @@ -1,270 +1,248 @@ /*========================================================================= 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 #include -#include // Includes for image casting between ITK and MITK: added after using Plugin Generator -#include // added for surface dynamic cast + +#include #include #include #include #include #include #include #include +#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include #include #include #include +#include +#include +#include +#include +#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) { + m_colorBarAnnotation = mitk::ColorBarAnnotation::New(); } QmitkSurfaceRegistration::~QmitkSurfaceRegistration() { // delete pointer objects m_movingSurfaceNode = nullptr; m_targetSurfaceNode = nullptr; } -// void QmitkSurfaceRegistration::SetFocus(){ m_Controls.groupBoxMoving->setFocus(); } QWidget * QmitkSurfaceRegistration::GetControls() { return nullptr; } 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())); mitk::RenderingManager::GetInstance()->SetDataStorage(this->GetDataStorageReference()->GetDataStorage()); mitk::RenderingManager::GetInstance()->InitializeViews(); + mitk::RenderingModeProperty::LOOKUPTABLE_COLOR;//works without? m_ParentWidget = parent; } 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.groupBoxMoving->setEnabled(true); m_Controls.groupBoxMappedData->setEnabled(false); if (m_useTestConfig) { m_Controls.pushButtonExecute->setEnabled(true); } else{ m_Controls.pushButtonExecute->setEnabled(false); } m_Controls.radioButtonMirroring->setEnabled(false); return; } else { if (nodes.size() == 1) { 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())); m_Controls.radioButtonMirroring->setEnabled(true); m_Controls.groupBoxTarget->setEnabled(true); m_Controls.groupBoxMappedData->setEnabled(true); m_Controls.groupBoxTarget->setEnabled(true); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } else { QMessageBox::information(nullptr, "Warning", "Are you sure? - I dont think this is a Surface! Try again!"); } } else if (nodes.size() == 2) { if (nodes[1].IsNotNull() && dynamic_cast(nodes[1]->GetData())) { MITK_INFO << "There are two images 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.textMappedDataName->setEnabled(true); m_Controls.pushButtonExecute->setEnabled(true); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); m_useTestConfig = false; } 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? } } } void QmitkSurfaceRegistration::doExecute() { if (m_useTestConfig) { setUpTestConfig(); } MITK_INFO << "pushButtonExecute clicked"; - performICPRegistration(); - showLookUpTable(); + + mitk::Surface::Pointer movingSurface = dynamic_cast (m_movingSurfaceNode->GetData()); + mitk::Surface::Pointer targetSurface = dynamic_cast (m_targetSurfaceNode->GetData()); + + mitk::ShapeComparisonManager *manager = new mitk::ShapeComparisonManager(movingSurface, targetSurface); + manager->execute(); + + mitk::DataNode::Pointer registeredNode = mitk::DataNode::New(); + registeredNode->SetData(manager->getRegisteredSurface()); + this->GetDataStorageReference()->GetDataStorage()->Add(registeredNode, m_movingSurfaceNode); + MITK_INFO << "registration done"; + + mitk::DataNode::Pointer colouredData = manager->getColourTransformedDataNode(); + this->GetDataStorage()->Add(colouredData); + this->GetDataStorageReference()->GetDataStorage()->Modified(); + + registeredNode->SetName("defaultMappedDataName"); + mitk::RenderingManager::GetInstance()->InitializeViews(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + + vtkSmartPointer lut = manager->getTable(); + showLookUpTable(lut); } void QmitkSurfaceRegistration::setUpTestConfig() { mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); mitk::IOUtil::Load("//ad/fs/E130-Projekte/BGLU/Fibula/Python/DataGAN/Registered/Surface/Tibia/tibia01_q0.stl", *ds); mitk::IOUtil::Load("//ad/fs/E130-Projekte/BGLU/Fibula/Python/DataGAN/Registered/Surface/Tibia/tibia02_q0.stl", *ds); m_movingSurfaceNode = ds->GetAll()->at(0); m_targetSurfaceNode = ds->GetAll()->at(1); this->GetDataStorageReference()->GetDataStorage()->Add(mitk::DataNode::Pointer(ds->GetAll()->at(0))); this->GetDataStorageReference()->GetDataStorage()->Add(mitk::DataNode::Pointer(ds->GetAll()->at(1))); this->GetDataStorageReference()->GetDataStorage()->Modified(); mitk::RenderingManager::GetInstance()->SetDataStorage(this->GetDataStorageReference()->GetDataStorage()); mitk::RenderingManager::GetInstance()->InitializeViews(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); m_Controls.pushButtonExecute->setEnabled(true); m_Controls.labelMovingSurfaceName->setText("tibia01_q0"); m_Controls.labelTargetSurfaceName->setText("tibia02_q0"); m_Controls.labelSelectMovingSurface->setText("Selected moving surface:"); m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); m_Controls.labelSelectTargetSurface->setText("Selected target surface:"); m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); this->GetDataStorageReference()->GetDataStorage()->Modified(); mitk::RenderingManager::GetInstance()->InitializeViews(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } - -void QmitkSurfaceRegistration::performICPRegistration() -{ - mitk::Surface::Pointer movingSurface = dynamic_cast (m_movingSurfaceNode->GetData()); - mitk::Surface::Pointer targetSurface = dynamic_cast (m_targetSurfaceNode->GetData()); - - mitk::ShapeComparisonManager *manager = new mitk::ShapeComparisonManager(movingSurface, targetSurface); - manager->execute(); - mitk::DataNode::Pointer registeredNode = mitk::DataNode::New(); - registeredNode->SetData(manager->getRegisteredSurface()); - this->GetDataStorageReference()->GetDataStorage()->Add(registeredNode, m_movingSurfaceNode); - - registeredNode->SetName("defaultMappedDataName"); - this->GetDataStorageReference()->GetDataStorage()->Modified(); - mitk::RenderingManager::GetInstance()->InitializeViews(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - MITK_INFO << "registration done"; -} - -void QmitkSurfaceRegistration::showLookUpTable() +void QmitkSurfaceRegistration::showLookUpTable(vtkSmartPointer lut) { - //// Create a ColorBarAnnotation - //mitk::ColorBarAnnotation::Pointer colorbar = mitk::ColorBarAnnotation::New(); - - //colorbar->SetDrawAnnotations(true); - //colorbar->SetOrientationToHorizontal(); - //vtkSmartPointer table = vtkSmartPointer::New(); - //table->SetTableRange(0.0, 10.0); - //// If you don't want to use the whole color range, you can use - //// SetValueRange, SetHueRange, and SetSaturationRange - //table->Build(); - //colorbar->SetLookupTable(table); - - //std::string rendererID = "axial"; - - //mitk::LayoutAnnotationRenderer::AddAnnotation( - // colorbar, rendererID); - - // Create a textAnnotation2D - - QString renderWindowName; - QHash renderWindows = this->GetRenderWindowPart()->GetQmitkRenderWindows(); - Q_FOREACH(QString renderWindow, renderWindows.keys()) - { - MITK_INFO << "BLABLABLA " << renderWindow; - renderWindowName = renderWindow; - } - - //http://docs.mitk.org/nightly/AnnotationModulePage.html - - mitk::TextAnnotation2D::Pointer textAnnotation = mitk::TextAnnotation2D::New(); - textAnnotation->SetText("Test!"); // set UTF-8 encoded text to render - textAnnotation->SetFontSize(40); - textAnnotation->SetColor(1, 0, 0); // Set text color to red - textAnnotation->SetOpacity(1); - // The position of the Annotation can be set to a fixed coordinate on the display. - mitk::Point2D pos; - pos[0] = 10; - pos[1] = 20; - textAnnotation->SetPosition2D(pos); - std::string rendererID = renderWindowName.toStdString(); - // The LayoutAnnotationRenderer can place the TextAnnotation2D at some defined corner positions + mitk::BaseRenderer::Pointer renderer = mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4")); + + mitk::LookupTable::Pointer mitkTable = mitk::LookupTable::New(); + mitkTable->SetVtkLookupTable(lut); + //mitkTable->SetType(mitk::LookupTable::JET); + mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(mitkTable); + + m_colorBarAnnotation->SetProperty("ColorBarAnnotation.LookupTable", prop.GetPointer()); + m_colorBarAnnotation->SetNumberOfLabels(9); + m_colorBarAnnotation->SetAnnotationTextScaling(true); + m_colorBarAnnotation->SetDrawAnnotations(true); + m_colorBarAnnotation->SetDrawTickLabels(false); mitk::LayoutAnnotationRenderer::AddAnnotation( - textAnnotation, rendererID, mitk::LayoutAnnotationRenderer::TopLeft, 5, 5, 1); - - - MITK_INFO << "is there a lookuptable?"; - -} + m_colorBarAnnotation, renderer, mitk::LayoutAnnotationRenderer::Right, 5, 5, 1); +} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h index 5272c7dc6e..7408e31d75 100644 --- a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h +++ b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h @@ -1,112 +1,117 @@ /*========================================================================= 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. =========================================================================*/ #ifndef QmitkSurfaceRegistration_h #define QmitkSurfaceRegistration_h #include #ifdef WIN32 #pragma warning( disable : 4250 ) #endif #include "QVTKWidget.h" #include "QmitkRegisterClasses.h" #include #include "ui_SurfaceRegistrationControls.h" #include "usServiceRegistration.h" #include "mitkAnnotation.h" +#include "mitkColorBarAnnotation.h" +#include +#include /*! @brief QmitkSurfaceRegistrationView \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkSurfaceRegistration : 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) private: Q_OBJECT public: /*! @brief Constructor. Called by SampleApp (or other apps that use functionalities) */ QmitkSurfaceRegistration(QObject *parent = 0); virtual ~QmitkSurfaceRegistration(); static const std::string VIEW_ID; virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus() override; ///*! //@brief Creates the Qt connections needed //*/ QWidget* GetControls(); /// @brief Called when the user clicks the GUI button protected slots: void doExecute(); protected: // /*! //@brief called by QmitkFunctionality when DataManager's selection has changed // */ void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList& nodes) override; private: /*! * The parent QWidget */ QWidget* m_ParentWidget; mitk::BaseRenderer *m_Renderer; /*! * @brief A pointer to the node of the moving surface. */ mitk::DataNode::Pointer m_movingSurfaceNode; /*! * @brief A pointer to the node of the target surface. */ mitk::DataNode::Pointer m_targetSurfaceNode; Ui::SurfaceRegistrationControls m_Controls; + mitk::ColorBarAnnotation::Pointer m_colorBarAnnotation; + bool m_useTestConfig = true; void performICPRegistration(); void setUpTestConfig(); - void showLookUpTable(); + void showLookUpTable(vtkSmartPointer lut); }; #endif // QmitkSurfaceRegistration_h \ No newline at end of file