Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkLiveWireTool2D.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 
13 #include <mitkContourModelUtils.h>
14 #include <mitkLiveWireTool2D.h>
15 #include <mitkLiveWireTool2D.xpm>
16 #include <mitkToolManager.h>
17 
18 #include <usGetModuleContext.h>
19 #include <usModuleResource.h>
20 
21 #include <type_traits>
22 
23 namespace mitk
24 {
25  MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, LiveWireTool2D, "LiveWire tool");
26 }
27 
29  : SegTool2D("LiveWireTool"), m_CreateAndUseDynamicCosts(false)
30 {
31 }
32 
34 {
35  this->ClearSegmentation();
36 }
37 
38 void mitk::LiveWireTool2D::RemoveHelperObjects()
39 {
40  auto dataStorage = m_ToolManager->GetDataStorage();
41 
42  if (nullptr == dataStorage)
43  return;
44 
45  for (const auto &editingContour : m_EditingContours)
46  dataStorage->Remove(editingContour.first);
47 
48  for (const auto &workingContour : m_WorkingContours)
49  dataStorage->Remove(workingContour.first);
50 
51  if (m_EditingContourNode.IsNotNull())
52  dataStorage->Remove(m_EditingContourNode);
53 
54  if (m_LiveWireContourNode.IsNotNull())
55  dataStorage->Remove(m_LiveWireContourNode);
56 
57  if (m_ContourNode.IsNotNull())
58  dataStorage->Remove(m_ContourNode);
59 
61 }
62 
63 void mitk::LiveWireTool2D::ReleaseHelperObjects()
64 {
65  this->RemoveHelperObjects();
66 
67  m_EditingContours.clear();
68  m_WorkingContours.clear();
69 
70  m_EditingContourNode = nullptr;
71  m_EditingContour = nullptr;
72 
73  m_LiveWireContourNode = nullptr;
74  m_LiveWireContour = nullptr;
75 
76  m_ContourNode = nullptr;
77  m_Contour = nullptr;
78 }
79 
80 void mitk::LiveWireTool2D::ReleaseInteractors()
81 {
82  this->EnableContourLiveWireInteraction(false);
83  m_LiveWireInteractors.clear();
84 }
85 
87 {
88  CONNECT_CONDITION("CheckContourClosed", OnCheckPoint);
89 
90  CONNECT_FUNCTION("InitObject", OnInitLiveWire);
91  CONNECT_FUNCTION("AddPoint", OnAddPoint);
92  CONNECT_FUNCTION("CtrlAddPoint", OnAddPoint);
93  CONNECT_FUNCTION("MovePoint", OnMouseMoveNoDynamicCosts);
94  CONNECT_FUNCTION("FinishContour", OnFinish);
95  CONNECT_FUNCTION("DeletePoint", OnLastSegmentDelete);
96  CONNECT_FUNCTION("CtrlMovePoint", OnMouseMoved);
97 }
98 
99 const char **mitk::LiveWireTool2D::GetXPM() const
100 {
101  return mitkLiveWireTool2D_xpm;
102 }
103 
105 {
106  return us::GetModuleContext()->GetModule()->GetResource("LiveWire_48x48.png");
107 }
108 
110 {
111  return us::GetModuleContext()->GetModule()->GetResource("LiveWire_Cursor_32x32.png");
112 }
113 
114 const char *mitk::LiveWireTool2D::GetName() const
115 {
116  return "Live Wire";
117 }
118 
120 {
121  Superclass::Activated();
122  this->ResetToStartState();
123  this->EnableContourLiveWireInteraction(true);
124 }
125 
127 {
128  this->ConfirmSegmentation();
129  Superclass::Deactivated();
130 }
131 
132 void mitk::LiveWireTool2D::EnableContourLiveWireInteraction(bool on)
133 {
134  for (const auto &interactor : m_LiveWireInteractors)
135  interactor->EnableInteraction(on);
136 }
137 
139 {
140  auto workingNode = m_ToolManager->GetWorkingData(0);
141 
142  if (nullptr == workingNode)
143  return;
144 
145  auto workingImage = dynamic_cast<Image *>(workingNode->GetData());
146 
147  if (nullptr == workingImage)
148  return;
149 
150  std::vector<SliceInformation> sliceInfos;
151  sliceInfos.reserve(m_WorkingContours.size());
152 
153  for (const auto &workingContour : m_WorkingContours)
154  {
155  auto contour = dynamic_cast<ContourModel *>(workingContour.first->GetData());
156 
157  if (nullptr == contour)
158  continue;
159 
160  const auto numberOfTimeSteps = contour->GetTimeSteps();
161 
162  for (std::remove_const_t<decltype(numberOfTimeSteps)> t = 0; t < numberOfTimeSteps; ++t)
163  {
164  if (contour->IsEmptyTimeStep(t))
165  continue;
166 
167  auto workingSlice = this->GetAffectedImageSliceAs2DImage(workingContour.second, workingImage, t);
168  auto projectedContour = ContourModelUtils::ProjectContourTo2DSlice(workingSlice, contour, true, false);
169 
170  ContourModelUtils::FillContourInSlice(projectedContour, t, workingSlice, workingImage, 1);
171 
172  sliceInfos.emplace_back(workingSlice, workingContour.second, t);
173  this->WriteSliceToVolume(sliceInfos.back());
174  }
175  }
176 
177  this->WriteBackSegmentationResult(sliceInfos, false);
178  this->ClearSegmentation();
179 }
180 
182 {
183  this->ReleaseHelperObjects();
184  this->ReleaseInteractors();
185  this->ResetToStartState();
186 }
187 
188 bool mitk::LiveWireTool2D::IsPositionEventInsideImageRegion(mitk::InteractionPositionEvent *positionEvent,
189  mitk::BaseData *data)
190 {
191  bool isPositionEventInsideImageRegion = nullptr != data && data->GetGeometry()->IsInside(positionEvent->GetPositionInWorld());
192 
193  if (!isPositionEventInsideImageRegion)
194  MITK_WARN("LiveWireTool2D") << "PositionEvent is outside ImageRegion!";
195 
196  return isPositionEventInsideImageRegion;
197 }
198 
199 void mitk::LiveWireTool2D::OnInitLiveWire(StateMachineAction *, InteractionEvent *interactionEvent)
200 {
201  auto positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
202 
203  if (nullptr == positionEvent)
204  return;
205 
206  auto workingDataNode = m_ToolManager->GetWorkingData(0);
207 
208  if (!IsPositionEventInsideImageRegion(positionEvent, workingDataNode->GetData()))
209  {
210  this->ResetToStartState();
211  return;
212  }
213 
214  m_LastEventSender = positionEvent->GetSender();
216 
217  auto t = positionEvent->GetSender()->GetTimeStep();
218 
219  m_Contour = mitk::ContourModel::New();
220  m_Contour->Expand(t + 1);
221  m_ContourNode = mitk::DataNode::New();
222  m_ContourNode->SetData(m_Contour);
223  m_ContourNode->SetName("working contour node");
224  m_ContourNode->SetProperty("layer", IntProperty::New(100));
225  m_ContourNode->AddProperty("fixedLayer", BoolProperty::New(true));
226  m_ContourNode->SetProperty("helper object", mitk::BoolProperty::New(true));
227  m_ContourNode->AddProperty("contour.color", ColorProperty::New(1.0f, 1.0f, 0.0f), nullptr, true);
228  m_ContourNode->AddProperty("contour.points.color", ColorProperty::New(1.0f, 0.0f, 0.1f), nullptr, true);
229  m_ContourNode->AddProperty("contour.controlpoints.show", BoolProperty::New(true), nullptr, true);
230 
231  m_LiveWireContour = mitk::ContourModel::New();
232  m_LiveWireContour->Expand(t + 1);
233  m_LiveWireContourNode = mitk::DataNode::New();
234  m_LiveWireContourNode->SetData(m_LiveWireContour);
235  m_LiveWireContourNode->SetName("active livewire node");
236  m_LiveWireContourNode->SetProperty("layer", IntProperty::New(101));
237  m_LiveWireContourNode->AddProperty("fixedLayer", BoolProperty::New(true));
238  m_LiveWireContourNode->SetProperty("helper object", mitk::BoolProperty::New(true));
239  m_LiveWireContourNode->AddProperty("contour.color", ColorProperty::New(0.1f, 1.0f, 0.1f), nullptr, true);
240  m_LiveWireContourNode->AddProperty("contour.width", mitk::FloatProperty::New(4.0f), nullptr, true);
241 
242  m_EditingContour = mitk::ContourModel::New();
243  m_EditingContour->Expand(t + 1);
244  m_EditingContourNode = mitk::DataNode::New();
245  m_EditingContourNode->SetData(m_EditingContour);
246  m_EditingContourNode->SetName("editing node");
247  m_EditingContourNode->SetProperty("layer", IntProperty::New(102));
248  m_EditingContourNode->AddProperty("fixedLayer", BoolProperty::New(true));
249  m_EditingContourNode->SetProperty("helper object", mitk::BoolProperty::New(true));
250  m_EditingContourNode->AddProperty("contour.color", ColorProperty::New(0.1f, 1.0f, 0.1f), nullptr, true);
251  m_EditingContourNode->AddProperty("contour.points.color", ColorProperty::New(0.0f, 0.0f, 1.0f), nullptr, true);
252  m_EditingContourNode->AddProperty("contour.width", mitk::FloatProperty::New(4.0f), nullptr, true);
253 
254  auto dataStorage = m_ToolManager->GetDataStorage();
255  dataStorage->Add(m_ContourNode, workingDataNode);
256  dataStorage->Add(m_LiveWireContourNode, workingDataNode);
257  dataStorage->Add(m_EditingContourNode, workingDataNode);
258 
259  // Set current slice as input for ImageToLiveWireContourFilter
260  m_WorkingSlice = this->GetAffectedReferenceSlice(positionEvent);
261 
262  auto origin = m_WorkingSlice->GetSlicedGeometry()->GetOrigin();
263  m_WorkingSlice->GetSlicedGeometry()->WorldToIndex(origin, origin);
264  m_WorkingSlice->GetSlicedGeometry()->IndexToWorld(origin, origin);
265  m_WorkingSlice->GetSlicedGeometry()->SetOrigin(origin);
266 
267  m_LiveWireFilter = ImageLiveWireContourModelFilter::New();
268  m_LiveWireFilter->SetInput(m_WorkingSlice);
269 
270  // Map click to pixel coordinates
271  auto click = positionEvent->GetPositionInWorld();
272  itk::Index<3> idx;
273  m_WorkingSlice->GetGeometry()->WorldToIndex(click, idx);
274 
275  // Get the pixel with the highest gradient in a 7x7 region
276  itk::Index<3> indexWithHighestGradient;
277  AccessFixedDimensionByItk_2(m_WorkingSlice, FindHighestGradientMagnitudeByITK, 2, idx, indexWithHighestGradient);
278 
279  click[0] = indexWithHighestGradient[0];
280  click[1] = indexWithHighestGradient[1];
281  click[2] = indexWithHighestGradient[2];
282  m_WorkingSlice->GetGeometry()->IndexToWorld(click, click);
283 
284  // Set initial start point
285  m_Contour->AddVertex(click, true, t);
286  m_LiveWireFilter->SetStartPoint(click);
287 
288  // Remember PlaneGeometry to determine if events were triggered in the same plane
289  m_PlaneGeometry = interactionEvent->GetSender()->GetCurrentWorldPlaneGeometry();
290 
291  m_CreateAndUseDynamicCosts = true;
292 
294 }
295 
296 void mitk::LiveWireTool2D::OnAddPoint(StateMachineAction *, InteractionEvent *interactionEvent)
297 {
298  // Complete LiveWire interaction for the last segment. Add current LiveWire contour to
299  // the finished contour and reset to start a new segment and computation.
300 
301  auto positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
302 
303  if (nullptr == positionEvent)
304  return;
305 
306  if (m_PlaneGeometry.IsNotNull())
307  {
308  // Check if the point is in the correct slice
309  if (m_PlaneGeometry->DistanceFromPlane(positionEvent->GetPositionInWorld()) > mitk::sqrteps)
310  return;
311  }
312 
313  auto t = static_cast<int>(positionEvent->GetSender()->GetTimeStep());
314 
315  // Add repulsive points to avoid getting the same path again
316  std::for_each(m_LiveWireContour->IteratorBegin(), m_LiveWireContour->IteratorEnd(), [this](ContourElement::VertexType *vertex) {
317  ImageLiveWireContourModelFilter::InternalImageType::IndexType idx;
318  this->m_WorkingSlice->GetGeometry()->WorldToIndex(vertex->Coordinates, idx);
319  this->m_LiveWireFilter->AddRepulsivePoint(idx);
320  });
321 
322  // Remove duplicate first vertex, it's already contained in m_Contour
323  m_LiveWireContour->RemoveVertexAt(0, t);
324 
325  // Set last point as control point
326  m_LiveWireContour->SetControlVertexAt(m_LiveWireContour->GetNumberOfVertices(t) - 1, t);
327 
328  // Merge contours
329  m_Contour->Concatenate(m_LiveWireContour, t);
330 
331  // Clear the LiveWire contour and reset the corresponding DataNode
332  m_LiveWireContour->Clear(t);
333 
334  // Set new start point
335  m_LiveWireFilter->SetStartPoint(positionEvent->GetPositionInWorld());
336 
337  if (m_CreateAndUseDynamicCosts)
338  {
339  // Use dynamic cost map for next update
340  m_LiveWireFilter->CreateDynamicCostMap(m_Contour);
341  m_LiveWireFilter->SetUseDynamicCostMap(true);
342  }
343 
345 }
346 
347 void mitk::LiveWireTool2D::OnMouseMoved(StateMachineAction *, InteractionEvent *interactionEvent)
348 {
349  // Compute LiveWire segment from last control point to current mouse position
350 
351  auto positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
352 
353  if (nullptr == positionEvent)
354  return;
355 
356  auto t = positionEvent->GetSender()->GetTimeStep();
357 
358  m_LiveWireFilter->SetEndPoint(positionEvent->GetPositionInWorld());
359  m_LiveWireFilter->SetTimeStep(t);
360  m_LiveWireFilter->Update();
361 
362  m_LiveWireContour = this->m_LiveWireFilter->GetOutput();
363  m_LiveWireContourNode->SetData(this->m_LiveWireContour);
364 
366 }
367 
368 void mitk::LiveWireTool2D::OnMouseMoveNoDynamicCosts(StateMachineAction *, InteractionEvent *interactionEvent)
369 {
370  m_LiveWireFilter->SetUseDynamicCostMap(false);
371  this->OnMouseMoved(nullptr, interactionEvent);
372  m_LiveWireFilter->SetUseDynamicCostMap(true);
373 }
374 
375 bool mitk::LiveWireTool2D::OnCheckPoint(const InteractionEvent *interactionEvent)
376 {
377  // Check double click on first control point to finish the LiveWire tool
378 
379  auto positionEvent = dynamic_cast<const mitk::InteractionPositionEvent *>(interactionEvent);
380 
381  if (nullptr == positionEvent)
382  return false;
383 
384  auto t = static_cast<int>(positionEvent->GetSender()->GetTimeStep());
385 
386  mitk::Point3D click = positionEvent->GetPositionInWorld();
387  mitk::Point3D first = this->m_Contour->GetVertexAt(0, t)->Coordinates;
388 
389  return first.EuclideanDistanceTo(click) < 4.5;
390 }
391 
392 void mitk::LiveWireTool2D::OnFinish(StateMachineAction *, InteractionEvent *interactionEvent)
393 {
394  // Finish LiveWire tool interaction
395 
396  auto positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
397 
398  if (nullptr == positionEvent)
399  return;
400 
401  // Have to do that here so that the m_LastEventSender is set correctly
403 
404  auto t = static_cast<int>(positionEvent->GetSender()->GetTimeStep());
405 
406  // Remove last control point added by double click
407  m_Contour->RemoveVertexAt(m_Contour->GetNumberOfVertices(t) - 1, t);
408 
409  // Save contour and corresponding plane geometry to list
410  this->m_WorkingContours.emplace_back(std::make_pair(m_ContourNode, positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()->Clone()));
411  this->m_EditingContours.emplace_back(std::make_pair(m_EditingContourNode, positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()->Clone()));
412 
413  m_LiveWireFilter->SetUseDynamicCostMap(false);
414 
415  this->FinishTool();
416 }
417 
418 void mitk::LiveWireTool2D::FinishTool()
419 {
420  auto numberOfTimesteps = static_cast<int>(m_Contour->GetTimeGeometry()->CountTimeSteps());
421 
422  for (int i = 0; i <= numberOfTimesteps; ++i)
423  m_Contour->Close(i);
424 
425  m_ToolManager->GetDataStorage()->Remove(m_LiveWireContourNode);
426 
427  m_LiveWireContourNode = nullptr;
428  m_LiveWireContour = nullptr;
429 
430  m_ContourInteractor = mitk::ContourModelLiveWireInteractor::New();
431  m_ContourInteractor->SetDataNode(m_ContourNode);
432  m_ContourInteractor->LoadStateMachine("ContourModelModificationInteractor.xml", us::GetModuleContext()->GetModule());
433  m_ContourInteractor->SetEventConfig("ContourModelModificationConfig.xml", us::GetModuleContext()->GetModule());
434  m_ContourInteractor->SetWorkingImage(this->m_WorkingSlice);
435  m_ContourInteractor->SetEditingContourModelNode(this->m_EditingContourNode);
436 
437  m_ContourNode->SetDataInteractor(m_ContourInteractor.GetPointer());
438 
439  this->m_LiveWireInteractors.push_back(m_ContourInteractor);
440 }
441 
442 void mitk::LiveWireTool2D::OnLastSegmentDelete(StateMachineAction *, InteractionEvent *interactionEvent)
443 {
444  int t = static_cast<int>(interactionEvent->GetSender()->GetTimeStep());
445 
446  // If last point of current contour will be removed go to start state and remove nodes
447  if (m_Contour->GetNumberOfVertices(t) <= 1)
448  {
449  auto dataStorage = m_ToolManager->GetDataStorage();
450 
451  dataStorage->Remove(m_LiveWireContourNode);
452  dataStorage->Remove(m_ContourNode);
453  dataStorage->Remove(m_EditingContourNode);
454 
455  m_LiveWireContour = mitk::ContourModel::New();
456  m_LiveWireContourNode->SetData(m_LiveWireContour);
457 
458  m_Contour = mitk::ContourModel::New();
459  m_ContourNode->SetData(m_Contour);
460 
461  this->ResetToStartState();
462  }
463  else // Remove last segment from contour and reset LiveWire contour
464  {
465  m_LiveWireContour = mitk::ContourModel::New();
466  m_LiveWireContourNode->SetData(m_LiveWireContour);
467 
468  auto newContour = mitk::ContourModel::New();
469  newContour->Expand(m_Contour->GetTimeSteps());
470 
471  auto begin = m_Contour->IteratorBegin();
472 
473  // Iterate from last point to next active point
474  auto newLast = m_Contour->IteratorBegin() + (m_Contour->GetNumberOfVertices() - 1);
475 
476  // Go at least one down
477  if (newLast != begin)
478  --newLast;
479 
480  // Search next active control point
481  while (newLast != begin && !((*newLast)->IsControlPoint))
482  --newLast;
483 
484  // Set position of start point for LiveWire filter to coordinates of the new last point
485  m_LiveWireFilter->SetStartPoint((*newLast)->Coordinates);
486 
487  auto it = m_Contour->IteratorBegin();
488 
489  // Fll new Contour
490  while (it <= newLast)
491  {
492  newContour->AddVertex((*it)->Coordinates, (*it)->IsControlPoint, t);
493  ++it;
494  }
495 
496  newContour->SetClosed(m_Contour->IsClosed());
497 
498  m_ContourNode->SetData(newContour);
499  m_Contour = newContour;
500 
502  }
503 }
504 
505 template <typename TPixel, unsigned int VImageDimension>
506 void mitk::LiveWireTool2D::FindHighestGradientMagnitudeByITK(itk::Image<TPixel, VImageDimension> *inputImage,
507  itk::Index<3> &index,
508  itk::Index<3> &returnIndex)
509 {
510  typedef itk::Image<TPixel, VImageDimension> InputImageType;
511  typedef typename InputImageType::IndexType IndexType;
512 
513  const auto MAX_X = inputImage->GetLargestPossibleRegion().GetSize()[0];
514  const auto MAX_Y = inputImage->GetLargestPossibleRegion().GetSize()[1];
515 
516  returnIndex[0] = index[0];
517  returnIndex[1] = index[1];
518  returnIndex[2] = 0.0;
519 
520  double gradientMagnitude = 0.0;
521  double maxGradientMagnitude = 0.0;
522 
523  // The size and thus the region of 7x7 is only used to calculate the gradient magnitude in that region,
524  // not for searching the maximum value.
525 
526  // Maximum value in each direction for size
527  typename InputImageType::SizeType size;
528  size[0] = 7;
529  size[1] = 7;
530 
531  // Minimum value in each direction for startRegion
532  IndexType startRegion;
533  startRegion[0] = index[0] - 3;
534  startRegion[1] = index[1] - 3;
535  if (startRegion[0] < 0)
536  startRegion[0] = 0;
537  if (startRegion[1] < 0)
538  startRegion[1] = 0;
539  if (MAX_X - index[0] < 7)
540  startRegion[0] = MAX_X - 7;
541  if (MAX_Y - index[1] < 7)
542  startRegion[1] = MAX_Y - 7;
543 
544  index[0] = startRegion[0] + 3;
545  index[1] = startRegion[1] + 3;
546 
547  typename InputImageType::RegionType region;
548  region.SetSize(size);
549  region.SetIndex(startRegion);
550 
551  typedef typename itk::GradientMagnitudeImageFilter<InputImageType, InputImageType> GradientMagnitudeFilterType;
552  typename GradientMagnitudeFilterType::Pointer gradientFilter = GradientMagnitudeFilterType::New();
553  gradientFilter->SetInput(inputImage);
554  gradientFilter->GetOutput()->SetRequestedRegion(region);
555 
556  gradientFilter->Update();
557  typename InputImageType::Pointer gradientMagnitudeImage;
558  gradientMagnitudeImage = gradientFilter->GetOutput();
559 
560  IndexType currentIndex;
561  currentIndex[0] = 0;
562  currentIndex[1] = 0;
563 
564  // Search max (approximate) gradient magnitude
565  for (int x = -1; x <= 1; ++x)
566  {
567  currentIndex[0] = index[0] + x;
568 
569  for (int y = -1; y <= 1; ++y)
570  {
571  currentIndex[1] = index[1] + y;
572  gradientMagnitude = gradientMagnitudeImage->GetPixel(currentIndex);
573 
574  // Check for new max
575  if (maxGradientMagnitude < gradientMagnitude)
576  {
577  maxGradientMagnitude = gradientMagnitude;
578  returnIndex[0] = currentIndex[0];
579  returnIndex[1] = currentIndex[1];
580  returnIndex[2] = 0.0;
581  }
582  }
583 
584  currentIndex[1] = index[1];
585  }
586 }
void Deactivated() override
Called when the tool gets deactivated.
unsigned int m_LastEventSlice
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
Super class for all position events.
static Pointer New()
Image::Pointer GetAffectedImageSliceAs2DImage(const InteractionPositionEvent *positionEvent, const Image *image, unsigned int component=0)
Extract the slice of an image that the user just scribbles on. The given component denotes the vector...
virtual unsigned int GetSlice() const
DataStorage * GetDataStorage()
Base of all data objects.
Definition: mitkBaseData.h:37
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.
us::ModuleResource GetCursorIconResource() const override
Returns the path of a cursor icon.
bool IsInside(const mitk::Point3D &p) const
Test whether the point p (world coordinates in mm) is inside the bounding box.
static Pointer New()
const char ** GetXPM() const override
Returns an icon in the XPM format.
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
Pointer Clone() const
void WriteSliceToVolume(const SliceInformation &sliceInfo)
BaseRenderer * m_LastEventSender
Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *)
Extract the slice of the currently selected reference image that the user just scribbles on...
virtual void Add(DataNode *node, const DataStorage::SetOfObjects *parents=nullptr)=0
Adds a DataNode containing a data object to its internal storage.
BaseRenderer * GetSender() const
static Pointer New()
MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, LiveWireTool2D, "LiveWire tool")
#define MITK_WARN
Definition: mitkLogMacros.h:19
void ConfirmSegmentation()
Convert all current contours to binary segmentations.
static Pointer New()
#define AccessFixedDimensionByItk_2(mitkImage, itkImageTypeFunction, dimension, arg1, arg2)
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
const char * GetName() const override
Returns the name of this tool. Make it short!
virtual unsigned int GetTimeStep() const
Module * GetModule() const
Image class for storing images.
Definition: mitkImage.h:72
void WriteBackSegmentationResult(const InteractionPositionEvent *, Image *)
void ResetToStartState()
ResetToStartState Reset state machine to it initial starting state.
void Activated() override
Called when the tool gets activated.
us::ModuleResource GetIconResource() const override
Returns the tool button icon of the tool wrapped by a usModuleResource.
static Pointer New()
virtual void Remove(const DataNode *node)=0
Removes node from the DataStorage.
void ClearSegmentation()
Delete all current contours.
void RequestUpdate(vtkRenderWindow *renderWindow)
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
MITKCORE_EXPORT const ScalarType sqrteps
#define CONNECT_CONDITION(a, f)
static Pointer New()
Abstract base class for segmentation tools.
Definition: mitkSegTool2D.h:54
const RegionType & GetLargestPossibleRegion() const
ToolManager * m_ToolManager
Definition: mitkTool.h:230
unsigned int GetTimeSteps() const
Get the number of time steps from the TimeGeometry As the base data has not a data vector given by it...
Definition: mitkBaseData.h:355
static Pointer New()
#define CONNECT_FUNCTION(a, f)
int AddContourmarker()
Adds a new node called Contourmarker to the datastorage which holds a mitk::PlanarFigure. By selecting this node the slicestack will be reoriented according to the PlanarFigure&#39;s Geometry.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Represents a single vertex of contour.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
void ConnectActionsAndFunctions() override
DataVectorType GetWorkingData()