57 if (contour ==
nullptr)
69 if (contour->SelectVertexAt(click, 1.5, timestep))
71 contour->SetSelectedVertexAsControlPoint(
false);
92 auto iter = contour->IteratorBegin(timestep);
96 this->
m_WorkingSlice->GetGeometry()->WorldToIndex((*iter)->Coordinates, idx);
102 for (; iter != contour->IteratorEnd(timestep); iter++)
105 this->
m_WorkingSlice->GetGeometry()->WorldToIndex((*iter)->Coordinates, idx);
113 contour->SetSelectedVertexAsControlPoint(
true);
150 if (contour ==
nullptr)
156 if (contour->GetSelectedVertex())
159 newContour->Expand(contour->GetTimeSteps());
170 assert(liveWireContour);
172 if (liveWireContour->
IsEmpty(timestep))
179 newContour->Concatenate(liveWireContour, timestep);
184 newContour->SetClosed(contour->IsClosed(timestep), timestep);
187 if (newContour->GetNumberOfVertices(timestep) <= 2)
189 newContour->Clear(timestep);
205 mitk::Point3D currentPosition = positionEvent->GetPositionInWorld();
208 if (contour ==
nullptr)
215 editingContour->Expand(contour->GetTimeSteps());
236 assert(leftLiveWire);
238 if (!leftLiveWire->IsEmpty(timestep))
239 leftLiveWire->RemoveVertexAt(0, timestep);
241 editingContour->Concatenate(leftLiveWire, timestep);
244 unsigned int selectedVertexIndex =
245 this->
m_ContourLeft->GetNumberOfVertices(timestep) + leftLiveWire->GetNumberOfVertices(timestep) - 1;
251 auto iter = leftLiveWire->IteratorBegin(timestep);
252 for (; iter != leftLiveWire->IteratorEnd(timestep); iter++)
255 this->
m_WorkingSlice->GetGeometry()->WorldToIndex((*iter)->Coordinates, idx);
270 assert(rightLiveWire);
273 if (abs(rightLiveWire->GetNumberOfVertices(timestep) - leftLiveWire->GetNumberOfVertices(timestep)) > 50)
278 if (!leftLiveWire->IsEmpty(timestep))
279 leftLiveWire->SetControlVertexAt(leftLiveWire->GetNumberOfVertices() - 1, timestep);
281 if (!rightLiveWire->IsEmpty(timestep))
282 rightLiveWire->RemoveVertexAt(0, timestep);
284 editingContour->Concatenate(rightLiveWire, timestep);
289 newContour->Expand(contour->GetTimeSteps());
294 newContour->Concatenate(editingContour, timestep,
true);
297 newContour->SelectVertexAt(selectedVertexIndex, timestep);
300 newContour->SetSelectedVertexAsControlPoint(
true);
305 newContour->SetClosed(contour->IsClosed(timestep), timestep);
321 mitk::Point3D currentPosition = positionEvent->GetPositionInWorld();
323 bool isHover =
false;
325 if (contour->IsNearContour(currentPosition, 1.5, timestep))
327 if (isHover ==
false)
346 bool fromSelectedUpwards,
353 auto itSelected = begin;
362 if (fromSelectedUpwards)
364 auto itUp = itSelected;
371 while (itUp != end && !((*itUp)->IsControlPoint))
378 if (itSelected != begin)
383 destContour->
AddVertex((*it)->Coordinates, (*it)->IsControlPoint, timestep);
392 return std::distance(begin, itUp) - 1;
396 return std::distance(begin, itUp);
401 auto itDown = itSelected;
404 if (itSelected != begin)
411 while (itDown != begin && !((*itDown)->IsControlPoint))
419 destContour->
AddVertex((*it)->Coordinates, (*it)->IsControlPoint, timestep);
425 destContour->
AddVertex((*it)->Coordinates, (*it)->IsControlPoint, timestep);
434 while (!((*itDown)->IsControlPoint) && itDown != begin)
442 while ((it != end) && !((*it)->IsControlPoint))
450 destContour->
AddVertex((*it)->Coordinates, (*it)->IsControlPoint, timestep);
464 return std::distance(begin, itDown);
468 return std::distance(begin, itDown) - 1;
479 editingContour->
Clear(timestep);
bool IsHovering(const InteractionEvent *interactionEvent) override
int GetNumberOfVertices(int timestep=0) const
Returns the number of vertices at a given timestep.
void OnMovePoint(StateMachineAction *, InteractionEvent *interactionEvent) override
bool RemoveVertexAt(int index, int timestep=0)
Remove a vertex at given index within the container.
std::vector< itk::Index< 2 > > m_ContourBeingModified
virtual bool IsEmpty(int timestep) const
Returns whether the contour model is empty at a given timestep. timestep - default = 0...
virtual void Clear(int timestep)
Clear the storage container at given timestep.
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
Super class for all position events.
mitk::Image::Pointer m_WorkingSlice
mitk::ContourModel::VertexIterator m_NextActiveVertexUpIter
mitk::DataNode::Pointer m_EditingContourNode
void OnFinishEditing(StateMachineAction *, InteractionEvent *interactionEvent) override
virtual void SetData(mitk::BaseData *baseData)
Set the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
bool OnCheckPointClick(const InteractionEvent *interactionEvent) override
Constants for most interaction classes, due to the generic StateMachines.
mitk::Point3D m_NextActiveVertexDown
mitk::ContourModel::Pointer m_ContourLeft
int SplitContourFromSelectedVertex(mitk::ContourModel *srcContour, mitk::ContourModel *destContour, bool fromSelectedUpwards, int timestep)
mitk::ImageLiveWireContourModelFilter::Pointer m_LiveWireFilter
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
DataNode * GetDataNode() const
BaseRenderer * GetSender() const
void AddVertex(mitk::Point3D &vertex, int timestep=0)
Add a vertex to the contour at given timestep. The vertex is added at the end of contour.
ContourModelLiveWireInteractor()
VertexType * GetSelectedVertex()
Get the current selected vertex.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
mitk::ContourModel::Pointer m_ContourRight
mitk::Point3D m_NextActiveVertexUp
mitk::ContourModel::VertexIterator m_NextActiveVertexDownIter
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
virtual unsigned int GetTimeStep() const
Image class for storing images.
~ContourModelLiveWireInteractor() override
VertexIterator IteratorEnd(int timestep=0) const
Returns a const VertexIterator at the end element of the contour.
virtual void SetWorkingImage(mitk::Image *_arg)
void SetBoolProperty(const char *propertyKey, bool boolValue, const mitk::BaseRenderer *renderer=nullptr)
Convenience method for setting boolean properties (instances of BoolProperty)
void RequestUpdate(vtkRenderWindow *renderWindow)
void ConnectActionsAndFunctions() override
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
#define CONNECT_CONDITION(a, f)
VertexIterator IteratorBegin(int timestep=0) const
Returns a const VertexIterator at the start element of the contour.
#define CONNECT_FUNCTION(a, f)
void OnDeletePoint(StateMachineAction *, InteractionEvent *interactionEvent) override
virtual void SetEditingContourModelNode(mitk::DataNode *_arg)
Class for nodes of the DataTree.