Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasPort.cxx
index 859611ee6c7f6478240952cb9cd3c881ff2414c9..e7db50f26a12c9e6bf2c0ac6bacf7d5601839c3a 100644 (file)
@@ -1,12 +1,28 @@
 //  SUPERV SUPERVGUI : GUI for Supervisor component
 //
-//  Copyright (C) 2003  OPEN CASCADE
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  File   : SUPERVGUI_CanvasPort.cxx
 //  Author : Natalia KOPNOVA
 //  Module : SUPERV
 
-using namespace std;
 #include "SUPERVGUI_CanvasPort.h"
 #include "SUPERVGUI_CanvasNode.h"
 #include "SUPERVGUI_CanvasLink.h"
@@ -16,8 +32,10 @@ using namespace std;
 #include "SUPERVGUI.h"
 #include "SUPERVGUI_BrowseNodeDlg.h"
 
+#include "SalomeApp_Study.h"
 
-SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort):
+SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort (QObject* theParent, SUPERVGUI_Main* theMain,
+                                            SUPERV::Port_ptr thePort):
     QObject(theParent),
     myMain(theMain),
     myPrs(0),
@@ -28,6 +46,9 @@ SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort(QObject* theParent, SUPERVGUI_Main* t
 
   // setName(myPort->Name());
   setName(myMain->getCanvas()->getPortName(thePort));
+
+  // mkr : PAL8237
+  connect(this, SIGNAL(objectDeleted()), myMain, SLOT(onObjectCreatedDeleted()));
 }
 
 SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort()
@@ -137,6 +158,9 @@ void SUPERVGUI_CanvasPort::remove() {
 
   Trace("SUPERVGUI_CanvasPort::remove");
   myPort->destroy();
+  
+  emit objectDeleted(); // mkr : PAL8237
+
   delete this;
 }
 
@@ -176,7 +200,7 @@ void SUPERVGUI_CanvasPort::browse()
 {
   QString aMes(getEngine()->IsInput()? tr("MSG_IPORT_VAL") : tr("MSG_OPORT_VAL"));
   aMes += getEngine()->ToString();
-  QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), aMes);
+  QMessageBox::information(SUIT_Session::session()->activeApplication()->desktop(), tr("MSG_INFO"), aMes);
 }
 
 void SUPERVGUI_CanvasPort::copy()
@@ -188,7 +212,8 @@ void SUPERVGUI_CanvasPort::copy()
 //***********************************************************
 // Input Port
 //***********************************************************
-SUPERVGUI_CanvasPortIn::SUPERVGUI_CanvasPortIn(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort):
+SUPERVGUI_CanvasPortIn::SUPERVGUI_CanvasPortIn (QObject* theParent, SUPERVGUI_Main* theMain,
+                                                SUPERV::Port_ptr thePort):
   SUPERVGUI_CanvasPort(theParent, theMain, thePort)
 {
   Trace("SUPERVGUI_CanvasPortIn::SUPERVGUI_CanvasPortIn");
@@ -203,7 +228,9 @@ SUPERVGUI_CanvasPortIn::~SUPERVGUI_CanvasPortIn()
 QPopupMenu* SUPERVGUI_CanvasPortIn::getPopupMenu(QWidget* theParent) 
 {
   QPopupMenu* popup = SUPERVGUI_CanvasPort::getPopupMenu(theParent);
-  bool editable = getEngine()->IsInput() && !getEngine()->IsLinked() && !getMain()->getDataflow()->IsExecuting();
+  bool editable = (getEngine()->IsInput() &&
+                   !getEngine()->IsLinked() &&
+                   !getMain()->getDataflow()->IsExecuting());
 
   if (!getEngine()->IsGate() && editable)
     popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput()));
@@ -213,10 +240,11 @@ QPopupMenu* SUPERVGUI_CanvasPortIn::getPopupMenu(QWidget* theParent)
 
 void SUPERVGUI_CanvasPortIn::setValue(const char* theValue) 
 {
-  if (getEngine()->Input(Supervision.getEngine()->StringValue(theValue)))
+  SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+  if (aSupMod && getEngine()->Input(aSupMod->getEngine()->StringValue(theValue)))
     update(); // sync();
   else
-    QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SETVAL"));
+    QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_SETVAL"));
 }
 
 void SUPERVGUI_CanvasPortIn::setInput() 
@@ -247,11 +275,15 @@ bool SUPERVGUI_CanvasPortIn::eventFilter(QObject* o, QEvent* e)
 //***********************************************************
 // Output Port
 //***********************************************************
-SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort):
+SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut (QObject* theParent, SUPERVGUI_Main* theMain,
+                                                  SUPERV::Port_ptr thePort):
   SUPERVGUI_CanvasPort(theParent, theMain, thePort)
 {
   Trace("SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut");
   myInStudy = false;
+
+  // mkr : PAL8150
+  connect(this, SIGNAL(putInStudy( QString* )), getMain(), SLOT(onPutInStudy( QString* )));
 }
 
 SUPERVGUI_CanvasPortOut::~SUPERVGUI_CanvasPortOut()
@@ -291,21 +323,34 @@ void SUPERVGUI_CanvasPortOut::toStudy()
 {
   Trace("SUPERVGUI_CanvasPortOut::toStudy");
 
-  if (getMain()->getStudy()->getStudyDocument()->GetProperties()->IsLocked()) {
-    QMessageBox::warning(QAD_Application::getDesktop(), tr("WRN_WARNING"), 
+  // asv 08.02.05 : added && !myInStudy - fix for PAL8105
+  if ( (( SalomeApp_Study* )(getMain()->getStudy()))->studyDS()->GetProperties()->IsLocked() && !myInStudy ) {
+    QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WRN_WARNING"), 
                         tr("WRN_STUDY_LOCKED"));
     return;
   }
 
-  if ( !getMain()->isFromStudy() ) {
-    if ( getMain()->addStudy() ) {
-      getMain()->setAsFromStudy( true ); // put an "computation" item under "Supervisor" item in the Study tree
-      getMain()->putDataStudy( getEngine(), STUDY_PORT_OUT ); // put another new item under some another corresponding item
-    }                                                         // GEOM -> Compound_1
-  }
   myInStudy = !myInStudy;
   sync();
   getMain()->getCanvas()->update();
+
+  if ( myInStudy ) // put values to study (supervision, supervision->dataflow, supervision->dataflow->runXXX, etc.
+    if ( getMain()->putDataStudy( getEngine(), STUDY_PORT_OUT ) ) {
+      // mkr : PAL8110 : re-register dataflow in object browser with 
+      //       changing its key to IOR name (from xml-file name, for example)
+      SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+      if ( !aSupMod ) {
+       MESSAGE("NULL Supervision module!");
+       return;
+      }
+      aSupMod->unregisterGraph(getMain());
+      aSupMod->registerGraph(getMain()->getDataflow()->getIOR(), getMain());
+    }
+  
+  // mkr : PAL8150
+  QString aNodePortName = QString( getEngine()->Node()->Name() ) + QString( "_" ) + QString( getEngine()->Name() );
+  emit putInStudy( &aNodePortName );
+
 }