28 #include <vtkCellArray.h>
29 #include <vtkFloatArray.h>
30 #include <vtkGlyph3D.h>
31 #include <vtkGlyphSource2D.h>
33 #include <vtkPointData.h>
34 #include <vtkPolyDataMapper.h>
35 #include <vtkPropAssembly.h>
36 #include <vtkTextActor.h>
37 #include <vtkTextProperty.h>
38 #include <vtkTransform.h>
39 #include <vtkTransformFilter.h>
139 if ((fabs(in[0]) > 0) && ((fabs(in[0]) > fabs(in[1])) || (in[1] == 0)))
142 out[0] = -in[1] / in[0];
147 else if (fabs(in[1]) > 0)
151 out[1] = -in[0] / in[1];
198 this->GetDataNode()->GetBoolProperty(
"updateDataOnRender", update);
202 int timestep = this->GetTimestep();
205 if (itkPointSet.GetPointer() == NULL)
212 mitk::PointSet::PointsContainer::Iterator pointsIter = itkPointSet->GetPoints()->Begin();
216 mitk::PointSet::PointDataContainer::Iterator pointDataIter;
217 pointDataIter = itkPointSet->GetPointData()->Begin();
222 bool pointDataBroken = (itkPointSet->GetPointData()->Size() != itkPointSet->GetPoints()->Size());
224 if (itkPointSet->GetPointData()->size() == 0 || pointDataBroken)
251 int NumberContourPoints = 0;
252 bool pointsOnSameSideOfPlane =
false;
254 const int text2dDistance = 10;
259 itk::Point<ScalarType> point = pointsIter->Value();
276 vtkLinearTransform *dataNodeTransform = input->GetGeometry()->GetVtkTransform();
280 for (pointsIter = itkPointSet->GetPoints()->Begin(); pointsIter != itkPointSet->GetPoints()->End(); pointsIter++)
283 preLastPt2d = lastPt2d;
289 point = pointsIter->Value();
295 dataNodeTransform->TransformPoint(vtkp, vtkp);
308 float dist = geo2D->
Distance(point);
312 if (dist < m_DistanceToPlane)
315 if (pointDataIter->Value().selected)
330 if (dynamic_cast<mitk::StringProperty *>(this->GetDataNode()->GetProperty(
"label")) != NULL)
332 const char *pointLabel =
334 std::string l = pointLabel;
335 if (input->GetSize() > 1)
337 std::stringstream ss;
338 ss << pointsIter->Index();
344 ls->
m_VtkTextActor->SetDisplayPosition(pt2d[0] + text2dDistance, pt2d[1] + text2dDistance);
348 float unselectedColor[4] = {1.0, 1.0, 0.0, 1.0};
351 GetDataNode()->GetColor(unselectedColor);
353 ls->
m_VtkTextActor->GetTextProperty()->SetColor(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
362 if (m_ShowContour && count > 0)
367 pointsOnSameSideOfPlane = (distance * lastDistance) > 0.5;
371 if (!pointsOnSameSideOfPlane || m_ShowDistantLines)
376 line->GetPointIds()->SetId(0, NumberContourPoints);
377 NumberContourPoints++;
380 line->GetPointIds()->SetId(1, NumberContourPoints);
381 NumberContourPoints++;
387 float distancePoints = point.EuclideanDistanceTo(lastP);
389 std::stringstream buffer;
390 buffer << std::fixed << std::setprecision(m_DistancesDecimalDigits) << distancePoints <<
" mm";
396 Vector2D pos2d = (lastPt2d.GetVectorFromOrigin() + pt2d.GetVectorFromOrigin()) * 0.5 + vec2d * text2dDistance;
407 if (m_ShowAngles && count > 1)
409 std::stringstream buffer;
410 buffer << angle(vec.GetVnlVector(), -lastVec.GetVnlVector()) * 180 / vnl_math::pi <<
"°";
415 Vector2D lastVec2d = lastPt2d - preLastPt2d;
416 lastVec2d.Normalize();
417 vec2d = vec2d - lastVec2d;
421 Vector2D pos2d = lastPt2d.GetVectorFromOrigin() + vec2d * text2dDistance * text2dDistance;
434 if (pointDataIter != itkPointSet->GetPointData()->End())
463 if (m_CloseContour && NumberContourPoints > 1)
466 closingLine->GetPointIds()->SetId(0, 0);
467 closingLine->GetPointIds()->SetId(1, NumberContourPoints - 1);
490 b->SetElement(3, 3, 1);
491 b->SetElement(2, 3, 0);
492 b->SetElement(1, 3, 0);
493 b->SetElement(0, 3, 0);
494 b->SetElement(3, 2, 0);
495 b->SetElement(3, 1, 0);
496 b->SetElement(3, 0, 0);
501 b->SetElement(0, 0, b->GetElement(0, 0) / spacing[0]);
502 b->SetElement(1, 0, b->GetElement(1, 0) / spacing[0]);
503 b->SetElement(2, 0, b->GetElement(2, 0) / spacing[0]);
504 b->SetElement(1, 1, b->GetElement(1, 1) / spacing[1]);
505 b->SetElement(2, 1, b->GetElement(2, 1) / spacing[1]);
507 b->SetElement(0, 2, b->GetElement(0, 2) / spacing[2]);
508 b->SetElement(1, 2, b->GetElement(1, 2) / spacing[2]);
509 b->SetElement(2, 2, b->GetElement(2, 2) / spacing[2]);
511 transform->SetMatrix(b);
526 transformFilterU->SetTransform(transform);
552 transformFilterS->SetTransform(transform);
601 node->
GetIntProperty(
"distance decimal digits", m_DistancesDecimalDigits, renderer);
603 node->
GetBoolProperty(
"show distant lines", m_ShowDistantLines, renderer);
605 node->
GetIntProperty(
"point line width", m_PointLineWidth, renderer);
607 "point 2D size", m_Point2DSize, renderer))
609 int oldPointSize = m_Point2DSize;
610 if (node->
GetIntProperty(
"point 2D size", oldPointSize, renderer))
612 m_Point2DSize = oldPointSize;
615 node->
GetBoolProperty(
"Pointset.2D.fill shape", m_FillShape, renderer);
616 node->
GetFloatProperty(
"Pointset.2D.distance to plane", m_DistanceToPlane, renderer);
620 if (shape.IsNotNull())
622 m_IDShapeProperty = shape->GetPointSetShape();
630 GetDataNode()->GetOpacity(opacity, renderer);
635 float unselectedColor[4];
642 GetDataNode()->GetColor(unselectedColor);
645 if (dynamic_cast<mitk::ColorProperty *>(
646 this->GetDataNode()->GetPropertyList(renderer)->GetProperty(
"selectedcolor")) != NULL)
649 this->GetDataNode()->GetPropertyList(renderer)->GetProperty(
"selectedcolor"))
651 selectedColor[0] = tmpColor[0];
652 selectedColor[1] = tmpColor[1];
653 selectedColor[2] = tmpColor[2];
654 selectedColor[3] = 1.0f;
656 else if (dynamic_cast<mitk::ColorProperty *>(
657 this->GetDataNode()->GetPropertyList(NULL)->GetProperty(
"selectedcolor")) != NULL)
660 dynamic_cast<mitk::ColorProperty *
>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty(
"selectedcolor"))
662 selectedColor[0] = tmpColor[0];
663 selectedColor[1] = tmpColor[1];
664 selectedColor[2] = tmpColor[2];
665 selectedColor[3] = 1.0f;
671 ls->
m_UnselectedActor->GetProperty()->SetColor(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
682 double contourColor[4] = {1.0f, 0.0f, 0.0f, 1.0f};
686 if (dynamic_cast<mitk::ColorProperty *>(
687 this->GetDataNode()->GetPropertyList(renderer)->GetProperty(
"contourcolor")) != NULL)
690 dynamic_cast<mitk::ColorProperty *
>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty(
"contourcolor"))
692 contourColor[0] = tmpColor[0];
693 contourColor[1] = tmpColor[1];
694 contourColor[2] = tmpColor[2];
695 contourColor[3] = 1.0f;
697 else if (dynamic_cast<mitk::ColorProperty *>(
698 this->GetDataNode()->GetPropertyList(NULL)->GetProperty(
"contourcolor")) != NULL)
701 dynamic_cast<mitk::ColorProperty *
>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty(
"contourcolor"))
703 contourColor[0] = tmpColor[0];
704 contourColor[1] = tmpColor[1];
705 contourColor[2] = tmpColor[2];
706 contourColor[3] = 1.0f;
717 if (needGenerateData)
720 this->CreateVTKRenderObjects(renderer);
742 node->
AddProperty(
"Pointset.2D.shape", pointsetShapeProperty, renderer, overwrite);
748 Superclass::SetDefaultProperties(node, renderer, overwrite);
std::vector< vtkSmartPointer< vtkTextActor > > m_VtkTextLabelActors
itk::SmartPointer< Self > Pointer
vtkSmartPointer< vtkPropAssembly > m_PropAssembly
vtkSmartPointer< vtkActor > m_ContourActor
vtkSmartPointer< vtkActor > m_UnselectedActor
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
vtkSmartPointer< vtkPolyDataMapper > m_VtkSelectedPolyDataMapper
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)
virtual const mitk::PointSet * GetInput() const
vtkSmartPointer< vtkGlyph3D > m_UnselectedGlyph3D
DataCollection - Class to facilitate loading/accessing structured data.
ScalarType Distance(const Point3D &pt3d_mm) const
Distance of the point from the geometry (bounding-box not considered)
const mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
vtkSmartPointer< vtkPolyData > m_VtkUnselectedPointListPolyData
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
vtkSmartPointer< vtkFloatArray > m_DistancesBetweenPoints
vtkSmartPointer< vtkPoints > m_SelectedPoints
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
set the default properties for this mapper
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
returns the a prop assembly
vtkSmartPointer< vtkFloatArray > m_UnselectedScales
vtkSmartPointer< vtkPolyDataMapper > m_VtkContourPolyDataMapper
std::vector< vtkSmartPointer< vtkTextActor > > m_VtkTextAngleActors
vtkSmartPointer< vtkPolyDataMapper > m_VtkUnselectedPolyDataMapper
vtkSmartPointer< vtkFloatArray > m_SelectedScales
vtkSmartPointer< vtkPoints > m_UnselectedPoints
The ColorProperty class RGB color property.
vtkSmartPointer< vtkPolyData > m_VtkSelectedPointListPolyData
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...
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Mapper *mapper, mitk::DataNode *dataNode) const
Data structure which stores a set of points. Superclass of mitk::Mesh.
vtkSmartPointer< vtkPolyData > m_VtkContourPolyData
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
vtkSmartPointer< vtkPoints > m_ContourPoints
vtkSmartPointer< vtkActor > m_SelectedActor
vtkSmartPointer< vtkCellArray > m_ContourLines
void vtk2itk(const Tin &in, Tout &out)
vtkSmartPointer< vtkGlyphSource2D > m_SelectedGlyphSource2D
vtkSmartPointer< vtkGlyph3D > m_SelectedGlyph3D
int m_DistancesDecimalDigits
vtkSmartPointer< vtkTextActor > m_VtkTextActor
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
void itk2vtk(const Tin &in, Tout &out)
vtkSmartPointer< vtkGlyphSource2D > m_UnselectedGlyphSource2D
virtual ~PointSetVtkMapper2D()
virtual void ResetMapper(BaseRenderer *renderer) override
Reset the mapper (i.e., make sure that nothing is displayed) if no valid data is present. In most cases the reimplemented function disables the according actors (toggling visibility off)
const float selectedColor[]
virtual void CreateVTKRenderObjects(mitk::BaseRenderer *renderer)
Describes a two-dimensional, rectangular plane.
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
std::vector< vtkSmartPointer< vtkTextActor > > m_VtkTextDistanceActors
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
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...
Class for nodes of the DataTree.
static bool makePerpendicularVector2D(const mitk::Vector2D &in, mitk::Vector2D &out)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.