diff --git a/Core/Code/Rendering/mitkGLMapper2D.h b/Core/Code/Rendering/mitkGLMapper2D.h index d332e5ee60..cb4cc6fec3 100644 --- a/Core/Code/Rendering/mitkGLMapper2D.h +++ b/Core/Code/Rendering/mitkGLMapper2D.h @@ -1,35 +1,35 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKGLMAPPER2D_H_HEADER_INCLUDED_C197C872 #define MITKGLMAPPER2D_H_HEADER_INCLUDED_C197C872 #include "mitkGLMapper.h" namespace mitk { // typedef allows integration of mappers into the new mapper architecture - // @deprecated Use GLMapper instead + // \deprecatedSince{2013_03} Use GLMapper instead DEPRECATED(typedef GLMapper GLMapper2D); } // namespace mitk #endif /* MITKGLMAPPER2D_H_HEADER_INCLUDED_C197C872 */ diff --git a/Core/Code/Rendering/mitkPointSetVtkMapper2D.cpp b/Core/Code/Rendering/mitkPointSetVtkMapper2D.cpp index 70fc445df6..c4fea1b06e 100644 --- a/Core/Code/Rendering/mitkPointSetVtkMapper2D.cpp +++ b/Core/Code/Rendering/mitkPointSetVtkMapper2D.cpp @@ -1,765 +1,765 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPointSetVtkMapper2D.h" #include "mitkDataNode.h" #include "mitkProperties.h" #include "mitkColorProperty.h" #include "mitkEnumerationProperty.h" #include "mitkVtkPropRenderer.h" #include "mitkPointSet.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include mitk::PointSetVtkMapper2D::LocalStorage::LocalStorage() { // points m_UnselectedPoints = vtkSmartPointer::New(); m_SelectedPoints = vtkSmartPointer::New(); m_ContourPoints = vtkSmartPointer::New(); // scales m_UnselectedScales = vtkSmartPointer::New(); m_SelectedScales = vtkSmartPointer::New(); // distances m_DistancesBetweenPoints = vtkSmartPointer::New(); // lines m_ContourLines = vtkSmartPointer::New(); // glyph source (provides the different shapes) m_UnselectedGlyphSource2D = vtkSmartPointer::New(); m_SelectedGlyphSource2D = vtkSmartPointer::New(); // glyphs m_UnselectedGlyph3D = vtkSmartPointer::New(); m_SelectedGlyph3D = vtkSmartPointer::New(); // polydata m_VtkUnselectedPointListPolyData = vtkSmartPointer::New(); m_VtkSelectedPointListPolyData = vtkSmartPointer ::New(); m_VtkContourPolyData = vtkSmartPointer::New(); // actors m_UnselectedActor = vtkSmartPointer ::New(); m_SelectedActor = vtkSmartPointer ::New(); m_ContourActor = vtkSmartPointer ::New(); // mappers m_VtkUnselectedPolyDataMapper = vtkSmartPointer::New(); m_VtkSelectedPolyDataMapper = vtkSmartPointer::New(); m_VtkContourPolyDataMapper = vtkSmartPointer::New(); // propassembly m_PropAssembly = vtkSmartPointer ::New(); } mitk::PointSetVtkMapper2D::LocalStorage::~LocalStorage() { } // input for this mapper ( = point set) const mitk::PointSet* mitk::PointSetVtkMapper2D::GetInput() { return static_cast ( GetDataNode()->GetData() ); } // constructor mitk::PointSetVtkMapper2D::PointSetVtkMapper2D() : m_Polygon(false), m_PolygonClosed(false), m_ShowPoints(true), m_ShowDistances(false), m_DistancesDecimalDigits(1), m_ShowAngles(false), m_ShowDistantLines(false), m_LineWidth(1), m_PointLineWidth(1), m_Point2DSize(6), m_IdGlyph(3), // default: cross m_FillGlyphs(false) { } // destructor mitk::PointSetVtkMapper2D::~PointSetVtkMapper2D() { } // toggles visiblity of the prop assembly void mitk::PointSetVtkMapper2D::ResetMapper( BaseRenderer* renderer ) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); ls->m_PropAssembly->VisibilityOff(); } // returns propassembly vtkProp* mitk::PointSetVtkMapper2D::GetVtkProp(mitk::BaseRenderer * renderer) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); return ls->m_PropAssembly; } static bool makePerpendicularVector2D(const mitk::Vector2D& in, mitk::Vector2D& out) { if((fabs(in[0])>0) && ( (fabs(in[0])>fabs(in[1])) || (in[1] == 0) ) ) { out[0]=-in[1]/in[0]; out[1]=1; out.Normalize(); return true; } else if(fabs(in[1])>0) { out[0]=1; out[1]=-in[0]/in[1]; out.Normalize(); return true; } else return false; } void mitk::PointSetVtkMapper2D::CreateVTKRenderObjects(mitk::BaseRenderer* renderer) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_UnselectedActor)) ls->m_PropAssembly->RemovePart(ls->m_UnselectedActor); if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_SelectedActor)) ls->m_PropAssembly->RemovePart(ls->m_SelectedActor); if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_ContourActor)) ls->m_PropAssembly->RemovePart(ls->m_ContourActor); if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_VtkTextActor)) ls->m_PropAssembly->RemovePart(ls->m_VtkTextActor); unsigned i = 0; for(i=0; i< ls->m_VtkTextLabelActors.size(); i++) { if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_VtkTextLabelActors.at(i))) ls->m_PropAssembly->RemovePart(ls->m_VtkTextLabelActors.at(i)); } for(i=0; i< ls->m_VtkTextDistanceActors.size(); i++) { if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_VtkTextDistanceActors.at(i))) ls->m_PropAssembly->RemovePart(ls->m_VtkTextDistanceActors.at(i)); } for(i=0; i< ls->m_VtkTextAngleActors.size(); i++) { if(ls->m_PropAssembly->GetParts()->IsItemPresent(ls->m_VtkTextAngleActors.at(i))) ls->m_PropAssembly->RemovePart(ls->m_VtkTextAngleActors.at(i)); } // polydata ls->m_VtkUnselectedPointListPolyData = vtkSmartPointer::New(); ls->m_VtkSelectedPointListPolyData = vtkSmartPointer ::New(); ls->m_VtkContourPolyData = vtkSmartPointer::New(); // exceptional displaying for PositionTracker -> MouseOrientationTool int mapperID; bool isInputDevice=false; if( this->GetDataNode()->GetBoolProperty("inputdevice",isInputDevice) && isInputDevice ) { if( this->GetDataNode()->GetIntProperty("BaseRendererMapperID",mapperID) && mapperID == 2) return; //The event for the PositionTracker came from the 3d widget and not needs to be displayed } // get input point set and update the PointSet mitk::PointSet::Pointer input = const_cast(this->GetInput()); /* only update the input data, if the property tells us to */ bool update = true; this->GetDataNode()->GetBoolProperty("updateDataOnRender", update); if (update == true) input->Update(); //TODO: insert last changes on timestamps int timestep = this->GetTimestep(); mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet( timestep ); if ( itkPointSet.GetPointer() == NULL) { ls->m_PropAssembly->VisibilityOff(); return; } //iterator for point set mitk::PointSet::PointsContainer::Iterator pointsIter; mitk::PointSet::PointsContainer::Iterator pointsIterPredecessor; pointsIterPredecessor = itkPointSet->GetPoints()->Begin(); // PointDataContainer has additional information to each point, e.g. whether // it is selected or not mitk::PointSet::PointDataContainer::Iterator pointDataIter; pointDataIter = itkPointSet->GetPointData()->Begin(); //check if the list for the PointDataContainer is the same size as the PointsContainer. //If not, then the points were inserted manually and can not be visualized according to the PointData (selected/unselected) bool pointDataBroken = (itkPointSet->GetPointData()->Size() != itkPointSet->GetPoints()->Size()); if(itkPointSet->GetPointData()->size() == 0 || pointDataBroken) { return; } // empty point sets, cellarrays, scalars ls->m_UnselectedPoints->Reset(); ls->m_SelectedPoints->Reset(); ls->m_ContourPoints->Reset(); ls->m_ContourLines->Reset(); ls->m_UnselectedScales->Reset(); ls->m_SelectedScales->Reset(); ls->m_DistancesBetweenPoints->Reset(); ls->m_VtkTextLabelActors.clear(); ls->m_VtkTextDistanceActors.clear(); ls->m_VtkTextAngleActors.clear(); ls->m_UnselectedScales->SetNumberOfComponents(3); ls->m_SelectedScales->SetNumberOfComponents(3); int NumberContourPoints = 0; bool pointsOnSameSideOfPlane = false; const int text2dDistance = 10; // current point in point set itk::Point point; Point3D p; // currently visited point Point3D lastP; // last visited point Vector3D vec; // p - lastP Vector3D lastVec; // lastP - point before lastP vec.Fill(0); mitk::Point3D projected_p; // p projected on viewplane Point2D pt2d; // projected_p in display coordinates Point2D lastPt2d; // last projected_p in display coordinates Point2D preLastPt2d;// projected_p in display coordinates before lastPt2 vtkLinearTransform* linearTransform = GetDataNode()->GetVtkTransform(); // get display geometry mitk::DisplayGeometry::Pointer displayGeometry = renderer->GetDisplayGeometry(); // get plane geometry mitk::PlaneGeometry::ConstPointer planeGeometry = renderer->GetSliceNavigationController()->GetCurrentPlaneGeometry(); int count = 0; for (pointsIter=itkPointSet->GetPoints()->Begin(); pointsIter!=itkPointSet->GetPoints()->End(); pointsIter++) { lastP = p; // valid for number of points count > 0 preLastPt2d = lastPt2d; // valid only for count > 1 lastPt2d = pt2d; // valid for number of points count > 0 lastVec = vec; // valid only for counter > 1 // get current point in point set point = pointsIter->Value(); p[0] = point[0]; p[1] = point[1]; p[2] = point[2]; displayGeometry->Project(p, projected_p); displayGeometry->Map(projected_p, pt2d); displayGeometry->WorldToDisplay(pt2d, pt2d); vec = p-lastP; // valid only for counter > 0 // compute distance to current plane float diff = planeGeometry->DistanceFromPlane(point); diff = diff * diff; //MouseOrientation bool isInputDevice=false; this->GetDataNode()->GetBoolProperty("inputdevice",isInputDevice); // if point is close to current plane ( distance < 4) it will be displayed if(!isInputDevice && (diff < 4.0)) { // is point selected or not? if (pointDataIter->Value().selected) { ls->m_SelectedPoints->InsertNextPoint(point[0],point[1],point[2]); // point is scaled according to its distance to the plane ls->m_SelectedScales->InsertNextTuple3(m_Point2DSize - (2*diff),0,0); } else { ls->m_UnselectedPoints->InsertNextPoint(point[0],point[1],point[2]); // point is scaled according to its distance to the plane ls->m_UnselectedScales->InsertNextTuple3(m_Point2DSize - (2*diff),0,0); } //---- LABEL -----// // paint label for each point if available if (dynamic_cast(this->GetDataNode()->GetProperty("label")) != NULL) { const char * pointLabel = dynamic_cast( this->GetDataNode()->GetProperty("label"))->GetValue(); std::string l = pointLabel; if (input->GetSize()>1) { char buffer[20]; sprintf(buffer,"%d",pointsIter->Index()); std::stringstream ss; ss << pointsIter->Index(); l.append(ss.str()); } ls->m_VtkTextActor = vtkSmartPointer::New(); ls->m_VtkTextActor->SetPosition(pt2d[0] + text2dDistance, pt2d[1] + text2dDistance); ls->m_VtkTextActor->SetInput(l.c_str()); ls->m_VtkTextActor->GetTextProperty()->SetOpacity( 100 ); float unselectedColor[4]; //check if there is a color property GetDataNode()->GetColor(unselectedColor); if (unselectedColor != NULL) ls->m_VtkTextActor->GetTextProperty()->SetColor(unselectedColor[0], unselectedColor[1], unselectedColor[2]); else ls->m_VtkTextActor->GetTextProperty()->SetColor(0.0f, 1.0f, 0.0f); ls->m_VtkTextLabelActors.push_back(ls->m_VtkTextActor); } } // draw contour, distance text and angle text in render window // lines between points, which intersect the current plane, are drawn if( m_Polygon && count > 0 ) { ScalarType distance = displayGeometry->GetWorldGeometry()->SignedDistance(point); ScalarType lastDistance = displayGeometry->GetWorldGeometry()->SignedDistance(lastP); pointsOnSameSideOfPlane = (distance * lastDistance) > 0.5; if ( !pointsOnSameSideOfPlane ) // points on different sides of plane -> draw it { vtkSmartPointer line = vtkSmartPointer::New(); ls->m_ContourPoints->InsertNextPoint(lastP[0],lastP[1],lastP[2]); line->GetPointIds()->SetId(0, NumberContourPoints); NumberContourPoints++; ls->m_ContourPoints->InsertNextPoint(point[0], point[1], point[2]); line->GetPointIds()->SetId(1, NumberContourPoints); NumberContourPoints++; ls->m_ContourLines->InsertNextCell(line); if(m_ShowDistances) // calculate and print distance between adjacent points { float distancePoints = point.EuclideanDistanceTo(lastP); std::stringstream buffer; buffer<m_VtkTextActor = vtkSmartPointer::New(); ls->m_VtkTextActor->SetPosition(pos2d[0],pos2d[1]); ls->m_VtkTextActor->SetInput(buffer.str().c_str()); ls->m_VtkTextActor->GetTextProperty()->SetColor(0.0, 1.0, 0.0); ls->m_VtkTextDistanceActors.push_back(ls->m_VtkTextActor); } if(m_ShowAngles && count > 1) // calculate and print angle between connected lines { std::stringstream buffer; //(char) 176 is the degree sign buffer << angle(vec.GetVnlVector(), -lastVec.GetVnlVector())*180/vnl_math::pi << (char)176; //compute desired display position of text Vector2D vec2d = pt2d-lastPt2d; // first arm enclosing the angle vec2d.Normalize(); Vector2D lastVec2d = lastPt2d-preLastPt2d; // second arm enclosing the angle lastVec2d.Normalize(); vec2d=vec2d-lastVec2d; // vector connecting both arms vec2d.Normalize(); // middle between two vectors that enclose the angle Vector2D pos2d = lastPt2d.GetVectorFromOrigin() + vec2d * text2dDistance * text2dDistance; ls->m_VtkTextActor = vtkSmartPointer::New(); ls->m_VtkTextActor->SetPosition(pos2d[0],pos2d[1]); ls->m_VtkTextActor->SetInput(buffer.str().c_str()); ls->m_VtkTextActor->GetTextProperty()->SetColor(0.0, 1.0, 0.0); ls->m_VtkTextAngleActors.push_back(ls->m_VtkTextActor); } } } if(pointDataIter != itkPointSet->GetPointData()->End()) { pointDataIter++; count++; } } // add each single text actor to the assembly for(i=0; i< ls->m_VtkTextLabelActors.size(); i++) { ls->m_PropAssembly->AddPart(ls->m_VtkTextLabelActors.at(i)); } for(i=0; i< ls->m_VtkTextDistanceActors.size(); i++) { ls->m_PropAssembly->AddPart(ls->m_VtkTextDistanceActors.at(i)); } for(i=0; i< ls->m_VtkTextAngleActors.size(); i++) { ls->m_PropAssembly->AddPart(ls->m_VtkTextAngleActors.at(i)); } //---- CONTOUR -----// //create lines between the points which intersect the plane if (m_Polygon) { // draw line between first and last point which is rendered if(m_PolygonClosed && NumberContourPoints > 1){ vtkSmartPointer closingLine = vtkSmartPointer::New(); closingLine->GetPointIds()->SetId(0, 0); // index of first point closingLine->GetPointIds()->SetId(1, NumberContourPoints-1); // index of last point ls->m_ContourLines->InsertNextCell(closingLine); } ls->m_VtkContourPolyData->SetPoints(ls->m_ContourPoints); ls->m_VtkContourPolyData->SetLines(ls->m_ContourLines); ls->m_VtkContourPolyDataMapper->SetInput(ls->m_VtkContourPolyData); ls->m_ContourActor->SetMapper(ls->m_VtkContourPolyDataMapper); ls->m_ContourActor->GetProperty()->SetLineWidth(m_LineWidth); ls->m_PropAssembly->AddPart(ls->m_ContourActor); } // the point set must be transformed in order to obtain the appropriate glyph orientation // according to the current view vtkSmartPointer transform = vtkSmartPointer::New(); vtkSmartPointer a,b = vtkSmartPointer::New(); a = planeGeometry->GetVtkTransform()->GetMatrix(); b->DeepCopy( a ); // delete transformation from matrix, only take orientation b->SetElement(3,3,1); b->SetElement(2,3,0); b->SetElement(1,3,0); b->SetElement(0,3,0); b->SetElement(3,2,0); b->SetElement(3,1,0); b->SetElement(3,0,0); transform->SetMatrix( b ); //---- UNSELECTED POINTS -----// // apply properties to glyph ls->m_UnselectedGlyphSource2D->SetGlyphType(m_IdGlyph); if(m_FillGlyphs) ls->m_UnselectedGlyphSource2D->FilledOn(); else ls->m_UnselectedGlyphSource2D->FilledOff(); // apply transform vtkSmartPointer transformFilterU = vtkSmartPointer::New(); transformFilterU->SetInputConnection(ls->m_UnselectedGlyphSource2D->GetOutputPort()); transformFilterU->SetTransform(transform); ls->m_VtkUnselectedPointListPolyData->SetPoints(ls->m_UnselectedPoints); ls->m_VtkUnselectedPointListPolyData->GetPointData()->SetVectors(ls->m_UnselectedScales); // apply transform of current plane to glyphs ls->m_UnselectedGlyph3D->SetSourceConnection(transformFilterU->GetOutputPort()); ls->m_UnselectedGlyph3D->SetInput(ls->m_VtkUnselectedPointListPolyData); ls->m_UnselectedGlyph3D->SetScaleModeToScaleByVector(); ls->m_UnselectedGlyph3D->SetVectorModeToUseVector(); ls->m_VtkUnselectedPolyDataMapper->SetInput(ls->m_UnselectedGlyph3D->GetOutput()); ls->m_UnselectedActor->SetMapper(ls->m_VtkUnselectedPolyDataMapper); ls->m_UnselectedActor->GetProperty()->SetLineWidth(m_PointLineWidth); ls->m_PropAssembly->AddPart(ls->m_UnselectedActor); //---- SELECTED POINTS -----// ls->m_SelectedGlyphSource2D->SetGlyphTypeToDiamond(); ls->m_SelectedGlyphSource2D->CrossOn(); ls->m_SelectedGlyphSource2D->FilledOff(); // apply transform vtkSmartPointer transformFilterS = vtkSmartPointer::New(); transformFilterS->SetInputConnection(ls->m_SelectedGlyphSource2D->GetOutputPort()); transformFilterS->SetTransform(transform); ls->m_VtkSelectedPointListPolyData->SetPoints(ls->m_SelectedPoints); ls->m_VtkSelectedPointListPolyData->GetPointData()->SetVectors(ls->m_SelectedScales); // apply transform of current plane to glyphs ls->m_SelectedGlyph3D->SetSourceConnection(transformFilterS->GetOutputPort()); ls->m_SelectedGlyph3D->SetInput(ls->m_VtkSelectedPointListPolyData); ls->m_SelectedGlyph3D->SetScaleModeToScaleByVector(); ls->m_SelectedGlyph3D->SetVectorModeToUseVector(); ls->m_VtkSelectedPolyDataMapper->SetInput(ls->m_SelectedGlyph3D->GetOutput()); ls->m_SelectedActor->SetMapper(ls->m_VtkSelectedPolyDataMapper); ls->m_SelectedActor->GetProperty()->SetLineWidth(m_PointLineWidth); ls->m_PropAssembly->AddPart(ls->m_SelectedActor); } void mitk::PointSetVtkMapper2D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { const mitk::DataNode* node = GetDataNode(); if( node == NULL ) return; LocalStorage *ls = m_LSH.GetLocalStorage(renderer); bool needGenerateData = ls->IsGenerateDataRequired( renderer, this, GetDataNode() ); // toggle visibility bool visible = true; node->GetVisibility(visible, renderer, "visible"); if(!visible) { ls->m_UnselectedActor->VisibilityOff(); ls->m_SelectedActor->VisibilityOff(); ls->m_ContourActor->VisibilityOff(); ls->m_PropAssembly->VisibilityOff(); return; }else{ ls->m_PropAssembly->VisibilityOn(); } node->GetBoolProperty("show contour", m_Polygon, renderer); node->GetBoolProperty("close contour", m_PolygonClosed, renderer); node->GetBoolProperty("show points", m_ShowPoints, renderer); node->GetBoolProperty("show distances", m_ShowDistances, renderer); node->GetIntProperty("distance decimal digits", m_DistancesDecimalDigits, renderer); node->GetBoolProperty("show angles", m_ShowAngles, renderer); node->GetBoolProperty("show distant lines", m_ShowDistantLines, renderer); node->GetIntProperty("line width", m_LineWidth, renderer); node->GetIntProperty("point line width", m_PointLineWidth, renderer); node->GetIntProperty("point 2D size", m_Point2DSize, renderer); - mitk::EnumerationProperty* eP = dynamic_cast (node->GetProperty("glyph type", renderer)); + mitk::EnumerationProperty* eP = dynamic_cast (node->GetProperty("Pointset.2D.shape", renderer)); m_IdGlyph = eP->GetValueAsId(); - node->GetBoolProperty("fill glyphs", m_FillGlyphs, renderer); + node->GetBoolProperty("Pointset.2D.fill shape", m_FillGlyphs, renderer); //check for color props and use it for rendering of selected/unselected points and contour //due to different params in VTK (double/float) we have to convert float unselectedColor[4]; vtkFloatingPointType selectedColor[4]={1.0f,0.0f,0.0f,1.0f}; //red vtkFloatingPointType contourColor[4]={1.0f,0.0f,0.0f,1.0f}; //red //different types for color mitk::Color tmpColor; float opacity = 1.0; GetDataNode()->GetOpacity(opacity, renderer); // apply color and opacity if(m_ShowPoints) { ls->m_UnselectedActor->VisibilityOn(); ls->m_SelectedActor->VisibilityOn(); //check if there is a color property GetDataNode()->GetColor(unselectedColor); //get selected color property if (dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor"))->GetValue(); } else if (dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor"))->GetValue(); } selectedColor[0] = tmpColor[0]; selectedColor[1] = tmpColor[1]; selectedColor[2] = tmpColor[2]; selectedColor[3] = 1.0f; // alpha value ls->m_SelectedActor->GetProperty()->SetColor(selectedColor); ls->m_SelectedActor->GetProperty()->SetOpacity(opacity); ls->m_UnselectedActor->GetProperty()->SetColor(unselectedColor[0],unselectedColor[1],unselectedColor[2]); ls->m_UnselectedActor->GetProperty()->SetOpacity(opacity); } else { ls->m_UnselectedActor->VisibilityOff(); ls-> m_SelectedActor->VisibilityOff(); } if (m_Polygon) { ls->m_ContourActor->VisibilityOn(); //get contour color property if (dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor"))->GetValue(); } else if (dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor"))->GetValue(); } contourColor[0] = tmpColor[0]; contourColor[1] = tmpColor[1]; contourColor[2] = tmpColor[2]; contourColor[3] = 1.0f; ls->m_ContourActor->GetProperty()->SetColor(contourColor); ls->m_ContourActor->GetProperty()->SetOpacity(opacity); } else { ls->m_ContourActor->VisibilityOff(); } if(needGenerateData) { // create new vtk render objects (e.g. a circle for a point) this->CreateVTKRenderObjects(renderer); } } void mitk::PointSetVtkMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { node->AddProperty( "line width", mitk::IntProperty::New(2), renderer, overwrite ); node->AddProperty( "point line width", mitk::IntProperty::New(1), renderer, overwrite ); node->AddProperty( "point 2D size", mitk::IntProperty::New(6), renderer, overwrite ); node->AddProperty( "show contour", mitk::BoolProperty::New(false), renderer, overwrite ); node->AddProperty( "close contour", mitk::BoolProperty::New(false), renderer, overwrite ); node->AddProperty( "show points", mitk::BoolProperty::New(true), renderer, overwrite ); node->AddProperty( "show distances", mitk::BoolProperty::New(false), renderer, overwrite ); node->AddProperty( "distance decimal digits", mitk::IntProperty::New(2), renderer, overwrite ); node->AddProperty( "show angles", mitk::BoolProperty::New(false), renderer, overwrite ); node->AddProperty( "show distant lines", mitk::BoolProperty::New(false), renderer, overwrite ); node->AddProperty( "layer", mitk::IntProperty::New(1), renderer, overwrite ); mitk::EnumerationProperty::Pointer glyphType = mitk::EnumerationProperty::New(); glyphType->AddEnum("None", 0); glyphType->AddEnum("Vertex", 1); glyphType->AddEnum("Dash", 2); glyphType->AddEnum("Cross", 3); glyphType->AddEnum("ThickCross", 4); glyphType->AddEnum("Triangle", 5); glyphType->AddEnum("Square", 6); glyphType->AddEnum("Circle", 7); glyphType->AddEnum("Diamond", 8); glyphType->AddEnum("Arrow", 9); glyphType->AddEnum("ThickArrow", 10); glyphType->AddEnum("HookedArrow", 11); glyphType->SetValue("Cross"); - node->AddProperty( "glyph type", glyphType, renderer, overwrite); + node->AddProperty( "Pointset.2D.shape", glyphType, renderer, overwrite); - node->AddProperty("fill glyphs", mitk::BoolProperty::New(false), renderer, overwrite); // fill or do not fill the glyph shape + node->AddProperty("Pointset.2D.fill shape", mitk::BoolProperty::New(false), renderer, overwrite); // fill or do not fill the glyph shape Superclass::SetDefaultProperties(node, renderer, overwrite); } diff --git a/Core/Code/Rendering/mitkVtkMapper2D.h b/Core/Code/Rendering/mitkVtkMapper2D.h index f9db3be352..1c18e0ef19 100644 --- a/Core/Code/Rendering/mitkVtkMapper2D.h +++ b/Core/Code/Rendering/mitkVtkMapper2D.h @@ -1,32 +1,32 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef BASEVTKMAPPER2D_H_HEADER_INCLUDED #define BASEVTKMAPPER2D_H_HEADER_INCLUDED #include "mitkVtkMapper.h" namespace mitk { // typedef allows integration of mappers into the new mapper architecture - // @deprecated Use VtkMapper instead. + // \deprecatedSince{2013_03} Use VtkMapper instead. DEPRECATED(typedef VtkMapper VtkMapper2D); } // namespace mitk #endif /* BASEVTKMAPPER2D_H_HEADER_INCLUDED */ diff --git a/Core/Code/Rendering/mitkVtkMapper3D.h b/Core/Code/Rendering/mitkVtkMapper3D.h index f31560ec0f..1958ac3614 100644 --- a/Core/Code/Rendering/mitkVtkMapper3D.h +++ b/Core/Code/Rendering/mitkVtkMapper3D.h @@ -1,31 +1,31 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef BASEVTKMAPPER3D_H_HEADER_INCLUDED #define BASEVTKMAPPER3D_H_HEADER_INCLUDED #include "mitkVtkMapper.h" namespace mitk { // typedef allows integration of mappers into the new mapper architecture - // @deprecated Use VtkMapper instead + // \deprecatedSince{2013_03} Use VtkMapper instead DEPRECATED(typedef VtkMapper VtkMapper3D); } // namespace mitk #endif /* BASEVTKMAPPER3D_H_HEADER_INCLUDED */ diff --git a/Core/Code/Testing/mitkPointSetVtkMapper2DGlyphTypeTest.cpp b/Core/Code/Testing/mitkPointSetVtkMapper2DGlyphTypeTest.cpp index 88af0bcebd..1557729adf 100644 --- a/Core/Code/Testing/mitkPointSetVtkMapper2DGlyphTypeTest.cpp +++ b/Core/Code/Testing/mitkPointSetVtkMapper2DGlyphTypeTest.cpp @@ -1,55 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include #include #include #include //VTK #include int mitkPointSetVtkMapper2DGlyphTypeTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkPointSetVtkMapper2DGlyphTypeTest") mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); renderingHelper.SetViewDirection(mitk::SliceNavigationController::ViewDirection::Sagittal); - mitk::EnumerationProperty* eP = dynamic_cast (renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("PointSet"))->GetProperty("glyph type")); + mitk::EnumerationProperty* eP = dynamic_cast (renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("PointSet"))->GetProperty("Pointset.2D.shape")); // render triangles instead of crosses eP->SetValue(5); //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //use this to generate a reference screenshot or save the file: if(false) { renderingHelper.SaveReferenceScreenShot("C:/development_ITK4/output.png"); } MITK_TEST_END(); } \ No newline at end of file diff --git a/Core/Code/files.cmake b/Core/Code/files.cmake index e85ea5df15..9cf6ec1bc6 100644 --- a/Core/Code/files.cmake +++ b/Core/Code/files.cmake @@ -1,361 +1,362 @@ set(H_FILES Algorithms/itkImportMitkImageContainer.h Algorithms/itkImportMitkImageContainer.txx Algorithms/itkLocalVariationImageFilter.h Algorithms/itkLocalVariationImageFilter.txx Algorithms/itkMITKScalarImageToHistogramGenerator.h Algorithms/itkMITKScalarImageToHistogramGenerator.txx Algorithms/itkTotalVariationDenoisingImageFilter.h Algorithms/itkTotalVariationDenoisingImageFilter.txx Algorithms/itkTotalVariationSingleIterationImageFilter.h Algorithms/itkTotalVariationSingleIterationImageFilter.txx Algorithms/mitkBilateralFilter.h Algorithms/mitkBilateralFilter.cpp Algorithms/mitkInstantiateAccessFunctions.h Algorithms/mitkPixelTypeList.h # Preprocessor macros taken from Boost Algorithms/mitkPPArithmeticDec.h Algorithms/mitkPPArgCount.h Algorithms/mitkPPCat.h Algorithms/mitkPPConfig.h Algorithms/mitkPPControlExprIIf.h Algorithms/mitkPPControlIf.h Algorithms/mitkPPControlIIf.h Algorithms/mitkPPDebugError.h Algorithms/mitkPPDetailAutoRec.h Algorithms/mitkPPDetailDMCAutoRec.h Algorithms/mitkPPExpand.h Algorithms/mitkPPFacilitiesEmpty.h Algorithms/mitkPPFacilitiesExpand.h Algorithms/mitkPPLogicalBool.h Algorithms/mitkPPRepetitionDetailDMCFor.h Algorithms/mitkPPRepetitionDetailEDGFor.h Algorithms/mitkPPRepetitionDetailFor.h Algorithms/mitkPPRepetitionDetailMSVCFor.h Algorithms/mitkPPRepetitionFor.h Algorithms/mitkPPSeqElem.h Algorithms/mitkPPSeqForEach.h Algorithms/mitkPPSeqForEachProduct.h Algorithms/mitkPPSeq.h Algorithms/mitkPPSeqEnum.h Algorithms/mitkPPSeqSize.h Algorithms/mitkPPSeqToTuple.h Algorithms/mitkPPStringize.h Algorithms/mitkPPTupleEat.h Algorithms/mitkPPTupleElem.h Algorithms/mitkPPTupleRem.h Algorithms/mitkClippedSurfaceBoundsCalculator.h Algorithms/mitkExtractSliceFilter.h Algorithms/mitkConvert2Dto3DImageFilter.h Algorithms/mitkPlaneClipping.h Common/mitkExceptionMacro.h Common/mitkServiceBaseObject.h Common/mitkTestingMacros.h DataManagement/mitkImageAccessByItk.h DataManagement/mitkImageCast.h DataManagement/mitkImagePixelAccessor.h DataManagement/mitkImagePixelReadAccessor.h DataManagement/mitkImagePixelWriteAccessor.h DataManagement/mitkImageReadAccessor.h DataManagement/mitkImageWriteAccessor.h DataManagement/mitkITKImageImport.h DataManagement/mitkITKImageImport.txx DataManagement/mitkImageToItk.h DataManagement/mitkImageToItk.txx Interactions/mitkEventMapperAddOn.h Interfaces/mitkIDataNodeReader.h Rendering/mitkLocalStorageHandler.h IO/mitkPixelTypeTraits.h ) set(CPP_FILES Algorithms/mitkBaseDataSource.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkCoreActivator.cpp Controllers/mitkFocusManager.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkSlicesRotator.cpp Controllers/mitkSlicesSwiveller.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkInteractorCameraController.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataStorage.cpp #DataManagement/mitkDataTree.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataNodeFactory.cpp #DataManagement/mitkDataTreeStorage.cpp DataManagement/mitkDisplayGeometry.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkGeometry2D.cpp DataManagement/mitkGeometry2DData.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkLandmarkBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModeOperation.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStateTransitionOperation.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeSlicedGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkVector.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkShaderProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkMaterial.cpp Interactions/mitkAction.cpp Interactions/mitkAffineInteractor.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCoordinateSupplier.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkDisplayPositionEvent.cpp # Interactions/mitkDisplayVectorInteractorLevelWindow.cpp # legacy, prob even now unneeded # Interactions/mitkDisplayVectorInteractorScroll.cpp Interactions/mitkEvent.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventDescription.cpp Interactions/mitkEventFactory.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkEventMapper.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkGlobalInteraction.cpp Interactions/mitkInteractor.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMovePointSetInteractor.cpp Interactions/mitkMoveBaseDataInteractor.cpp Interactions/mitkNodeDepententPointSetInteractor.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkPointSetInteractor.cpp Interactions/mitkPositionEvent.cpp Interactions/mitkPositionTracker.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkState.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateEvent.cpp Interactions/mitkStateMachine.cpp Interactions/mitkStateMachineFactory.cpp Interactions/mitkTransition.cpp Interactions/mitkWheelEvent.cpp Interactions/mitkKeyEvent.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkCrosshairPositionEvent.cpp Interfaces/mitkInteractionEventObserver.cpp Interfaces/mitkIShaderRepository.cpp IO/mitkBaseDataIOFactory.cpp IO/mitkCoreDataNodeReader.cpp IO/mitkDicomSeriesReader.cpp IO/mitkFileReader.cpp IO/mitkFileSeriesReader.cpp IO/mitkFileWriter.cpp #IO/mitkIpPicGet.c IO/mitkImageGenerator.cpp IO/mitkImageWriter.cpp IO/mitkImageWriterFactory.cpp IO/mitkItkImageFileIOFactory.cpp IO/mitkItkImageFileReader.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkItkPictureWrite.cpp IO/mitkIOUtil.cpp IO/mitkLookupTableProperty.cpp IO/mitkOperation.cpp #IO/mitkPicFileIOFactory.cpp #IO/mitkPicFileReader.cpp #IO/mitkPicFileWriter.cpp #IO/mitkPicHelper.cpp #IO/mitkPicVolumeTimeSeriesIOFactory.cpp #IO/mitkPicVolumeTimeSeriesReader.cpp IO/mitkPixelType.cpp IO/mitkPointSetIOFactory.cpp IO/mitkPointSetReader.cpp IO/mitkPointSetWriter.cpp IO/mitkPointSetWriterFactory.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSTLFileIOFactory.cpp IO/mitkSTLFileReader.cpp IO/mitkSurfaceVtkWriter.cpp IO/mitkSurfaceVtkWriterFactory.cpp IO/mitkVtkLoggingAdapter.cpp IO/mitkVtiFileIOFactory.cpp IO/mitkVtiFileReader.cpp IO/mitkVtkImageIOFactory.cpp IO/mitkVtkImageReader.cpp IO/mitkVtkSurfaceIOFactory.cpp IO/mitkVtkSurfaceReader.cpp IO/vtkPointSetXMLParser.cpp IO/mitkLog.cpp Rendering/mitkBaseRenderer.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkRenderWindowFrame.cpp Rendering/mitkGeometry2DDataMapper2D.cpp Rendering/mitkGeometry2DDataVtkMapper3D.cpp Rendering/mitkGLMapper.cpp Rendering/mitkGradientBackground.cpp Rendering/mitkManufacturerLogo.cpp Rendering/mitkMapper.cpp + Rendering/mitkPointSetGLMapper2D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkPolyDataGLMapper2D.cpp Rendering/mitkSurfaceGLMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVolumeDataVtkMapper3D.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkShaderRepository.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp Rendering/mitkRenderingTestHelper.cpp Common/mitkException.cpp Common/mitkCommon.h Common/mitkCoreObjectFactoryBase.cpp Common/mitkCoreObjectFactory.cpp Common/mitkCoreServices.cpp ) list(APPEND CPP_FILES ${CppMicroServices_SOURCES}) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml Shaders/mitkShaderLighting.xml mitkLevelWindowPresets.xml ) diff --git a/Modules/MitkExt/Rendering/mitkLineMapper2D.cpp b/Modules/MitkExt/Rendering/mitkLineMapper2D.cpp index c310ddb53e..19560e23ca 100644 --- a/Modules/MitkExt/Rendering/mitkLineMapper2D.cpp +++ b/Modules/MitkExt/Rendering/mitkLineMapper2D.cpp @@ -1,140 +1,140 @@ -///*=================================================================== -// -//The Medical Imaging Interaction Toolkit (MITK) -// -//Copyright (c) German Cancer Research Center, -//Division of Medical and Biological Informatics. -//All rights reserved. -// -//This software is distributed WITHOUT ANY WARRANTY; without -//even the implied warranty of MERCHANTABILITY or FITNESS FOR -//A PARTICULAR PURPOSE. -// -//See LICENSE.txt or http://www.mitk.org for details. -// -//===================================================================*/ -// -// -//#include "mitkLineMapper2D.h" -//#include "mitkPointSet.h" -//#include "mitkBaseRenderer.h" -//#include "mitkPlaneGeometry.h" -//#include "mitkColorProperty.h" -//#include "mitkProperties.h" -//#include -//#include "mitkPointSet.h" -//#include "mitkGL.h" -// -//mitk::LineMapper2D::LineMapper2D() -//: mitk::PointSetGLMapper2D() -//{ -// -//} -// -//mitk::LineMapper2D::~LineMapper2D() -//{ -//} -// -//const mitk::PointSet *mitk::LineMapper2D::GetInput(void) -//{ -// return static_cast ( GetDataNode()->GetData() ); -//} -// -//void mitk::LineMapper2D::Paint(mitk::BaseRenderer * renderer) -//{ -// -// bool visible = true; -// GetDataNode()->GetVisibility(visible, renderer, "visible"); -// if(!visible) return; -// -// bool updateNeccesary = true;//!!!! @TODO !??!! -// -// if (updateNeccesary) -// { -// mitk::PointSet::Pointer input = const_cast(this->GetInput()); -// mitk::DisplayGeometry::Pointer displayGeometry = renderer->GetDisplayGeometry(); -// assert(displayGeometry.IsNotNull()); -// -// //apply color and opacity read from the PropertyList -// ApplyColorAndOpacityProperties(renderer); -// -// vtkLinearTransform* transform = GetDataNode()->GetVtkTransform(); -// -// //List of the Points -// PointSet::DataType::PointsContainerConstIterator it, end; -// it = input->GetPointSet()->GetPoints()->Begin(); -// end = input->GetPointSet()->GetPoints()->End();//the last before end, because lines from n to n+1 -// if (end!=it) // otherwise PointSet is empty -// end--; -// -// //bool list for the selection of the points -// PointSet::DataType::PointDataContainerIterator selIt, selItNext; -// selIt=input->GetPointSet()->GetPointData()->Begin(); -// -// int j=0; -// while(it!=end) -// { -// mitk::Point3D p, q, projected_p, projected_q; -// float vtkp[3]; -// itk2vtk(it->Value(), vtkp); -// transform->TransformPoint(vtkp, vtkp); -// vtk2itk(vtkp,p); -// -// //next point n+1 -// it++; -// itk2vtk(it->Value(), vtkp); -// transform->TransformPoint(vtkp, vtkp); -// vtk2itk(vtkp,q); -// it--; -// -// displayGeometry->Project(p, projected_p); -// displayGeometry->Project(q, projected_q); -// -// Vector3D diffp=p-projected_p, diffq=q-projected_q; -// if((diffp.GetSquaredNorm()<4.0) && -// (diffq.GetSquaredNorm()<4.0)) -// { -// Point2D p2d, q2d, tmp; -// -// displayGeometry->Map(projected_p, p2d); -// displayGeometry->WorldToDisplay(p2d, p2d); -// displayGeometry->Map(projected_q, q2d); -// displayGeometry->WorldToDisplay(q2d, q2d); -// -// //outlined, cause iterators behave strange and multiple points can't be selected anyway by now! -// //selItNext = selIt++;//Iterator to the next Element, cause only when the two points ar selected, then the Line is Selected -// //if (selIt->Value() && selItNext->Value())//selected -// //{ -// // float colorSel[]={1.0,0.0,0.6}; //for selected! -// -// // //current color for changing to a diferent color if selected -// // float currCol[4]; -// // glGetFloatv(GL_CURRENT_COLOR,currCol); -// -// // glColor3f(colorSel[0],colorSel[1],colorSel[2]);//red -// -// -// // glBegin (GL_LINES); -// // glVertex2f(p2d[0], p2d[1]); -// // glVertex2f(q2d[0], q2d[1]); -// // glEnd (); -// -// // glColor3f(currCol[0],currCol[1],currCol[2]);//the color before changing to select! -// -// //} -// //else -// //{ -// glBegin (GL_LINES); -// glVertex2f(p2d[0], p2d[1]); -// glVertex2f(q2d[0], q2d[1]); -// glEnd (); -// //} -// } -// ++it; -// ++selIt; -// j++; -// } -// //drawing the points -// PointSetGLMapper2D::Paint(renderer); -// } -//} +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#include "mitkLineMapper2D.h" +#include "mitkPointSet.h" +#include "mitkBaseRenderer.h" +#include "mitkPlaneGeometry.h" +#include "mitkColorProperty.h" +#include "mitkProperties.h" +#include +#include "mitkPointSet.h" +#include "mitkGL.h" + +mitk::LineMapper2D::LineMapper2D() +: mitk::PointSetGLMapper2D() +{ + +} + +mitk::LineMapper2D::~LineMapper2D() +{ +} + +const mitk::PointSet *mitk::LineMapper2D::GetInput(void) +{ + return static_cast ( GetDataNode()->GetData() ); +} + +void mitk::LineMapper2D::Paint(mitk::BaseRenderer * renderer) +{ + + bool visible = true; + GetDataNode()->GetVisibility(visible, renderer, "visible"); + if(!visible) return; + + bool updateNeccesary = true;//!!!! @TODO !??!! + + if (updateNeccesary) + { + mitk::PointSet::Pointer input = const_cast(this->GetInput()); + mitk::DisplayGeometry::Pointer displayGeometry = renderer->GetDisplayGeometry(); + assert(displayGeometry.IsNotNull()); + + //apply color and opacity read from the PropertyList + ApplyColorAndOpacityProperties(renderer); + + vtkLinearTransform* transform = GetDataNode()->GetVtkTransform(); + + //List of the Points + PointSet::DataType::PointsContainerConstIterator it, end; + it = input->GetPointSet()->GetPoints()->Begin(); + end = input->GetPointSet()->GetPoints()->End();//the last before end, because lines from n to n+1 + if (end!=it) // otherwise PointSet is empty + end--; + + //bool list for the selection of the points + PointSet::DataType::PointDataContainerIterator selIt, selItNext; + selIt=input->GetPointSet()->GetPointData()->Begin(); + + int j=0; + while(it!=end) + { + mitk::Point3D p, q, projected_p, projected_q; + float vtkp[3]; + itk2vtk(it->Value(), vtkp); + transform->TransformPoint(vtkp, vtkp); + vtk2itk(vtkp,p); + + //next point n+1 + it++; + itk2vtk(it->Value(), vtkp); + transform->TransformPoint(vtkp, vtkp); + vtk2itk(vtkp,q); + it--; + + displayGeometry->Project(p, projected_p); + displayGeometry->Project(q, projected_q); + + Vector3D diffp=p-projected_p, diffq=q-projected_q; + if((diffp.GetSquaredNorm()<4.0) && + (diffq.GetSquaredNorm()<4.0)) + { + Point2D p2d, q2d, tmp; + + displayGeometry->Map(projected_p, p2d); + displayGeometry->WorldToDisplay(p2d, p2d); + displayGeometry->Map(projected_q, q2d); + displayGeometry->WorldToDisplay(q2d, q2d); + + //outlined, cause iterators behave strange and multiple points can't be selected anyway by now! + //selItNext = selIt++;//Iterator to the next Element, cause only when the two points ar selected, then the Line is Selected + //if (selIt->Value() && selItNext->Value())//selected + //{ + // float colorSel[]={1.0,0.0,0.6}; //for selected! + + // //current color for changing to a diferent color if selected + // float currCol[4]; + // glGetFloatv(GL_CURRENT_COLOR,currCol); + + // glColor3f(colorSel[0],colorSel[1],colorSel[2]);//red + + + // glBegin (GL_LINES); + // glVertex2f(p2d[0], p2d[1]); + // glVertex2f(q2d[0], q2d[1]); + // glEnd (); + + // glColor3f(currCol[0],currCol[1],currCol[2]);//the color before changing to select! + + //} + //else + //{ + glBegin (GL_LINES); + glVertex2f(p2d[0], p2d[1]); + glVertex2f(q2d[0], q2d[1]); + glEnd (); + //} + } + ++it; + ++selIt; + j++; + } + //drawing the points + PointSetGLMapper2D::Paint(renderer); + } +} diff --git a/Modules/MitkExt/Rendering/mitkLineMapper2D.h b/Modules/MitkExt/Rendering/mitkLineMapper2D.h index f7a29db08a..ac1180f57e 100644 --- a/Modules/MitkExt/Rendering/mitkLineMapper2D.h +++ b/Modules/MitkExt/Rendering/mitkLineMapper2D.h @@ -1,56 +1,58 @@ -///*=================================================================== -// -//The Medical Imaging Interaction Toolkit (MITK) -// -//Copyright (c) German Cancer Research Center, -//Division of Medical and Biological Informatics. -//All rights reserved. -// -//This software is distributed WITHOUT ANY WARRANTY; without -//even the implied warranty of MERCHANTABILITY or FITNESS FOR -//A PARTICULAR PURPOSE. -// -//See LICENSE.txt or http://www.mitk.org for details. -// -//===================================================================*/ -// -// -//#ifndef MITKLINEMAPPER2D_H_HEADER_INCLUDED -//#define MITKLINEMAPPER2D_H_HEADER_INCLUDED -// -//#include "mitkCommon.h" -//#include "MitkExtExports.h" -//#include "mitkPointSetGLMapper2D.h" -// -//namespace mitk { -// -//class BaseRenderer; -//class PointSet; -// -////##Documentation -////## @brief OpenGL-based mapper to display Lines -////## -////## uses the information from the PointSet to build up the lines. -////## Only lines in 2D in one Slice are drawn, not between slices! -////## @ingroup Mapper -//class MitkExt_EXPORT LineMapper2D : public PointSetGLMapper2D -//{ -//public: -// mitkClassMacro(LineMapper2D, PointSetGLMapper2D); -// itkNewMacro(Self); -// -// //##Documentation -// //## @brief Get the PointDataList to map -// const PointSet * GetInput(void); -// -// virtual void Paint(mitk::BaseRenderer * renderer); -// -//protected: -// LineMapper2D(); -// -// virtual ~LineMapper2D(); -//}; -// -//} // namespace mitk -// -//#endif /* MITKLINEMAPPER2D_H_HEADER_INCLUDED */ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#ifndef MITKLINEMAPPER2D_H_HEADER_INCLUDED +#define MITKLINEMAPPER2D_H_HEADER_INCLUDED + +#include "mitkCommon.h" +#include "MitkExtExports.h" +#include "mitkPointSetGLMapper2D.h" + +namespace mitk { + +class BaseRenderer; +class PointSet; + +//##Documentation +//## @brief OpenGL-based mapper to display Lines +//## +//## uses the information from the PointSet to build up the lines. +//## Only lines in 2D in one Slice are drawn, not between slices! +//## @ingroup Mapper + +/** \deprecatedSince{2013_06} This mapper is deprecated. */ +DEPRECATED(class MitkExt_EXPORT LineMapper2D) : public PointSetGLMapper2D +{ +public: + mitkClassMacro(LineMapper2D, PointSetGLMapper2D); + itkNewMacro(Self); + + //##Documentation + //## @brief Get the PointDataList to map + const PointSet * GetInput(void); + + virtual void Paint(mitk::BaseRenderer * renderer); + +protected: + LineMapper2D(); + + virtual ~LineMapper2D(); +}; + +} // namespace mitk + +#endif /* MITKLINEMAPPER2D_H_HEADER_INCLUDED */ diff --git a/Modules/MitkExt/Rendering/mitkSplineMapper2D.cpp b/Modules/MitkExt/Rendering/mitkSplineMapper2D.cpp index 8fd473c4a6..18d1f35445 100755 --- a/Modules/MitkExt/Rendering/mitkSplineMapper2D.cpp +++ b/Modules/MitkExt/Rendering/mitkSplineMapper2D.cpp @@ -1,193 +1,193 @@ -///*=================================================================== -// -//The Medical Imaging Interaction Toolkit (MITK) -// -//Copyright (c) German Cancer Research Center, -//Division of Medical and Biological Informatics. -//All rights reserved. -// -//This software is distributed WITHOUT ANY WARRANTY; without -//even the implied warranty of MERCHANTABILITY or FITNESS FOR -//A PARTICULAR PURPOSE. -// -//See LICENSE.txt or http://www.mitk.org for details. -// -//===================================================================*/ -// -// -//#include "mitkSplineMapper2D.h" -//#include "mitkSplineVtkMapper3D.h" -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -// -//void mitk::SplineMapper2D::Paint ( mitk::BaseRenderer * renderer ) -//{ -// Superclass::Paint ( renderer ); -// -// bool visible = true; -// GetDataNode()->GetVisibility(visible, renderer, "visible"); -// -// if ( !visible ) -// return; -// -// // -// // get the poly data of the splines in 3D -// // -// mitk::SplineVtkMapper3D::Pointer mapper3D = dynamic_cast ( this->GetDataNode()->GetMapper ( 2 ) ); -// if ( mapper3D.IsNull() ) -// { -// itkWarningMacro ( "Mapper used for 3D mapping is not a mitk::SplineVtkMapper3D!" ); -// return; -// } -// // -// // update the 3D spline, if the accoring mapper has not been updated yet -// // -// if ( mapper3D->GetLastUpdateTime() < GetDataNode()->GetData()->GetMTime() ) -// mapper3D->UpdateSpline(); -// vtkPolyData* spline3D = NULL; -// if ( mapper3D->SplinesAreAvailable() ) -// spline3D = mapper3D->GetSplinesPolyData(); -// else -// return; -// if ( spline3D == NULL ) -// { -// itkWarningMacro ( "3D spline is not available!" ); -// return; -// } -// // -// // get the transform associated with the data tree node -// // -// vtkLinearTransform* transform = this->GetDataNode()->GetVtkTransform(); -// if ( transform == NULL ) -// { -// itkWarningMacro("transfrom is NULL"); -// } -// -// // -// // get the plane geometry of the current renderer -// // -// mitk::Geometry2D::ConstPointer worldGeometry = renderer->GetCurrentWorldGeometry2D(); -// if ( worldGeometry.IsNull() ) -// { -// itkWarningMacro("worldGeometry is NULL!"); -// return; -// } -// PlaneGeometry::ConstPointer worldPlaneGeometry = dynamic_cast ( worldGeometry.GetPointer() ); -// if ( worldPlaneGeometry.IsNull() ) -// { -// itkWarningMacro("worldPlaneGeometry is NULL!"); -// return; -// } -// -// // -// // determine color of the spline -// // -// float color[3]; -// this->GetDataNode()->GetColor ( color, renderer ); -// -// // -// // iterate over the points -// // -// vtkPoints *vpoints = spline3D->GetPoints(); -// vtkCellArray *vlines = spline3D->GetLines(); -// if (vpoints == NULL) -// { -// itkWarningMacro("points are NULL!"); -// return; -// } -// if (vlines == NULL) -// { -// itkWarningMacro("lines are NULL!"); -// return; -// } -// -// mitk::Point3D currentPoint3D; -// mitk::Point2D currentPoint2D; -// vtkFloatingPointType currentPoint3DVtk[3]; -// -// vlines->InitTraversal(); -// int numberOfLines = vlines->GetNumberOfCells(); -// vtkFloatingPointType currentPointDistance; -// for ( int i = 0;i < numberOfLines; ++i ) -// { -// bool previousPointOnPlane = false; -// bool currentPointOnPlane = false; -// vtkIdType* cell ( NULL ); -// vtkIdType cellSize ( 0 ); -// vlines->GetNextCell ( cellSize, cell ); -// for ( int j = 0 ; j < cellSize; ++j ) -// { -// vpoints->GetPoint ( cell[j], currentPoint3DVtk ); -// -// // take transformation via vtktransform into account -// transform->TransformPoint ( currentPoint3DVtk, currentPoint3DVtk ); -// vtk2itk ( currentPoint3DVtk, currentPoint3D ); -// -// // check if the point has a distance to the plane -// // which is smaller than m_MaxProjectionDistance -// currentPointDistance = worldPlaneGeometry->DistanceFromPlane ( currentPoint3D ); -// -// if ( currentPointDistance < m_MaxProjectionDistance ) -// { -// currentPointOnPlane = true; -// //convert 3D point (in mm) to 2D point on slice (also in mm) -// worldGeometry->Map ( currentPoint3D, currentPoint2D ); -// //convert point (until now mm and in worldcoordinates) to display coordinates (units ) -// renderer->GetDisplayGeometry()->WorldToDisplay ( currentPoint2D, currentPoint2D ); -// } -// else -// currentPointOnPlane = false; -// -// // -// // check if we have to begin or end a GL_LINE -// // -// if ( ( previousPointOnPlane == false ) && ( currentPointOnPlane == true ) ) -// { -// glLineWidth ( m_LineWidth ); -// glColor3f ( color[0], color[1], color[2] ); -// glBegin ( GL_LINE_STRIP ); -// } -// else if ( ( previousPointOnPlane == true ) && ( currentPointOnPlane == false ) ) -// { -// glEnd (); -// glLineWidth ( 1.0 ); -// } -// // the current ponit is on the plane, add it as point to the -// // line segment -// if ( currentPointOnPlane == true ) -// { -// glVertex2f ( currentPoint2D[0], currentPoint2D[1] ); -// } -// previousPointOnPlane = currentPointOnPlane; -// } -// // the last point of the spline segment is on the plane, thus we have to -// // close the GL_LINE -// if ( previousPointOnPlane == true ) -// { -// glEnd (); -// glLineWidth ( 1.0 ); -// } -// previousPointOnPlane = false; -// } -//} -// -//void mitk::SplineMapper2D::ApplyProperties ( mitk::BaseRenderer* renderer ) -//{ -// ApplyColorAndOpacityProperties ( renderer ); -//} -// -//mitk::SplineMapper2D::SplineMapper2D() -//{ -// m_MaxProjectionDistance = 1; -// m_ShowDistantLines = false ; -// m_LineWidth = 1; -//} -// -//mitk::SplineMapper2D::~SplineMapper2D() -//{} +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#include "mitkSplineMapper2D.h" +#include "mitkSplineVtkMapper3D.h" +#include +#include +#include +#include +#include +#include +#include +#include + +void mitk::SplineMapper2D::Paint ( mitk::BaseRenderer * renderer ) +{ + Superclass::Paint ( renderer ); + + bool visible = true; + GetDataNode()->GetVisibility(visible, renderer, "visible"); + + if ( !visible ) + return; + + // + // get the poly data of the splines in 3D + // + mitk::SplineVtkMapper3D::Pointer mapper3D = dynamic_cast ( this->GetDataNode()->GetMapper ( 2 ) ); + if ( mapper3D.IsNull() ) + { + itkWarningMacro ( "Mapper used for 3D mapping is not a mitk::SplineVtkMapper3D!" ); + return; + } + // + // update the 3D spline, if the accoring mapper has not been updated yet + // + //if ( mapper3D->GetLastUpdateTime() < GetDataNode()->GetData()->GetMTime() ) + mapper3D->UpdateSpline(); + vtkPolyData* spline3D = NULL; + if ( mapper3D->SplinesAreAvailable() ) + spline3D = mapper3D->GetSplinesPolyData(); + else + return; + if ( spline3D == NULL ) + { + itkWarningMacro ( "3D spline is not available!" ); + return; + } + // + // get the transform associated with the data tree node + // + vtkLinearTransform* transform = this->GetDataNode()->GetVtkTransform(); + if ( transform == NULL ) + { + itkWarningMacro("transfrom is NULL"); + } + + // + // get the plane geometry of the current renderer + // + mitk::Geometry2D::ConstPointer worldGeometry = renderer->GetCurrentWorldGeometry2D(); + if ( worldGeometry.IsNull() ) + { + itkWarningMacro("worldGeometry is NULL!"); + return; + } + PlaneGeometry::ConstPointer worldPlaneGeometry = dynamic_cast ( worldGeometry.GetPointer() ); + if ( worldPlaneGeometry.IsNull() ) + { + itkWarningMacro("worldPlaneGeometry is NULL!"); + return; + } + + // + // determine color of the spline + // + float color[3]; + this->GetDataNode()->GetColor ( color, renderer ); + + // + // iterate over the points + // + vtkPoints *vpoints = spline3D->GetPoints(); + vtkCellArray *vlines = spline3D->GetLines(); + if (vpoints == NULL) + { + itkWarningMacro("points are NULL!"); + return; + } + if (vlines == NULL) + { + itkWarningMacro("lines are NULL!"); + return; + } + + mitk::Point3D currentPoint3D; + mitk::Point2D currentPoint2D; + vtkFloatingPointType currentPoint3DVtk[3]; + + vlines->InitTraversal(); + int numberOfLines = vlines->GetNumberOfCells(); + vtkFloatingPointType currentPointDistance; + for ( int i = 0;i < numberOfLines; ++i ) + { + bool previousPointOnPlane = false; + bool currentPointOnPlane = false; + vtkIdType* cell ( NULL ); + vtkIdType cellSize ( 0 ); + vlines->GetNextCell ( cellSize, cell ); + for ( int j = 0 ; j < cellSize; ++j ) + { + vpoints->GetPoint ( cell[j], currentPoint3DVtk ); + + // take transformation via vtktransform into account + transform->TransformPoint ( currentPoint3DVtk, currentPoint3DVtk ); + vtk2itk ( currentPoint3DVtk, currentPoint3D ); + + // check if the point has a distance to the plane + // which is smaller than m_MaxProjectionDistance + currentPointDistance = worldPlaneGeometry->DistanceFromPlane ( currentPoint3D ); + + if ( currentPointDistance < m_MaxProjectionDistance ) + { + currentPointOnPlane = true; + //convert 3D point (in mm) to 2D point on slice (also in mm) + worldGeometry->Map ( currentPoint3D, currentPoint2D ); + //convert point (until now mm and in worldcoordinates) to display coordinates (units ) + renderer->GetDisplayGeometry()->WorldToDisplay ( currentPoint2D, currentPoint2D ); + } + else + currentPointOnPlane = false; + + // + // check if we have to begin or end a GL_LINE + // + if ( ( previousPointOnPlane == false ) && ( currentPointOnPlane == true ) ) + { + glLineWidth ( m_LineWidth ); + glColor3f ( color[0], color[1], color[2] ); + glBegin ( GL_LINE_STRIP ); + } + else if ( ( previousPointOnPlane == true ) && ( currentPointOnPlane == false ) ) + { + glEnd (); + glLineWidth ( 1.0 ); + } + // the current ponit is on the plane, add it as point to the + // line segment + if ( currentPointOnPlane == true ) + { + glVertex2f ( currentPoint2D[0], currentPoint2D[1] ); + } + previousPointOnPlane = currentPointOnPlane; + } + // the last point of the spline segment is on the plane, thus we have to + // close the GL_LINE + if ( previousPointOnPlane == true ) + { + glEnd (); + glLineWidth ( 1.0 ); + } + previousPointOnPlane = false; + } +} + +void mitk::SplineMapper2D::ApplyProperties ( mitk::BaseRenderer* renderer ) +{ + ApplyColorAndOpacityProperties ( renderer ); +} + +mitk::SplineMapper2D::SplineMapper2D() +{ + m_MaxProjectionDistance = 1; + m_ShowDistantLines = false ; + m_LineWidth = 1; +} + +mitk::SplineMapper2D::~SplineMapper2D() +{} diff --git a/Modules/MitkExt/Rendering/mitkSplineMapper2D.h b/Modules/MitkExt/Rendering/mitkSplineMapper2D.h index e23db3ae5d..dcb24752b7 100755 --- a/Modules/MitkExt/Rendering/mitkSplineMapper2D.h +++ b/Modules/MitkExt/Rendering/mitkSplineMapper2D.h @@ -1,83 +1,85 @@ -///*=================================================================== -// -//The Medical Imaging Interaction Toolkit (MITK) -// -//Copyright (c) German Cancer Research Center, -//Division of Medical and Biological Informatics. -//All rights reserved. -// -//This software is distributed WITHOUT ANY WARRANTY; without -//even the implied warranty of MERCHANTABILITY or FITNESS FOR -//A PARTICULAR PURPOSE. -// -//See LICENSE.txt or http://www.mitk.org for details. -// -//===================================================================*/ -// -// -//#ifndef MITKSplineMapper2D_H_HEADER_INCLUDED -//#define MITKSplineMapper2D_H_HEADER_INCLUDED -// -//#include "mitkCommon.h" -//#include "MitkExtExports.h" -//#include "mitkGLMapper.h" -//#include "mitkPointSetGLMapper2D.h" -//#include -// -//namespace mitk -//{ -// -//class BaseRenderer; -//class PointSet; -// -////##Documentation -////## @brief OpenGL-based mapper to display a spline based on a mitk::PointSet in a 2D window. -////## -///** This mapper can actually more than just draw a number of points of a -//* mitk::PointSet. If you set the right properties of the mitk::DataNode, -//* which contains the point set, then this mapper will also draw lines -//* connecting the points, and calculate and display distances and angles -//* between adjacent points. Here is a complete list of boolean properties, -//* which might be of interest: -//* -//* - \b "show contour": Draw not only the points but also the connections between -//* them (default false) -//* - \b "line width": IntProperty which gives the width of the contour lines -//* - \b "show points": Wheter or not to draw the actual points (default true) -//* - \b "show distances": Wheter or not to calculate and print the distance -//* between adjacent points (default false) -//* - \b "show angles": Wheter or not to calculate and print the angle between -//* adjacent points (default false) -//* - \b "show distant lines": When true, the mapper will also draw contour -//* lines that are far away form the current slice (default true) -//* - \b "label": StringProperty with a label for this point set -//*/ -////## @ingroup Mapper -//class MitkExt_EXPORT SplineMapper2D : public PointSetGLMapper2D -//{ -//public: -// mitkClassMacro ( SplineMapper2D, PointSetGLMapper2D ); -// -// itkNewMacro ( Self ); -// -// virtual void Paint ( mitk::BaseRenderer * renderer ); -// -// virtual void ApplyProperties ( mitk::BaseRenderer* renderer ); -// -// itkSetMacro ( MaxProjectionDistance, vtkFloatingPointType ); -// -// itkGetMacro ( MaxProjectionDistance, vtkFloatingPointType ); -// -//protected: -// SplineMapper2D(); -// -// virtual ~SplineMapper2D(); -// -// vtkFloatingPointType m_MaxProjectionDistance; -//}; -// -//} // namespace mitk -// -// -// -//#endif /* MITKSplineMapper2D_H_HEADER_INCLUDED */ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#ifndef MITKSplineMapper2D_H_HEADER_INCLUDED +#define MITKSplineMapper2D_H_HEADER_INCLUDED + +#include "mitkCommon.h" +#include "MitkExtExports.h" +#include "mitkGLMapper.h" +#include "mitkPointSetGLMapper2D.h" +#include + +namespace mitk +{ + +class BaseRenderer; +class PointSet; + +//##Documentation +//## @brief OpenGL-based mapper to display a spline based on a mitk::PointSet in a 2D window. +//## +/** This mapper can actually more than just draw a number of points of a +* mitk::PointSet. If you set the right properties of the mitk::DataNode, +* which contains the point set, then this mapper will also draw lines +* connecting the points, and calculate and display distances and angles +* between adjacent points. Here is a complete list of boolean properties, +* which might be of interest: +* +* - \b "show contour": Draw not only the points but also the connections between +* them (default false) +* - \b "line width": IntProperty which gives the width of the contour lines +* - \b "show points": Wheter or not to draw the actual points (default true) +* - \b "show distances": Wheter or not to calculate and print the distance +* between adjacent points (default false) +* - \b "show angles": Wheter or not to calculate and print the angle between +* adjacent points (default false) +* - \b "show distant lines": When true, the mapper will also draw contour +* lines that are far away form the current slice (default true) +* - \b "label": StringProperty with a label for this point set +*/ +//## @ingroup Mapper + +/** \deprecatedSince{2013_06} This mapper is deprecated. */ +DEPRECATED(class MitkExt_EXPORT SplineMapper2D) : public PointSetGLMapper2D +{ +public: + mitkClassMacro ( SplineMapper2D, PointSetGLMapper2D ); + + itkNewMacro ( Self ); + + virtual void Paint ( mitk::BaseRenderer * renderer ); + + virtual void ApplyProperties ( mitk::BaseRenderer* renderer ); + + itkSetMacro ( MaxProjectionDistance, vtkFloatingPointType ); + + itkGetMacro ( MaxProjectionDistance, vtkFloatingPointType ); + +protected: + SplineMapper2D(); + + virtual ~SplineMapper2D(); + + vtkFloatingPointType m_MaxProjectionDistance; +}; + +} // namespace mitk + + + +#endif /* MITKSplineMapper2D_H_HEADER_INCLUDED */ diff --git a/Modules/MitkExt/Testing/mitkDataNodeExtTest.cpp b/Modules/MitkExt/Testing/mitkDataNodeExtTest.cpp index 40d5725499..5b9dfd95b8 100644 --- a/Modules/MitkExt/Testing/mitkDataNodeExtTest.cpp +++ b/Modules/MitkExt/Testing/mitkDataNodeExtTest.cpp @@ -1,213 +1,213 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDataNode.h" #include #include "mitkVtkPropRenderer.h" #include "mitkTestingMacros.h" #include "mitkGlobalInteraction.h" #include //Basedata Test #include #include #include #include #include //Mapper Test #include #include #include #include #include #include #include #include #include #include #include //Interactors #include #include #include #include #include //Propertylist Test #include #include #include #include #include #include #include #include #include #include #include /** * Extended test for mitk::DataNode. A number of tests from the core test * mitkDataNodeTest are assumed to pass! */ class mitkDataNodeExtTestClass { public: static void TestDataSetting(mitk::DataNode::Pointer dataNode) { mitk::BaseData::Pointer baseData; //NULL pointer Test dataNode->SetData(baseData); MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a NULL pointer was set correctly" ) baseData = mitk::ItkBaseDataAdapter::New(); dataNode->SetData(baseData); MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a ItkBaseDataAdapter object was set correctly" ) baseData = mitk::Mesh::New(); dataNode->SetData(baseData); MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a Mesh object was set correctly" ) baseData = mitk::SeedsImage::New(); dataNode->SetData(baseData); MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a SeedsImage object was set correctly" ) baseData = mitk::BoundingObject::New(); dataNode->SetData(baseData); MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a BoundingObject object was set correctly" ) baseData = mitk::UnstructuredGrid::New(); dataNode->SetData(baseData); MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a UnstructuredGrid object was set correctly" ) } static void TestMapperSetting(mitk::DataNode::Pointer dataNode) { //tests the SetMapper() method //in dataNode is a mapper vector which can be accessed by index //in this test method we use only slot 0 (filled with null) and slot 1 //so we also test the destructor of the mapper classes mitk::Mapper::Pointer mapper; dataNode->SetMapper(0,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(0), "Testing if a NULL pointer was set correctly" ) mapper = mitk::MeshMapper2D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a MeshMapper2D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) mapper = mitk::UnstructuredGridMapper2D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a UnstructuredGridMapper2D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) - /*mapper = mitk::LineMapper2D::New(); + mapper = mitk::LineMapper2D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a LineMapper2D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) mapper = mitk::SplineMapper2D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a SplineMapper2D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) -*/ + mapper = mitk::MeshVtkMapper3D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a MeshVtkMapper3D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) mapper = mitk::UnstructuredGridVtkMapper3D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a UnstructuredGridVtkMapper3D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) //linker error //mapper = mitk::LineVtkMapper3D::New(); //dataNode->SetMapper(1,mapper); //MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a LineVtkMapper3D was set correctly" ) //MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) mapper = mitk::SplineVtkMapper3D::New(); dataNode->SetMapper(1,mapper); MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a SplineVtkMapper3D was set correctly" ) MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) } static void TestInteractorSetting(mitk::DataNode::Pointer dataNode) { //this method tests the SetInteractor() and GetInteractor methods //the Interactor base class calls the DataNode->SetInteractor method mitk::Interactor::Pointer interactor; MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a NULL pointer was set correctly (Interactor)" ) interactor = mitk::ConnectPointsInteractor::New("AffineInteractions click to select", dataNode); MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a ConnectPointsInteractor was set correctly" ) interactor = mitk::PointInteractor::New("AffineInteractions click to select", dataNode); MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a PointInteractor was set correctly" ) interactor = mitk::PointSelectorInteractor::New("AffineInteractions click to select", dataNode); MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a PointSelectorInteractor was set correctly" ) interactor = mitk::SeedsInteractor::New("AffineInteractions click to select", dataNode); MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a SeedsInteractor was set correctly" ) interactor = mitk::DisplayPointSetInteractor::New("AffineInteractions click to select", dataNode); MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a DisplayPointSetInteractor was set correctly" ) } }; int mitkDataNodeExtTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("DataNode") // Global interaction must(!) be initialized mitk::GlobalInteraction::GetInstance()->Initialize("global"); // let's create an object of our class mitk::DataNode::Pointer myDataNode = mitk::DataNode::New(); // first test: did this work? // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since // it makes no sense to continue without an object. MITK_TEST_CONDITION_REQUIRED(myDataNode.IsNotNull(),"Testing instantiation") //test setData() Method mitkDataNodeExtTestClass::TestDataSetting(myDataNode); mitkDataNodeExtTestClass::TestMapperSetting(myDataNode); //note, that no data is set to the dataNode mitkDataNodeExtTestClass::TestInteractorSetting(myDataNode); // write your own tests here and use the macros from mitkTestingMacros.h !!! // do not write to std::cout and do not return from this function yourself! // always end with this! MITK_TEST_END() }