23 #include <vtkLinearTransform.h>
44 if (std::find(m_RendererList.begin(), m_RendererList.end(), renderer) == m_RendererList.end())
46 m_RendererList.push_back(renderer);
49 renderer->
GetOverlayManager()->AddOverlay(m_PointNumbersOverlay.GetPointer(), renderer);
50 m_PointNumbersOverlay->SetVisibility(
false, renderer);
52 renderer->
GetOverlayManager()->AddOverlay(m_ControlPointNumbersOverlay.GetPointer(), renderer);
53 m_ControlPointNumbersOverlay->SetVisibility(
false, renderer);
55 InternalDrawContour(renderingContour, renderer);
61 if (!renderingContour)
73 ApplyColorAndOpacityProperties(renderer);
83 double red = colorprop->GetColor().GetRed();
84 double green = colorprop->GetColor().GetGreen();
85 double blue = colorprop->GetColor().GetBlue();
86 glColor4f(red, green, blue, opacity);
103 float lineWidth = 3.0;
107 bool isHovering =
false;
115 bool showSegments =
false;
118 bool showControlPoints =
false;
119 dataNode->
GetBoolProperty(
"contour.controlpoints.show", showControlPoints);
121 bool showPoints =
false;
124 bool showPointsNumbers =
false;
127 bool showControlPointsNumbers =
false;
128 dataNode->
GetBoolProperty(
"contour.controlpoints.text", showControlPointsNumbers);
130 bool projectmode =
false;
131 dataNode->
GetVisibility(projectmode, renderer,
"contour.project-onto-plane");
142 while (pointsIt != renderingContour->
IteratorEnd(timestep))
146 point = (*pointsIt)->Coordinates;
149 transform->TransformPoint(vtkp, vtkp);
161 else if (scalardiff < maxDiff)
176 if (!(pointsIt == renderingContour->
IteratorBegin(timestep)))
178 glLineWidth(lineWidth);
180 glVertex2f(pt2d[0], pt2d[1]);
181 glVertex2f(lastPt2d[0], lastPt2d[1]);
187 if (showControlPoints)
190 if ((*pointsIt)->IsControlPoint)
200 glColor3f(selectedcolor->GetColor().GetRed(),
201 selectedcolor->GetColor().GetBlue(),
202 selectedcolor->GetColor().GetGreen());
205 glBegin(GL_LINE_LOOP);
207 glVertex2dv(&tmp[0]);
209 glVertex2dv(&tmp[0]);
211 glVertex2dv(&tmp[0]);
213 glVertex2dv(&tmp[0]);
218 colorprop->GetColor().GetRed(), colorprop->GetColor().GetGreen(), colorprop->GetColor().GetBlue());
222 glVertex2dv(&tmp[0]);
237 glColor3f(0.0, 0.0, 0.0);
240 glBegin(GL_LINE_LOOP);
242 glVertex2dv(&tmp[0]);
244 glVertex2dv(&tmp[0]);
246 glVertex2dv(&tmp[0]);
248 glVertex2dv(&tmp[0]);
252 glColor3f(colorprop->GetColor().GetRed(), colorprop->GetColor().GetGreen(), colorprop->GetColor().GetBlue());
256 glVertex2dv(&tmp[0]);
260 if (showPointsNumbers)
263 std::stringstream ss;
272 WriteTextWithOverlay(m_PointNumbersOverlay, l.c_str(), rgb, pt2d, renderer);
275 if (showControlPointsNumbers && (*pointsIt)->IsControlPoint)
278 std::stringstream ss;
287 WriteTextWithOverlay(m_ControlPointNumbersOverlay, l.c_str(), rgb, pt2d, renderer);
297 if (renderingContour->
IsClosed(timestep) && drawit && showSegments)
302 transform->TransformPoint(vtkp, vtkp);
306 glLineWidth(lineWidth);
308 glVertex2f(lastPt2d[0], lastPt2d[1]);
309 glVertex2f(pt2d[0], pt2d[1]);
321 transform->TransformPoint(vtkp, vtkp);
330 if (scalardiff < maxDiff)
334 glColor3f(0.0, 1.0, 0.0);
337 glBegin(GL_LINE_LOOP);
339 tmp[0] = pt2d[0] - pointsize;
340 tmp[1] = pt2d[1] + pointsize;
341 glVertex2dv(&tmp[0]);
342 tmp[0] = pt2d[0] + pointsize;
343 tmp[1] = pt2d[1] + pointsize;
344 glVertex2dv(&tmp[0]);
345 tmp[0] = pt2d[0] + pointsize;
346 tmp[1] = pt2d[1] - pointsize;
347 glVertex2dv(&tmp[0]);
348 tmp[0] = pt2d[0] - pointsize;
349 tmp[1] = pt2d[1] - pointsize;
350 glVertex2dv(&tmp[0]);
361 textOverlay->SetText(text);
362 textOverlay->SetColor(rgb);
363 textOverlay->SetOpacity(1);
364 textOverlay->SetFontSize(16);
365 textOverlay->SetBoolProperty(
"drawShadow",
false);
366 textOverlay->SetVisibility(
true, renderer);
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
virtual void UpdateOutputInformation() override
Update the OutputInformation of a ContourModel object.
mitk::Point3D Coordinates
Coordinates in 3D space.
virtual void InternalDrawContour(mitk::ContourModel *renderingContour, mitk::BaseRenderer *renderer)
Organizes the rendering process.
virtual ScalarType SignedDistance(const Point3D &pt3d_mm) const
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
mitk::ContourElement::VertexIterator VertexIterator
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
VertexIterator IteratorBegin(int timestep=0) const
Returns a const VertexIterator at the start element of the contour.
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
TextOverlayPointerType m_ControlPointNumbersOverlay
The ColorProperty class RGB color property.
VertexType * GetSelectedVertex()
Get the current selected vertex.
void WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
This method converts a 3D world index to the display point using the geometry of the renderWindow...
ContourModelGLMapper2DBase()
TextOverlayPointerType m_PointNumbersOverlay
virtual bool IsEmptyTimeStep(unsigned int t) const override
Check if there isn't something at this timestep.
void DrawContour(mitk::ContourModel *contour, mitk::BaseRenderer *renderer)
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
void vtk2itk(const Tin &in, Tout &out)
virtual ~ContourModelGLMapper2DBase()
vtkLinearTransform * GetVtkTransform(int t=0) const
Get the transformation applied prior to displaying the data as a vtkTransform.
virtual unsigned int GetTimeStep() const
itk::SmartPointer< OverlayManager > GetOverlayManager()
Get the OverlayManager registered with this renderer if none was set, it will be created at this poin...
void itk2vtk(const Tin &in, Tout &out)
bool IsClosed(int timestep=0) const
Return if the contour is closed or not.
VertexIterator IteratorEnd(int timestep=0) const
Returns a const VertexIterator at the end element of the contour.
bool GetVisibility(bool &visible, const mitk::BaseRenderer *renderer, const char *propertyKey="visible") const
Convenience access method for visibility properties (instances of BoolProperty with property-key "vis...
void WriteTextWithOverlay(TextOverlayPointerType textOverlay, const char *text, float rgb[3], Point2D pt2d, mitk::BaseRenderer *renderer)
Class for nodes of the DataTree.
virtual const VertexType * GetVertexAt(int index, int timestep=0) const
Returns the vertex at the index position within the container.