Salome HOME
Fix crash of BugRevolution.py import: apply the same patch, as on V2_2_0_maintainance
[modules/geom.git] / src / OBJECT / GEOM_Actor.cxx
index 6dcfb88050ac49c240808f7b859e399db7d39511..0ebbf32f4e412e0d78df0246bba60bbe9e8e3bf3 100644 (file)
@@ -1,10 +1,29 @@
-using namespace std;
-//  File      : GEOM_Actor.cxx
-//  Created   : Wed Feb 20 17:24:59 2002
-//  Author    : Christophe ATTANASIO
-//  Project   : SALOME
-//  Module    : GEOM
-//  Copyright : Open CASCADE 2002
+//  GEOM OBJECT : interactive object for Geometry entities visualization
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  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 
+//
+//
+//
+//  File   : GEOM_Actor.cxx
+//  Author : Christophe ATTANASIO
+//  Module : GEOM
 //  $Header$
 
 /*!
@@ -14,16 +33,24 @@ using namespace std;
 
 #include "GEOM_Actor.h"
 
-// VTK Includes
 #include <vtkObjectFactory.h>
+#include <vtkPolyData.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkPolyDataNormals.h>
+
+#include <vtkTransform.h>
+#include <vtkMatrix4x4.h>
 #include <vtkMath.h>
 
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+
 // OpenCASCADE Includes
 #include "GEOM_OCCReader.h"
 #include <BRep_Tool.hxx>
 
+using namespace std;
+
 //-------------------------------------------------------------
 // Main methods
 //-------------------------------------------------------------
@@ -59,9 +86,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()
@@ -157,6 +185,7 @@ void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) {
 // Mapper creating function
 //-------------------------------------------------------------
 void GEOM_Actor::CreateMapper(int theMode) {
+  this->myIsInfinite = myShape.Infinite();  
   if(myShape.ShapeType() == TopAbs_VERTEX) {
     gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
     this->SetPosition(aPnt.X(),aPnt.Y(),aPnt.Z());
@@ -205,8 +234,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;
     }
@@ -214,8 +245,6 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper)
       this->Property = WireframeProperty;     
     }
 
-    if ( ispreselected )
-      this->Property = PreviewProperty;
   }
 
   this->Property->Render(this, ren);
@@ -260,7 +289,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
@@ -297,20 +327,20 @@ void GEOM_Actor::SetColor(float r,float g,float 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];
+  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();
@@ -327,8 +357,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;
@@ -341,11 +371,6 @@ void GEOM_Actor::highlight(Standard_Boolean highlight) {
   }
 }
 
-bool GEOM_Actor::hasHighlight()
-{
-  return true;
-}
-
 void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop) {
   this->HighlightProperty = Prop;
 }