Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI.cxx
index b1c609572b4b4d1030ef67c4ed374ce7167d806f..aced7fee3dae189f5d4a204c08d1993f7f734417 100644 (file)
@@ -1,23 +1,23 @@
 //  SUPERV SUPERVGUI : GUI for Supervisor component
 //
 //  Copyright (C) 2003  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 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 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  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 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 //  Author : Francis KLOSS
 //  Module : SUPERV
 
-using namespace std;
 #include "SUPERVGUI.h"
 #include "SUPERVGUI_DataModel.h"
 #include "SUPERVGUI_Selection.h"
 
-#include "SALOMEDSClient.hxx"
-#include <boost/shared_ptr.hpp>
-using namespace boost;
-
 #include "CAM_Application.h"
 #include "OB_Browser.h"
 #include "OB_ListItem.h"
 #include "SalomeApp_Application.h"
 #include "SalomeApp_ImportOperation.h"
-#include "SalomeApp_NameDlg.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "SalomeApp_Study.h"
 #include "SUIT_Desktop.h"
 #include "SUIT_FileDlg.h"
@@ -51,6 +45,7 @@ using namespace boost;
 #include "SUIT_Study.h"
 
 #include "SUPERVGraph_ViewManager.h"
+#include "SUPERVGraph_ViewFrame.h"
 
 #include "SALOME_ListIO.hxx"
 #include "SALOME_ListIteratorOfListIO.hxx"
@@ -59,8 +54,13 @@ using namespace boost;
 
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
 
+#include <qinputdialog.h>
 #include <qmenubar.h>
 
+#include "SALOMEDSClient.hxx"
+#include <boost/shared_ptr.hpp>
+using namespace boost;
+
 int SUPERVGUI::factory = 0;
 
 extern "C" {
@@ -76,7 +76,8 @@ SUPERVGUI::SUPERVGUI()
        browser(0),
        myFirstActivation(true),
        myAllGraphsClosed(false),
-       myInitialViewFrame(0)
+       myInitialViewFrame(0),
+       myIVFBackgroundColor(QColor())
   //info(0)
 {
     Trace("SUPERVGUI::SUPERVGUI")
@@ -92,13 +93,13 @@ SUPERVGUI::~SUPERVGUI() {
     Trace("SUPERVGUI::~SUPERVGUI")
     if (factory==1) {
         factory = 0;
-       //if (!engine->_is_nil()) CORBA::release(engine);         
+        //if (!engine->_is_nil()) CORBA::release(engine);
         //info->close();
         if (browser) {
-         if (browser->isVisible())
-           browser->close();
-         delete browser;
-       }
+          if (browser->isVisible())
+            browser->close();
+          delete browser;
+        }
         MESSAGE("SUPERVGUI Info : factory destroy");
     } else {
         MESSAGE("SUPERVGUI Error : another call to factory destructor");
@@ -114,24 +115,26 @@ SUPERVGUI* SUPERVGUI::Supervision() {
   return NULL;
 }
 
-void SUPERVGUI::createSupervAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle  )
+void SUPERVGUI::createSupervAction (const int id, const QString& po_id, const QString& icon_id,
+                                    const int key, const bool toggle)
 {
   QIconSet icon;
   QWidget* parent = application()->desktop();
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   QPixmap pix;
-  if ( icon_id.length() ) 
-    pix = resMgr->loadPixmap( "SUPERV", tr( icon_id ) );
-  else
-    pix = resMgr->loadPixmap( "SUPERV", tr( QString( "ICO_" )+po_id ) );
-  if ( !pix.isNull() )
-    icon = QIconSet( pix );
+  if (!icon_id.isEmpty())
+    pix = resMgr->loadPixmap("SUPERV", tr(icon_id));
+  //else
+  //  pix = resMgr->loadPixmap("SUPERV", tr(QString("ICO_") + po_id));
+
+  if (!pix.isNull())
+    icon = QIconSet(pix);
 
-  QString tooltip    = tr( QString( "TOP_" )+po_id ),
-          menu       = tr( QString( "MEN_" )+po_id ),
-          status_bar = tr( QString( "STB_" )+po_id );
+  QString tooltip    = tr(QString("TOP_") + po_id),
+          menu       = tr(QString("MEN_") + po_id),
+          status_bar = tr(QString("STB_") + po_id);
 
-  createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() )  );
+  createAction(id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT(OnGUIEvent()));
 }
 
 void SUPERVGUI::initialize( CAM_Application* app )
@@ -148,22 +151,22 @@ void SUPERVGUI::initialize( CAM_Application* app )
   fillInterfaceNameMap();
 
   // ----- create actions --------------
-  createSupervAction( 301, "IMPORT" );
-  createSupervAction( 302, "EXPORT" );
+  createSupervAction( 301, "IMPORT"        , "ICO_IMPORT" );
+  createSupervAction( 302, "EXPORT"        , "ICO_EXPORT" );
 
-  createSupervAction( 303, "NEW" );
-  createSupervAction( 304, "MODIFY" );
+  createSupervAction( 303, "NEW"           , "ICO_NEW" );
+  createSupervAction( 304, "MODIFY"        , "ICO_MODIFY" );
 
-  createSupervAction( 305, "RELOAD" );
-  createSupervAction( 306, "RUN" );
-  createSupervAction( 307, "KILL" );
-  createSupervAction( 308, "SUSPEND/RESUME" );
-  createSupervAction( 309, "ADDNODE" );
-  createSupervAction( 310, "STEPBYSTEP" );
+  createSupervAction( 305, "RELOAD"        , "ICO_RELOAD" );
+  createSupervAction( 306, "RUN"           , "ICO_RUN" );
+  createSupervAction( 307, "KILL"          , "ICO_KILL" );
+  createSupervAction( 308, "SUSPEND/RESUME", "ICO_SUSPEND/RESUME" );
+  createSupervAction( 309, "ADDNODE"       , "ICO_ADDNODE" );
+  createSupervAction( 310, "STEPBYSTEP"    , "ICO_STEPBYSTEP" );
 
-  createSupervAction( 311, "POP_RENAME" );
+  createSupervAction( 311, "POP_RENAME", "", Key_F2 );
   createSupervAction( 312, "POP_DISPLAY" );
-  createSupervAction( 313, "POP_DELETE" );
+  createSupervAction( 313, "POP_DELETE", "", Key_Delete );
 
   // ----- create menu -----------------
   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
@@ -183,7 +186,7 @@ void SUPERVGUI::initialize( CAM_Application* app )
   createMenu( 306, supervId, -1 );
   createMenu( 310, supervId, -1 );
   createMenu( 307, supervId, -1 );
-  createMenu( 308, supervId, -1 );     
+  createMenu( 308, supervId, -1 );
 
   // ----- create toolbars -------------
   int supervisorId = createTool( tr( "TOOL_SUPERVISOR" ) );
@@ -208,7 +211,7 @@ void SUPERVGUI::initialize( CAM_Application* app )
   mgr->setRule( action( 312 ), "$type in {'Dataflow'} and selcount=1", true );
   mgr->insert( separator(), -1, -1 ); // -----------
   mgr->insert( action(  313 ), -1, -1 ); // delete object
-  mgr->setRule( action( 313 ), "$client in {'ObjectBrowser'} and $type in {'Dataflow' 'SupervisorObject'} and selcount>0", true );
+  mgr->setRule( action( 313 ), "client='ObjectBrowser' and $type in {'Dataflow' 'SupervisorObject'} and selcount>0", true );
 }
 
 bool SUPERVGUI::activateModule( SUIT_Study* theStudy )
@@ -227,19 +230,19 @@ bool SUPERVGUI::activateModule( SUIT_Study* theStudy )
 
   study = application()->activeStudy();
 
-  connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), 
-          this, SLOT( setMain( SUIT_ViewWindow* ) ) );
+  connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+           this, SLOT( setMain( SUIT_ViewWindow* ) ) );
 
   if ( myFirstActivation ) {
     myAllGraphsClosed = false;
     // create new empty dataflow
     createDataflow( New, true );
   }
-  
+
   return true;
 }
 
-QString SUPERVGUI::engineIOR() const 
+QString SUPERVGUI::engineIOR() const
 {
  if ( !CORBA::is_nil( engine ) )
     return QString( getApp()->orb()->object_to_string( engine));
@@ -251,10 +254,10 @@ bool SUPERVGUI::deactivateModule( SUIT_Study* theStudy )
   setMenuShown( false );
   setToolShown( false );
 
-  disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), 
-             this, SLOT( setMain( SUIT_ViewWindow* ) ) );
+  disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+              this, SLOT( setMain( SUIT_ViewWindow* ) ) );
   //---------------------------------------
-  
+
   if ( !myAllGraphsClosed )
     myFirstActivation = false;
 
@@ -266,7 +269,7 @@ CAM_DataModel* SUPERVGUI::createDataModel()
   return new SUPERVGUI_DataModel( this );
 }
 
-SalomeApp_Selection* SUPERVGUI::createSelection() const
+LightApp_Selection* SUPERVGUI::createSelection() const
 {
   return new SUPERVGUI_Selection();
 }
@@ -274,12 +277,15 @@ SalomeApp_Selection* SUPERVGUI::createSelection() const
 SUIT_ViewWindow* SUPERVGUI::createGraph() {
   SUPERVGraph_ViewManager* aVM = new SUPERVGraph_ViewManager( study, application()->desktop(), new SUPERVGraph_Viewer() );
   (( SalomeApp_Application* )application())->addViewManager( aVM );
-  SUIT_ViewWindow* aVW = aVM->createViewWindow();
+  SUPERVGraph_ViewFrame* aVW = dynamic_cast<SUPERVGraph_ViewFrame*>( aVM->createViewWindow() );
   if ( aVW ) {
-    connect( aVM, 
-            SIGNAL( deleteView( SUIT_ViewWindow* ) ),
-            this,
-            SLOT( onGraphClosed( SUIT_ViewWindow* ) ) );
+    QColor back = getApp()->resourceMgr()->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR );
+    qDebug( QString( "background: %1 %2 %3" ).arg( back.red() ).arg( back.green() ).arg( back.blue() ) );
+    aVW->setBackgroundColor( back );
+    connect( aVM,
+             SIGNAL( deleteView( SUIT_ViewWindow* ) ),
+             this,
+             SLOT( onGraphClosed( SUIT_ViewWindow* ) ) );
   }
   return aVW;
 }
@@ -369,14 +375,26 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
     SUPERVGraph_View* view = supervFrame->getViewWidget();
     SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
     if ( aGraph ) {
+      // mkr: PAL12449 --->
+      if ( (( SalomeApp_Study* )(aGraph->getStudy()))->studyDS() && !aGraph->isDataflowInStudy() ) {
+       const int aWarnResult = QMessageBox::information(application()->desktop(), tr("MSG_INFO"),
+                                                        tr("MSG_GRAPH_UNSAVED"),
+                                                        QMessageBox::Yes, QMessageBox::No);
+       if ( aWarnResult == QMessageBox::Yes ) {
+         aGraph->addDataflowToStudy();
+         updateObjBrowser();
+       }
+      }
+      // mkr: PAL12449 <---
+      
       unregisterGraph(aGraph);
       SUPERV_Graph aDataFlow = aGraph->getDataflow();
       if ( !SUPERV_isNull( aDataFlow ) ) {
        if ( aDataFlow->IsExecuting() ) {
          const int aMsgResult = QMessageBox::warning(application()->desktop(),
-                                                     tr("WARNING"), 
-                                                     tr("MSG_DF_RUNNING"), 
-                                                     tr("MSG_DF_EXECUTION"), 
+                                                     tr("WARNING"),
+                                                     tr("MSG_DF_RUNNING"),
+                                                     tr("MSG_DF_EXECUTION"),
                                                      tr("MSG_DF_KILL"));
          if ( aMsgResult == 1 ) {
            // KILL EXECUTION
@@ -384,14 +402,14 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
              // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
              // while sets myIsActive flag to false when it receives such event/state
              // after myIsActive is false it calls QThread::exit() to terminate.
-
+             
              // why while() { qApp->processEvents() } ?
              // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
-             // method using SALOME_Event paradigm, ProcessVoidEvent() function - 
+             // method using SALOME_Event paradigm, ProcessVoidEvent() function -
              // it puts this event to the main application event loop, in which we are being now.
              // So if we block main GUI application thread (by calling aGraph->getMyThread()->wait() here)
-             // then we will have a deadlock of 2 threads waiting for one another 
-             while (aGraph->getMyThread()->running()) 
+             // then we will have a deadlock of 2 threads waiting for one another
+             while (aGraph->getMyThread()->running())
                qApp->processEvents();
            }
          }
@@ -403,7 +421,7 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
        }
        else { // EXECUTION IS FINISHED, JUST DESTROY THE SUPERVGUI_Thread object and return.
          emit KillMainThread(true);
-         while ( aGraph->getMyThread()->running() ) 
+         while ( aGraph->getMyThread()->running() )
            qApp->processEvents();
        }
       }
@@ -413,6 +431,7 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
     myAllGraphsClosed = true;
     myFirstActivation = true;
     myInitialViewFrame = 0;
+    myIVFBackgroundColor = QColor();
     main = 0;
   }
 }
@@ -436,47 +455,76 @@ void SUPERVGUI::setMain( SUIT_ViewWindow* w) {
 }
 
 void SUPERVGUI::displayDataflow() {
-    Trace("SUPERVGUI::displayDataflow");
-    OB_Browser* aBrowser = (( SalomeApp_Application* )application())->objectBrowser();
-    SUPERV_Graph aDataFlow;
-    QString aIORName;
-
-    OB_ListItem* item = (OB_ListItem*)(aBrowser->listView()->currentItem());
-    _PTR(SObject) aObj 
-      ( (( SalomeApp_Study* )(application()->activeStudy()))->studyDS()->FindObjectID(item->text(2).latin1()) );
-    _PTR(GenericAttribute) anAttr;
-    if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
-      _PTR(AttributeIOR) anIOR ( anAttr );
-      aIORName = QString(anIOR->Value().c_str());
-      if (isContains(study, aIORName)) {
-       if (QMessageBox::warning(application()->desktop(), tr("WARNING"), 
-                                tr("MSG_GRAPH_DISPLAYED").arg(""), 
-                                QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
-         return;
-      }
-      //aDataFlow = engine->getStreamGraph(anIOR->Value().c_str());
-      aDataFlow = engine->getGraph(anIOR->Value().c_str());
-      if (SUPERV_isNull(aDataFlow)) {
-       QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
-       return;
-      }
-      /* ASV: 20.10.04: fix for 6896
-      if (aDataFlow->IsStreamGraph()) {
-       SUPERV_StreamGraph aDataFlowStream = aDataFlow->ToStreamGraph();
-       if (SUPERV_isNull(aDataFlowStream)) {
-         QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
-         return;
-       }
-       aDataFlow = aDataFlowStream;
-      }
-      */
+  Trace("SUPERVGUI::displayDataflow");
+
+  OB_Browser* aBrowser = getApp()->objectBrowser();
+  OB_ListItem* item = (OB_ListItem*)(aBrowser->listView()->currentItem());
+
+  SalomeApp_Study* anAppStudy = (SalomeApp_Study*)(getApp()->activeStudy());
+  _PTR(SObject) aObj (anAppStudy->studyDS()->FindObjectID(item->text(2).latin1()));
+
+  SUPERV_Graph aDataFlow;
+  QString aIORName;
+
+  _PTR(GenericAttribute) anAttr;
+  if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
+    _PTR(AttributeIOR) anIOR ( anAttr );
+    aIORName = QString(anIOR->Value().c_str());
+    if (isContains(study, aIORName)) {
+      if (QMessageBox::warning(application()->desktop(), tr("WARNING"),
+                               tr("MSG_GRAPH_DISPLAYED").arg(""),
+                               QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
+        return;
     }
-    SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
-    if( aViewFrame ) {
-      main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aDataFlow );
-      registerGraph( aIORName, main );
-      aViewFrame->show();
+
+    //SUPERV_Graph aDataFlow = engine->getStreamGraph(anIOR->Value().c_str());
+    aDataFlow = engine->getGraph(anIOR->Value().c_str());
+    if (SUPERV_isNull(aDataFlow)) {
+      QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
+      return;
     }
+
+    /* ASV: 20.10.04: fix for 6896
+    if (aDataFlow->IsStreamGraph()) {
+      SUPERV_StreamGraph aDataFlowStream = aDataFlow->ToStreamGraph();
+      if (SUPERV_isNull(aDataFlowStream)) {
+        QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
+        return;
+      }
+      aDataFlow = aDataFlowStream;
+    }
+    */
+  }
+
+  SUPERVGraph_ViewFrame* aViewFrame;
+  if ( !myInitialViewFrame ) {
+    // first case : create a ViewFrame object
+    aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
+  }
+  else {
+    // second case : get empty initial view frame as new ViewFrame object
+    aViewFrame = myInitialViewFrame;
+    // mkr : IPAL12991 -->
+    SUPERVGraph_View* view = myInitialViewFrame->getViewWidget();
+    if (view)
+      unregisterGraph(dynamic_cast<SUPERVGUI_Main*>(view));
+    // mkr : IPAL12991 <--
+    // mkr : PAL8237 : remove first "gag" Main from children
+    // srn: commented as it cases on application exit "X Windows error"
+    //aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
+    delete view;
+  }
+
+  if ( aViewFrame ) {
+    main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aDataFlow );
+    registerGraph( aIORName, main );
+    aViewFrame->show();
+  }
+
+  if ( myInitialViewFrame ) {
+    myInitialViewFrame = 0;
+    myIVFBackgroundColor = QColor();
+  }
 }
 
 
@@ -488,31 +536,53 @@ void SUPERVGUI::renameDataflow() {
   SALOME_ListIteratorOfListIO It( aList );
   for ( ; It.More(); It.Next() ) {
     Handle(SALOME_InteractiveObject) IObject = It.Value();
-    
+
     _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
     _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
     _PTR(GenericAttribute) anAttr;
     if ( obj ) {
       if ( obj->FindAttribute(anAttr, "AttributeName") ) {
-       _PTR(AttributeName) aName ( anAttr );
-       QString nm = QString( aName->Value().c_str() );
-       nm = SalomeApp_NameDlg::getName( application()->desktop(), nm );
-       if ( !nm.isEmpty() ) {
-         // sak : 24.11.04 : fix for PAL6898 : if rename fails (study locked), 
-         // a message box is displayed, and cursor is "wait cursor".  We think that "wait cursor"
-         // is not neccessary here, because the rename operation is fast.
-         //QApplication::setOverrideCursor( Qt::waitCursor );
-         //study->renameIObject( IObject, nm );
-
-         //--->
-         aName->SetValue( nm.latin1() );
-         //rename Interactive object 
-         IObject->setName( ( char* )nm.latin1() );
-         //<---
-
-         updateObjBrowser();
-         //QApplication::restoreOverrideCursor();
-       }
+        _PTR(AttributeName) aName ( anAttr );
+        QString nm = QString( aName->Value().c_str() );
+       bool ok;
+       nm = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
+                                    nm, &ok, application()->desktop() );
+        if ( ok && !nm.isEmpty() ) {
+          // sak : 24.11.04 : fix for PAL6898 : if rename fails (study locked),
+          // a message box is displayed, and cursor is "wait cursor".  We think that "wait cursor"
+          // is not neccessary here, because the rename operation is fast.
+          //QApplication::setOverrideCursor( Qt::waitCursor );
+          //study->renameIObject( IObject, nm );
+
+          //--->
+          aName->SetValue( nm.latin1() );
+          //rename Interactive object
+          IObject->setName( ( char* )nm.latin1() );
+          //<---
+
+          updateObjBrowser();
+          //QApplication::restoreOverrideCursor();
+
+         // mkr : PAL7037 => rename engine of the graph (i.e. corresponding SUPERV_Graph) -->
+          if ( obj->FindAttribute(anAttr, "AttributeIOR") ) {
+            _PTR(AttributeIOR) anIOR ( anAttr );
+            SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
+            if ( !SUPERV_isNull(aDataFlow) ) {
+              if ( aDataFlow->IsStreamGraph() ) {
+               SUPERV_StreamGraph aStreamDataFlow = aDataFlow->ToStreamGraph();
+                if ( !SUPERV_isNull(aStreamDataFlow) )
+                  aStreamDataFlow->SetName( nm.latin1() );
+              }
+              else {
+                aDataFlow->SetName( nm.latin1() );
+              }
+
+              // update "Save" icon and menu state, if dataflow is published
+              SUPERVGUI_Main::setModifiedFlag();  
+            }
+          }
+         // mkr : PAL7037 <--
+        }
       }
     }
   }
@@ -522,39 +592,42 @@ void SUPERVGUI::exportDataflow() {
     Trace("SUPERVGUI::exportDataflow")
     if ( main==0 ) {
       QMessageBox::warning(application()->desktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT"));
-    } 
+    }
     else if ( SUPERV_isNull( main->getDataflow() ) ) { // should not normally happen..
       QMessageBox::warning(application()->desktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT"));
-    } 
+    }
     else {
       QString f = SUIT_FileDlg::getFileName(application()->desktop(),
-                                           "",
-                                           "*.xml",
-                                           tr("TTL_EXPORT_DATAFLOW"),
-                                           false);
+                                            "",
+                                            "*.xml",
+                                            tr("TTL_EXPORT_DATAFLOW"),
+                                            false);
       if ( !f.isEmpty() ) {
-       
-       // asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, 
-       // a backup copy of an existing file must be created (in case Export fails..)
-       QString aBackupFile = SUPERVGUI::createBackupFile( f );
-
-       if ( main->getDataflow()->Export(f.latin1()) ) {
-         unregisterGraph(main);
-         registerGraph(f, main);
-
-         // remove a backup file if export was successfull
-         if ( !aBackupFile.isNull() && !aBackupFile.isEmpty() )
-           QFile::remove( aBackupFile );
-       }
-       else {
-         QMessageBox::warning(application()->desktop(), tr("ERROR"), tr("MSG_BAD_WRITING").arg(aBackupFile));
-       }
+
+        // asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file,
+        // a backup copy of an existing file must be created (in case Export fails..)
+        QString aBackupFile = SUPERVGUI::createBackupFile( f );
+
+        if ( main->getDataflow()->Export(f.latin1()) ) {
+         // mkr : PAL8110 : if we re-register graph with its xml-file name the "Supervisor Warning"
+         //       after object browser popup "Display" item will not appear, it's an error,
+         //       because of this dataflow is already displayed.
+          //unregisterGraph(main);
+          //registerGraph(f, main);
+
+          // remove a backup file if export was successfull
+          if ( !aBackupFile.isNull() && !aBackupFile.isEmpty() )
+            QFile::remove( aBackupFile );
+        }
+        else {
+          QMessageBox::warning(application()->desktop(), tr("ERROR"), tr("MSG_BAD_WRITING").arg(aBackupFile));
+        }
       }
     }
 }
 
-/** 
- *If a file with theOriginalFileName exists, then the function tries to create 
+/**
+ *If a file with theOriginalFileName exists, then the function tries to create
  * its backup copy of it (the_name + ".bakX", X = 0,1,2,..,99).  Returns backup file's name
  * If a file with theOriginalFileName does not exist, or creation fails - Return empty string.
  */
@@ -567,10 +640,10 @@ QString SUPERVGUI::createBackupFile( const QString& theOriginalFileName ) {
       theBackupFileName = theOriginalFileName;
       theBackupFileName += ".bak";
       theBackupFileName += QString::number(i++);
-    } 
+    }
     while ( QFile::exists( theBackupFileName ) && i < 100 ); // max 99 backup files
-    // if *.bak99 exists -- it will be overwritten 
-    
+    // if *.bak99 exists -- it will be overwritten
+
     // 2. copy the original file to theBackupFileName
     QString cmd( "cp \"");
     cmd += theOriginalFileName;
@@ -578,7 +651,7 @@ QString SUPERVGUI::createBackupFile( const QString& theOriginalFileName ) {
     cmd += theBackupFileName;
     cmd += "\"";
     bool res = system( cmd.latin1() );
-    if ( res ) 
+    if ( res )
       theBackupFileName = QString("");
   }
   return theBackupFileName;
@@ -621,16 +694,16 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
     f = SUIT_FileDlg::getFileName( application()->desktop(), "", "*.xml", tr( title ), true );
     if ( f.isEmpty() ) // pressed Cancel in file select dialog
       return false;
-    
+
     // check if study already contains a graph imported from the same file
     if ( isContains( study, f ) ) {
-      if ( QMessageBox::warning( application()->desktop(), tr("WARNING"), tr("MSG_GRAPH_DISPLAYED").arg(f), 
-                                QMessageBox::Yes, QMessageBox::No) == QMessageBox::No )
-       return false;
+      if ( QMessageBox::warning( application()->desktop(), tr("WARNING"), tr("MSG_GRAPH_DISPLAYED").arg(f),
+                                 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No )
+        return false;
     }
-    
+
     // 1. create a graph
-    aGraph = ( mode == Import ) ? engine->StreamGraphE( f ) : engine->StreamGraph( f );        
+    aGraph = ( mode == Import ) ? engine->StreamGraphE( f ) : engine->StreamGraph( f );
   }
   else
     aGraph = engine->StreamGraph( MAIN_NEW );
@@ -641,7 +714,7 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
     return false;
   }
 
-  SUPERVGraph_ViewFrame* aViewFrame; 
+  SUPERVGraph_ViewFrame* aViewFrame;
   if ( theInitialDF || !myInitialViewFrame ) {
     // 2. create a ViewFrame object
     aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
@@ -649,7 +722,16 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
   else {
     // 2. get empty initial view frame as new ViewFrame object
     aViewFrame = myInitialViewFrame;
-    myInitialViewFrame = 0;
+    // mkr : IPAL12991 -->
+    if ( myInitialViewFrame ) {
+      SUPERVGraph_View* view = myInitialViewFrame->getViewWidget();
+      if (view)
+       unregisterGraph(dynamic_cast<SUPERVGUI_Main*>(view));
+    }
+    // mkr : IPAL12991 <--
+    // mkr : PAL8237 : remove first "gag" Main from children
+    // srn: commented as it cases on application exit "X Windows error"
+    //aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
   }
 
   if ( aViewFrame ) {
@@ -657,14 +739,23 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
     // 3. bind Graph and ViewFrame == create SUPERVGUI_Main object
     main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aGraph );
     if ( mode == New ) {
-      if ( !theInitialDF )
-       main->addNode();
+      if ( !theInitialDF )     
+        main->addNode();
       else
-       myInitialViewFrame = aViewFrame;
+        myInitialViewFrame = aViewFrame;
     }
-    else
-      registerGraph( f, main );
+    // mkr : IPAL11550 : register graph not depend on creation mode
+    registerGraph( f, main );
+    main->resizeView( new QResizeEvent( aViewFrame->size(), aViewFrame->size() ) );
     aViewFrame->show();
+    QFileInfo inf( f );
+    if( !f.isEmpty() )
+      aViewFrame->setCaption( inf.fileName() );
+  }
+
+  if ( !theInitialDF ) {
+    myInitialViewFrame = 0;
+    myIVFBackgroundColor = QColor();
   }
 
   return true;
@@ -672,9 +763,9 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
 
 void SUPERVGUI::reloadDataflow() {
   Trace("SUPERVGUI::reloadDataflow");
-  if ( main )  
+  if ( main )
     main->sync();
-  else 
+  else
     QMessageBox::warning(application()->desktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RELOAD"));
 }
 
@@ -736,20 +827,20 @@ void SUPERVGUI::showComponents() {
     if (id < 0 && id != -1) popup->removeItem(id); // separator
     // Temporary code end
   }
-  
+
   SALOME_ListIO aList;
   aList.Clear();
   (( SalomeApp_Application* )application())->selectionMgr()->selectedObjects( aList );
   if ( aList.Extent() == 0 ) return false;
-  
+
   if ( aList.Extent() == 1 ) {
     Handle(SALOME_InteractiveObject) anIObj = aList.First();
-    
+
     // insert SUPERV-specific popup items here
-    
+
     bool isDataflow, ownObj;
     whatIsSelected(anIObj, ownObj, isDataflow);
-    
+
     if (isDataflow) {
       popup->insertItem(tr( "MSG_RENAME" ), this, SLOT(renameDataflow()));
       popup->insertItem("Display", this, SLOT(displayDataflow()));
@@ -766,7 +857,7 @@ void SUPERVGUI::showComponents() {
       Handle(SALOME_InteractiveObject) anIObj = It_forCheckOwner.Value();
       bool aIsOwner, aIsDataflow;
       whatIsSelected(anIObj, aIsOwner, aIsDataflow);
-      
+
       if (aIsOwner) aIObjCount++;
     }
     if ( aIObjCount == aList.Extent() )  //all selected objects belong to Supervision
@@ -776,7 +867,7 @@ void SUPERVGUI::showComponents() {
   return(true);
   }*/
 
+
 
 /** Returns:
     theIsOwner = true if Selected object belongs to Supervision.
@@ -791,27 +882,27 @@ void SUPERVGUI::whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bo
     if ( comp ) {
       _PTR(GenericAttribute) anAttr;
       if (comp->FindAttribute(anAttr, "AttributeName")) {
-       _PTR(AttributeName) aName ( anAttr );
-       QString compName(aName->Value().c_str());
-       if ( compName.compare( moduleName() ) == 0 ) {
-         _PTR(GenericAttribute) anAttr;
-         if (theObj->FindAttribute(anAttr, "AttributeIOR")) {
-           _PTR(AttributeIOR) anIOR ( anAttr );
-           SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
-           if (!SUPERV_isNull(aDataFlow)) {
-             if (aDataFlow->IsStreamGraph()) {
-               if (!SUPERV_isNull(aDataFlow->ToStreamGraph()))
-                 theIsDataflow = true;
-             }
-             else
-               theIsDataflow = true;
-           }
-         }
-         CORBA::String_var anObjectID = theObj->GetID().c_str();
-         CORBA::String_var aComponentID = comp->GetID().c_str();
-         if (strcmp(anObjectID, aComponentID))
-           theIsOwner = true;      
-       }
+        _PTR(AttributeName) aName ( anAttr );
+        QString compName(aName->Value().c_str());
+        if ( compName.compare( moduleName() ) == 0 ) {
+          _PTR(GenericAttribute) anAttr;
+          if (theObj->FindAttribute(anAttr, "AttributeIOR")) {
+            _PTR(AttributeIOR) anIOR ( anAttr );
+            SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
+            if (!SUPERV_isNull(aDataFlow)) {
+              if (aDataFlow->IsStreamGraph()) {
+                if (!SUPERV_isNull(aDataFlow->ToStreamGraph()))
+                  theIsDataflow = true;
+              }
+              else
+                theIsDataflow = true;
+            }
+          }
+          CORBA::String_var anObjectID = theObj->GetID().c_str();
+          CORBA::String_var aComponentID = comp->GetID().c_str();
+          if (strcmp(anObjectID, aComponentID))
+            theIsOwner = true;
+        }
       }
     }
   }
@@ -820,9 +911,9 @@ void SUPERVGUI::whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bo
 void SUPERVGUI::deleteObject() {
   SALOME_ListIO aList;
   aList.Clear();
-  (( SalomeApp_Application* )application())->selectionMgr()->selectedObjects( aList );
+  (( SalomeApp_Application* )application())->selectionMgr()->selectedObjects( aList, QString::null, false );
   if ( aList.Extent() == 0 ) return;
-   
+
   // sak : 24.11.04 : fix for PAL6899 : if the study is locked - warn the user and return.
   _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
   if ( aStudy->GetProperties()->IsLocked() ) {
@@ -833,17 +924,17 @@ void SUPERVGUI::deleteObject() {
   // sak : 24.11.04 : fix for PAL6901 : Incorrect deletion of the objects : pressing ESC button
   // emitted "YES" button click, now it is corrected, and treated as "NO" button click.
   if (QMessageBox::warning(application()->desktop(),
-                          tr("WARNING"),
-                          tr("MSG_ASK_DELETE"),
-                          QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes)
+                           tr("WARNING"),
+                           tr("MSG_ASK_DELETE"),
+                           QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
     return;
-   
+
   SALOME_ListIteratorOfListIO It( aList );
   for(;It.More();It.Next()) {
     Handle(SALOME_InteractiveObject) anIObj = It.Value();
     //bool aIsOwner, aIsDataflow;
     //whatIsSelected(anIObj, aIsOwner, aIsDataflow);
-    
+
     _PTR(SObject) aObj ( aStudy->FindObjectID( anIObj->getEntry() ) );
     if ( aObj ) {
       SUIT_Operation* op = new SalomeApp_ImportOperation( application() );
@@ -869,43 +960,43 @@ void SUPERVGUI::OnGUIEvent()
 
 bool SUPERVGUI::OnGUIEvent(int command) {
   switch (command) {
-  case 301: 
+  case 301:
     importDataflow();
     return(false);
-    
-  case 302: 
+
+  case 302:
     exportDataflow();
     return(false);
-    
-  case 303: 
+
+  case 303:
     newDataflow();
     return(false);
-    
-  case 304: 
+
+  case 304:
     modifyDataflow();
     return(false);
-    
+
   case 305:
     reloadDataflow();
     return(false);
-    
+
   case 306:
     runDataflow();
     return(false);
-    
-  case 307: 
+
+  case 307:
     killDataflow();
     return(false);
-    
+
   case 308:
     suspendResumeDataflow();
     return(false);
-    
-  case 309: 
+
+  case 309:
     showComponents();
     return(false);
-    
-  case 310: 
+
+  case 310:
     stepByStep();
     return(false);
 
@@ -921,7 +1012,7 @@ bool SUPERVGUI::OnGUIEvent(int command) {
     deleteObject();
     return(false);
 
-  default: 
+  default:
     QMessageBox::warning(application()->desktop(), "Supervision Error", "Unknown Command From Salome");
     return(false);
   }
@@ -970,12 +1061,8 @@ void SUPERVGUI::fillInterfaceNameMap() {
       //get component
       SALOME_ModuleCatalog::Acomponent_ptr aComponent = (*aModuleCatalog)->GetComponent(aCompList[ind1]);
       if ( aComponent != NULL ) {
-       //get interface list 
-       SALOME_ModuleCatalog::ListOfInterfaces_var anIntList = aComponent->GetInterfaceList();
-       for (int ind2 = 0; ind2 < anIntList->length(); ind2++) {
-         const char* anIntName = anIntList[ind2];
-         myInterfaceNameMap.insert(QString(anIntName), QString(aComponent->componentname()));
-       }
+       // mkr : PAL13135
+       myInterfaceNameMap.insert(QString(aComponent->componentusername()), QString(aComponent->componentname()));
       }
     }
   }
@@ -984,3 +1071,20 @@ void SUPERVGUI::fillInterfaceNameMap() {
 QMap<QString, QString> SUPERVGUI::getInterfaceNameMap() const {
   return myInterfaceNameMap;
 }
+
+bool SUPERVGUI::updateDataFlowSOName( SUPERV::Graph_ptr theDataflow ) {
+  if ( !SUPERV_isNull(theDataflow) ) {
+    _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
+    _PTR(SObject) aSO ( aStudy->FindObjectIOR( theDataflow->getIOR() ) );
+
+    _PTR(GenericAttribute) anAttr;
+    if ( aSO ) // i.e. if theDataflow is in study
+      if ( aSO->FindAttribute(anAttr, "AttributeName") ) {
+        _PTR(AttributeName) aName ( anAttr );
+       aName->SetValue( theDataflow->Name() );
+       updateObjBrowser();
+       return true;
+      }    
+  }
+  return false;
+}