Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / OBJECT / VISU_MeshAct.cxx
index ac262e529002d65aa946b27fc023d26ae5824899..68f7446a6c7e2000cd61fb7644f9004c74f5ae94 100644 (file)
@@ -1,23 +1,23 @@
 //  VISU OBJECT : interactive object for VISU entities implementation
 //
 //  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 
+//  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
 //
 //
 //
@@ -27,7 +27,7 @@
 //  $Header$
 
 #include "VISU_MeshAct.h"
-#include "SALOME_PassThroughFilter.h"
+#include "VTKViewer_PassThroughFilter.h"
 
 #include <vtkObjectFactory.h>
 #include <vtkRenderer.h>
 #include <vtkDataSetMapper.h>
 #include <vtkDataSet.h>
 #include <vtkMatrix4x4.h>
-#include <vtkMapperCollection.h> 
+#include <vtkMapperCollection.h>
 
 vtkStandardNewMacro(VISU_MeshAct);
 
 VISU_MeshAct::VISU_MeshAct(){
-  
+
   vtkMatrix4x4 *m;
   m = vtkMatrix4x4::New();
 
@@ -52,7 +52,7 @@ VISU_MeshAct::VISU_MeshAct(){
   mySurfaceActor->GetProperty()->BackfaceCullingOff();
   mySurfaceActor->SetUserMatrix(m);
   mySurfaceActor->SetRepresentation(2); //SURFACE
+
   myEdgeActor = VISU_Actor::New();
   myEdgeActor->SetParent(this);
   myEdgeActor->PickableOff();
@@ -60,7 +60,7 @@ VISU_MeshAct::VISU_MeshAct(){
   myEdgeActor->GetProperty()->BackfaceCullingOff();
   myEdgeActor->SetUserMatrix(m);
   myEdgeActor->SetRepresentation(1); //WIREFRAME
+
   myNodeActor = VISU_Actor::New();
   myNodeActor->SetParent(this);
   myNodeActor->PickableOff();
@@ -87,7 +87,7 @@ void VISU_MeshAct::setIO(const Handle(SALOME_InteractiveObject)& theIO){
   myNodeActor->setIO(theIO);
 }
 
-void VISU_MeshAct::SetPrs3d(VISU::Prs3d_i* thePrs3d){ 
+void VISU_MeshAct::SetPrs3d(VISU::Prs3d_i* thePrs3d){
   if(thePrs3d){
     VISU_Actor::SetPrs3d(thePrs3d);
     mySurfaceActor->SetPrs3d(thePrs3d);
@@ -97,12 +97,12 @@ void VISU_MeshAct::SetPrs3d(VISU::Prs3d_i* thePrs3d){
 }
 
 void VISU_MeshAct::AddToRender(vtkRenderer* theRenderer){
-  theRenderer->AddActor(this);
+  VISU_Actor::AddToRender(theRenderer);
   theRenderer->AddActor(myEdgeActor);
 }
 
 void VISU_MeshAct::RemoveFromRender(vtkRenderer* theRenderer){
-  theRenderer->RemoveActor(this);
+  VISU_Actor::RemoveFromRender(theRenderer);
   theRenderer->RemoveActor(myEdgeActor);
 }
 
@@ -113,7 +113,7 @@ void VISU_MeshAct::SetPipeLine(VISU_PipeLine* thePipeLine) {
   myNodeActor->SetPipeLine(thePipeLine);
 }
 
-void VISU_MeshAct::SetTransform(SALOME_Transform* theTransform){
+void VISU_MeshAct::SetTransform(VTKViewer_Transform* theTransform){
   VISU_Actor::SetTransform(theTransform);
   mySurfaceActor->SetTransform(theTransform);
   myEdgeActor->SetTransform(theTransform);
@@ -133,27 +133,27 @@ void VISU_MeshAct::SetShrinkFactor(float theValue){
   myEdgeActor->SetShrinkFactor(theValue);
 }
 
-vtkProperty* VISU_MeshAct::GetSurfaceProperty(){ 
+vtkProperty* VISU_MeshAct::GetSurfaceProperty(){
   return mySurfaceActor->GetProperty();
-} 
+}
 
-void VISU_MeshAct::SetSurfaceProperty(vtkProperty* theProperty){ 
+void VISU_MeshAct::SetSurfaceProperty(vtkProperty* theProperty){
   mySurfaceActor->SetProperty(theProperty);
 }
 
-vtkProperty* VISU_MeshAct::GetEdgeProperty(){ 
+vtkProperty* VISU_MeshAct::GetEdgeProperty(){
   return myEdgeActor->GetProperty();
-} 
+}
 
-void VISU_MeshAct::SetEdgeProperty(vtkProperty* theProperty){ 
+void VISU_MeshAct::SetEdgeProperty(vtkProperty* theProperty){
   myEdgeActor->SetProperty(theProperty);
 }
 
-vtkProperty* VISU_MeshAct::GetNodeProperty(){ 
+vtkProperty* VISU_MeshAct::GetNodeProperty(){
   return myNodeActor->GetProperty();
-} 
+}
 
-void VISU_MeshAct::SetNodeProperty(vtkProperty* theProperty){ 
+void VISU_MeshAct::SetNodeProperty(vtkProperty* theProperty){
   myNodeActor->SetProperty(theProperty);
 }
 
@@ -161,7 +161,7 @@ void VISU_MeshAct::SetOpacity(float theValue){
   GetSurfaceProperty()->SetOpacity(theValue);
 }
 
-float VISU_MeshAct::GetOpacity(){ 
+float VISU_MeshAct::GetOpacity(){
   return GetSurfaceProperty()->GetOpacity();
 }
 
@@ -189,14 +189,18 @@ void VISU_MeshAct::UnShrink(){
   //SetRepresentation(GetRepresentation());
 }
 
-void VISU_MeshAct::SetRepresentation(int theMode){
+void VISU_MeshAct::SetRepresentation(int theMode)
+{
   SALOME_Actor::SetRepresentation(theMode);
+
+  if (!GetVisibility()) return; // Fix IPAL9555
+
   mySurfaceActor->VisibilityOff();
   myEdgeActor->VisibilityOff();
   myNodeActor->VisibilityOff();
   myEdgeActor->PickableOff();
   myNodeActor->PickableOff();
-  switch(theMode){
+  switch (theMode) {
   case VTK_POINTS:
     myNodeActor->VisibilityOn();
     myNodeActor->PickableOn();
@@ -220,7 +224,7 @@ void VISU_MeshAct::SetRepresentation(int theMode){
     mySurfaceActor->VisibilityOn();
     break;
   }
-  if(myRepresentation == VTK_POINTS)
+  if (myRepresentation == VTK_POINTS)
     UnShrink();
 }
 
@@ -241,53 +245,53 @@ void VISU_MeshAct::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
   float myTime, bestTime, tempTime;
   vtkMatrix4x4 *matrix;
   vtkMapper *mapper, *bestMapper;
-  
+
   if (this->Mapper == NULL)
     {
     vtkErrorMacro("No mapper for actor.");
     return;
     }
-  
+
   // first time through create lods if non have been added
   if (this->LODMappers->GetNumberOfItems() == 0)
     {
     this->CreateOwnLODs();
     }
-  
+
   // If the actor has changed or the primary mapper has changed ...
   // Is this the correct test?
   if (this->MediumMapper)
     {
-    if (this->GetMTime() > this->BuildTime || 
+    if (this->GetMTime() > this->BuildTime ||
         this->Mapper->GetMTime() > this->BuildTime)
       {
       this->UpdateOwnLODs();
       }
     }
-  
+
   // figure out how much time we have to render
   myTime = this->AllocatedRenderTime;
 
-  // Figure out which resolution to use 
+  // Figure out which resolution to use
   // none is a valid resolution. Do we want to have a lowest:
   // bbox, single point, ...
   // There is no order to the list, so it is assumed that mappers that take
   // longer to render are better quality.
-  // Timings might become out of date, but we rely on 
+  // Timings might become out of date, but we rely on
 
   bestMapper = this->Mapper;
   bestTime = bestMapper->GetTimeToDraw();
   if (bestTime > myTime)
     {
     this->LODMappers->InitTraversal();
-    while ((mapper = this->LODMappers->GetNextItem()) != NULL && 
+    while ((mapper = this->LODMappers->GetNextItem()) != NULL &&
            bestTime != 0.0)
       {
       tempTime = mapper->GetTimeToDraw();
-      
+
       // If the LOD has never been rendered, select it!
       if (tempTime == 0.0)
-        { 
+        {
         bestMapper = mapper;
         bestTime = 0.0;
         }
@@ -299,14 +303,14 @@ void VISU_MeshAct::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
           bestTime = tempTime;
           }
         if (tempTime > bestTime && tempTime < myTime)
-          { 
+          {
           bestMapper = mapper;
           bestTime = tempTime;
           }
         }
       }
     }
-    
+
   switch(GetRepresentation()){
   case 0: //POINTS
     myNodeActor->GetProperty()->Render(this, ren);
@@ -325,13 +329,13 @@ void VISU_MeshAct::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
     mySurfaceActor->GetProperty()->Render(this, ren);
     break;
   }
-   
+
   // render the texture
   if (this->Texture)
     {
     this->Texture->Render(ren);
     }
-     
+
   switch(GetRepresentation()){
   case 0: //POINTS
     matrix = myNodeActor->GetUserMatrix();
@@ -352,7 +356,7 @@ void VISU_MeshAct::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
     break;
   }
   this->GetMatrix(matrix);
+
   switch(GetRepresentation()){
   case 0: //POINTS
     myNodeActor->Render(ren,bestMapper);
@@ -371,7 +375,7 @@ void VISU_MeshAct::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
     mySurfaceActor->Render(ren,bestMapper);
     break;
   }
-  
+
   this->EstimatedRenderTime = bestMapper->GetTimeToDraw();
 }