X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FGEOM_Actor.cxx;h=0e7f3ccbaf1b1f25aa34529dc850d2454426a56b;hb=6e638ed22140cb8c1a65e73c43541e44b2aa3bf5;hp=e29c665cbd465c69308d824bf5810aa1d031f2ff;hpb=f72094caafac8a8fe54afa58ffe44879a6388258;p=modules%2Fgeom.git diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index e29c665cb..0e7f3ccba 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -26,7 +26,6 @@ // Module : GEOM // $Header$ -using namespace std; /*! \class GEOM_Actor GEOM_Actor.h \brief This class allows to display an OpenCASCADE CAD model in a VTK viewer. @@ -34,10 +33,25 @@ using namespace std; #include "GEOM_Actor.h" +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + // OpenCASCADE Includes #include "GEOM_OCCReader.h" #include +using namespace std; + //------------------------------------------------------------- // Main methods //------------------------------------------------------------- @@ -73,9 +87,10 @@ GEOM_Actor::GEOM_Actor() this->myName = ""; this->HighlightProperty = NULL; - this->ishighlighted = false; + this->myIsHighlighted = false; this->subshape = false; + this->myIsInfinite = false; } GEOM_Actor::~GEOM_Actor() @@ -171,6 +186,7 @@ void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) { // Mapper creating function //------------------------------------------------------------- void GEOM_Actor::CreateMapper(int theMode) { + this->myIsInfinite = (bool)myShape.Infinite(); if(myShape.ShapeType() == TopAbs_VERTEX) { gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(myShape)); this->SetPosition(aPnt.X(),aPnt.Y(),aPnt.Z()); @@ -219,8 +235,10 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) this->Property->SetSpecularColor(0.99,0.98,0.83); } - if(!ishighlighted) { - if(myDisplayMode >= 1) { + if(!myIsHighlighted) { + if ( myIsPreselected ) + this->Property = PreviewProperty; + else if(myDisplayMode >= 1) { // SHADING this->Property = ShadingProperty; } @@ -228,8 +246,6 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) this->Property = WireframeProperty; } - if ( ispreselected ) - this->Property = PreviewProperty; } this->Property->Render(this, ren); @@ -259,10 +275,10 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) if(myShape.ShapeType() == TopAbs_VERTEX) { if(ren){ //The parameter determine size of vertex actor relate to diagonal of RendererWindow - static float delta = 0.01; - float X1 = -1, Y1 = -1, Z1 = 0; + static vtkFloatingPointType delta = 0.01; + vtkFloatingPointType X1 = -1, Y1 = -1, Z1 = 0; ren->ViewToWorld(X1,Y1,Z1); - float X2 = +1, Y2 = +1, Z2 = 0; + vtkFloatingPointType X2 = +1, Y2 = +1, Z2 = 0; ren->ViewToWorld(X2,Y2,Z2); Z2 = sqrt((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1) + (Z2-Z1)*(Z2-Z1)); this->SetScale(Z2*delta); @@ -274,7 +290,8 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) aMatrix->Delete(); } else this->Device->Render(ren, this->Mapper); - this->EstimatedRenderTime = WireframeMapper->GetTimeToDraw(); + if(WireframeMapper!=NULL) this->EstimatedRenderTime = WireframeMapper->GetTimeToDraw(); + else if(ShadingMapper!=NULL) this->EstimatedRenderTime = ShadingMapper->GetTimeToDraw(); } // SubShape @@ -291,40 +308,40 @@ void GEOM_Actor::SubShapeOff() // Opacity methods //------------------------------------------------------------- -void GEOM_Actor::SetOpacity(float opa) +void GEOM_Actor::SetOpacity(vtkFloatingPointType opa) { //HighlightProperty->SetOpacity(opa); SALOME_Actor::SetOpacity(opa); ShadingProperty->SetOpacity(opa); } -float GEOM_Actor::GetOpacity() { +vtkFloatingPointType GEOM_Actor::GetOpacity() { return ShadingProperty->GetOpacity(); } //------------------------------------------------------------- // Color methods //------------------------------------------------------------- -void GEOM_Actor::SetColor(float r,float g,float b) { +void GEOM_Actor::SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b) { ShadingProperty->SetColor(r,g,b); } -void GEOM_Actor::GetColor(float& r,float& g,float& b) { - float color[3]; - ShadingProperty->GetColor(color); - r = color[0]; - g = color[1]; - b = color[2]; +void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b) { + vtkFloatingPointType color[3]; + ShadingProperty->GetColor(color); + r = color[0]; + g = color[1]; + b = color[2]; } //------------------------------------------------------------- // Highlight methods //------------------------------------------------------------- -void GEOM_Actor::highlight(Standard_Boolean highlight) { +void GEOM_Actor::highlight(bool highlight) { - if(highlight && !ishighlighted) { - ishighlighted=true; + if(highlight && !myIsHighlighted) { + myIsHighlighted=true; // build highlight property is necessary if(HighlightProperty==NULL) { HighlightProperty = vtkProperty::New(); @@ -341,8 +358,8 @@ void GEOM_Actor::highlight(Standard_Boolean highlight) { } else if (!highlight) { - if(ishighlighted) { - ishighlighted=false; + if(myIsHighlighted) { + myIsHighlighted=false; if(myDisplayMode==1) { //unhilight in shading this->Property = ShadingProperty; @@ -355,11 +372,6 @@ void GEOM_Actor::highlight(Standard_Boolean highlight) { } } -bool GEOM_Actor::hasHighlight() -{ - return true; -} - void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop) { this->HighlightProperty = Prop; }