]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx
Salome HOME
Implement fix for bug PAL8551 ( Supervision message "Dataflow is not valid"
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasNode.cxx
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE
4 //
5 //  File   : SUPERVGUI_CanvasNode.cxx
6 //  Author : Natalia KOPNOVA
7 //  Module : SUPERV
8
9 using namespace std;
10 #include "SUPERVGUI_CanvasNode.h"
11 #include "SUPERVGUI_CanvasNodePrs.h"
12 #include "SUPERVGUI_CanvasPort.h"
13 #include "SUPERVGUI_Clipboard.h"
14 #include "SUPERVGUI_Main.h"
15 #include "SUPERVGUI.h"
16 #include "SUPERVGUI_BrowseNodeDlg.h"
17 #include "SUPERVGUI_ManagePortsDlg.h"
18 #include "SUPERVGUI_Information.h"
19 #include "SUPERVGUI_Library.h"
20
21 #include "LightApp_NameDlg.h"
22 #include "SUIT_MessageBox.h"
23 #include "LogWindow.h"
24 #include "SUIT_Session.h"
25
26
27 SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode( SUIT_ResourceMgr* mgr, QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, bool theIsCell):
28     QObject(theParent),
29     myMain(theMain),
30     myNode(theNode),
31     myPrs(0),
32     myDestroyed(false),
33     warning(true),
34     step(true),
35     trace(true),
36     verbose(true),
37     myBrowseDlg(0),
38     myMgr( mgr )
39 {
40   Trace("SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode");
41
42   setName(myNode->Name());
43
44   QString aComment(myNode->Comment());
45   QString aNewComment = aComment;
46   if (getNodeType() == SUPERV::FactoryNode) {
47     aNewComment = QString(myNode->Service()->ServiceName) +
48       QString(tr("COMMENT_FROM")) +
49       QString(getFactoryNode()->GetComponentName());
50   }
51   else if (myNode->IsMacro()) {
52     aNewComment = tr("COMMENT_MNODE");
53   }
54   else {
55     aNewComment = tr("COMMENT_CNODE");
56   }
57   if (aComment.isEmpty()) {
58     myNode->SetComment(aNewComment.latin1());
59   }
60
61   myLabelText = aNewComment;
62
63   // mkr : if the SUPERVGUI_CavasCellNode created (for CANVASTABLE view), 
64   // we don't create the ports
65   if (!theIsCell) {
66     // create node ports
67     isIgnore = true;
68     SUPERV_Ports aPortList = myNode->Ports();
69     for (int i = 0; i < aPortList->length(); i++)
70       createPort(aPortList[i].in());
71     
72     SUPERV_StreamPorts aStreamPortList = myNode->StreamPorts();
73     for (int i = 0; i < aStreamPortList->length(); i++) {
74       createStreamPort(aStreamPortList[i].in());
75     }
76   }
77
78   isIgnore = false;
79 }
80
81 SUPERVGUI_CanvasNode::~SUPERVGUI_CanvasNode()
82 {
83   isIgnore = true;
84   if ( myPrs ) {
85     myPrs->hide();
86     delete myPrs;
87     myPrs = 0;
88   }
89 }
90
91 void SUPERVGUI_CanvasNode::setDestroyed()
92 {
93   myDestroyed = true;
94   getPrs()->hide();
95 }
96
97 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::getPrs()
98 {
99   if ( !myPrs )
100     myPrs = createPrs();
101
102   return myPrs;
103 }
104
105 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::createPrs() const
106 {
107   return new SUPERVGUI_CanvasNodePrs( myMgr, myMain->getCanvas(), (SUPERVGUI_CanvasNode*)this);
108 }
109
110 void SUPERVGUI_CanvasNode::createPort(SUPERV::Port_ptr thePort)
111 {
112   SUPERVGUI_CanvasPort* aPort = 0;
113   if (thePort->IsInput())
114     aPort = new SUPERVGUI_CanvasPortIn((SUPERVGUI_CanvasNode*)this, myMain, thePort);
115   else
116     aPort = new SUPERVGUI_CanvasPortOut((SUPERVGUI_CanvasNode*)this, myMain, thePort);
117
118   if (aPort) {
119     connect(aPort, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
120     if (!isIgnore) getPrs()->updatePorts();
121   }
122 }
123
124 void SUPERVGUI_CanvasNode::createStreamPort(SUPERV::StreamPort_ptr thePort)
125 {
126   SUPERVGUI_CanvasPort* aPort = 0;
127   if (thePort->IsInput())
128     aPort = new SUPERVGUI_CanvasStreamPortIn((SUPERVGUI_CanvasNode*)this, myMain, thePort);
129   else
130     aPort = new SUPERVGUI_CanvasStreamPortOut((SUPERVGUI_CanvasNode*)this, myMain, thePort);
131
132   if (aPort) {
133     connect(aPort, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
134     if (!isIgnore) getPrs()->updatePorts();
135   }
136 }
137
138 void SUPERVGUI_CanvasNode::onDestroyed(QObject* theObject)
139 {
140   if (!isIgnore) {
141     removeChild(theObject); // signal is sent before removing the object
142     getPrs()->updatePorts();
143   }
144 }
145
146 QPopupMenu* SUPERVGUI_CanvasNode::getPopupMenu(QWidget* theParent) 
147 {
148   QPopupMenu* popup = new QPopupMenu(theParent);
149
150   if (myMain->getDataflow()->IsExecuting()) { // Execution time
151     popup->insertItem((myNode->IsSuspended()?tr("MSG_RESUME"):tr("MSG_SUSPEND")), this, SLOT(suspendResume()));
152     popup->insertItem(tr("MSG_KILL"), this, SLOT(kill()));
153   }
154   else { // Edition time
155     const int type = getNodeType();
156
157     // for all nodes except EndLoop and EndSwitch : Rename, Delete, Copy
158     if ( myMain->isEditable() && type != SUPERV::EndLoopNode && type != SUPERV::EndSwitchNode &&
159         // asv 26.01.05 : don't allow nodes "edition" commands in Table view
160         myMain->getViewType() != CANVASTABLE ) { 
161       popup->insertItem(tr("MSG_RENAME"), this, SLOT(rename()));
162       popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove()));
163     }
164     
165     // tmp: Copy temporary does not work for Macro nodes...
166     if ( type != SUPERV::MacroNode )
167       popup->insertItem(tr("ITM_COPY_NODE"), this, SLOT(copy())); // Copy Node functionality
168     popup->insertSeparator();
169         
170     // for all nodes : Browse
171     popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse()));
172
173     // for all nodes except EndLoop and EndSwitch : Change info
174     if (type != SUPERV::EndLoopNode && type != SUPERV::EndSwitchNode)
175       popup->insertItem(tr("MSG_CHANGE_INFO"), this, SLOT(changeInformation()));
176
177     // for all InLine nodes
178     if ( type != SUPERV::FactoryNode && type != SUPERV::ComputingNode && type != SUPERV::MacroNode ) {
179       if ( myMain->isEditable() ) { 
180         popup->insertSeparator();
181         popup->insertItem( tr( "MNU_EDIT_FUNC" ), this, SLOT(editFunction()));
182       }
183
184       // for all InLine, regardless isEditable() : Export to Library
185       popup->insertItem( tr( "MNU_EXPORT" ), this, SLOT( exportToLib()));
186
187       // for all InLine except EndLoop : Add Ports menu, Paste, Manage Ports
188       if ( myMain->isEditable() && type != SUPERV::EndLoopNode ) {
189         // mkr : IPAL9815 : commented the following code
190         /*QPopupMenu* addPortMenu = new QPopupMenu(theParent);
191         addPortMenu->insertItem( tr( "MNU_INPUT" ), this, SLOT(addInputPort()));
192         if (getNodeType() != SUPERV::LoopNode)
193           addPortMenu->insertItem( tr( "MNU_OUTPUT" ), this, SLOT(addOutputPort()));
194
195           popup->insertItem( tr( "MNU_ADD_PORT" ), addPortMenu);*/
196         popup->insertItem( tr( "MNU_MANAGE_PORTS" ), this, SLOT(managePorts()));
197
198         // Paste Port functionality
199         int aPasteItem = popup->insertItem(tr("ITM_PASTE_PORT"), this, SLOT(pastePort()));
200         SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
201         if ( !aCB->isCopyPort() || (type == SUPERV::LoopNode && !aCB->getCopyPort()->IsInput()) )
202           popup->setItemEnabled( aPasteItem, false );
203       }
204     }
205   }
206   return popup;
207 }
208
209 void SUPERVGUI_CanvasNode::show() 
210 {
211   getPrs()->show();
212 }
213
214 void SUPERVGUI_CanvasNode::showAll() 
215 {
216   getPrs()->showAll();
217 }
218
219 void SUPERVGUI_CanvasNode::hideAll() 
220 {
221   getPrs()->hideAll();
222 }
223
224 void SUPERVGUI_CanvasNode::switchLabel()
225 {
226   getPrs()->setLabelVisible(!getPrs()->isLabelVisible());
227 }
228
229 void SUPERVGUI_CanvasNode::switchPorts()
230 {
231   getPrs()->setPortVisible(!getPrs()->isPortVisible());
232 }
233
234 void SUPERVGUI_CanvasNode::move(int x, int y)
235 {
236   //  myNode->Coords(x, y); //  <<<- done inside Prs to reflect item movement by mouse press
237   if (x > GRAPH_MAX) x = (int) getPrs()->x();
238   if (y > GRAPH_MAX) y = (int) getPrs()->y();
239   getPrs()->move(x, y);
240 }
241
242 void SUPERVGUI_CanvasNode::merge() 
243 {
244   // synchronize port list
245   bool update = false;
246   isIgnore = true;
247   SUPERVGUI_CanvasPort* aPort;
248   QObjectList* aPortList = queryList("SUPERVGUI_CanvasPort");
249   SUPERV_Ports aPorts = myNode->Ports();
250   for (int i = 0; i < aPorts->length(); i++) {
251     aPort = (SUPERVGUI_CanvasPort*) 
252       child(myMain->getCanvas()->getPortName(aPorts[i].in()), "SUPERVGUI_CanvasPort");
253     if (aPort) {
254       aPortList->removeRef(aPort);
255       aPort->update();
256     }
257     else {
258       createPort(aPorts[i].in());
259       update = true;
260     }
261   }
262
263   SUPERV_StreamPorts aStreamPorts = myNode->StreamPorts();
264   for (int i = 0; i < aStreamPorts->length(); i++) {
265     aPort = (SUPERVGUI_CanvasPort*) 
266       child(myMain->getCanvas()->getPortName(aStreamPorts[i].in()), "SUPERVGUI_CanvasPort");
267     if (aPort) {
268       aPortList->removeRef(aPort);
269       aPort->update();
270     }
271     else {
272       createPort(aStreamPorts[i].in());
273       update = true;
274     }
275   }
276
277   QObjectListIt it(*aPortList);
278   while ((aPort=(SUPERVGUI_CanvasPort*)it.current()) != 0) {
279     ++it;
280     aPortList->removeRef(aPort);
281     delete aPort;
282     update = true;
283   }
284   delete aPortList;
285   isIgnore = false;
286   if (update) getPrs()->updatePorts();
287
288   sync(); // update node state also
289 }
290
291 void SUPERVGUI_CanvasNode::sync()  {
292   const bool isExecuting = myMain->getDataflow()->IsExecuting();
293   if ( myNode->IsMacro() && isExecuting ) {
294     // get SubGraph from MacroNode
295     SUPERV_Graph aMacro = SUPERV::Graph::_narrow(myNode);
296     if (!SUPERV_isNull(aMacro)) {
297       SUPERV_Graph aGraph;
298       if (aMacro->IsStreamMacro())
299         aGraph = aMacro->StreamObjRef();
300       else
301         aGraph = aMacro->FlowObjRef();
302       if (!SUPERV_isNull(aGraph)) {
303         if (aGraph->State() != SUPERV::UndefinedState && aGraph->State() != SUPERV::NoState)
304           getPrs()->setState(aGraph->State());
305         else 
306           getPrs()->setState(myNode->State());
307       }
308     }
309   }
310   else {
311     SUPERV::GraphState aState = myNode->State();
312
313     // asv : 18.11.04 : fix for 6170 : after execution is finished, nodes' status must be reset.
314     // asv : 13.12.04 : commented out setting EditingState.  See 2.21.
315     //if ( !isExecuting && myMain->IsGUIEventLoopFinished() && (aState == SUPERV::DoneState || 
316     //  aState == SUPERV::KillState || aState == SUPERV::StopState ) )
317     //  aState = SUPERV::EditingState;
318     getPrs()->setState(aState);
319   }
320   
321   // update child ports
322   const QObjectList* list = children();
323   if (list) {
324     QObjectListIt it(*list);
325     while (QObject* obj = it.current()) {
326       ++it;
327       if (obj->inherits("SUPERVGUI_CanvasPort")) {
328         ((SUPERVGUI_CanvasPort*)obj)->sync();
329       }
330     }
331   }
332 }
333
334 void SUPERVGUI_CanvasNode::syncOnEvent(SUPERV::GraphState theStateFromEvent) 
335 {
336   getPrs()->setState(theStateFromEvent);
337 }
338
339 bool SUPERVGUI_CanvasNode::setNodeName(QString aName)  {
340   bool result = myNode->SetName(aName.latin1());
341   if (result) {
342     setName(myNode->Name());
343     getPrs()->updateInfo();
344     // TODO: update name of all the links to this node
345   } 
346   else {
347     QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr( "ERROR" ), tr( "MSG_CANT_RENAMENODE" ) );
348   }
349   return result;
350 }
351
352 void SUPERVGUI_CanvasNode::rename()  {
353   QString aName = LightApp_NameDlg::getName( SUIT_Session::session()->activeApplication()->desktop(), myNode->Name() );
354   //mkr : modifications for fixing bug IPAL9972
355   if (!aName.isEmpty() && aName.compare( myNode->Name() ) != 0) {
356     setNodeName(aName);
357   }
358 }
359
360 void SUPERVGUI_CanvasNode::remove() {
361   Trace("SUPERVGUI_CanvasNode::remove");
362   myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
363
364   //set myCopyPort from Main object to empty if engine of this port is deleted
365   //check if any port of this deleted node has been copied
366   SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
367   if ( aCB->isCopyPort() )
368     if ( QString(myNode->Name()) == QString(aCB->getCopyPort()->Node()->Name()) )
369       aCB->setCopyPort( 0 );
370
371   //set myCopyNode from Main object to empty if engine of this node is deleted
372   //check if myCopyNode and this node engine is equal
373   if ( aCB->isCopyNode() )
374     if ( QString(myNode->Name()) == QString(aCB->getCopyNode()->Name()) ) 
375       aCB->setCopyNode( 0 );
376
377   // mkr: since the deletion of the node allow only in CANVAS view,
378   // it is necessary to remove the CanvasArray's children, which
379   // have the same CNode engine as deleting node
380   myMain->removeArrayChild(myNode);
381
382   SUPERVGUI_Canvas* aCanvas = myMain->getCanvas();
383   setDestroyed();
384   myNode->destroy();
385   delete this;
386   aCanvas->update();
387 }
388
389 void SUPERVGUI_CanvasNode::copy() {
390   Trace("SUPERVGUI_CanvasNode::copy()");
391   SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard();
392   const int aKind = getNodeType(); 
393   if ( aKind == SUPERV::EndLoopNode || aKind == SUPERV::EndSwitchNode )
394     aCB->setCopyNode( SUPERV::CNode::_duplicate(SUPERV::GNode::_narrow(getEngine())->Coupled()) );
395   else
396     aCB->setCopyNode( SUPERV::CNode::_duplicate( getEngine() ) );
397 }
398
399 void SUPERVGUI_CanvasNode::suspendResume() {
400   Trace("SUPERVGUI_CanvasNode::suspendResume");
401   int n = queryList("SUPERVGUI_CanvasNode")->count(); 
402   if (myNode->IsSuspended()) {
403     if (!((n==1)? myMain->getDataflow()->Resume() : myNode->Resume())) {
404       QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_RESUMENODE") );
405     }
406     else {
407       sync();
408       myMain->getMyThread()->startThread(tr("MSG_NODE_RESUMED1")+myNode->Name()+tr("MSG_NODE_RESUMED2"));
409     }
410   } else {
411     if (!((n==1)? myMain->getDataflow()->Suspend() : myNode->Suspend())) {
412       QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_SUSPENDNODE") );
413     } else {
414       syncOnEvent(SUPERV::SuspendReadyState);
415       myMain->getMessage()->putMessage(tr("MSG_NODE_SUSPENDED1")+myNode->Name()+tr("MSG_NODE_SUSPENDED2"));
416     }
417   }
418 }
419
420 void SUPERVGUI_CanvasNode::kill() {
421   Trace("SUPERVGUI_CanvasNode::kill");
422   int n = queryList("SUPERVGUI_CanvasNode")->count(); 
423   if (!((n==1)? myMain->getDataflow()->Kill() : myNode->Kill())) {
424     QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_KILLNODE") );
425   } else {
426     syncOnEvent(SUPERV_Kill);
427     myMain->getMessage()->putMessage(tr("MSG_NODE_KILLED1")+myNode->Name()+tr("MSG_NODE_KILLED2"));
428   }
429 }
430 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
431    the comment from kloss (in Main.cxx) may be explaining it, but it's in French and I do not understand it..
432 void SUPERVGUI_CanvasNode::stopRestart() {
433   Trace("SUPERVGUI_CanvasNode::stopRestart");
434   
435   int n = queryList("SUPERVGUI_CanvasNode")->count(); 
436   if ((myNode->State() == SUPERV_Stop) || (myNode->State() == SUPERV_Kill)) {
437     if (!((n==1)? myMain->getDataflow()->Run() : myNode->ReStart())) {
438       QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),  tr("ERROR"), tr("MSG_CANT_RESTARTNODE") );
439     }
440   } else {
441     if (!((n==1)? myMain->getDataflow()->Stop() : myNode->Stop())) {
442       QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),  tr("ERROR"), tr("MSG_CANT_STOPNODE") );
443     }
444   }
445 }
446 */
447 void SUPERVGUI_CanvasNode::changeInformation() {
448   SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(myNode, !myMain->isEditable());
449   if (aDlg->exec()) {
450
451     QString aName = myNode->Name();
452     if (!aName.isEmpty() && myMain->isEditable()) {
453       //mkr : modifications for fixing bug IPAL9972
454       //setNodeName(aName);
455
456       setName(myNode->Name());
457       getPrs()->updateInfo();
458       // TODO: update name of all the links to this node
459     }
460
461   }
462   delete aDlg;
463 }
464
465 /* asv : 13.12.04 : The functions below are not called from anywhere, so commenting them out...
466 void SUPERVGUI_CanvasNode::configure() 
467 {
468   Trace("SUPERVGUI_CanvasNode::configure");
469   QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),  tr("ERROR"), tr("MSG_NOT_IMPLEMENTED") ); // kloss : a faire : lancer l'ihm DATA
470 }
471
472 void SUPERVGUI_CanvasNode::showPython() 
473 {
474   Trace("SUPERVGUI_CanvasNode::showPython");
475   SUPERVGUI_Python cp(myMain->getStudy()->get_PyInterp(), !myMain->isEditable());
476   cp.exec();
477 }
478 */
479
480 bool SUPERVGUI_CanvasNode::isWarning() 
481 {
482   Trace("SUPERVGUI_CanvasNode::isWarning");
483   return(warning);
484 }
485
486 bool SUPERVGUI_CanvasNode::isStep() 
487 {
488   Trace("SUPERVGUI_CanvasNode::isStep");
489   return(step);
490 }
491
492 bool SUPERVGUI_CanvasNode::isTrace() 
493 {
494   Trace("SUPERVGUI_CanvasNode::isTrace");
495   return(trace);
496 }
497
498 bool SUPERVGUI_CanvasNode::isVerbose() 
499 {
500   Trace("SUPERVGUI_CanvasNode::isVerbose");
501   return(verbose);
502 }
503
504 void SUPERVGUI_CanvasNode::setWarning(bool b) 
505 {
506   Trace("SUPERVGUI_CanvasNode::setWarning");
507   warning = b;
508 }
509
510 void SUPERVGUI_CanvasNode::setStep(bool b) 
511 {
512   Trace("SUPERVGUI_CanvasNode::setStep");
513   step = b;
514 }
515
516 void SUPERVGUI_CanvasNode::setTrace(bool b) 
517 {
518   Trace("SUPERVGUI_CanvasNode::setTrace");
519   trace = b;
520 }
521
522 void SUPERVGUI_CanvasNode::setVerbose(bool b) 
523 {
524   Trace("SUPERVGUI_CanvasNode::setVerbose");
525   verbose = b;
526 }
527
528
529 void SUPERVGUI_CanvasNode::browse() 
530 {
531   // asv 28.01.05 : set "Editing" flag only on "OK" pressed in BrowseDlg
532   //myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
533   if (!myBrowseDlg) {
534     myBrowseDlg = new SUPERVGUI_BrowseNodeDlg(this);
535     myBrowseDlg->installEventFilter(this);
536   }
537   if (!myBrowseDlg->isVisible())
538     myBrowseDlg->show();
539   else {
540     myBrowseDlg->raise();
541     myBrowseDlg->setActiveWindow();
542     myBrowseDlg->setFocus();
543   }
544 }
545
546 bool SUPERVGUI_CanvasNode::eventFilter( QObject* o, QEvent* e )
547 {
548   if (o == myBrowseDlg && e->type() == QEvent::Close)
549     myBrowseDlg = 0;
550   return QObject::eventFilter(o, e);
551 }
552
553 QStringList SUPERVGUI_CanvasNode::getPortsNamesIN(SUPERV_INode theNode, bool theInputPorts)
554 {
555   QStringList aPNList;
556   if (!SUPERV_isNull(theNode)) {
557     SUPERV_Ports aPorts = theNode->Ports();
558     for (int i=0; i<aPorts->length(); i++) {
559       if (theInputPorts) {
560         if (aPorts[i]->IsInput()) aPNList.append(QString(aPorts[i]->Name()));
561       }
562       else 
563         if (!aPorts[i]->IsInput()) aPNList.append(QString(aPorts[i]->Name()));
564     }
565   }
566   return aPNList;
567 }
568
569 SUPERV_Port SUPERVGUI_CanvasNode::createInPort() 
570 {
571   SUPERV_INode aNode = getInlineNode();
572   if (SUPERV_isNull(aNode)) {
573     MESSAGE("SUPERVGUI_CanvasNode::createInPort: Node is wrong type");
574     return NULL;
575   }
576   SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(getPortsNamesIN(aNode,true));
577   if (aDlg->exec()) {
578     myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
579     SUPERV_Port aPort = aNode->InPort(aDlg->getName().latin1(),
580                                       aDlg->getType().latin1());    
581     delete aDlg;
582     return aPort;
583   }
584   delete aDlg;
585   return NULL;
586 }
587
588 SUPERV_Port SUPERVGUI_CanvasNode::createOutPort() 
589 {
590   SUPERV_INode aNode = getInlineNode();
591   if (SUPERV_isNull(aNode)) {
592     MESSAGE("SUPERVGUI_CanvasNode::createOutPort: Node is wrong type");
593     return NULL;
594   }
595   
596   SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(getPortsNamesIN(aNode,false));
597   if (aDlg->exec()) {
598     myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
599     SUPERV_Port aPort = aNode->OutPort(aDlg->getName().latin1(),
600                                        aDlg->getType().latin1());
601     delete aDlg;
602     return aPort;
603   }
604   delete aDlg;
605   return NULL;
606 }
607
608 // mkr : IPAL9815 : commented the following code
609 /*void SUPERVGUI_CanvasNode::addInputPort() {
610   SUPERV_Port aPort = createInPort();
611   if (aPort == NULL || CORBA::is_nil( aPort ) ) return;
612
613   createPort(aPort.in());
614 }
615
616
617 void SUPERVGUI_CanvasNode::addOutputPort() {
618   SUPERV_Port aPort = createOutPort();
619   if (aPort == NULL || CORBA::is_nil( aPort ) ) return;
620
621   createPort(aPort.in());
622 }*/
623
624
625 void SUPERVGUI_CanvasNode::editFunction()  {
626   if (getNodeType() == SUPERV::LoopNode) {
627     SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg(true);
628     SUPERV_LNode aLNode = getLoopNode();
629     aDlg->setInitFunction(aLNode->PyInit());
630     aDlg->setMoreFunction(aLNode->PyMore());
631     aDlg->setNextFunction(aLNode->PyNext());
632     if (aDlg->exec()) {
633       myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
634       aLNode->SetPyInit(aDlg->getInitFuncName().latin1(), (aDlg->getInitFunction()).in());
635       aLNode->SetPyMore(aDlg->getMoreFuncName().latin1(), (aDlg->getMoreFunction()).in());
636       aLNode->SetPyNext(aDlg->getNextFuncName().latin1(), (aDlg->getNextFunction()).in());
637     }
638     delete aDlg;
639   } 
640   else {
641     SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg();
642     SUPERV_INode aINode = getInlineNode();
643     aDlg->setFunction(aINode->PyFunction());
644     if (aDlg->exec()) {
645       myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
646       aINode->SetPyFunction(aDlg->getFuncName().latin1(), (aDlg->getFunction()).in());
647     }
648     delete aDlg;
649   }
650 }
651
652 /** 
653  * Called on "Paste port" command of popup menu
654  */
655 void SUPERVGUI_CanvasNode::pastePort() {
656   SUPERVGUI_Clipboard::getClipboard()->pastePort( this );
657 }
658
659 /** 
660  * Called on "Edit ports" popup menu command. See SUPERVGUI_ManagePortsDlg.h
661  * for detailed description of the functionality
662  */
663 void SUPERVGUI_CanvasNode::managePorts() {
664   SUPERVGUI_ManagePortsDlg* aDlg = new SUPERVGUI_ManagePortsDlg( this );
665   aDlg->exec();
666   delete aDlg;
667 }
668
669 /**
670  * Called on "Export to Library" popup menu command.  See SUPERVGUI_Library.h
671  * for details on InLine nodes library functionality
672  */
673 void SUPERVGUI_CanvasNode::exportToLib() {
674   SUPERV::INode_var anINode = SUPERV::INode::_narrow( getEngine() );
675   if ( !CORBA::is_nil( anINode ) )
676     SUPERVGUI_Library::getLibrary()->Export( anINode );
677   else
678     SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(), tr( "ERROR" ), tr( "MSG_BAD_INODE" ), tr( "OK" ) );
679 }