Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkSliceBasedInterpolatorWidget.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <mitkColorProperty.h>
20 #include <mitkDiffSliceOperation.h>
22 #include <mitkExtractSliceFilter.h>
23 #include <mitkImageAccessByItk.h>
24 #include <mitkImageCast.h>
25 #include <mitkImageTimeSelector.h>
26 #include <mitkLabelSetImage.h>
27 #include <mitkOperationEvent.h>
28 #include <mitkProgressBar.h>
29 #include <mitkProperties.h>
30 #include <mitkRenderingManager.h>
31 #include <mitkSegTool2D.h>
33 #include <mitkToolManager.h>
35 #include <mitkUndoController.h>
36 #include <mitkVtkImageOverwrite.h>
37 
38 #include "QmitkStdMultiWidget.h"
39 
40 #include <itkCommand.h>
41 
42 #include <QApplication>
43 #include <QCursor>
44 #include <QMenu>
45 #include <QMessageBox>
46 
48  : QWidget(parent),
49  m_SliceInterpolatorController(mitk::SliceBasedInterpolationController::New()),
50  m_ToolManager(NULL),
51  m_Activated(false),
52  m_DataStorage(NULL),
53  m_LastSNC(0),
54  m_LastSliceIndex(0)
55 {
56  m_Controls.setupUi(this);
57 
59  Q_ASSERT(m_ToolManager);
60 
63 
64  connect(m_Controls.m_btStart, SIGNAL(toggled(bool)), this, SLOT(OnToggleWidgetActivation(bool)));
65  connect(m_Controls.m_btApplyForCurrentSlice, SIGNAL(clicked()), this, SLOT(OnAcceptInterpolationClicked()));
66  connect(m_Controls.m_btApplyForAllSlices, SIGNAL(clicked()), this, SLOT(OnAcceptAllInterpolationsClicked()));
67 
70  command->SetCallbackFunction(this, &QmitkSliceBasedInterpolatorWidget::OnSliceInterpolationInfoChanged);
71  m_InterpolationInfoChangedObserverTag = m_SliceInterpolatorController->AddObserver(itk::ModifiedEvent(), command);
72 
73  // feedback node and its visualization properties
74  m_PreviewNode = mitk::DataNode::New();
75  m_PreviewNode->SetName("3D tool preview");
76 
77  m_PreviewNode->SetProperty("texture interpolation", mitk::BoolProperty::New(false));
78  m_PreviewNode->SetProperty("layer", mitk::IntProperty::New(100));
79  m_PreviewNode->SetProperty("binary", mitk::BoolProperty::New(true));
80  m_PreviewNode->SetProperty("outline binary", mitk::BoolProperty::New(true));
81  m_PreviewNode->SetProperty("outline binary shadow", mitk::BoolProperty::New(true));
82  m_PreviewNode->SetProperty("helper object", mitk::BoolProperty::New(true));
83  m_PreviewNode->SetOpacity(1.0);
84  m_PreviewNode->SetColor(0.0, 1.0, 0.0);
85 
86  m_Controls.m_btApplyForCurrentSlice->setEnabled(false);
87  m_Controls.m_btApplyForAllSlices->setEnabled(false);
88 
89  this->setEnabled(false);
90 }
91 
93 {
96 
97  foreach (mitk::SliceNavigationController *slicer, m_ControllerToSliceObserverTag.keys())
98  {
99  slicer->RemoveObserver(m_ControllerToDeleteObserverTag.take(slicer));
100  slicer->RemoveObserver(m_ControllerToTimeObserverTag.take(slicer));
101  slicer->RemoveObserver(m_ControllerToSliceObserverTag.take(slicer));
102  }
103 
105 
106  // remove observer
107  m_SliceInterpolatorController->RemoveObserver(m_InterpolationInfoChangedObserverTag);
108 }
109 
112 {
113  ActionToSliceDimensionMapType actionToSliceDimension;
114  foreach (mitk::SliceNavigationController *slicer, m_ControllerToDeleteObserverTag.keys())
115  {
116  std::string name = slicer->GetRenderer()->GetName();
117  if (name == "stdmulti.widget1")
118  name = "Axial (red window)";
119  else if (name == "stdmulti.widget2")
120  name = "Sagittal (green window)";
121  else if (name == "stdmulti.widget3")
122  name = "Coronal (blue window)";
123  actionToSliceDimension[new QAction(QString::fromStdString(name), 0)] = slicer;
124  }
125 
126  return actionToSliceDimension;
127 }
128 
130 {
131  m_DataStorage = &storage;
132 }
133 
135  const QList<mitk::SliceNavigationController *> &controllers)
136 {
137  Q_ASSERT(!controllers.empty());
138 
139  // connect to the slice navigation controller. after each change, call the interpolator
140  foreach (mitk::SliceNavigationController *slicer, controllers)
141  {
142  // Has to be initialized
143  m_LastSNC = slicer;
144 
145  m_TimeStep.insert(slicer, slicer->GetTime()->GetPos());
146 
149  deleteCommand->SetCallbackFunction(this, &QmitkSliceBasedInterpolatorWidget::OnSliceNavigationControllerDeleted);
150  m_ControllerToDeleteObserverTag.insert(slicer, slicer->AddObserver(itk::DeleteEvent(), deleteCommand));
151 
154  timeChangedCommand->SetCallbackFunction(this, &QmitkSliceBasedInterpolatorWidget::OnTimeChanged);
155  m_ControllerToTimeObserverTag.insert(
156  slicer,
157  slicer->AddObserver(mitk::SliceNavigationController::TimeSlicedGeometryEvent(NULL, 0), timeChangedCommand));
158 
161  sliceChangedCommand->SetCallbackFunction(this, &QmitkSliceBasedInterpolatorWidget::OnSliceChanged);
162  m_ControllerToSliceObserverTag.insert(
163  slicer, slicer->AddObserver(mitk::SliceNavigationController::GeometrySliceEvent(NULL, 0), sliceChangedCommand));
164  }
165 
167 }
168 
170 {
171  mitk::DataNode *workingNode = this->m_ToolManager->GetWorkingData(0);
172  if (!workingNode)
173  {
174  this->setEnabled(false);
175  return;
176  }
177 
178  mitk::LabelSetImage *workingImage = dynamic_cast<mitk::LabelSetImage *>(workingNode->GetData());
179  // TODO adapt tool manager so that this check is done there, e.g. convenience function
180  // Q_ASSERT(workingImage);
181  if (!workingImage)
182  {
183  this->setEnabled(false);
184  return;
185  }
186 
187  if (workingImage->GetDimension() > 4 || workingImage->GetDimension() < 3)
188  {
189  this->setEnabled(false);
190  return;
191  }
192 
193  m_WorkingImage = workingImage;
194 
195  this->setEnabled(true);
196 }
197 
198 void QmitkSliceBasedInterpolatorWidget::OnTimeChanged(itk::Object *sender, const itk::EventObject &e)
199 {
200  // Check if we really have a GeometryTimeEvent
201  if (!dynamic_cast<const mitk::SliceNavigationController::GeometryTimeEvent *>(&e))
202  return;
203 
204  mitk::SliceNavigationController *slicer = dynamic_cast<mitk::SliceNavigationController *>(sender);
205  Q_ASSERT(slicer);
206 
207  m_TimeStep[slicer] /* = event.GetPos()*/;
208 
209  // TODO Macht das hier wirklich Sinn????
210  if (m_LastSNC == slicer)
211  {
212  slicer->SendSlice(); // will trigger a new interpolation
213  }
214 }
215 
216 void QmitkSliceBasedInterpolatorWidget::OnSliceChanged(itk::Object *sender, const itk::EventObject &e)
217 {
218  if (m_Activated && m_WorkingImage.IsNotNull())
219  {
220  // Check whether we really have a GeometrySliceEvent
221  if (!dynamic_cast<const mitk::SliceNavigationController::GeometrySliceEvent *>(&e))
222  return;
223 
224  mitk::SliceNavigationController *slicer = dynamic_cast<mitk::SliceNavigationController *>(sender);
225  if (slicer)
226  {
227  this->TranslateAndInterpolateChangedSlice(e, slicer);
229  // slicer->GetRenderer()->RequestUpdate();
230  }
231  }
232 }
233 
236 {
237  if (m_Activated && m_WorkingImage.IsNotNull())
238  {
239  const mitk::SliceNavigationController::GeometrySliceEvent &geometrySliceEvent =
241  mitk::TimeGeometry *timeGeometry = geometrySliceEvent.GetTimeGeometry();
242  if (timeGeometry && m_TimeStep.contains(slicer))
243  {
244  mitk::SlicedGeometry3D *slicedGeometry =
245  dynamic_cast<mitk::SlicedGeometry3D *>(timeGeometry->GetGeometryForTimeStep(m_TimeStep[slicer]).GetPointer());
246  if (slicedGeometry)
247  {
248  mitk::PlaneGeometry *plane = slicedGeometry->GetPlaneGeometry(geometrySliceEvent.GetPos());
249  if (plane)
250  {
251  m_LastSNC = slicer;
252  this->Interpolate(plane, m_TimeStep[slicer], slicer);
253  }
254  }
255  }
256  }
257 }
258 
260  unsigned int timeStep,
262 {
263  int clickedSliceDimension(-1);
264  int clickedSliceIndex(-1);
265 
266  // calculate real slice position, i.e. slice of the image and not slice of the TimeSlicedGeometry
267  // see if timestep is needed here
268  mitk::SegTool2D::DetermineAffectedImageSlice(m_WorkingImage, plane, clickedSliceDimension, clickedSliceIndex);
269 
270  mitk::Image::Pointer interpolation =
271  m_SliceInterpolatorController->Interpolate(clickedSliceDimension, clickedSliceIndex, plane, timeStep);
272 
273  m_PreviewNode->SetData(interpolation);
274 
275  const mitk::Color &color = m_WorkingImage->GetActiveLabel()->GetColor();
276  m_PreviewNode->SetColor(color);
277 
278  m_LastSNC = slicer;
279  m_LastSliceIndex = clickedSliceIndex;
280 }
281 
283 {
284  unsigned int timeStep = m_LastSNC->GetTime()->GetPos();
285 
286  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk
287  // reslicer
288  vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New();
289  // set to false to extract a slice
290  reslice->SetOverwriteMode(false);
291  reslice->Modified();
292 
293  // use ExtractSliceFilter with our specific vtkImageReslice for overwriting and extracting
295  extractor->SetInput(m_WorkingImage);
296  extractor->SetTimeStep(timeStep);
297  extractor->SetWorldGeometry(planeGeometry);
298  extractor->SetVtkOutputRequest(false);
299  extractor->SetResliceTransformByGeometry(m_WorkingImage->GetTimeGeometry()->GetGeometryForTimeStep(timeStep));
300 
301  extractor->Modified();
302 
303  try
304  {
305  extractor->Update();
306  }
307  catch (itk::ExceptionObject &excep)
308  {
309  MITK_ERROR << "Exception caught: " << excep.GetDescription();
310  return NULL;
311  }
312 
313  mitk::Image::Pointer slice = extractor->GetOutput();
314 
315  // specify the undo operation with the non edited slice
316  // MLI TODO added code starts here
317  mitk::SlicedGeometry3D *sliceGeometry = dynamic_cast<mitk::SlicedGeometry3D *>(slice->GetGeometry());
318  // m_undoOperation = new mitk::DiffSliceOperation(m_WorkingImage, extractor->GetVtkOutput(), slice->GetGeometry(),
319  // timeStep, const_cast<mitk::PlaneGeometry*>(planeGeometry));
320  // added code ends here
321  m_undoOperation = new mitk::DiffSliceOperation(
322  m_WorkingImage, extractor->GetOutput(), sliceGeometry, timeStep, const_cast<mitk::PlaneGeometry *>(planeGeometry));
323 
324  slice->DisconnectPipeline();
325 
326  return slice;
327 }
328 
330 {
331  Q_ASSERT(m_ToolManager);
332 
333  mitk::DataNode *workingNode = m_ToolManager->GetWorkingData(0);
334  if (!workingNode)
335  return;
336 
337  m_Controls.m_btApplyForCurrentSlice->setEnabled(enabled);
338  m_Controls.m_btApplyForAllSlices->setEnabled(enabled);
339 
340  if (enabled)
341  m_Controls.m_btStart->setText("Stop");
342  else
343  m_Controls.m_btStart->setText("Start");
344 
345  unsigned int numberOfExistingTools = m_ToolManager->GetTools().size();
346  for (unsigned int i = 0; i < numberOfExistingTools; i++)
347  {
348  // mitk::SegTool2D* tool = dynamic_cast<mitk::SegTool2D*>(m_ToolManager->GetToolById(i));
349  // MLI TODO
350  // if (tool) tool->SetEnable2DInterpolation( enabled );
351  }
352 
353  if (enabled)
354  {
355  if (!m_DataStorage->Exists(m_PreviewNode))
356  {
357  m_DataStorage->Add(m_PreviewNode);
358  }
359 
360  m_SliceInterpolatorController->SetWorkingImage(m_WorkingImage);
361  this->UpdateVisibleSuggestion();
362  }
363  else
364  {
365  if (m_DataStorage->Exists(m_PreviewNode))
366  {
367  m_DataStorage->Remove(m_PreviewNode);
368  }
369 
371  }
372 
373  m_Activated = enabled;
374 
376 }
377 
378 template <typename TPixel, unsigned int VImageDimension>
379 void QmitkSliceBasedInterpolatorWidget::WritePreviewOnWorkingImage(itk::Image<TPixel, VImageDimension> *targetSlice,
380  const mitk::Image *sourceSlice,
381  int overwritevalue)
382 {
383  typedef itk::Image<TPixel, VImageDimension> ImageType;
384 
385  typename ImageType::Pointer sourceSliceITK;
386  mitk::CastToItkImage(sourceSlice, sourceSliceITK);
387 
388  // now the original slice and the ipSegmentation-painted slice are in the same format, and we can just copy all pixels
389  // that are non-zero
390  typedef itk::ImageRegionIterator<ImageType> OutputIteratorType;
391  typedef itk::ImageRegionConstIterator<ImageType> InputIteratorType;
392 
393  InputIteratorType inputIterator(sourceSliceITK, sourceSliceITK->GetLargestPossibleRegion());
394  OutputIteratorType outputIterator(targetSlice, targetSlice->GetLargestPossibleRegion());
395 
396  outputIterator.GoToBegin();
397  inputIterator.GoToBegin();
398 
399  int activePixelValue = m_WorkingImage->GetActiveLabel()->GetValue();
400 
401  if (activePixelValue == 0) // if exterior is the active label
402  {
403  while (!outputIterator.IsAtEnd())
404  {
405  if (inputIterator.Get() != 0)
406  {
407  outputIterator.Set(overwritevalue);
408  }
409  ++outputIterator;
410  ++inputIterator;
411  }
412  }
413  else if (overwritevalue != 0) // if we are not erasing
414  {
415  while (!outputIterator.IsAtEnd())
416  {
417  int targetValue = static_cast<int>(outputIterator.Get());
418  if (inputIterator.Get() != 0)
419  {
420  if (!m_WorkingImage->GetLabel(targetValue)->GetLocked())
421  outputIterator.Set(overwritevalue);
422  }
423 
424  ++outputIterator;
425  ++inputIterator;
426  }
427  }
428  else // if we are erasing
429  {
430  while (!outputIterator.IsAtEnd())
431  {
432  const int targetValue = outputIterator.Get();
433  if (inputIterator.Get() != 0)
434  {
435  if (targetValue == activePixelValue)
436  outputIterator.Set(overwritevalue);
437  }
438 
439  ++outputIterator;
440  ++inputIterator;
441  }
442  }
443 }
444 
446 {
447  if (m_WorkingImage.IsNotNull() && m_PreviewNode->GetData())
448  {
449  const mitk::PlaneGeometry *planeGeometry = m_LastSNC->GetCurrentPlaneGeometry();
450  if (!planeGeometry)
451  return;
452 
453  mitk::Image::Pointer sliceImage = this->GetWorkingSlice(planeGeometry);
454  if (sliceImage.IsNull())
455  return;
456 
457  mitk::Image::Pointer previewSlice = dynamic_cast<mitk::Image *>(m_PreviewNode->GetData());
458 
460  sliceImage, WritePreviewOnWorkingImage, 2, previewSlice, m_WorkingImage->GetActiveLabel()->GetValue());
461 
462  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk
463  // reslicer
464  vtkSmartPointer<mitkVtkImageOverwrite> overwrite = vtkSmartPointer<mitkVtkImageOverwrite>::New();
465  overwrite->SetInputSlice(sliceImage->GetVtkImageData());
466  // set overwrite mode to true to write back to the image volume
467  overwrite->SetOverwriteMode(true);
468  overwrite->Modified();
469 
470  unsigned int timeStep = m_LastSNC->GetTime()->GetPos();
471 
473  extractor->SetInput(m_WorkingImage);
474  extractor->SetTimeStep(timeStep);
475  extractor->SetWorldGeometry(planeGeometry);
476  extractor->SetVtkOutputRequest(false);
477  extractor->SetResliceTransformByGeometry(m_WorkingImage->GetTimeGeometry()->GetGeometryForTimeStep(timeStep));
478 
479  extractor->Modified();
480 
481  try
482  {
483  extractor->Update();
484  }
485  catch (itk::ExceptionObject &excep)
486  {
487  MITK_ERROR << "Exception caught: " << excep.GetDescription();
488  return;
489  }
490 
491  // the image was modified within the pipeline, but not marked so
492  m_WorkingImage->Modified();
493 
494  int clickedSliceDimension(-1);
495  int clickedSliceIndex(-1);
496 
498  m_WorkingImage, planeGeometry, clickedSliceDimension, clickedSliceIndex);
499 
500  m_SliceInterpolatorController->SetChangedSlice(sliceImage, clickedSliceDimension, clickedSliceIndex, timeStep);
501 
502  // specify the undo operation with the edited slice
503  // MLI TODO added code starts here
504  mitk::SlicedGeometry3D *sliceGeometry = dynamic_cast<mitk::SlicedGeometry3D *>(sliceImage->GetGeometry());
505  // m_undoOperation = new mitk::DiffSliceOperation(m_WorkingImage, extractor->GetVtkOutput(), slice->GetGeometry(),
506  // timeStep, const_cast<mitk::PlaneGeometry*>(planeGeometry));
507  // added code ends here
508  m_doOperation = new mitk::DiffSliceOperation(m_WorkingImage,
509  extractor->GetOutput(),
510  sliceGeometry,
511  timeStep,
512  const_cast<mitk::PlaneGeometry *>(planeGeometry));
513 
514  // create an operation event for the undo stack
515  mitk::OperationEvent *undoStackItem = new mitk::OperationEvent(
516  mitk::DiffSliceOperationApplier::GetInstance(), m_doOperation, m_undoOperation, "Slice Interpolation");
517 
518  // add it to the undo controller
520 
521  // clear the pointers as the operation are stored in the undo controller and also deleted from there
522  m_undoOperation = NULL;
523  m_doOperation = NULL;
524 
525  m_PreviewNode->SetData(NULL);
526 
528  }
529 }
530 
532 {
533  // Since we need to shift the plane it must be clone so that the original plane isn't altered
534  mitk::PlaneGeometry::Pointer reslicePlane = slicer->GetCurrentPlaneGeometry()->Clone();
535  unsigned int timeStep = slicer->GetTime()->GetPos();
536 
537  int sliceDimension(-1);
538  int sliceIndex(-1);
539 
540  mitk::SegTool2D::DetermineAffectedImageSlice(m_WorkingImage, reslicePlane, sliceDimension, sliceIndex);
541 
542  unsigned int zslices = m_WorkingImage->GetDimension(sliceDimension);
543 
546 
547  mitk::Point3D origin = reslicePlane->GetOrigin();
548 
549  for (unsigned int idx = 0; idx < zslices; ++idx)
550  {
551  // Transforming the current origin of the reslice plane
552  // so that it matches the one of the next slice
553  m_WorkingImage->GetSlicedGeometry()->WorldToIndex(origin, origin);
554  origin[sliceDimension] = idx;
555  m_WorkingImage->GetSlicedGeometry()->IndexToWorld(origin, origin);
556  reslicePlane->SetOrigin(origin);
557 
558  mitk::Image::Pointer interpolation =
559  m_SliceInterpolatorController->Interpolate(sliceDimension, idx, reslicePlane, timeStep);
560 
561  if (interpolation.IsNotNull())
562  {
563  m_PreviewNode->SetData(interpolation);
564 
565  mitk::Image::Pointer sliceImage = this->GetWorkingSlice(reslicePlane);
566  if (sliceImage.IsNull())
567  return;
568 
570  sliceImage, WritePreviewOnWorkingImage, 2, interpolation, m_WorkingImage->GetActiveLabel()->GetValue());
571 
572  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk
573  // reslicer
574  vtkSmartPointer<mitkVtkImageOverwrite> overwrite = vtkSmartPointer<mitkVtkImageOverwrite>::New();
575  overwrite->SetInputSlice(sliceImage->GetVtkImageData());
576  // set overwrite mode to true to write back to the image volume
577  overwrite->SetOverwriteMode(true);
578  overwrite->Modified();
579 
581  extractor->SetInput(m_WorkingImage);
582  extractor->SetTimeStep(timeStep);
583  extractor->SetWorldGeometry(reslicePlane);
584  extractor->SetVtkOutputRequest(true);
585  extractor->SetResliceTransformByGeometry(m_WorkingImage->GetTimeGeometry()->GetGeometryForTimeStep(timeStep));
586 
587  extractor->Modified();
588 
589  try
590  {
591  extractor->Update();
592  }
593  catch (itk::ExceptionObject &excep)
594  {
595  MITK_ERROR << "Exception caught: " << excep.GetDescription();
596  return;
597  }
598 
599  m_WorkingImage->Modified();
600 
602  }
603 
605  }
606 
607  m_SliceInterpolatorController->SetWorkingImage(m_WorkingImage);
608 
610 }
611 
613 {
614  QMenu orientationPopup(this);
615  std::map<QAction *, mitk::SliceNavigationController *>::const_iterator it;
616  for (it = m_ActionToSliceDimensionMap.begin(); it != m_ActionToSliceDimensionMap.end(); it++)
617  orientationPopup.addAction(it->first);
618 
619  connect(&orientationPopup, SIGNAL(triggered(QAction *)), this, SLOT(OnAcceptAllPopupActivated(QAction *)));
620 
621  orientationPopup.exec(QCursor::pos());
622 }
623 
625 {
626  ActionToSliceDimensionMapType::const_iterator iter = m_ActionToSliceDimensionMap.find(action);
627  if (iter != m_ActionToSliceDimensionMap.end())
628  {
629  mitk::SliceNavigationController *slicer = iter->second;
630  this->AcceptAllInterpolations(slicer);
631  }
632 }
633 
635 {
636  if (m_Activated && m_LastSNC)
637  {
638  // determine which one is the current view, try to do an initial interpolation
639  mitk::BaseRenderer *renderer = m_LastSNC->GetRenderer();
640  if (renderer && renderer->GetMapperID() == mitk::BaseRenderer::Standard2D)
641  {
642  const mitk::TimeGeometry *timeGeometry =
643  dynamic_cast<const mitk::TimeGeometry *>(renderer->GetWorldTimeGeometry());
644  if (timeGeometry)
645  {
646  mitk::SliceNavigationController::GeometrySliceEvent event(const_cast<mitk::TimeGeometry *>(timeGeometry),
647  renderer->GetSlice());
648  this->TranslateAndInterpolateChangedSlice(event, m_LastSNC);
650  }
651  }
652  }
653 }
654 
656 {
657  // something (e.g. undo) changed the interpolation info, we should refresh our display
658  this->UpdateVisibleSuggestion();
659 }
660 
662  const itk::EventObject & /*e*/)
663 {
664  // Don't know how to avoid const_cast here?!
666  dynamic_cast<mitk::SliceNavigationController *>(const_cast<itk::Object *>(sender));
667  if (slicer)
668  {
669  m_ControllerToTimeObserverTag.remove(slicer);
670  m_ControllerToSliceObserverTag.remove(slicer);
671  m_ControllerToDeleteObserverTag.remove(slicer);
672  }
673 }
674 
676 {
677  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
678 }
679 
681 {
682  this->RestoreOverrideCursor();
683 }
684 
686 {
687  QApplication::restoreOverrideCursor();
688 }
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
Ui::QmitkSliceBasedInterpolatorWidgetGUIControls m_Controls
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
virtual unsigned int GetSlice() const
BaseRenderer * GetRenderer() const
Gets the BaseRenderer associated with this SNC (if any). While the BaseRenderer is not directly used ...
itk::Image< unsigned char, 3 > ImageType
#define MITK_ERROR
Definition: mitkLogMacros.h:24
void OnTimeChanged(itk::Object *sender, const itk::EventObject &)
Organizes the rendering process.
virtual const TimeGeometry * GetWorldTimeGeometry()
DataCollection - Class to facilitate loading/accessing structured data.
static Pointer New()
An Operation for applying an edited slice to the volume.
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
void TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
void Reset()
Explicitly reset progress bar.
Pointer Clone() const
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
Controls the selection of the slice the associated BaseRenderer will display.
void OnToggleWidgetActivation(bool)
Reaction to "Start/Stop" button click.
void AcceptAllInterpolations(mitk::SliceNavigationController *slicer)
void SetSliceNavigationControllers(const QList< mitk::SliceNavigationController * > &controllers)
static Pointer New()
void OnSliceInterpolationInfoChanged(const itk::EventObject &)
virtual void SendSlice()
Send the currently selected slice to the connected observers (renderers)
mitk::Image::Pointer GetWorkingSlice(const mitk::PlaneGeometry *planeGeometry)
mitk::DataStorage::Pointer m_DataStorage
QmitkSliceBasedInterpolatorWidget(QWidget *parent=0, const char *name=0)
static Pointer New()
#define AccessFixedDimensionByItk_2(mitkImage, itkImageTypeFunction, dimension, arg1, arg2)
static RenderingManager * GetInstance()
void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer)
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
Image class for storing images.
Definition: mitkImage.h:76
virtual mitk::PlaneGeometry * GetPlaneGeometry(int s) const
Returns the PlaneGeometry of the slice (s).
const mitk::PlaneGeometry * GetCurrentPlaneGeometry()
Returns the currently selected Plane in the current BaseGeometry (if existent).
virtual unsigned int GetPos() const
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
Describes the geometry of a data object consisting of slices.
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
static Pointer New()
const char * GetName() const
get the name of the Renderer
const ToolVectorTypeConst GetTools()
Gives you a list of all tools. This is const on purpose.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
ActionToSliceDimensionMapType m_ActionToSliceDimensionMap
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
virtual bool SetOperationEvent(UndoStackItem *stackItem)=0
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.
mitk::Stepper * GetTime()
Get the Stepper through the time.
Describes a two-dimensional, rectangular plane.
std::map< QAction *, mitk::SliceNavigationController * > ActionToSliceDimensionMapType
void OnSliceChanged(itk::Object *sender, const itk::EventObject &)
virtual void Clear()=0
clears undo and Redolist
unsigned int GetDimension() const
Get dimension of the image.
Definition: mitkImage.cpp:110
void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &)
const ActionToSliceDimensionMapType CreateActionToSliceDimension()
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Represents a pair of operations: undo and the according redo.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
void OnAcceptInterpolationClicked()
Reaction to "Accept Current Slice" button click.
DataVectorType GetWorkingData()
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
static bool DetermineAffectedImageSlice(const Image *image, const PlaneGeometry *plane, int &affectedDimension, int &affectedSlice)
Calculates for a given Image and PlaneGeometry, which slice of the image (in index corrdinates) is me...
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.