Salome HOME
Suppress warnings.
[modules/visu.git] / src / VISUGUI / VisuGUI_Module.cxx
index 7da3b5eaa9fe560f60e6d1b9d52148f682cffe88..e1aad77a237edcd0f9462719ac38e432c7a1dcdc 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  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 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  VISU VISUGUI : GUI of VISU component
@@ -143,10 +143,10 @@ static int MYDEBUG = 0;
 #define GAUSS_DISPLAY_PRS        5500
 #define GAUSS_DISPLAY_ONLY_PRS   5600
 
-#define GAUSS_SAVE_CONFIGURATION       5700
-#define GAUSS_OVERWRITE_CONFIGURATION  5701
-#define GAUSS_RESTORE_CONFIGURATION    5702
-#define GAUSS_RENAME_CONFIGURATION     5703
+//#define GAUSS_SAVE_CONFIGURATION       5700
+//#define GAUSS_OVERWRITE_CONFIGURATION  5701
+//#define GAUSS_RESTORE_CONFIGURATION    5702
+//#define GAUSS_RENAME_CONFIGURATION     5703
 
 using namespace std;
 
@@ -267,13 +267,15 @@ void VisuGUI_Module::initialize( CAM_Application* theApp )
   createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 );
   createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 );
 
-  createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(),
+  /*  
+      createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(),
                 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
                 this, SLOT(OnRename()));
-  mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
-  mgr->setRule( action( GAUSS_RENAME ),
-    "selcount=1 and type='VISU::TGAUSSPOINTS'" );
-
+               mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
+               mgr->setRule( action( GAUSS_RENAME ),
+               "selcount=1 and type='VISU::TGAUSSPOINTS'" );
+  */
+  
   createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIcon(),
                 VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false,
                 this, SLOT(OnEditGaussPoints()));
@@ -289,7 +291,7 @@ void VisuGUI_Module::initialize( CAM_Application* theApp )
     "selcount=1 and type='VISU::TGAUSSPOINTS'" );
 
   action( GAUSS_COPY_PRS )->setEnabled(false);
-
+  
   QStringList viewers;
 
 #ifndef DISABLE_OCCVIEWER
@@ -347,7 +349,7 @@ void VisuGUI_Module::initialize( CAM_Application* theApp )
   mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
   mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
     aRule + " and ({true} in $canBeDisplayed)" );*/
-
+/*
   createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIcon(),
                 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
                 this, SLOT(OnRename()));
@@ -374,6 +376,7 @@ void VisuGUI_Module::initialize( CAM_Application* theApp )
   mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
   mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
   "selcount=1 and type='VISU::TGAUSSVIEW'" );
+*/
 }
 
 // //---------------------------------------------------------------
@@ -429,8 +432,8 @@ void VisuGUI_Module::createPreferences()
   VisuGUI::createPreferences();
 
   createGaussPointsPreferences();
-  createInsideCursorPreferences();
-  createOutsideCursorPreferences();
+  //createInsideCursorPreferences();
+  //createOutsideCursorPreferences();
   createPickingPreferences();
   // createSpaceMousePreferences();
   //createRecorderPreferences();
@@ -1801,7 +1804,7 @@ void VisuGUI_Module::storeVisualParameters(int savePoint)
                     ip->setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).toLatin1().data() );
                   }
                 }
-                } // salome actor is downcasted to the VISU_PointMap3dActor
+             } // salome actor is downcasted to the VISU_PointMap3dActor
             } // isVisible
           } // end of ..while.. actors traversal
         } // if ( vtkView )
@@ -1876,7 +1879,7 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint)
   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
 
   // actors are stored in a map after displaying of them for quicker access in future
-  QMap<QString, QMap<QString, VISU_Actor*> > vtkActors; // map: entry to map: ViewType_<ID> to actor (SVTK/VVTK)
+  QMap<QString, QMap<QString, VISU_ActorBase*> > vtkActors; // map: entry to map: ViewType_<ID> to actor (SVTK/VVTK)
 
   std::vector<std::string> entries = ip->getEntries();
 
@@ -1944,86 +1947,117 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint)
 
             // store displayed actor in a temporary map for quicker access later when restoring other parameters
             SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
-            QMap<QString, VISU_Actor*> viewActorMap;
+            QMap<QString, VISU_ActorBase*> viewActorMap;
             if ( vtkActors.contains( entry ) )
               viewActorMap = vtkActors[ entry ];
-            viewActorMap[ viewerTypeIndex ] = FindActor( GetAppStudy(this), vtkView, entry );
+            viewActorMap[ viewerTypeIndex ] = FindActorBase( GetAppStudy(this), vtkView, entry );
             vtkActors[ entry ] = viewActorMap;
           }
         }
         else { // the rest properties "work" with VISU_Actor, so we initialize it at first
           VISU_Actor* vActor = 0;
+          VISU_PointMap3dActor* vP3dActor = 0;
           if ( vtkActors.contains( entry ) ) {
-            QMap<QString, VISU_Actor*> viewActorMap = vtkActors[ entry ];
-            if ( viewActorMap.contains( viewerTypeIndex ) )
-              vActor = viewActorMap[ viewerTypeIndex ];
-          }
-          if ( !vActor )
-            continue;
-
+            QMap<QString, VISU_ActorBase*> viewActorMap = vtkActors[ entry ];
+            if ( viewActorMap.contains( viewerTypeIndex ) ) {
+              vActor = VISU_Actor::SafeDownCast( viewActorMap[ viewerTypeIndex ] );
+             vP3dActor = VISU_PointMap3dActor::SafeDownCast( viewActorMap[ viewerTypeIndex ] );
+           }
+         }
           QString val( (*valuesIt).c_str() );
-
-          if ( paramName == "Name" )
-            vActor->setName( val.toLatin1().data() );
-
-          else if ( paramName == "RepresentationMode" )
-            vActor->SetRepresentation( val.toInt() );
-
-          else if (paramName == "Quadratic2DRepresentation")
-            vActor->SetQuadratic2DRepresentation(VISU_Actor::EQuadratic2DRepresentation(val.toInt()));
-
-          else if ( paramName == "Opacity" )
-            vActor->SetOpacity( val.toFloat() );
-
-          else if ( paramName == "Color" ) {
-            QStringList colors = val.split( gDigitsSep, QString::SkipEmptyParts );
-            if ( colors.count() == 3 )
-              vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
-          }
-
-          else if ( paramName == "LineWidth" )
-            vActor->SetLineWidth( val.toFloat() );
-
-          else if ( paramName == "ShrinkMode" ) {
-            vActor->SetShrinkable( true );
-            vActor->SetShrink();
-          }
-
-          else if ( paramName == "ShrunkFactor" )
-            vActor->SetShrinkFactor( val.toFloat() );
-
-          else if ( paramName == "Shading" ) {
-            if ( VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor ) )
-              scalarMapActor->SetShading();
-          }
-
-          else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
-            VISU::Prs3d_i* prs = vActor->GetPrs3d();
-            if ( !prs )
-              continue;
-
-            //prs->RemoveAllClippingPlanes();
-            for (int i = prs->GetNumberOfClippingPlanes() - 1; i >= 0 ; i--) {
-              OrientedPlane* aPlane = dynamic_cast<OrientedPlane*>(prs->GetClippingPlane(i));
-              if (aPlane) 
-                prs->RemoveClippingPlane(i);
-            }
-            if ( val != "Off" ) {
-              QStringList vals = val.split( gDigitsSep, QString::SkipEmptyParts );
-              if ( vals.count() == 6 ) { // format check: 6 float values
-                vtkFloatingPointType normal[3], origin[3];
-                for (int x = 0; x < 3; x++ ) {
-                  normal[x] = vals[x].toFloat();
-                  origin[x] = vals[x+3].toFloat();
-                }
-                OrientedPlane* plane = OrientedPlane::New();
-                plane->SetNormal( normal );
-                plane->SetOrigin( origin );
-                prs->AddClippingPlane( plane );
-                plane->Delete();
-              }
-            }
-          }
+          if ( vActor ) {
+           // salome_actor successfull downcast to the VISU_Actor
+           if ( paramName == "Name" )
+             vActor->setName( val.toLatin1().data() );
+
+           else if ( paramName == "RepresentationMode" )
+             vActor->SetRepresentation( val.toInt() );
+
+           else if (paramName == "Quadratic2DRepresentation")
+             vActor->SetQuadratic2DRepresentation(VISU_Actor::EQuadratic2DRepresentation(val.toInt()));
+
+           else if ( paramName == "Opacity" )
+             vActor->SetOpacity( val.toFloat() );
+           
+           else if ( paramName == "Color" ) {
+             QStringList colors = val.split( gDigitsSep, QString::SkipEmptyParts );
+             if ( colors.count() == 3 )
+               vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
+           }
+
+           else if ( paramName == "LineWidth" )
+             vActor->SetLineWidth( val.toFloat() );
+
+           else if ( paramName == "ShrinkMode" ) {
+             vActor->SetShrinkable( true );
+             vActor->SetShrink();
+           }
+
+           else if ( paramName == "ShrinkFactor" )
+             vActor->SetShrinkFactor( val.toFloat() );
+
+           else if ( paramName == "Shading" ) {
+             if ( VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor ) )
+               scalarMapActor->SetShading();
+           }
+
+           else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
+             VISU::Prs3d_i* prs = vActor->GetPrs3d();
+             if ( !prs )
+               continue;
+             
+             //prs->RemoveAllClippingPlanes();
+             for (int i = prs->GetNumberOfClippingPlanes() - 1; i >= 0 ; i--) {
+               OrientedPlane* aPlane = dynamic_cast<OrientedPlane*>(prs->GetClippingPlane(i));
+               if (aPlane) 
+                 prs->RemoveClippingPlane(i);
+             }
+             if ( val != "Off" ) {
+               QStringList vals = val.split( gDigitsSep, QString::SkipEmptyParts );
+               if ( vals.count() == 6 ) { // format check: 6 float values
+                 vtkFloatingPointType normal[3], origin[3];
+                 for (int x = 0; x < 3; x++ ) {
+                   normal[x] = vals[x].toFloat();
+                   origin[x] = vals[x+3].toFloat();
+                 }
+                 OrientedPlane* plane = OrientedPlane::New();
+                 plane->SetNormal( normal );
+                 plane->SetOrigin( origin );
+                 prs->AddClippingPlane( plane );
+                 plane->Delete();
+               }
+             }
+           }
+         } // if ( vActor ) --> salome_actor successfull downcast to the VISU_Actor
+         else if ( vP3dActor ) {
+           // salome actor is downcasted to the VISU_PointMap3dActor
+           if ( paramName == "Name" )
+             vP3dActor->setName( val.toLatin1().data() );
+
+           else if ( paramName == "RepresentationMode" )
+             vP3dActor->SetRepresentation( val.toInt() );
+
+           else if ( paramName == "Opacity" )
+             vP3dActor->SetOpacity( val.toFloat() );
+
+           else if ( paramName == "Color" ) {
+             QStringList colors = val.split( gDigitsSep, QString::SkipEmptyParts );
+             if ( colors.count() == 3 )
+               vP3dActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
+           }
+
+           else if ( paramName == "LineWidth" )
+             vP3dActor->SetLineWidth( val.toFloat() );
+
+           else if ( paramName == "ShrinkMode" ) {
+             vP3dActor->SetShrinkable( true );
+             vP3dActor->SetShrink();
+           }
+
+           else if ( paramName == "ShrinkFactor" )
+             vP3dActor->SetShrinkFactor( val.toFloat() );
+
+         } // else if ( vP3dActor ) --> salome actor is downcasted to the VISU_PointMap3dActor
         } // else ..
       } // if SVTK