Fixing visibility of standalone vertices in compound in VTK viewer.

This commit is contained in:
akl 2014-09-17 12:30:45 +04:00
parent bd2026a383
commit d50ae9ad41
6 changed files with 51 additions and 7 deletions

View File

@ -721,7 +721,8 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const
GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor ); GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor );
if ( aGeomGActor ) { if ( aGeomGActor ) {
GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty()); GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty());
res = mat->GetPhysical(); if ( mat )
res = mat->GetPhysical();
} // if ( salome actor ) } // if ( salome actor )
} // if ( actor ) } // if ( actor )
} // if ( lst == vtkPrs->GetObjects() ) } // if ( lst == vtkPrs->GetObjects() )

View File

@ -87,6 +87,9 @@ GEOM_Actor::GEOM_Actor():
myVertexActor(GEOM_DeviceActor::New(),true), myVertexActor(GEOM_DeviceActor::New(),true),
myVertexSource(GEOM_VertexSource::New(),true), myVertexSource(GEOM_VertexSource::New(),true),
myStandaloneVertexActor(GEOM_DeviceActor::New(),true),
myStandaloneVertexSource(GEOM_VertexSource::New(),true),
myIsolatedEdgeActor(GEOM_DeviceActor::New(),true), myIsolatedEdgeActor(GEOM_DeviceActor::New(),true),
myIsolatedEdgeSource(GEOM_EdgeSource::New(),true), myIsolatedEdgeSource(GEOM_EdgeSource::New(),true),
@ -130,13 +133,13 @@ GEOM_Actor::GEOM_Actor():
myHighlightProp->SetAmbientColor(1, 1, 1); myHighlightProp->SetAmbientColor(1, 1, 1);
myHighlightProp->SetDiffuseColor(1, 1, 1); myHighlightProp->SetDiffuseColor(1, 1, 1);
myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5); myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5);
myHighlightProp->SetPointSize(0); myHighlightProp->SetPointSize(SALOME_POINT_SIZE+2);
myHighlightActor->SetProperty(myHighlightProp.GetPointer()); myHighlightActor->SetProperty(myHighlightProp.GetPointer());
this->myHighlightActor->SetInput(myAppendFilter->GetOutputPort(),false); this->myHighlightActor->SetInput(myAppendFilter->GetOutputPort(),false);
myPreHighlightProp->SetColor(0,1,1); myPreHighlightProp->SetColor(0,1,1);
myPreHighlightProp->SetPointSize(0); myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE);
myPreHighlightProp->SetLineWidth(SALOME_LINE_WIDTH+1); myPreHighlightProp->SetLineWidth(SALOME_LINE_WIDTH+1);
myPreHighlightProp->SetRepresentationToWireframe(); myPreHighlightProp->SetRepresentationToWireframe();
@ -147,6 +150,13 @@ GEOM_Actor::GEOM_Actor():
aProperty->SetPointSize(3); aProperty->SetPointSize(3);
aProperty->SetColor(1, 1, 0); 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()); myAppendFilter->AddInputConnection(myIsolatedEdgeSource->GetOutputPort());
myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutputPort(),false); myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutputPort(),false);
aProperty = myIsolatedEdgeActor->GetProperty(); aProperty = myIsolatedEdgeActor->GetProperty();
@ -229,6 +239,7 @@ GEOM_Actor::
SetModified() SetModified()
{ {
this->myVertexSource->Modified(); this->myVertexSource->Modified();
this->myStandaloneVertexSource->Modified();
this->myIsolatedEdgeSource->Modified(); this->myIsolatedEdgeSource->Modified();
this->myOneFaceEdgeSource->Modified(); this->myOneFaceEdgeSource->Modified();
this->mySharedEdgeSource->Modified(); this->mySharedEdgeSource->Modified();
@ -262,6 +273,7 @@ AddToRender(vtkRenderer* theRenderer)
myIsolatedEdgeActor->AddToRender(theRenderer); myIsolatedEdgeActor->AddToRender(theRenderer);
myVertexActor->AddToRender(theRenderer); myVertexActor->AddToRender(theRenderer);
myStandaloneVertexActor->AddToRender(theRenderer);
} }
void void
@ -282,6 +294,7 @@ RemoveFromRender(vtkRenderer* theRenderer)
myIsolatedEdgeActor->RemoveFromRender(theRenderer); myIsolatedEdgeActor->RemoveFromRender(theRenderer);
myVertexActor->RemoveFromRender(theRenderer); myVertexActor->RemoveFromRender(theRenderer);
myStandaloneVertexActor->RemoveFromRender(theRenderer);
SetSelected(false); SetSelected(false);
@ -358,6 +371,8 @@ SetVisibility(int theVisibility)
myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected); myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected);
myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points
myStandaloneVertexActor->SetVisibility(theVisibility);
} }
@ -399,11 +414,9 @@ GEOM_Actor
{ {
myVerticesMode = theMode; myVerticesMode = theMode;
if ( theMode || isOnlyVertex ) { if ( theMode || isOnlyVertex ) {
myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE+2); myAppendFilter->AddInputConnection(myVertexSource->GetOutputPort());
myHighlightProp->SetPointSize(SALOME_POINT_SIZE);
} else { } else {
myPreHighlightProp->SetPointSize(0); myAppendFilter->RemoveInputConnection(0, myVertexSource->GetOutputPort());
myHighlightProp->SetPointSize(0);
} }
SetModified(); SetModified();
} }
@ -436,6 +449,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
myShape = theShape; myShape = theShape;
myVertexSource->Clear(); myVertexSource->Clear();
myStandaloneVertexSource->Clear();
myIsolatedEdgeSource->Clear(); myIsolatedEdgeSource->Clear();
myOneFaceEdgeSource->Clear(); myOneFaceEdgeSource->Clear();
mySharedEdgeSource->Clear(); mySharedEdgeSource->Clear();
@ -456,6 +470,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap); TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
GEOM::SetShape(theShape,anEdgeMap,theIsVector, GEOM::SetShape(theShape,anEdgeMap,theIsVector,
myStandaloneVertexSource.Get(),
myIsolatedEdgeSource.Get(), myIsolatedEdgeSource.Get(),
myOneFaceEdgeSource.Get(), myOneFaceEdgeSource.Get(),
mySharedEdgeSource.Get(), mySharedEdgeSource.Get(),
@ -471,6 +486,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
if((bool)myShape.Infinite() || isOnlyVertex ){ if((bool)myShape.Infinite() || isOnlyVertex ){
myVertexActor->GetDeviceActor()->SetInfinitive(true); myVertexActor->GetDeviceActor()->SetInfinitive(true);
myStandaloneVertexActor->GetDeviceActor()->SetInfinitive(true);
myHighlightActor->GetDeviceActor()->SetInfinitive(true); myHighlightActor->GetDeviceActor()->SetInfinitive(true);
} }
@ -526,6 +542,11 @@ vtkProperty* GEOM_Actor::GetVertexProperty()
return myVertexActor->GetProperty(); return myVertexActor->GetProperty();
} }
vtkProperty* GEOM_Actor::GetStandaloneVertexProperty()
{
return myStandaloneVertexActor->GetProperty();
}
vtkProperty* GEOM_Actor::GetSharedEdgeProperty() vtkProperty* GEOM_Actor::GetSharedEdgeProperty()
{ {
return mySharedEdgeActor->GetProperty(); return mySharedEdgeActor->GetProperty();
@ -715,6 +736,7 @@ void GEOM_Actor::SetOpacity(double opa)
myHighlightProp->SetOpacity(opa); myHighlightProp->SetOpacity(opa);
myPreHighlightProp->SetOpacity(opa); myPreHighlightProp->SetOpacity(opa);
myVertexActor->GetProperty()->SetOpacity(opa); myVertexActor->GetProperty()->SetOpacity(opa);
myStandaloneVertexActor->GetProperty()->SetOpacity(opa);
} }
double GEOM_Actor::GetOpacity() 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) void GEOM_Actor::SetPointColor(double r, double g, double b)
{ {
myVertexActor->GetProperty()->SetColor(r, g, b); myVertexActor->GetProperty()->SetColor(r, g, b);
myStandaloneVertexActor->GetProperty()->SetColor(r, g, b);
} }
/*! /*!
@ -818,6 +841,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aCoefnt = theProps[0]->GetAmbient(); aCoefnt = theProps[0]->GetAmbient();
myShadingFaceProp->SetAmbient(aCoefnt); myShadingFaceProp->SetAmbient(aCoefnt);
myVertexActor->GetProperty()->SetAmbient(aCoefnt); myVertexActor->GetProperty()->SetAmbient(aCoefnt);
myStandaloneVertexActor->GetProperty()->SetAmbient(aCoefnt);
if ( aSize == 2 ) if ( aSize == 2 )
aCoefnt = theProps[1]->GetAmbient(); aCoefnt = theProps[1]->GetAmbient();
myShadingBackFaceProp->SetAmbient(aCoefnt); myShadingBackFaceProp->SetAmbient(aCoefnt);
@ -826,6 +850,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aCoefnt = theProps[0]->GetDiffuse(); aCoefnt = theProps[0]->GetDiffuse();
myShadingFaceProp->SetDiffuse(aCoefnt); myShadingFaceProp->SetDiffuse(aCoefnt);
myVertexActor->GetProperty()->SetDiffuse(aCoefnt); myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
myStandaloneVertexActor->GetProperty()->SetDiffuse(aCoefnt);
if ( aSize == 2 ) if ( aSize == 2 )
aCoefnt = theProps[1]->GetDiffuse(); aCoefnt = theProps[1]->GetDiffuse();
myShadingBackFaceProp->SetDiffuse(aCoefnt); myShadingBackFaceProp->SetDiffuse(aCoefnt);
@ -834,6 +859,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aCoefnt = theProps[0]->GetSpecular(); aCoefnt = theProps[0]->GetSpecular();
myShadingFaceProp->SetSpecular(aCoefnt); myShadingFaceProp->SetSpecular(aCoefnt);
myVertexActor->GetProperty()->SetSpecular(aCoefnt); myVertexActor->GetProperty()->SetSpecular(aCoefnt);
myStandaloneVertexActor->GetProperty()->SetSpecular(aCoefnt);
if ( aSize == 2 ) if ( aSize == 2 )
aCoefnt = theProps[1]->GetSpecular(); aCoefnt = theProps[1]->GetSpecular();
myShadingBackFaceProp->SetSpecular(aCoefnt); myShadingBackFaceProp->SetSpecular(aCoefnt);
@ -845,6 +871,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aColor = theProps[0]->GetAmbientColor(); aColor = theProps[0]->GetAmbientColor();
myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->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 ) if ( aSize == 2 )
aColor = theProps[1]->GetAmbientColor(); aColor = theProps[1]->GetAmbientColor();
myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
@ -853,6 +880,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aColor = theProps[0]->GetDiffuseColor(); aColor = theProps[0]->GetDiffuseColor();
myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->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 ) if ( aSize == 2 )
aColor = theProps[1]->GetDiffuseColor(); aColor = theProps[1]->GetDiffuseColor();
myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
@ -861,6 +889,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aColor = theProps[0]->GetSpecularColor(); aColor = theProps[0]->GetSpecularColor();
myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->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 ) if ( aSize == 2 )
aColor = theProps[1]->GetSpecularColor(); aColor = theProps[1]->GetSpecularColor();
myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
@ -869,6 +898,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aCoefnt = theProps[0]->GetSpecularPower(); aCoefnt = theProps[0]->GetSpecularPower();
myShadingFaceProp->SetSpecularPower(aCoefnt); myShadingFaceProp->SetSpecularPower(aCoefnt);
myVertexActor->GetProperty()->SetSpecularPower(aCoefnt); myVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
myStandaloneVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
if ( aSize == 2 ) if ( aSize == 2 )
aCoefnt = theProps[1]->GetSpecularPower(); aCoefnt = theProps[1]->GetSpecularPower();
myShadingBackFaceProp->SetSpecularPower(aCoefnt); myShadingBackFaceProp->SetSpecularPower(aCoefnt);

View File

@ -89,6 +89,7 @@ public:
vtkProperty* GetShadingProperty(); vtkProperty* GetShadingProperty();
vtkProperty* GetIsolatedEdgeProperty(); vtkProperty* GetIsolatedEdgeProperty();
vtkProperty* GetVertexProperty(); vtkProperty* GetVertexProperty();
vtkProperty* GetStandaloneVertexProperty();
vtkProperty* GetSharedEdgeProperty(); vtkProperty* GetSharedEdgeProperty();
vtkProperty* GetFaceEdgeProperty(); vtkProperty* GetFaceEdgeProperty();
@ -234,6 +235,9 @@ private:
PDeviceActor myVertexActor; PDeviceActor myVertexActor;
PVertexSource myVertexSource; PVertexSource myVertexSource;
PDeviceActor myStandaloneVertexActor;
PVertexSource myStandaloneVertexSource;
PDeviceActor myIsolatedEdgeActor; PDeviceActor myIsolatedEdgeActor;
PEdgeSource myIsolatedEdgeSource; PEdgeSource myIsolatedEdgeSource;

View File

@ -88,6 +88,7 @@ namespace GEOM
void SetShape(const TopoDS_Shape& theShape, void SetShape(const TopoDS_Shape& theShape,
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
bool theIsVector, bool theIsVector,
GEOM_VertexSource* theStandaloneVertexSource,
GEOM_EdgeSource* theIsolatedEdgeSource, GEOM_EdgeSource* theIsolatedEdgeSource,
GEOM_EdgeSource* theOneFaceEdgeSource, GEOM_EdgeSource* theOneFaceEdgeSource,
GEOM_EdgeSource* theSharedEdgeSource, GEOM_EdgeSource* theSharedEdgeSource,
@ -98,6 +99,7 @@ namespace GEOM
TopoDS_Iterator anItr(theShape); TopoDS_Iterator anItr(theShape);
for (; anItr.More(); anItr.Next()) { for (; anItr.More(); anItr.Next()) {
SetShape(anItr.Value(),theEdgeMap,theIsVector, SetShape(anItr.Value(),theEdgeMap,theIsVector,
theStandaloneVertexSource,
theIsolatedEdgeSource, theIsolatedEdgeSource,
theOneFaceEdgeSource, theOneFaceEdgeSource,
theSharedEdgeSource, theSharedEdgeSource,
@ -123,6 +125,10 @@ namespace GEOM
break; break;
} }
case TopAbs_VERTEX: { case TopAbs_VERTEX: {
if ( theStandaloneVertexSource ) {
const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
theStandaloneVertexSource->AddVertex(aVertex);
}
break; break;
} }
default: { default: {

View File

@ -25,6 +25,7 @@
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
class GEOM_VertexSource;
class GEOM_EdgeSource; class GEOM_EdgeSource;
class GEOM_WireframeFace; class GEOM_WireframeFace;
class GEOM_ShadingFace; class GEOM_ShadingFace;
@ -40,6 +41,7 @@ namespace GEOM
OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape, OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape,
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
bool theIsVector, bool theIsVector,
GEOM_VertexSource* theStandaloneVertexSource,
GEOM_EdgeSource* theIsolatedEdgeSource, GEOM_EdgeSource* theIsolatedEdgeSource,
GEOM_EdgeSource* theOneFaceEdgeSource, GEOM_EdgeSource* theOneFaceEdgeSource,
GEOM_EdgeSource* theSharedEdgeSource, GEOM_EdgeSource* theSharedEdgeSource,

View File

@ -119,6 +119,7 @@ extern "C"
GEOM::SetShape( theShape, GEOM::SetShape( theShape,
anEdgeMap, anEdgeMap,
anIsVector, anIsVector,
0, // all vertices were added above
myIsolatedEdgeSource, myIsolatedEdgeSource,
myOneFaceEdgeSource, myOneFaceEdgeSource,
mySharedEdgeSource, mySharedEdgeSource,