From: akl Date: Wed, 17 Sep 2014 08:30:45 +0000 (+0400) Subject: Fixing visibility of standalone vertices in compound in VTK viewer. X-Git-Tag: V7_5_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d50ae9ad41b362bef2d058c53c0abeb5ed089db0;p=modules%2Fgeom.git Fixing visibility of standalone vertices in compound in VTK viewer. --- diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index a2ad57d4b..583a73078 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -721,7 +721,8 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor ); if ( aGeomGActor ) { GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty()); - res = mat->GetPhysical(); + if ( mat ) + res = mat->GetPhysical(); } // if ( salome actor ) } // if ( actor ) } // if ( lst == vtkPrs->GetObjects() ) diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index a5cdfbfcb..1b15c5640 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -87,6 +87,9 @@ GEOM_Actor::GEOM_Actor(): myVertexActor(GEOM_DeviceActor::New(),true), myVertexSource(GEOM_VertexSource::New(),true), + myStandaloneVertexActor(GEOM_DeviceActor::New(),true), + myStandaloneVertexSource(GEOM_VertexSource::New(),true), + myIsolatedEdgeActor(GEOM_DeviceActor::New(),true), myIsolatedEdgeSource(GEOM_EdgeSource::New(),true), @@ -130,13 +133,13 @@ GEOM_Actor::GEOM_Actor(): myHighlightProp->SetAmbientColor(1, 1, 1); myHighlightProp->SetDiffuseColor(1, 1, 1); myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5); - myHighlightProp->SetPointSize(0); + myHighlightProp->SetPointSize(SALOME_POINT_SIZE+2); myHighlightActor->SetProperty(myHighlightProp.GetPointer()); this->myHighlightActor->SetInput(myAppendFilter->GetOutputPort(),false); myPreHighlightProp->SetColor(0,1,1); - myPreHighlightProp->SetPointSize(0); + myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE); myPreHighlightProp->SetLineWidth(SALOME_LINE_WIDTH+1); myPreHighlightProp->SetRepresentationToWireframe(); @@ -147,6 +150,13 @@ GEOM_Actor::GEOM_Actor(): aProperty->SetPointSize(3); aProperty->SetColor(1, 1, 0); + myAppendFilter->AddInputConnection(myStandaloneVertexSource->GetOutputPort()); + myStandaloneVertexActor->SetInput(myStandaloneVertexSource->GetOutputPort(),false); + aProperty = myStandaloneVertexActor->GetProperty(); + aProperty->SetRepresentation(VTK_POINTS); + aProperty->SetPointSize(3); + aProperty->SetColor(1, 1, 0); + myAppendFilter->AddInputConnection(myIsolatedEdgeSource->GetOutputPort()); myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutputPort(),false); aProperty = myIsolatedEdgeActor->GetProperty(); @@ -229,6 +239,7 @@ GEOM_Actor:: SetModified() { this->myVertexSource->Modified(); + this->myStandaloneVertexSource->Modified(); this->myIsolatedEdgeSource->Modified(); this->myOneFaceEdgeSource->Modified(); this->mySharedEdgeSource->Modified(); @@ -262,6 +273,7 @@ AddToRender(vtkRenderer* theRenderer) myIsolatedEdgeActor->AddToRender(theRenderer); myVertexActor->AddToRender(theRenderer); + myStandaloneVertexActor->AddToRender(theRenderer); } void @@ -282,6 +294,7 @@ RemoveFromRender(vtkRenderer* theRenderer) myIsolatedEdgeActor->RemoveFromRender(theRenderer); myVertexActor->RemoveFromRender(theRenderer); + myStandaloneVertexActor->RemoveFromRender(theRenderer); SetSelected(false); @@ -358,6 +371,8 @@ SetVisibility(int theVisibility) myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected); myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points + + myStandaloneVertexActor->SetVisibility(theVisibility); } @@ -399,11 +414,9 @@ GEOM_Actor { myVerticesMode = theMode; if ( theMode || isOnlyVertex ) { - myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE+2); - myHighlightProp->SetPointSize(SALOME_POINT_SIZE); + myAppendFilter->AddInputConnection(myVertexSource->GetOutputPort()); } else { - myPreHighlightProp->SetPointSize(0); - myHighlightProp->SetPointSize(0); + myAppendFilter->RemoveInputConnection(0, myVertexSource->GetOutputPort()); } SetModified(); } @@ -436,6 +449,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape, myShape = theShape; myVertexSource->Clear(); + myStandaloneVertexSource->Clear(); myIsolatedEdgeSource->Clear(); myOneFaceEdgeSource->Clear(); mySharedEdgeSource->Clear(); @@ -456,6 +470,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape, TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap); GEOM::SetShape(theShape,anEdgeMap,theIsVector, + myStandaloneVertexSource.Get(), myIsolatedEdgeSource.Get(), myOneFaceEdgeSource.Get(), mySharedEdgeSource.Get(), @@ -471,6 +486,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape, if((bool)myShape.Infinite() || isOnlyVertex ){ myVertexActor->GetDeviceActor()->SetInfinitive(true); + myStandaloneVertexActor->GetDeviceActor()->SetInfinitive(true); myHighlightActor->GetDeviceActor()->SetInfinitive(true); } @@ -526,6 +542,11 @@ vtkProperty* GEOM_Actor::GetVertexProperty() return myVertexActor->GetProperty(); } +vtkProperty* GEOM_Actor::GetStandaloneVertexProperty() +{ + return myStandaloneVertexActor->GetProperty(); +} + vtkProperty* GEOM_Actor::GetSharedEdgeProperty() { return mySharedEdgeActor->GetProperty(); @@ -715,6 +736,7 @@ void GEOM_Actor::SetOpacity(double opa) myHighlightProp->SetOpacity(opa); myPreHighlightProp->SetOpacity(opa); myVertexActor->GetProperty()->SetOpacity(opa); + myStandaloneVertexActor->GetProperty()->SetOpacity(opa); } double GEOM_Actor::GetOpacity() @@ -755,6 +777,7 @@ void GEOM_Actor::GetColor(double& r,double& g,double& b) void GEOM_Actor::SetPointColor(double r, double g, double b) { myVertexActor->GetProperty()->SetColor(r, g, b); + myStandaloneVertexActor->GetProperty()->SetColor(r, g, b); } /*! @@ -818,6 +841,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetAmbient(); myShadingFaceProp->SetAmbient(aCoefnt); myVertexActor->GetProperty()->SetAmbient(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetAmbient(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetAmbient(); myShadingBackFaceProp->SetAmbient(aCoefnt); @@ -826,6 +850,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetDiffuse(); myShadingFaceProp->SetDiffuse(aCoefnt); myVertexActor->GetProperty()->SetDiffuse(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetDiffuse(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetDiffuse(); myShadingBackFaceProp->SetDiffuse(aCoefnt); @@ -834,6 +859,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetSpecular(); myShadingFaceProp->SetSpecular(aCoefnt); myVertexActor->GetProperty()->SetSpecular(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetSpecular(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetSpecular(); myShadingBackFaceProp->SetSpecular(aCoefnt); @@ -845,6 +871,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetAmbientColor(); myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]); + myStandaloneVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]); if ( aSize == 2 ) aColor = theProps[1]->GetAmbientColor(); myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); @@ -853,6 +880,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetDiffuseColor(); myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); + myStandaloneVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); if ( aSize == 2 ) aColor = theProps[1]->GetDiffuseColor(); myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); @@ -861,6 +889,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetSpecularColor(); myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]); + myStandaloneVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]); if ( aSize == 2 ) aColor = theProps[1]->GetSpecularColor(); myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); @@ -869,6 +898,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetSpecularPower(); myShadingFaceProp->SetSpecularPower(aCoefnt); myVertexActor->GetProperty()->SetSpecularPower(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetSpecularPower(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetSpecularPower(); myShadingBackFaceProp->SetSpecularPower(aCoefnt); diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index 173f40a0b..117f1afcb 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -89,6 +89,7 @@ public: vtkProperty* GetShadingProperty(); vtkProperty* GetIsolatedEdgeProperty(); vtkProperty* GetVertexProperty(); + vtkProperty* GetStandaloneVertexProperty(); vtkProperty* GetSharedEdgeProperty(); vtkProperty* GetFaceEdgeProperty(); @@ -234,6 +235,9 @@ private: PDeviceActor myVertexActor; PVertexSource myVertexSource; + PDeviceActor myStandaloneVertexActor; + PVertexSource myStandaloneVertexSource; + PDeviceActor myIsolatedEdgeActor; PEdgeSource myIsolatedEdgeSource; diff --git a/src/OCC2VTK/OCC2VTK_Tools.cxx b/src/OCC2VTK/OCC2VTK_Tools.cxx index 8e325c887..e9b592035 100755 --- a/src/OCC2VTK/OCC2VTK_Tools.cxx +++ b/src/OCC2VTK/OCC2VTK_Tools.cxx @@ -88,6 +88,7 @@ namespace GEOM void SetShape(const TopoDS_Shape& theShape, const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, bool theIsVector, + GEOM_VertexSource* theStandaloneVertexSource, GEOM_EdgeSource* theIsolatedEdgeSource, GEOM_EdgeSource* theOneFaceEdgeSource, GEOM_EdgeSource* theSharedEdgeSource, @@ -98,6 +99,7 @@ namespace GEOM TopoDS_Iterator anItr(theShape); for (; anItr.More(); anItr.Next()) { SetShape(anItr.Value(),theEdgeMap,theIsVector, + theStandaloneVertexSource, theIsolatedEdgeSource, theOneFaceEdgeSource, theSharedEdgeSource, @@ -123,6 +125,10 @@ namespace GEOM break; } case TopAbs_VERTEX: { + if ( theStandaloneVertexSource ) { + const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape); + theStandaloneVertexSource->AddVertex(aVertex); + } break; } default: { diff --git a/src/OCC2VTK/OCC2VTK_Tools.h b/src/OCC2VTK/OCC2VTK_Tools.h index c4fb478c6..523ca14b9 100755 --- a/src/OCC2VTK/OCC2VTK_Tools.h +++ b/src/OCC2VTK/OCC2VTK_Tools.h @@ -25,6 +25,7 @@ #include #include +class GEOM_VertexSource; class GEOM_EdgeSource; class GEOM_WireframeFace; class GEOM_ShadingFace; @@ -40,6 +41,7 @@ namespace GEOM OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape, const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, bool theIsVector, + GEOM_VertexSource* theStandaloneVertexSource, GEOM_EdgeSource* theIsolatedEdgeSource, GEOM_EdgeSource* theOneFaceEdgeSource, GEOM_EdgeSource* theSharedEdgeSource, diff --git a/src/VTKExport/VTKExport.cxx b/src/VTKExport/VTKExport.cxx index bc342d396..ab853c4af 100644 --- a/src/VTKExport/VTKExport.cxx +++ b/src/VTKExport/VTKExport.cxx @@ -119,6 +119,7 @@ extern "C" GEOM::SetShape( theShape, anEdgeMap, anIsVector, + 0, // all vertices were added above myIsolatedEdgeSource, myOneFaceEdgeSource, mySharedEdgeSource,