]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx
Salome HOME
Merging with JR_ASV_2_1_0_deb_with_KERNEL_Head branch, which contains many bug fixes...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasPort.cxx
index 91f32e5eb94777027ef7806d5574434453ff82ca..198c5ed0a91bcfb7ed2e2f8941b77a2c3140908f 100644 (file)
@@ -11,6 +11,7 @@ using namespace std;
 #include "SUPERVGUI_CanvasNode.h"
 #include "SUPERVGUI_CanvasLink.h"
 #include "SUPERVGUI_CanvasNodePrs.h"
+#include "SUPERVGUI_Clipboard.h"
 #include "SUPERVGUI_Main.h"
 #include "SUPERVGUI.h"
 #include "SUPERVGUI_BrowseNodeDlg.h"
@@ -55,7 +56,7 @@ SUPERVGUI_CanvasPortPrs* SUPERVGUI_CanvasPort::createPrs() const
 QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) 
 {
   QPopupMenu* popup = new QPopupMenu(theParent);
-  if (myMain->isEditable()) {
+  if ( myMain->isEditable() && !myMain->getDataflow()->IsExecuting() ) {
     int anItem = popup->insertItem(tr("MSG_SKETCH_LINK"), this, SLOT(sketchLink()));
     if (myMain->getDataflow()->IsExecuting())
       popup->setItemEnabled(anItem, false);
@@ -64,7 +65,7 @@ QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent)
                            || myPort->Kind() == SUPERV::EndSwitchParameter);
     popup->insertSeparator();
   }
-  if (myMain->isEditable() 
+  if (myMain->isEditable() && !myMain->getDataflow()->IsExecuting()
       &&
       ((myPort->IsEndSwitch() && myPort->IsInput()) 
        ||
@@ -73,8 +74,13 @@ QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent)
        !(myPort->Node()->Kind() == SUPERV::LoopNode && !myPort->IsInput())))) {
     popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(remove()));    
   }
+  // Copy Port functionality
+  if (myMain->isEditable() && !myPort->Node()->IsFactory()
+                           && !myPort->Node()->IsComputing()
+                           && !myPort->Node()->IsMacro())
+    popup->insertItem(tr("ITM_COPY_PORT"), this, SLOT(copy()));
 
-  int anItem = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse()));
+//int anItem = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse()));
 //   if (getEngine()->IsLinked())
 //     popup->setItemEnabled(anItem, getEngine()->State() == SUPERV_Ready);
 //   else 
@@ -111,12 +117,24 @@ void SUPERVGUI_CanvasPort::sync()
   getPrs()->update();
 }
 
-void SUPERVGUI_CanvasPort::sketchLink() 
-{
+void SUPERVGUI_CanvasPort::sketchLink() {
+  myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
+  
   myMain->getCanvasView()->startSketch(this);
 }
 
 void SUPERVGUI_CanvasPort::remove() {
+  myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
+
+  //set myCopyPort from Main object to empty if engine of this port is deleted
+  //check if myCopyPort and this port engine is equal
+  SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
+  if ( aCB->isCopyPort() )
+    if ( QString(myPort->Node()->Name()) == QString(aCB->getCopyPort()->Node()->Name()) &&
+        QString(myPort->Name()) == QString(aCB->getCopyPort()->Name()) &&
+        myPort->IsInput() == aCB->getCopyPort()->IsInput() )
+       aCB->setCopyPort( 0 );
+
   Trace("SUPERVGUI_CanvasPort::remove");
   myPort->destroy();
   delete this;
@@ -161,6 +179,11 @@ void SUPERVGUI_CanvasPort::browse()
   QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), aMes);
 }
 
+void SUPERVGUI_CanvasPort::copy()
+{
+  SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
+  aCB->setCopyPort(SUPERV::Port::_duplicate(getEngine()));
+}
 
 //***********************************************************
 // Input Port
@@ -180,7 +203,7 @@ SUPERVGUI_CanvasPortIn::~SUPERVGUI_CanvasPortIn()
 QPopupMenu* SUPERVGUI_CanvasPortIn::getPopupMenu(QWidget* theParent) 
 {
   QPopupMenu* popup = SUPERVGUI_CanvasPort::getPopupMenu(theParent);
-  bool editable = getEngine()->IsInput() && (!getEngine()->IsLinked());
+  bool editable = getEngine()->IsInput() && !getEngine()->IsLinked() && !getMain()->getDataflow()->IsExecuting();
 
   if (!getEngine()->IsGate() && editable)
     popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput()));
@@ -198,6 +221,7 @@ void SUPERVGUI_CanvasPortIn::setValue(const char* theValue)
 
 void SUPERVGUI_CanvasPortIn::setInput() 
 {
+  getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
   if (!myDlg) {
     myDlg = new SUPERVGUI_GetValueDlg(this);
     myDlg->installEventFilter(this);
@@ -209,7 +233,6 @@ void SUPERVGUI_CanvasPortIn::setInput()
     myDlg->setActiveWindow();
     myDlg->setFocus();
   }
-  
 }
 
 bool SUPERVGUI_CanvasPortIn::eventFilter(QObject* o, QEvent* e)