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