Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
Step6.cpp
/*===================================================================
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 "Step6.h"
#include "mitkProperties.h"
#include "mitkPointSet.h"
#include <mitkIOUtil.h>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QPushButton>
#include <QVBoxLayout>
//##Documentation
//## @brief Start region-grower at interactively added points
Step6::Step6(int argc, char *argv[], QWidget *parent) : QWidget(parent)
{
// load data as in the previous steps; a reference to the first loaded
// image is kept in the member m_FirstImage and used as input for the
// region growing
Load(argc, argv);
}
{
// setup the widgets as in the previous steps, but with an additional
// QVBox for a button to start the segmentation
this->SetupWidgets();
// Create controlsParent widget with horizontal layout
QWidget *controlsParent = new QWidget(this);
this->layout()->addWidget(controlsParent);
QHBoxLayout *hlayout = new QHBoxLayout(controlsParent);
hlayout->setSpacing(2);
QLabel *labelThresholdMin = new QLabel("Lower Threshold:", controlsParent);
hlayout->addWidget(labelThresholdMin);
m_LineEditThresholdMin = new QLineEdit("-1000", controlsParent);
hlayout->addWidget(m_LineEditThresholdMin);
QLabel *labelThresholdMax = new QLabel("Upper Threshold:", controlsParent);
hlayout->addWidget(labelThresholdMax);
m_LineEditThresholdMax = new QLineEdit("-400", controlsParent);
hlayout->addWidget(m_LineEditThresholdMax);
// create button to start the segmentation and connect its clicked()
// signal to method StartRegionGrowing
QPushButton *startButton = new QPushButton("start region growing", controlsParent);
hlayout->addWidget(startButton);
connect(startButton, SIGNAL(clicked()), this, SLOT(StartRegionGrowing()));
if (m_FirstImage.IsNull())
startButton->setEnabled(false);
// as in Step5, create PointSet (now as a member m_Seeds) and
// associate a interactor to it
pointSetNode->SetData(m_Seeds);
pointSetNode->SetProperty("layer", mitk::IntProperty::New(2));
m_DataStorage->Add(pointSetNode);
// Create PointSetDataInteractor
interactor->LoadStateMachine("PointSet.xml");
interactor->SetEventConfig("PointSetConfig.xml");
interactor->SetDataNode(pointSetNode);
}
{
return m_LineEditThresholdMin->text().toInt();
}
{
return m_LineEditThresholdMax->text().toInt();
}
{
}
void Step6::Load(int argc, char *argv[])
{
//*************************************************************************
// Part I: Basic initialization
//*************************************************************************
//*************************************************************************
// Part II: Create some data by reading files
//*************************************************************************
int i;
for (i = 1; i < argc; ++i)
{
// For testing
if (strcmp(argv[i], "-testing") == 0)
continue;
// Load datanode (eg. many image formats, surface formats, etc.)
if (dataNodes->empty())
{
fprintf(stderr, "Could not open file %s \n\n", argv[i]);
exit(2);
}
mitk::Image::Pointer image = dynamic_cast<mitk::Image *>(dataNodes->at(0)->GetData());
if ((m_FirstImage.IsNull()) && (image.IsNotNull()))
m_FirstImage = image;
}
}
{
//*************************************************************************
// Part I: Create windows and pass the datastorage to it
//*************************************************************************
// Create toplevel widget with vertical layout
QVBoxLayout *vlayout = new QVBoxLayout(this);
vlayout->setMargin(0);
vlayout->setSpacing(2);
// Create viewParent widget with horizontal layout
QWidget *viewParent = new QWidget(this);
vlayout->addWidget(viewParent);
QHBoxLayout *hlayout = new QHBoxLayout(viewParent);
hlayout->setMargin(0);
hlayout->setSpacing(2);
//*************************************************************************
// Part Ia: 3D view
//*************************************************************************
// Create a renderwindow
QmitkRenderWindow *renderWindow = new QmitkRenderWindow(viewParent);
hlayout->addWidget(renderWindow);
// Tell the renderwindow which (part of) the tree to render
// Use it as a 3D view
// Reposition the camera to include all visible actors
renderWindow->GetRenderer()->GetVtkRenderer()->ResetCamera();
//*************************************************************************
// Part Ib: 2D view for slicing axially
//*************************************************************************
// Create QmitkSliceWidget, which is based on the class
// QmitkRenderWindow, but additionally provides sliders
QmitkSliceWidget *view2 = new QmitkSliceWidget(viewParent);
hlayout->addWidget(view2);
// Tell the QmitkSliceWidget which (part of) the tree to render.
// By default, it slices the data axially
// We want to see the position of the slice in 2D and the
// slice itself in 3D: add it to the tree!
//*************************************************************************
// Part Ic: 2D view for slicing sagitally
//*************************************************************************
// Create QmitkSliceWidget, which is based on the class
// QmitkRenderWindow, but additionally provides sliders
QmitkSliceWidget *view3 = new QmitkSliceWidget(viewParent);
hlayout->addWidget(view3);
// Tell the QmitkSliceWidget which (part of) the tree to render
// and to slice sagitally
// We want to see the position of the slice in 2D and the
// slice itself in 3D: add it to the tree!
//*************************************************************************
// Part II: handle updates: To avoid unnecessary updates, we have to
//*************************************************************************
// define when to update. The RenderingManager serves this purpose, and
// each RenderWindow has to be registered to it.
/*mitk::RenderingManager *renderingManager =
mitk::RenderingManager::GetInstance();
renderingManager->AddRenderWindow( renderWindow );
renderingManager->AddRenderWindow( view2->GetRenderWindow() );
renderingManager->AddRenderWindow( view3->GetRenderWindow() );*/
}