Salome HOME
Fix for bug IPAL9204: 3.0.0: When Supervisor is opened, it's necessary to create...
authormkr <mkr@opencascade.com>
Wed, 22 Jun 2005 11:04:05 +0000 (11:04 +0000)
committermkr <mkr@opencascade.com>
Wed, 22 Jun 2005 11:04:05 +0000 (11:04 +0000)
src/SUPERVGUI/SUPERVGUI.cxx
src/SUPERVGUI/SUPERVGUI.h

index b6850979deec96a3635bf2cf21141852fa83998e..6ee1bda3a7ef5ddab9740236df2e496c7667ad7c 100644 (file)
@@ -73,7 +73,9 @@ extern "C" {
 SUPERVGUI::SUPERVGUI()
      : SalomeApp_Module( "SUPERV" ),
        study(0),
-       browser(0)
+       browser(0),
+       myFirstActivation(true),
+       myInitialViewFrame(0)
   //info(0)
 {
     Trace("SUPERVGUI::SUPERVGUI")
@@ -227,6 +229,10 @@ bool SUPERVGUI::activateModule( SUIT_Study* theStudy )
   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), 
           this, SLOT( setMain( SUIT_ViewWindow* ) ) );
 
+  if ( myFirstActivation )
+    // create new empty dataflow
+    createDataflow( New, true );
+  
   return true;
 }
 
@@ -245,6 +251,8 @@ bool SUPERVGUI::deactivateModule( SUIT_Study* theStudy )
   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), 
              this, SLOT( setMain( SUIT_ViewWindow* ) ) );
   //---------------------------------------
+  
+  myFirstActivation = false;
 
   return SalomeApp_Module::deactivateModule( theStudy );
 }
@@ -584,7 +592,7 @@ void SUPERVGUI::modifyDataflow() {
   createDataflow( Modify );
 }
 
-bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode ) {
+bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
   Trace("SUPERVGUI::createDataflow, mode = " << mode );
 
   // asv : 27.01.05 : fix for PAL7823 : if the study is locked - warn the user and return.
@@ -622,14 +630,27 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode ) {
     return false;
   }
 
-  // 2. create a ViewFrame object
-  SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
+  SUPERVGraph_ViewFrame* aViewFrame; 
+  if ( theInitialDF || !myInitialViewFrame ) {
+    // 2. create a ViewFrame object
+    aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
+  }
+  else {
+    // 2. get empty initial view frame as new ViewFrame object
+    aViewFrame = myInitialViewFrame;
+    myInitialViewFrame = 0;
+  }
+
   if ( aViewFrame ) {
 
     // 3. bind Graph and ViewFrame == create SUPERVGUI_Main object
     main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aGraph );
-    if ( mode == New )
-      main->addNode();
+    if ( mode == New ) {
+      if ( !theInitialDF )
+       main->addNode();
+      else
+       myInitialViewFrame = aViewFrame;
+    }
     else
       registerGraph( f, main );
     aViewFrame->show();
index 0c9649d3d908c61350e6b2bf338b695d9cfca910..578a7345bfca0d7e4ed3e0b4ed34962065f01e60 100644 (file)
@@ -137,7 +137,7 @@ class SUPERVGUI: public SalomeApp_Module {
     // method called from importDataflow(), modifyDataflow(), newDataflow() with
     // different modes.  The behavior of the function is very similar in all 3 cases, 
     // but some differences still exist.  These differences are implemented using NEW_DF_MODE param.
-    bool createDataflow( const NEW_DF_MODE f );  
+    bool createDataflow( const NEW_DF_MODE f, bool theInitialDF = false );  
 
     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
                             const int key = 0, const bool toggle = false );
@@ -154,6 +154,9 @@ class SUPERVGUI: public SalomeApp_Module {
     SUPERVGUI_Main*        main;  // active main    
     QPtrList<SUPERVGUI_Main> myGraphList;
     QMap<QString, QString> myInterfaceNameMap;
+
+    bool                   myFirstActivation;
+    SUPERVGraph_ViewFrame* myInitialViewFrame;
 };
 
 #endif