Medical Imaging Interaction Toolkit  2018.4.99-87d68d9f
Medical Imaging Interaction Toolkit
mitkFeedbackContourTool.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "mitkToolManager.h"
15 
16 #include "mitkColorProperty.h"
17 #include "mitkProperties.h"
18 #include "mitkStringProperty.h"
19 
20 #include "mitkBaseRenderer.h"
21 #include "mitkDataStorage.h"
22 
23 #include "mitkRenderingManager.h"
24 
25 mitk::FeedbackContourTool::FeedbackContourTool(const char *type) : SegTool2D(type), m_FeedbackContourVisible(false)
26 {
28  m_FeedbackContour->SetClosed(true);
31  m_FeedbackContourNode->SetProperty("name", StringProperty::New("One of FeedbackContourTool's feedback nodes"));
32  m_FeedbackContourNode->SetProperty("visible", BoolProperty::New(true));
33  m_FeedbackContourNode->SetProperty("helper object", BoolProperty::New(true));
34  m_FeedbackContourNode->SetProperty("layer", IntProperty::New(1000));
35  m_FeedbackContourNode->SetProperty("contour.project-onto-plane", BoolProperty::New(false));
36  m_FeedbackContourNode->SetProperty("contour.width", FloatProperty::New(1.0));
37  // set to max short, max int doesn't work, max value somewhere hardcoded?
39  m_FeedbackContourNode->SetProperty("fixedLayer", BoolProperty::New(true));
40 
42 }
43 
45 {
46 }
47 
49 {
50  m_FeedbackContourNode->SetProperty("contour.color", ColorProperty::New(r, g, b));
51 }
52 
54 {
55  m_FeedbackContourNode->SetProperty("contour.color", ColorProperty::New(0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0));
56 }
57 
59 {
60  Superclass::Deactivated();
62  if (storage && m_FeedbackContourNode.IsNotNull())
63  {
64  storage->Remove(m_FeedbackContourNode);
65  m_FeedbackContour->Clear();
67  }
68 }
69 
71 {
72  Superclass::Activated();
73 
75 }
76 
78 {
79  return m_FeedbackContour;
80 }
81 
83 {
84  m_FeedbackContour = contour;
86 }
87 
89 {
90  if (m_FeedbackContourVisible == visible)
91  return; // nothing changed
92 
93  if (DataStorage *storage = m_ToolManager->GetDataStorage())
94  {
95  if (visible)
96  {
97  // Add the feedback contour node as a derived node of the first working data.
98  // If there is no working data, the node is added at the top level.
100  }
101  else
102  {
103  storage->Remove(m_FeedbackContourNode);
104  }
105  }
106 
107  m_FeedbackContourVisible = visible;
108 }
109 
111  ContourModel *contourIn3D,
112  bool correctionForIpSegmentation,
113  bool constrainToInside)
114 {
116  slice, contourIn3D, correctionForIpSegmentation, constrainToInside);
117 }
118 
120  ContourModel *contourIn2D,
121  bool correctionForIpSegmentation)
122 {
124  sliceGeometry, contourIn2D, correctionForIpSegmentation);
125 }
126 
128  Image *sliceImage,
129  int paintingPixelValue)
130 {
131  this->FillContourInSlice(projectedContour, 0, sliceImage, paintingPixelValue);
132 }
133 
135  unsigned int timeStep,
136  Image *sliceImage,
137  int paintingPixelValue)
138 {
139  mitk::ContourModelUtils::FillContourInSlice(projectedContour, timeStep, sliceImage, sliceImage, paintingPixelValue);
140 }
static ContourModel::Pointer BackProjectContourFrom2DSlice(const BaseGeometry *sliceGeometry, ContourModel *contourIn2D, bool correctionForIpSegmentation=false)
Projects a slice index coordinates of a contour back into world coordinates.
ContourModel::Pointer m_FeedbackContour
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
void SetFeedbackContour(ContourModel::Pointer)
Data management class that handles 'was created by' relations.
void FillContourInSlice(ContourModel *projectedContour, Image *sliceImage, int paintingPixelValue=1)
Fill a contour in a 2D slice with a specified pixel value.
DataStorage * GetDataStorage()
static void FillContourInSlice(ContourModel *projectedContour, Image *sliceImage, mitk::Image::Pointer workingImage, int paintingPixelValue=1)
Fill a contour in a 2D slice with a specified pixel value at time step 0.
void SetFeedbackContourColor(float r, float g, float b)
Provide values from 0.0 (black) to 1.0 (full color)
static Pointer New()
void Deactivated() override
Called when the tool gets deactivated.
static Pointer New()
static Pointer New()
Image class for storing images.
Definition: mitkImage.h:72
static ContourModel::Pointer ProjectContourTo2DSlice(Image *slice, ContourModel *contourIn3D, bool correctionForIpSegmentation, bool constrainToInside)
Projects a contour onto an image point by point. Converts from world to index coordinates.
ContourModel::Pointer ProjectContourTo2DSlice(Image *slice, ContourModel *contourIn3D, bool correctionForIpSegmentation=false, bool constrainToInside=true)
Projects a contour onto an image point by point. Converts from world to index coordinates.
static T max(T x, T y)
Definition: svm.cpp:56
ContourModel::Pointer BackProjectContourFrom2DSlice(const BaseGeometry *sliceGeometry, ContourModel *contourIn2D, bool correctionForIpSegmentation=false)
Projects a slice index coordinates of a contour back into world coordinates.
static Pointer New()
virtual void Remove(const DataNode *node)=0
Removes node from the DataStorage.
static Pointer New()
Abstract base class for segmentation tools.
Definition: mitkSegTool2D.h:54
void Activated() override
Called when the tool gets activated.
ToolManager * m_ToolManager
Definition: mitkTool.h:228
static Pointer New()
itk::SmartPointer< Self > Pointer
Definition: mitkBaseData.h:41
static Pointer New()
BaseGeometry Describes the geometry of a data object.
DataVectorType GetWorkingData()