]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
IPAL9377: Save button remains inactive if to change the saved study - VISU fixed
authorjfa <jfa@opencascade.com>
Thu, 28 Jul 2005 10:53:56 +0000 (10:53 +0000)
committerjfa <jfa@opencascade.com>
Thu, 28 Jul 2005 10:53:56 +0000 (10:53 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Plot3DDlg.cxx
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_Tools.cxx
src/VISUGUI/VisuGUI_Tools.h

index 71de14b9167c80603a823210a943138205cf0cce..d2c810d2b2910a61e24619d92e6b2d252214b2b0 100644 (file)
@@ -171,37 +171,37 @@ OnImportFromFile()
                               aFilter,
                               tr("MEN_IMPORT_FROM_FILE"),
                               true);
-  if(aFileInfo.exists()){
+  if(aFileInfo.exists()) {
     application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
 
     VISU::Result_var aResult;
     bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
-    if(VisuGUI_FileDlg::IsBuild){
+    if (VisuGUI_FileDlg::IsBuild) {
       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
-      if(!CORBA::is_nil(aResult.in()))
-        if(Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())){
-          if(!aRes->IsPossible())
+      if (!CORBA::is_nil(aResult.in()))
+        if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
+          if (!aRes->IsPossible())
             SUIT_MessageBox::warn1(GetDesktop(this),
                                    tr("WRN_VISU"),
                                    tr("ERR_CANT_BUILD_PRESENTATION"),
-                                   tr("BUT_OK") );
+                                   tr("BUT_OK"));
           else
             aRes->BuildAll();
         }
-    }else{
+    } else {
       aResourceMgr->setValue("VISU", "full_med_loading", false);
       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
       aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
     }
 
-    if(CORBA::is_nil(aResult.in())) {
+    if (CORBA::is_nil(aResult.in())) {
       SUIT_MessageBox::warn1(GetDesktop(this),
                              tr("WRN_VISU"),
                              tr("ERR_ERROR_IN_THE_FILE"),
-                             tr("BUT_OK") );
+                             tr("BUT_OK"));
     }else{
-      application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
-      updateObjBrowser();
+      application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
+      UpdateObjBrowser(this);
     }
   }
 }
@@ -232,8 +232,8 @@ OnExploreMEDFile()
     std::string aStudyName = aStudy->Name();
     aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
     application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
-    //updateObjBrowser();
     getApp()->updateObjectBrowser(true); // as need to update MED tree
+    getApp()->updateActions();
   }
 }
 
@@ -255,19 +255,19 @@ OnImportTableFromFile()
                               aFilter,
                               tr("MEN_IMPORT_TABLE"),
                               true);
-  if(aFileInfo.exists()){
+  if (aFileInfo.exists()) {
     application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
 
     CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
 
-    if(CORBA::is_nil(anObject.in())) {
+    if (CORBA::is_nil(anObject.in())) {
       SUIT_MessageBox::warn1(GetDesktop(this),
                              tr("WRN_VISU"),
                              tr("ERR_ERROR_IN_THE_FILE"),
-                             tr("BUT_OK") );
-    }else{
+                             tr("BUT_OK"));
+    } else {
       application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
-      updateObjBrowser();
+      UpdateObjBrowser(this);
     }
   }
 }
@@ -317,7 +317,7 @@ OnImportMedField()
       }
     }
   }
-  updateObjBrowser(true);
+  UpdateObjBrowser(this, true);
   QApplication::restoreOverrideCursor();
 }
 
@@ -333,13 +333,14 @@ CreateCurves( SalomeApp_Module* theModule,
   if ( !aCutDlg )
     return;
 
-  _PTR(Study)     aStudy = GetCStudy( GetAppStudy( theModule ) );
+  _PTR(Study)   aStudy = GetCStudy( GetAppStudy( theModule ) );
   _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
 
-  if ( !theCreate && aSObject ){
+  if ( !theCreate && aSObject ) {
     // Remove old Table
     _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
-    for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) {
+    _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+    for (; aIter->More(); aIter->Next()) {
       _PTR(SObject) aTblObj = aIter->Value();
       if ( aTblObj ) {
         _PTR(GenericAttribute) anAttr;
@@ -354,9 +355,10 @@ CreateCurves( SalomeApp_Module* theModule,
   if ( aCutDlg->isGenerateTable() ) {
     GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
     if ( aCutDlg->isGenerateCurves() ) {
-      if( aSObject ) {
+      if ( aSObject ) {
         _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
-        for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) {
+        _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+        for (; aIter->More(); aIter->Next()) {
           _PTR(SObject) aTblObj = aIter->Value();
           if ( aTblObj ) {
             _PTR(GenericAttribute) anAttr;
@@ -368,6 +370,10 @@ CreateCurves( SalomeApp_Module* theModule,
       }
     }
   }
+
+  if (!theCreate && aSObject) {
+    UpdateObjBrowser(theModule);
+  }
 }
 
 template<class TPrs3d_i>
@@ -433,7 +439,10 @@ CreatePrs3d(SalomeApp_Module* theModule,
           if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
             // Optionally, create table and curves for cut lines
             QApplication::setOverrideCursor(Qt::waitCursor);
-            CreateCurves( theModule, dynamic_cast<VISU::CutLines_i*>( aPrs3d ), aDlg, true ); // in creation mode
+            CreateCurves( theModule,
+                          dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
+                          aDlg,
+                          true ); // in creation mode
             QApplication::restoreOverrideCursor();
             delete aDlg;
           } else {
@@ -471,6 +480,7 @@ CreatePrs3d(SalomeApp_Module* theModule)
 
   theModule->application()->putInfo(QObject::tr("INF_DONE"));
   theModule->updateObjBrowser();
+  UpdateObjBrowser(theModule);
 
   if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
     aView->onFitAll();
@@ -578,7 +588,7 @@ OnCreatePlot2dView()
 {
   CheckLock(GetCStudy(GetAppStudy(this)));
   GetVisuGen( this )->CreateContainer();
-  updateObjBrowser();
+  UpdateObjBrowser(this);
 }
 
 void
@@ -678,7 +688,6 @@ EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
 {
   TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
   if (aPrsObject) {
-    //TDlg* aDlg = new TDlg (GetDesktop(theModule), false, true);
     TDlg* aDlg = new TDlg (theModule);
     aDlg->initFromPrsObject(aPrsObject);
     if (aDlg->exec()) {
@@ -688,11 +697,16 @@ EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
       }
       RecreateActor(theModule, aPrsObject);
       if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
-        //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
-          vw->getRenderer()->ResetCameraClippingRange();
-          vw->Repaint();
-        //}
+        vw->getRenderer()->ResetCameraClippingRange();
+        vw->Repaint();
       }
+      // Optionally, create table and curves for cut lines
+      QApplication::setOverrideCursor(Qt::waitCursor);
+      CreateCurves( theModule,
+                    dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
+                    aDlg,
+                    false ); // in edition mode
+      QApplication::restoreOverrideCursor();
     }
     delete aDlg;
   }
@@ -725,27 +739,9 @@ OnEditPrs()
     break;
   case VISU::TCUTPLANES:
     EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
-    /*{
-      VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
-      if (aPrsObject) {
-        VisuGUI_CutPlanesDlg* aDlg =
-          new VisuGUI_CutPlanesDlg (GetDesktop(this), false, false);
-        aDlg->initFromPrsObject(aPrsObject);
-        aDlg->show();
-      }
-    }*/
     break;
   case VISU::TCUTLINES:
     EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
-    /*{
-      VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
-      if (aPrsObject) {
-        VisuGUI_CutLinesDlg* aDlg =
-          new VisuGUI_CutLinesDlg (GetDesktop(this), false, false);
-        aDlg->initFromPrsObject(aPrsObject);
-        aDlg->show();
-      }
-    }*/
     break;
   case VISU::TISOSURFACE:
     EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
@@ -758,15 +754,6 @@ OnEditPrs()
     break;
   case VISU::TPLOT3D:
     EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
-    /*{
-      VISU::Plot3D_i* aPrsObject = dynamic_cast<VISU::Plot3D_i*>(aPrs3d);
-      if (aPrsObject) {
-        VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg();
-        aDlg->initFromPrsObject(aPrsObject);
-        aDlg->show();
-        myActiveDialogBox = aDlg;
-      }
-    }*/
     break;
   default:
     return;
@@ -1074,7 +1061,7 @@ OnCreateTable()
   VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
   if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
-    updateObjBrowser();
+    UpdateObjBrowser(this);
   }
 }
 
@@ -1117,7 +1104,7 @@ OnDeleteObjects()
   aStudyBuilder->CommitCommand();
 
   //GetActiveStudy()->unHighlightAll();
-  updateObjBrowser(true);
+  UpdateObjBrowser(this, true);
 }
 
 void
@@ -1185,7 +1172,7 @@ OnPlotData()
                           }
                         }
                       }
-                      updateObjBrowser();
+                      UpdateObjBrowser(this);
                       PlotContainer( this, pContainer, VISU::eDisplay );
                     }
                   }
@@ -1256,7 +1243,7 @@ OnPlotData()
                     }
                   }
                 }
-                updateObjBrowser();
+                UpdateObjBrowser(this);
                 PlotContainer( this, pContainer, VISU::eDisplay );
               }
             }
@@ -1338,7 +1325,7 @@ OnClearContainer()
       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
       if (container && container->GetNbCurves() > 0) {
         container->Clear();
-        updateObjBrowser();
+        UpdateObjBrowser(this);
       }
     }
   }
@@ -1357,12 +1344,11 @@ OnEditContainer()
   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
   if (!aContainer) return;
 
-  //VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this));
   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
   aDlg->initFromPrsObject(aContainer);
   if (aDlg->exec()) {
     aDlg->storeToPrsObject(aContainer);
-    updateObjBrowser(true);
+    UpdateObjBrowser(this, true);
   }
   delete aDlg;
 }
@@ -1391,7 +1377,7 @@ OnSaveViewParams()
     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
   }
-  updateObjBrowser();
+  UpdateObjBrowser(this);
 }
 
 void
@@ -1485,7 +1471,7 @@ OnRename()
       // rename the study object
       aName->SetValue(Name.latin1()); // rename the SObject
       anIO->setName(Name.latin1()); // rename the InteractiveObject
-      updateObjBrowser(false);
+      UpdateObjBrowser(this, false);
 
       QApplication::restoreOverrideCursor();
     }
@@ -1716,7 +1702,7 @@ OnCopyPresentation()
     }
     break;
   }
-  updateObjBrowser();
+  UpdateObjBrowser(this);
 }
 
 void
index fe7671e2e00513200e1672b353dc4f81f6e6c57e..78cbcec2aa5c7dc520dcb2237d571878d869bf47 100644 (file)
@@ -562,13 +562,5 @@ void VisuGUI_Plot3DDlg::reject()
 {
   myIsoPane->check(); // hide preview
 
-/*if (!isModal() && myIsoPane->GetPrs() &&
-      !VISU::GetActor(myIsoPane->GetPrs(), myViewWindow)) {
-    _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
-    if (!aStudy->GetProperties()->IsLocked()) {
-      myIsoPane->GetPrs()->RemoveFromStudy();
-      myIsoPane->GetStudyFrame()->getStudy()->updateObjBrowser();
-    }
-}*/
   QDialog::reject();
 }
index 7d7c02322308a6ca049f47fbf757661ec9de0f74..509694eca334903c83d007dfe73a42261d38202d 100644 (file)
@@ -1244,14 +1244,14 @@ void VisuGUI_TimeAnimationDlg::onStop()
 void VisuGUI_TimeAnimationDlg::saveToStudy()
 {
   myAnimator->saveAnimation();
-  myModule->updateObjBrowser( true );
+  VISU::UpdateObjBrowser(myModule, true);
 }
 
 //************************************************************************
 void VisuGUI_TimeAnimationDlg::publishToStudy()
 {
   myAnimator->publishInStudy();
-  myModule->updateObjBrowser( true );
+  VISU::UpdateObjBrowser(myModule, true);
   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
 }
 
index 47acac98449d23758e2155b75f72312b58343a62..daa945005f0dd9545af44921e38371bf84f8443d 100644 (file)
@@ -415,7 +415,7 @@ namespace VISU
       }
     }
     thePrs->RemoveFromStudy();
-    theModule->updateObjBrowser(); //update Object browser
+    //theModule->updateObjBrowser(); //update Object browser
   }
 
   void
@@ -957,7 +957,7 @@ namespace VISU
               }
             }
           }
-          theModule->updateObjBrowser();
+          //theModule->updateObjBrowser();
           PlotContainer( theModule, pContainer, VISU::eDisplay );
         }
       }
index 0c2469bfb0789cf2d84682d0e88fecc4f3baf880..2af898e6bf4478c0da081d42a8add422b7d1f788 100644 (file)
@@ -32,6 +32,9 @@
 
 #include "VISUConfig.hh"
 
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Application.h"
+
 #include "SALOMEDSClient_Study.hxx"
 
 #include "SALOMEconfig.h"
@@ -43,7 +46,6 @@ class VISU_Actor;
 class SVTK_ViewWindow;
 class SPlot2d_Viewer;
 class CAM_Module;
-class SalomeApp_Module;
 class SalomeApp_SelectionMgr;
 class SalomeApp_Study;
 
@@ -63,6 +65,9 @@ namespace VISU {
   bool                                 IsStudyLocked( _PTR(Study) theStudy );
   bool                                 CheckLock( _PTR(Study) theStudy );
 
+  inline void                          UpdateObjBrowser(SalomeApp_Module* theModule,
+                                                       bool updateDataModel = true);
+
   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
   SALOME_MED::MED_Gen_var              GetMEDEngine();
 
@@ -179,4 +184,11 @@ bool VISU::IsSObjectTable( _PTR(SObject) theSObject )
   return false;
 }
 
+void VISU::UpdateObjBrowser(SalomeApp_Module* theModule,
+                           bool updateDataModel)
+{
+  theModule->updateObjBrowser(updateDataModel);
+  theModule->getApp()->updateActions();
+}
+
 #endif