Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_VisualStateOp.cxx
index 37f9c27f81c0183dcf2a3bc05140cf30df9e0b69..58c97b42c62b6d4570ed077aca5d5ebcd21ed151 100644 (file)
@@ -59,7 +59,8 @@ void HYDROGUI_VisualStateOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  startDocOperation();
+  if( !myIsLoad )
+    startDocOperation();
 
   bool aResult = false;
   if( myIsLoad )
@@ -69,13 +70,15 @@ void HYDROGUI_VisualStateOp::startOperation()
 
   if( aResult )
   {
-    commitDocOperation();
+    if( !myIsLoad )
+      commitDocOperation();
     commit();
   }
   else
   {
-    abortDocOperation();
-    abort(); // do not commit the document command
+    if( !myIsLoad )
+      abortDocOperation();
+    abort();
   }
 }
 
@@ -92,7 +95,7 @@ bool HYDROGUI_VisualStateOp::saveVisualState()
     if( aVisualState.IsNull() )
       return false;
 
-    QString aName = HYDROGUI_Tool::GenerateObjectName( module(), "VisualState" );
+    QString aName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_VISUAL_STATE_NAME" ) );
     aVisualState->SetName( aName );
   }
 
@@ -134,13 +137,13 @@ bool HYDROGUI_VisualStateOp::saveVisualState()
 
         for( int anObjIndex = 1, aLength = aSeq.Length(); anObjIndex <= aLength; anObjIndex++ )
         {
-          Handle(HYDROData_Object) anObject = aSeq.Value( anObjIndex );
+          Handle(HYDROData_Entity) anObject = aSeq.Value( anObjIndex );
           if( !anObject.IsNull() )
           {
             // Format: "Name|Visibility[|CoordX|CoordY]"
             QString aParameters = anObject->GetName();
 
-            int aVisibility = (int)anObject->IsVisible( aViewId );
+            int aVisibility = (int)( module()->isObjectVisible( aViewId, anObject ) );
             aParameters.append( QString( "|%1" ).arg( aVisibility ) );
 
             setVisualProperty( aPropertyMap, aViewerEntry, aParameters, true );
@@ -240,7 +243,7 @@ bool HYDROGUI_VisualStateOp::loadVisualState()
 
         for( int anObjIndex = 1, aLength = aSeq.Length(); anObjIndex <= aLength; anObjIndex++ )
         {
-          Handle(HYDROData_Object) anObject = aSeq.Value( anObjIndex );
+          Handle(HYDROData_Entity) anObject = aSeq.Value( anObjIndex );
           if( !anObject.IsNull() )
           {
             QString aName = anObject->GetName();
@@ -255,7 +258,7 @@ bool HYDROGUI_VisualStateOp::loadVisualState()
               {
                 bool anIsVisible = aParameters[ aParamIndex ].toInt( &anIsOk[ ++aParamIndex ] );
                 if( anIsOk[ 0 ] )
-                  anObject->SetVisible( aViewId, anIsVisible );
+                  module()->setObjectVisible( aViewId, anObject, anIsVisible );
               }
             }
           }