Medical Imaging Interaction Toolkit  2016.11.0
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,
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 #include "mitkToolManager.h"
19 
20 #include "mitkColorProperty.h"
21 #include "mitkProperties.h"
22 #include "mitkStringProperty.h"
23 
24 #include "mitkBaseRenderer.h"
25 #include "mitkDataStorage.h"
26 
27 #include "mitkRenderingManager.h"
28 
29 mitk::FeedbackContourTool::FeedbackContourTool(const char *type) : SegTool2D(type), m_FeedbackContourVisible(false)
30 {
32  m_FeedbackContour->SetClosed(true);
35  m_FeedbackContourNode->SetProperty("name", StringProperty::New("One of FeedbackContourTool's feedback nodes"));
36  m_FeedbackContourNode->SetProperty("visible", BoolProperty::New(true));
37  m_FeedbackContourNode->SetProperty("helper object", BoolProperty::New(true));
38  m_FeedbackContourNode->SetProperty("layer", IntProperty::New(1000));
39  m_FeedbackContourNode->SetProperty("contour.project-onto-plane", BoolProperty::New(false));
40  m_FeedbackContourNode->SetProperty("contour.width", FloatProperty::New(1.0));
41  // set to max short, max int doesn't work, max value somewhere hardcoded?
43  m_FeedbackContourNode->SetProperty("fixedLayer", BoolProperty::New(true));
44 
46 }
47 
49 {
50 }
51 
53 {
54  m_FeedbackContourNode->SetProperty("contour.color", ColorProperty::New(r, g, b));
55 }
56 
58 {
59  m_FeedbackContourNode->SetProperty("contour.color", ColorProperty::New(0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0));
60 }
61 
63 {
64  Superclass::Deactivated();
65  DataStorage *storage = m_ToolManager->GetDataStorage();
66  if (storage && m_FeedbackContourNode.IsNotNull())
67  {
68  storage->Remove(m_FeedbackContourNode);
69  m_FeedbackContour->Clear();
70  SetFeedbackContourVisible(false);
71  }
72 }
73 
75 {
76  Superclass::Activated();
77 
78  SetFeedbackContourVisible(true);
79 }
80 
82 {
83  return m_FeedbackContour;
84 }
85 
87 {
88  m_FeedbackContour = contour;
89  m_FeedbackContourNode->SetData(m_FeedbackContour);
90 }
91 
93 {
94  if (m_FeedbackContourVisible == visible)
95  return; // nothing changed
96 
97  if (DataStorage *storage = m_ToolManager->GetDataStorage())
98  {
99  if (visible)
100  {
101  storage->Add(m_FeedbackContourNode);
102  }
103  else
104  {
105  storage->Remove(m_FeedbackContourNode);
106  }
107  }
108 
109  m_FeedbackContourVisible = visible;
110 }
111 
113  ContourModel *contourIn3D,
114  bool correctionForIpSegmentation,
115  bool constrainToInside)
116 {
118  slice, contourIn3D, correctionForIpSegmentation, constrainToInside);
119 }
120 
122  ContourModel *contourIn2D,
123  bool correctionForIpSegmentation)
124 {
126  sliceGeometry, contourIn2D, correctionForIpSegmentation);
127 }
128 
130  Image *sliceImage,
131  int paintingPixelValue)
132 {
133  this->FillContourInSlice(projectedContour, 0, sliceImage, paintingPixelValue);
134 }
135 
137  unsigned int timeStep,
138  Image *sliceImage,
139  int paintingPixelValue)
140 {
141  mitk::ContourModelUtils::FillContourInSlice(projectedContour, timeStep, sliceImage, sliceImage, paintingPixelValue);
142 }
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.
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:76
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:70
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()
static Pointer New()
Abstract base class for segmentation tools.
Definition: mitkSegTool2D.h:58
void Activated() override
Called when the tool gets activated.
static Pointer New()
virtual void Remove(const mitk::DataNode *node)=0
Removes node from the DataStorage.
itk::SmartPointer< Self > Pointer
Definition: mitkBaseData.h:42
static Pointer New()
BaseGeometry Describes the geometry of a data object.