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
mitkApplyDiffImageOperation.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 <itkCommand.h>
20 
22  Image *image,
23  Image *diffImage,
24  unsigned int timeStep,
25  unsigned int sliceDimension,
26  unsigned int sliceIndex)
27  : Operation(operationType),
28  m_Image(image),
29  m_SliceIndex(sliceIndex),
30  m_SliceDimension(sliceDimension),
31  m_TimeStep(timeStep),
32  m_Factor(1.0),
33  m_ImageStillValid(false),
34  m_DeleteTag(0)
35 {
36  if (image && diffImage)
37  {
38  // observe 3D image for DeleteEvent
39  m_ImageStillValid = true;
40 
43  command->SetCallbackFunction(this, &ApplyDiffImageOperation::OnImageDeleted);
44  m_DeleteTag = image->AddObserver(itk::DeleteEvent(), command);
45 
46  // keep a compressed version of the image
48  zlibContainer->SetImage(diffImage);
49  }
50 }
51 
53 {
54  if (m_ImageStillValid)
55  {
56  m_Image->RemoveObserver(m_DeleteTag);
57  }
58 }
59 
61 {
62  m_ImageStillValid = false;
63 }
64 
66 {
67  // uncompress image to create a valid mitk::Image
68  Image::Pointer image = zlibContainer->GetImage().GetPointer();
69 
70  return image;
71 }
itk::SmartPointer< Self > Pointer
Base class of all Operation-classes.
Definition: mitkOperation.h:33
ApplyDiffImageOperation(OperationType operationType, Image *image, Image *diffImage, unsigned int timeStep=0, unsigned int sliceDimension=2, unsigned int sliceIndex=0)
CompressedImageContainer::Pointer zlibContainer
Image class for storing images.
Definition: mitkImage.h:76
int OperationType
Definition: mitkOperation.h:27
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.