34 #include <itkCommand.h>
35 #include <vtkProperty.h>
37 #include <QMessageBox>
41 m_SurfaceBasedInterpolatorController(
mitk::SurfaceBasedInterpolationController::GetInstance()),
49 Q_ASSERT(m_ToolManager);
61 m_SurfaceInterpolationInfoChangedObserverTag =
62 m_SurfaceBasedInterpolatorController->AddObserver(itk::ModifiedEvent(), command);
65 m_InterpolatedSurfaceNode->SetName(
"Surface Interpolation feedback");
70 m_InterpolatedSurfaceNode->SetVisibility(
false);
73 m_3DContourNode->SetName(
"Drawn Contours");
79 m_3DContourNode->SetVisibility(
81 m_3DContourNode->SetVisibility(
83 m_3DContourNode->SetVisibility(
85 m_3DContourNode->SetVisibility(
92 m_Timer =
new QTimer(
this);
96 m_Controls.m_cbShowPositionNodes->setEnabled(
false);
98 this->setEnabled(
false);
103 m_DataStorage = &storage;
111 if (m_DataStorage->Exists(m_3DContourNode))
112 m_DataStorage->Remove(m_3DContourNode);
114 if (m_DataStorage->Exists(m_InterpolatedSurfaceNode))
115 m_DataStorage->Remove(m_InterpolatedSurfaceNode);
118 m_SurfaceBasedInterpolatorController->RemoveObserver(m_SurfaceInterpolationInfoChangedObserverTag);
125 if (m_InterpolatedSurfaceNode.IsNotNull())
126 m_InterpolatedSurfaceNode->SetVisibility(status);
128 if (m_3DContourNode.IsNotNull())
129 m_3DContourNode->SetVisibility(
137 mitk::Surface::Pointer interpolatedSurface = m_SurfaceBasedInterpolatorController->GetInterpolationResult();
139 if (interpolatedSurface.IsNotNull())
141 m_InterpolatedSurfaceNode->SetData(interpolatedSurface);
142 m_3DContourNode->SetData(m_SurfaceBasedInterpolatorController->GetContoursAsSurface());
147 m_InterpolatedSurfaceNode->SetData(NULL);
148 m_3DContourNode->SetData(NULL);
158 for (mitk::DataStorage::SetOfObjects::ConstIterator it = allContourMarkers->Begin(); it != allContourMarkers->End();
166 unsigned int numberOfExistingTools = m_ToolManager->
GetTools().size();
168 for (
unsigned int i = 0; i < numberOfExistingTools; i++)
172 if (manualSegmentationTool)
174 manualSegmentationTool->SetShowMarkerNodes(state);
194 float currentColor[3];
195 m_InterpolatedSurfaceNode->GetColor(currentColor);
197 float yellow[3] = {255.0, 255.0, 0.0};
199 if (currentColor[2] == yellow[2])
207 m_InterpolatedSurfaceNode->Update();
217 this->setEnabled(
false);
226 this->setEnabled(
false);
232 this->setEnabled(
false);
236 m_WorkingImage = workingImage;
238 this->setEnabled(
true);
243 m_SurfaceBasedInterpolatorController->Interpolate();
248 Q_ASSERT(m_ToolManager);
255 m_Controls.m_cbShowPositionNodes->setEnabled(enabled);
262 for (
unsigned int i = 0; i < m_ToolManager->
GetTools().size(); i++)
271 if (!m_DataStorage->Exists(m_InterpolatedSurfaceNode))
273 m_DataStorage->Add(m_InterpolatedSurfaceNode);
276 if (!m_DataStorage->Exists(m_3DContourNode))
278 m_DataStorage->Add(m_3DContourNode);
281 mitk::Vector3D spacing = m_WorkingImage->GetGeometry(0)->GetSpacing();
282 double minSpacing(100);
283 double maxSpacing(0);
284 for (
int i = 0; i < 3; i++)
286 if (spacing[i] < minSpacing)
288 minSpacing = spacing[i];
290 else if (spacing[i] > maxSpacing)
292 maxSpacing = spacing[i];
296 m_SurfaceBasedInterpolatorController->SetWorkingImage(m_WorkingImage);
297 m_SurfaceBasedInterpolatorController->SetActiveLabel(m_WorkingImage->GetActiveLabel()->GetValue());
298 m_SurfaceBasedInterpolatorController->SetMaxSpacing(maxSpacing);
299 m_SurfaceBasedInterpolatorController->SetMinSpacing(minSpacing);
300 m_SurfaceBasedInterpolatorController->SetDistanceImageVolume(50000);
302 int ret = QMessageBox::Yes;
304 if (m_SurfaceBasedInterpolatorController->EstimatePortionOfNeededMemory() > 0.5)
307 msgBox.setText(
"Due to short handed system memory the 3D interpolation may be very slow!");
308 msgBox.setInformativeText(
"Are you sure you want to activate the 3D interpolation?");
309 msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
313 if (m_Watcher.isRunning())
314 m_Watcher.waitForFinished();
316 if (ret == QMessageBox::Yes)
319 m_Watcher.setFuture(m_Future);
324 if (m_DataStorage->Exists(m_InterpolatedSurfaceNode))
326 m_DataStorage->Remove(m_InterpolatedSurfaceNode);
328 if (m_DataStorage->Exists(m_3DContourNode))
330 m_DataStorage->Remove(m_3DContourNode);
336 m_Activated = enabled;
343 if (m_InterpolatedSurfaceNode.IsNotNull() && m_InterpolatedSurfaceNode->GetData())
354 if (m_Watcher.isRunning())
355 m_Watcher.waitForFinished();
358 m_Watcher.setFuture(m_Future);
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
static vtkRenderWindow * GetRenderWindowByName(const std::string &name)
DataCollection - Class to facilitate loading/accessing structured data.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
Constants for most interaction classes, due to the generic StateMachines.
itk::SmartPointer< const Self > ConstPointer
mitk::DataStorage::Pointer m_DataStorage
static RenderingManager * GetInstance()
static Pointer New(const char *_arg)
void RequestUpdate(vtkRenderWindow *renderWindow)
static UndoModel * GetCurrentUndoModel()
gives access to the currently used UndoModel Introduced to access special functions of more specific ...
LabelSetImage class for handling labels and layers in a segmentation session.
virtual void Clear()=0
clears undo and Redolist
unsigned int GetDimension() const
Get dimension of the image.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.