]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fixed 2 bugs with incorrect saving/restoring of clipping planes.
authorasv <asv@opencascade.com>
Thu, 6 Apr 2006 07:43:04 +0000 (07:43 +0000)
committerasv <asv@opencascade.com>
Thu, 6 Apr 2006 07:43:04 +0000 (07:43 +0000)
src/VISUGUI/VisuGUI_Module.cxx

index f1dd565298572e73685e3bdd8eba6352e97a307c..b08bb8c9171af6a4546d2230242c1bf407cc1d46 100644 (file)
@@ -1700,8 +1700,11 @@ void VisuGUI_Module::storeVisualParameters(int savePoint)
                    ip->setParameter( entry, param, "On" );
                  }
                  if ( const VISU::Prs3d_i* vPrs = vActor->GetPrs3d() ) {
-                   param = vtkParam + "ClippingPlane_";
-                   for ( int p = 0, nPlanes = vPrs->GetNumberOfClippingPlanes(); p < nPlanes; p++ ) {
+                   param = vtkParam + "ClippingPlane";
+                   int nPlanes = vPrs->GetNumberOfClippingPlanes();
+                   if ( !nPlanes )
+                     ip->setParameter( entry, param, "Off" );
+                   for ( int p = 0; p < nPlanes; p++ ) {
                      vtkPlane* plane = vPrs->GetClippingPlane( p );
                      float normal[3], origin[3];
                      plane->GetNormal( normal );
@@ -1712,7 +1715,7 @@ void VisuGUI_Module::storeVisualParameters(int savePoint)
                                  planeValue += QString::number( origin[0] ).latin1(); planeValue += gDigitsSep;
                                  planeValue += QString::number( origin[1] ).latin1(); planeValue += gDigitsSep;
                                  planeValue += QString::number( origin[2] ).latin1(); 
-                     param += QString::number( p+1 ).latin1();
+                     param = QString( "%1ClippingPlane_%2" ).arg( vtkParam.c_str() ).arg( p+1 ).latin1();
                      ip->setParameter( entry, param, planeValue );
                    }
                  }
@@ -1873,13 +1876,11 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint)
          if ( viewIndex >= 0 && viewIndex < lst.count() ) {
            SUIT_ViewManager* vman = lst.at( viewIndex );
            SUIT_ViewModel* vmodel = vman->getViewModel();
-           // SVTK and VVTK view models can be casted to SALOME_View
-           displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) ); 
-           SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
-           //      vtkView->getRenderer()->ResetCameraClippingRange();
-           //      vtkView->Repaint();
+           // both SVTK and VVTK view models can be casted to SALOME_View
+           displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
 
-           // store displayed actor so setting of color, opacity, etc. will be much faster
+           // 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;
            if ( vtkActors.contains( entry ) )
              viewActorMap = vtkActors[ entry ];
@@ -1931,17 +1932,25 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint)
          }
 
          else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
-           QStringList vals = QStringList::split( gDigitsSep, val );
-           if ( vals.count() == 6 && vActor->GetPrs3d() ) {
-             float normal[3], origin[3];
-             for (int x = 0; x < 3; x++ ) {
-               normal[x] = vals[x].toFloat();
-               origin[x] = vals[x+3].toFloat();
+           VISU::Prs3d_i* prs = vActor->GetPrs3d();
+           if ( !prs )
+             continue;
+           if ( val == "Off" ) {
+             prs->RemoveAllClippingPlanes();
+           }
+           else {
+             QStringList vals = QStringList::split( gDigitsSep, val );
+             if ( vals.count() == 6 ) { // format check: 6 float values
+               float normal[3], origin[3];
+               for (int x = 0; x < 3; x++ ) {
+                 normal[x] = vals[x].toFloat();
+                 origin[x] = vals[x+3].toFloat();
+               }
+               vtkPlane* plane = vtkPlane::New();
+               plane->SetNormal( normal );
+               plane->SetOrigin( origin );
+               prs->AddClippingPlane( plane );
              }
-             vtkPlane* plane = vtkPlane::New();
-             plane->SetNormal( normal );
-             plane->SetOrigin( origin );
-             vActor->GetPrs3d()->AddClippingPlane( plane );
            }
          }
        } // else ..