40 #include <itkCommand.h>
42 #include <QApplication>
45 #include <QMessageBox>
49 m_SliceInterpolatorController(
mitk::SliceBasedInterpolationController::
New()),
59 Q_ASSERT(m_ToolManager);
71 m_InterpolationInfoChangedObserverTag = m_SliceInterpolatorController->AddObserver(itk::ModifiedEvent(), command);
75 m_PreviewNode->SetName(
"3D tool preview");
83 m_PreviewNode->SetOpacity(1.0);
84 m_PreviewNode->SetColor(0.0, 1.0, 0.0);
86 m_Controls.m_btApplyForCurrentSlice->setEnabled(
false);
87 m_Controls.m_btApplyForAllSlices->setEnabled(
false);
89 this->setEnabled(
false);
99 slicer->RemoveObserver(m_ControllerToDeleteObserverTag.take(slicer));
100 slicer->RemoveObserver(m_ControllerToTimeObserverTag.take(slicer));
101 slicer->RemoveObserver(m_ControllerToSliceObserverTag.take(slicer));
107 m_SliceInterpolatorController->RemoveObserver(m_InterpolationInfoChangedObserverTag);
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;
126 return actionToSliceDimension;
131 m_DataStorage = &storage;
135 const QList<mitk::SliceNavigationController *> &controllers)
137 Q_ASSERT(!controllers.empty());
150 m_ControllerToDeleteObserverTag.insert(slicer, slicer->AddObserver(itk::DeleteEvent(), deleteCommand));
155 m_ControllerToTimeObserverTag.insert(
162 m_ControllerToSliceObserverTag.insert(
174 this->setEnabled(
false);
183 this->setEnabled(
false);
189 this->setEnabled(
false);
193 m_WorkingImage = workingImage;
195 this->setEnabled(
true);
201 if (!dynamic_cast<const mitk::SliceNavigationController::GeometryTimeEvent *>(&e))
210 if (m_LastSNC == slicer)
218 if (m_Activated && m_WorkingImage.IsNotNull())
221 if (!dynamic_cast<const mitk::SliceNavigationController::GeometrySliceEvent *>(&e))
237 if (m_Activated && m_WorkingImage.IsNotNull())
242 if (timeGeometry && m_TimeStep.contains(slicer))
252 this->
Interpolate(plane, m_TimeStep[slicer], slicer);
260 unsigned int timeStep,
263 int clickedSliceDimension(-1);
264 int clickedSliceIndex(-1);
271 m_SliceInterpolatorController->Interpolate(clickedSliceDimension, clickedSliceIndex, plane, timeStep);
273 m_PreviewNode->SetData(interpolation);
275 const mitk::Color &color = m_WorkingImage->GetActiveLabel()->GetColor();
276 m_PreviewNode->SetColor(color);
279 m_LastSliceIndex = clickedSliceIndex;
290 reslice->SetOverwriteMode(
false);
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));
301 extractor->Modified();
307 catch (itk::ExceptionObject &excep)
309 MITK_ERROR <<
"Exception caught: " << excep.GetDescription();
322 m_WorkingImage, extractor->GetOutput(), sliceGeometry, timeStep,
const_cast<mitk::PlaneGeometry *
>(planeGeometry));
324 slice->DisconnectPipeline();
331 Q_ASSERT(m_ToolManager);
337 m_Controls.m_btApplyForCurrentSlice->setEnabled(enabled);
338 m_Controls.m_btApplyForAllSlices->setEnabled(enabled);
345 unsigned int numberOfExistingTools = m_ToolManager->
GetTools().size();
346 for (
unsigned int i = 0; i < numberOfExistingTools; i++)
355 if (!m_DataStorage->Exists(m_PreviewNode))
357 m_DataStorage->Add(m_PreviewNode);
360 m_SliceInterpolatorController->SetWorkingImage(m_WorkingImage);
365 if (m_DataStorage->Exists(m_PreviewNode))
367 m_DataStorage->Remove(m_PreviewNode);
373 m_Activated = enabled;
378 template <
typename TPixel,
unsigned int VImageDimension>
379 void QmitkSliceBasedInterpolatorWidget::WritePreviewOnWorkingImage(itk::Image<TPixel, VImageDimension> *targetSlice,
383 typedef itk::Image<TPixel, VImageDimension>
ImageType;
390 typedef itk::ImageRegionIterator<ImageType> OutputIteratorType;
391 typedef itk::ImageRegionConstIterator<ImageType> InputIteratorType;
393 InputIteratorType inputIterator(sourceSliceITK, sourceSliceITK->GetLargestPossibleRegion());
394 OutputIteratorType outputIterator(targetSlice, targetSlice->GetLargestPossibleRegion());
396 outputIterator.GoToBegin();
397 inputIterator.GoToBegin();
399 int activePixelValue = m_WorkingImage->GetActiveLabel()->GetValue();
401 if (activePixelValue == 0)
403 while (!outputIterator.IsAtEnd())
405 if (inputIterator.Get() != 0)
407 outputIterator.Set(overwritevalue);
413 else if (overwritevalue != 0)
415 while (!outputIterator.IsAtEnd())
417 int targetValue =
static_cast<int>(outputIterator.Get());
418 if (inputIterator.Get() != 0)
420 if (!m_WorkingImage->GetLabel(targetValue)->GetLocked())
421 outputIterator.Set(overwritevalue);
430 while (!outputIterator.IsAtEnd())
432 const int targetValue = outputIterator.Get();
433 if (inputIterator.Get() != 0)
435 if (targetValue == activePixelValue)
436 outputIterator.Set(overwritevalue);
447 if (m_WorkingImage.IsNotNull() && m_PreviewNode->GetData())
454 if (sliceImage.IsNull())
460 sliceImage, WritePreviewOnWorkingImage, 2, previewSlice, m_WorkingImage->GetActiveLabel()->GetValue());
465 overwrite->SetInputSlice(sliceImage->GetVtkImageData());
467 overwrite->SetOverwriteMode(
true);
468 overwrite->Modified();
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));
479 extractor->Modified();
485 catch (itk::ExceptionObject &excep)
487 MITK_ERROR <<
"Exception caught: " << excep.GetDescription();
492 m_WorkingImage->Modified();
494 int clickedSliceDimension(-1);
495 int clickedSliceIndex(-1);
498 m_WorkingImage, planeGeometry, clickedSliceDimension, clickedSliceIndex);
500 m_SliceInterpolatorController->SetChangedSlice(sliceImage, clickedSliceDimension, clickedSliceIndex, timeStep);
509 extractor->GetOutput(),
516 mitk::DiffSliceOperationApplier::GetInstance(), m_doOperation, m_undoOperation,
"Slice Interpolation");
522 m_undoOperation = NULL;
523 m_doOperation = NULL;
525 m_PreviewNode->SetData(NULL);
537 int sliceDimension(-1);
542 unsigned int zslices = m_WorkingImage->GetDimension(sliceDimension);
549 for (
unsigned int idx = 0; idx < zslices; ++idx)
553 m_WorkingImage->GetSlicedGeometry()->WorldToIndex(origin, origin);
554 origin[sliceDimension] = idx;
555 m_WorkingImage->GetSlicedGeometry()->IndexToWorld(origin, origin);
556 reslicePlane->SetOrigin(origin);
559 m_SliceInterpolatorController->Interpolate(sliceDimension, idx, reslicePlane, timeStep);
561 if (interpolation.IsNotNull())
563 m_PreviewNode->SetData(interpolation);
566 if (sliceImage.IsNull())
570 sliceImage, WritePreviewOnWorkingImage, 2, interpolation, m_WorkingImage->GetActiveLabel()->GetValue());
575 overwrite->SetInputSlice(sliceImage->GetVtkImageData());
577 overwrite->SetOverwriteMode(
true);
578 overwrite->Modified();
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));
587 extractor->Modified();
593 catch (itk::ExceptionObject &excep)
595 MITK_ERROR <<
"Exception caught: " << excep.GetDescription();
599 m_WorkingImage->Modified();
607 m_SliceInterpolatorController->SetWorkingImage(m_WorkingImage);
614 QMenu orientationPopup(
this);
615 std::map<QAction *, mitk::SliceNavigationController *>::const_iterator it;
617 orientationPopup.addAction(it->first);
621 orientationPopup.exec(QCursor::pos());
636 if (m_Activated && m_LastSNC)
662 const itk::EventObject & )
669 m_ControllerToTimeObserverTag.remove(slicer);
670 m_ControllerToSliceObserverTag.remove(slicer);
671 m_ControllerToDeleteObserverTag.remove(slicer);
677 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
687 QApplication::restoreOverrideCursor();
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
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
Organizes the rendering process.
virtual const TimeGeometry * GetWorldTimeGeometry()
DataCollection - Class to facilitate loading/accessing structured data.
An Operation for applying an edited slice to the volume.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
TimeGeometry * GetTimeGeometry() const
void Reset()
Explicitly reset progress bar.
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.
virtual void SendSlice()
Send the currently selected slice to the connected observers (renderers)
mitk::DataStorage::Pointer m_DataStorage
#define AccessFixedDimensionByItk_2(mitkImage, itkImageTypeFunction, dimension, arg1, arg2)
static RenderingManager * GetInstance()
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
Image class for storing images.
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
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.
const char * GetName() const
get the name of the Renderer
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
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.
virtual void Clear()=0
clears undo and Redolist
unsigned int GetDimension() const
Get dimension of the image.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Represents a pair of operations: undo and the according redo.
Class for nodes of the DataTree.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.