1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SUPERVGUI_Service.cxx
25 // Author : Francis KLOSS
28 #include "SUPERVGUI_Service.h"
29 #include "SUPERVGUI_Main.h"
30 #include "SUPERVGUI_Library.h"
31 #include "SUPERVGUI.h"
33 #include "CAM_Application.h"
34 #include "SUIT_Desktop.h"
35 #include "SUIT_FileDlg.h"
36 #include "SUIT_Session.h"
37 #include "SUIT_Tools.h"
39 #include "SALOME_NamingService.hxx"
40 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
44 #include <qtextstream.h>
47 static const char * ComponentIcon[] = {
54 " .................. ",
63 " .................. ",
67 " .. .. .. .. .. .. ",
69 " .. .. .. .. .. .. ",
73 static const char * InterfaceIcon[] = {
101 SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns):
102 QDialog(SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
103 naming(ns), myMFile(0)
105 setSizeGripEnabled( true );
106 setCaption(tr("TIT_SERVICES"));
108 QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 4);
110 myTabPane = new QTabWidget(this);
111 connect(myTabPane, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *)));
113 // Create Tab for Corba services
114 QWidget* aCorbaPane = new QWidget(myTabPane);
115 QVBoxLayout* aBaseLayoutV= new QVBoxLayout(aCorbaPane, 0, 4);
116 aBaseLayoutV->setMargin(5);
117 aBaseLayoutV->setSpacing(10);
119 QHBoxLayout* aBaseLayout = new QHBoxLayout(aCorbaPane); //!!
120 aBaseLayout->setMargin(5);
121 aBaseLayout->setSpacing(10);
123 components = new QListView(aCorbaPane);
124 components->addColumn(tr("COL_COMPONENTS"));
125 components->addColumn(tr("COL_PORTTYPE"));
126 components->addColumn(tr("COL_PORTWAY"));
127 components->setColumnAlignment(1, AlignLeft);
128 components->setColumnAlignment(2, AlignLeft);
129 components->setColumnAlignment(3, AlignLeft);
130 components->setSelectionMode(QListView::Extended);
131 components->setRootIsDecorated(true);
133 // aBaseLayout->addWidget(components);
134 aBaseLayoutV->addWidget(components); //!!
136 //QHGroupBox* aAddBox = new QHGroupBox(tr("TIT_ADDNODE"), aCorbaPane); //!!
137 //aAddBox->setInsideSpacing(20); //!!
139 //NRI QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!!
140 //NRI connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!!
141 //NRI aComputeCBtn->setDefault(false);
143 QPushButton* aComputeBtnDef = new QPushButton(tr("TIT_ADDFNODE"), aCorbaPane);
144 connect(aComputeBtnDef, SIGNAL(clicked()), this, SLOT(addFactoryNodeDef()));
145 aComputeBtnDef->setDefault(true);
147 QPushButton* aComputeBtnCust = new QPushButton(tr("TIT_ADDFNODE_CUST"), aCorbaPane);
148 connect(aComputeBtnCust, SIGNAL(clicked()), this, SLOT(addFactoryNodeCust()));
149 aComputeBtnCust->setDefault(true);
151 aBaseLayout->addWidget(aComputeBtnDef);
152 aBaseLayout->addWidget(aComputeBtnCust);
153 //NRI aBaseLayout->addWidget(aComputeCBtn); //!!
155 aBaseLayoutV->insertLayout(-1, aBaseLayout);
156 myTabPane->addTab(aCorbaPane, tr("MODULES_PANE"));
159 // Create Tab for Python services
160 QWidget* aPythonPane = new QWidget(myTabPane);
161 QVBoxLayout* aPythonLayout = new QVBoxLayout(aPythonPane, 0, 4);
162 aPythonLayout->setMargin(5);
163 aPythonLayout->setSpacing(10);
166 QHGroupBox* aAddBox2 = new QHGroupBox(tr("TIT_ADDNODE"), aPythonPane);
167 aAddBox2->setInsideSpacing(20);
169 /*QLabel* aTypeLbl = */new QLabel(tr("LBL_NODETYPE"), aAddBox2);
171 myTypeCombo = new QComboBox(aAddBox2);
172 myTypeCombo->insertItem( tr( "INLINE_COMP" ) );
173 myTypeCombo->insertItem( tr( "INLINE_SWTC" ) );
174 myTypeCombo->insertItem( tr( "INLINE_LOOP" ) );
175 myTypeCombo->insertItem( tr( "INLINE_GOTO") );
176 connect(myTypeCombo, SIGNAL(activated(int)), this, SLOT(typeNodeSelected(int)));
178 aPythonLayout->addWidget(aAddBox2);
181 myStackWidget = new QWidgetStack(aPythonPane);
184 myScriptPane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY );
185 myOtherId = myStackWidget->addWidget(myScriptPane);
188 QTabWidget* aLoopTabPane = new QTabWidget(myStackWidget);
189 myInitPane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY );
190 aLoopTabPane->addTab(myInitPane, "Init");
192 myMorePane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY );
193 aLoopTabPane->addTab(myMorePane, "More");
195 myNextPane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY );
196 aLoopTabPane->addTab(myNextPane, "Next");
197 myLoopId = myStackWidget->addWidget(aLoopTabPane);
199 myStackWidget->raiseWidget(myOtherId);
201 aPythonLayout->addWidget(myStackWidget, 1);
204 QPushButton* aCreateBtn = new QPushButton(tr("TIT_ADDNODE"), aPythonPane);
205 connect(aCreateBtn, SIGNAL(clicked()), this, SLOT(addInlineNode()));
206 aPythonLayout->addWidget(aCreateBtn);
208 myTabPane->addTab(aPythonPane, tr("INLINE_PANE"));
210 // Create Tab for Macro node only if environmental variable ENABLE_MACRO_NODE is set
211 if ( getenv( "ENABLE_MACRO_NODE" ) != NULL ) {
212 QWidget* aMacroPane = new QWidget(myTabPane);
213 QVBoxLayout* aMacroLayout = new QVBoxLayout(aMacroPane, 0, 4);
214 aMacroLayout->setMargin(5);
215 aMacroLayout->setSpacing(10);
217 QHBoxLayout* aLoadLayout = new QHBoxLayout(aMacroPane); //!!
218 aLoadLayout->addStretch();
220 QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), aMacroPane);
221 connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadGraph()));
223 aLoadLayout->addWidget(aLoadBtn);
225 aMacroLayout->addLayout(aLoadLayout);
227 myMacroPane = new QListView(aMacroPane);
228 myMacroPane->addColumn(tr("COL_COMPONENTS"));
229 myMacroPane->addColumn(tr("COL_PORTTYPE"));
230 myMacroPane->addColumn(tr("COL_PORTWAY"));
231 myMacroPane->setColumnAlignment(1, AlignLeft);
232 myMacroPane->setColumnAlignment(2, AlignLeft);
233 myMacroPane->setColumnAlignment(3, AlignLeft);
234 myMacroPane->setSelectionMode(QListView::Extended);
235 myMacroPane->setRootIsDecorated(true);
236 aMacroLayout->addWidget(myMacroPane); //!!
238 QPushButton* aAddBtn = new QPushButton(tr("TIT_ADDFNODE"), aMacroPane);
239 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(addMacroNode()));
240 aAddBtn->setDefault(true);
242 aMacroLayout->addWidget(aAddBtn);
244 myTabPane->addTab(aMacroPane, tr("MACRO_PANE"));
247 aMainLayout->addWidget(myTabPane);
250 QHBox* aBtnBox = new QHBox(this);
251 QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
252 aBtnLayout->addStretch();
254 QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
255 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
257 aMainLayout->addWidget(aBtnBox);
266 char* getDataStreamParameterName(const char * aType)
268 QString type (aType);
270 if (aType == "int") // 1
272 if (aType == "float") // 2
274 if (aType == "double") // 3
276 if (aType == "string") // 4
278 if (aType == "bool") // 6 ??
284 void SUPERVGUI_Service::initialise() {
285 CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog");
286 SALOME_ModuleCatalog::ModuleCatalog_var *aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
287 *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
288 if (CORBA::is_nil(*aModuleCatalog)) {
289 setCaption("Error in Connexion to omniNames with '/Kernel/ModulCatalog'");
293 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
295 SALOME_ModuleCatalog::ListOfComponents_var lComponents = (*aModuleCatalog)->GetComponentList();
296 long nbComp = lComponents->length();
297 for (int i=0; i<nbComp; i++) {
298 SALOME_ModuleCatalog::Acomponent_ptr C = (*aModuleCatalog)->GetComponent((char *)lComponents[i]);
299 QListViewItem* myComponentItem = new QListViewItem(components, (char*)C->componentusername());
300 myComponentItem->setSelectable(false);
301 QString aIconName = C->component_icone();
302 if (!aIconName.isEmpty()) {
303 QString resFilePath = aResMgr->path(aResMgr->resSection(), C->componentname(), aIconName) ;
305 QPixmap aIcone(resFilePath);
306 QIconSet aIconSet(aIcone);
307 myComponentItem->setPixmap(0, aIconSet.pixmap(QIconSet::Small, QIconSet::Normal));
309 myComponentItem->setPixmap(0, ComponentIcon);
312 myComponentItem->setPixmap(0, ComponentIcon);
314 SALOME_ModuleCatalog::ListOfInterfaces* lInterfaces = C->GetInterfaceList();
315 long nbInterf = lInterfaces->length();
316 for (int j=0; j<nbInterf; j++) {
317 SALOME_ModuleCatalog::DefinitionInterface* Interface = C->GetInterface((char*)(*lInterfaces)[j]);
318 QListViewItem* myInterfaceItem = new QListViewItem(myComponentItem, (char*)Interface->interfacename);
319 myInterfaceItem->setSelectable(false);
320 myInterfaceItem->setPixmap(0, InterfaceIcon);
322 long nbServices = Interface->interfaceservicelist.length();
323 for (int k=0; k<nbServices; k++) {
324 SALOME_ModuleCatalog::Service* Service = &(Interface->interfaceservicelist[k]);
325 QListViewItem* myServiceItem = new QListViewItem(myInterfaceItem, (char*)Service->ServiceName);
326 myServiceItem->setSelectable(true);
327 //components->ensureItemVisible(myServiceItem);
329 long nbPortsOut = Service->ServiceoutParameter.length();
330 for (int m=0; m<nbPortsOut; m++) {
331 SALOME_ModuleCatalog::ServicesParameter* PortOut = &(Service->ServiceoutParameter[m]);
332 QListViewItem* myPortOutItem =
333 new QListViewItem(myServiceItem, (char*)PortOut->Parametername, (char*)PortOut->Parametertype, "Out");
334 myPortOutItem->setSelectable(false);
337 long nbStreamPortsOut = Service->ServiceoutDataStreamParameter.length();
338 for (int m=0; m<nbStreamPortsOut; m++) {
339 SALOME_ModuleCatalog::ServicesDataStreamParameter* PortOut =
340 &(Service->ServiceoutDataStreamParameter[m]);
341 QListViewItem* myPortOutItem =
342 new QListViewItem(myServiceItem, (char*)PortOut->Parametername,
343 getDataStreamParameterName(PortOut->Parametertype), "DataStream Out");
344 myPortOutItem->setSelectable(false);
347 long nbPortsIn = Service->ServiceinParameter.length();
348 for (int l=0; l<nbPortsIn; l++) {
349 SALOME_ModuleCatalog::ServicesParameter* PortIn = &(Service->ServiceinParameter[l]);
350 QListViewItem* myPortInItem =
351 new QListViewItem(myServiceItem, (char*)PortIn->Parametername, (char*)PortIn->Parametertype, "In");
352 myPortInItem->setSelectable(false);
355 long nbStreamPortsIn = Service->ServiceinDataStreamParameter.length();
356 for (int l=0; l<nbStreamPortsIn; l++) {
357 SALOME_ModuleCatalog::ServicesDataStreamParameter* PortIn = &(Service->ServiceinDataStreamParameter[l]);
358 QListViewItem* myPortInItem =
359 new QListViewItem(myServiceItem, (char*)PortIn->Parametername,
360 getDataStreamParameterName(PortIn->Parametertype), "DataStream In");
361 myPortInItem->setSelectable(false);
370 SUPERVGUI_Service::~SUPERVGUI_Service() {
371 Trace("SUPERVGUI_Service::~SUPERVGUI_Service")
372 if (myMFile) delete myMFile;
375 void SUPERVGUI_Service::addComputeNode() {
376 SUIT_Desktop* aDesktop = SUIT_Session::session()->activeApplication()->desktop();
377 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
378 if ( !anApp ) return;
380 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
382 MESSAGE("NULL Supervision module!");
386 SUPERVGUI_Main* aMain = aSupMod->getMain();
388 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
389 } else if (!aMain->isEditable()) {
390 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
392 CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog");
393 SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
394 *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
395 if (CORBA::is_nil(*aModuleCatalog)) {
396 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
400 QListViewItemIterator i(components);
401 for (; i.current(); ++i) {
403 if (item->isSelected()) {
404 const char* service = item->text(0).latin1();
405 const char* interface = item->parent()->text(0).latin1();
406 const char* component = item->parent()->parent()->text(0).latin1();
407 SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(anApp->moduleName(component));
408 if ( myComponent == NULL ) {
409 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
412 const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
413 SUPERV_CNode aNode = aMain->getDataflow()->CNode(*myService);
414 if ( CORBA::is_nil( aNode ) ) {
415 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
419 SUPERV::INode_var aDummyEndNode;
420 addNode( aNode, aDummyEndNode, myX, myY );
421 b = true; // at least one node was added
426 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
432 void SUPERVGUI_Service::addFactoryNodeDef() {
433 SUIT_Desktop* aDesktop = SUIT_Session::session()->activeApplication()->desktop();
434 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
435 if ( !anApp ) return;
437 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
439 MESSAGE("NULL Supervision module!");
443 SUPERVGUI_Main* aMain = aSupMod->getMain();
445 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
446 } else if (!aMain->isEditable()) {
447 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
449 CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog");
450 SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
451 *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
452 if (CORBA::is_nil(*aModuleCatalog)) {
453 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
457 QListViewItemIterator i(components);
458 for (; i.current(); ++i) {
460 if (item->isSelected()) {
461 const char* service = item->text(0).latin1();
462 const char* interface = item->parent()->text(0).latin1();
463 //const char* component = anApp->moduleName(item->parent()->parent()->text(0).latin1());
464 // mkr : PAL13135 -->
465 if ( aSupMod->getInterfaceNameMap().contains(item->parent()->parent()->text(0)) ) {
466 const char* component = aSupMod->getInterfaceNameMap().find(item->parent()->parent()->text(0)).data();
467 // mkr : PAL13135 <--
469 SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
470 if (myComponent==NULL) {
471 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
474 const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
476 if ( myService->TypeOfNode == 0 ) { // ComputeNode
477 aNode = aMain->getDataflow()->CNode(*myService);
478 if (CORBA::is_nil( aNode ) ) {
479 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
483 else { // Factory Node
484 aNode = aMain->getDataflow()->FNode(component, interface, *myService, myComponent->implementation_type()); // mkr : PAL11273
485 if ( CORBA::is_nil( aNode ) ) {
486 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
490 SUPERV::INode_var aDummyEndNode;
491 addNode( aNode, aDummyEndNode, myX, myY );
498 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
504 void SUPERVGUI_Service::addFactoryNodeCust() {
505 SUIT_Desktop* aDesktop = SUIT_Session::session()->activeApplication()->desktop();
506 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
507 if ( !anApp ) return;
509 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
511 MESSAGE("NULL Supervision module!");
515 SUPERVGUI_Main* aMain = aSupMod->getMain();
517 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
518 } else if (!aMain->isEditable()) {
519 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
521 CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog");
522 SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
523 *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
524 if (CORBA::is_nil(*aModuleCatalog)) {
525 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
530 QListViewItemIterator iSel(components);
532 for (; iSel.current(); ++iSel) { // check : how many objects are selected (single or multi)
533 item = iSel.current();
534 if (item->isSelected()) count++;
535 if ( count > 1) break;
538 QListViewItemIterator i(components);
539 QString anAuthor, aContainer, aComment;
540 bool DoneSetting = false;
542 for (; i.current(); ++i) {
544 if (item->isSelected()) {
545 const char* service = item->text(0).latin1();
546 const char* interface = item->parent()->text(0).latin1();
547 //const char* component = anApp->moduleName(item->parent()->parent()->text(0).latin1());
548 // mkr : PAL13135 -->
549 if ( aSupMod->getInterfaceNameMap().contains(item->parent()->parent()->text(0)) ) {
550 const char* component = aSupMod->getInterfaceNameMap().find(item->parent()->parent()->text(0)).data();
551 // mkr : PAL13135 <--
553 SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
554 if (myComponent==NULL) {
555 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
558 const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
560 if ( myService->TypeOfNode == 0 ) { // ComputeNode
561 aNode = aMain->getDataflow()->CNode(*myService);
562 if (CORBA::is_nil( aNode ) ) {
563 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
567 else { // Factory Node
569 SUPERVGUI_CustomSettings* aCSDialog = 0;
570 if ( count > 1 && !DoneSetting) { // multi selection
572 aCSDialog = new SUPERVGUI_CustomSettings(item, true, myComponent->implementation_type());
574 else if ( count == 1 ) // single selection
575 aCSDialog = new SUPERVGUI_CustomSettings(item, false, myComponent->implementation_type());
578 aRes = aCSDialog->exec();
580 anAuthor = aCSDialog->Author();
581 aContainer = aCSDialog->Container();
582 aComment = aCSDialog->Comment();
587 aNode = aMain->getDataflow()->FNode(component, interface, *myService, myComponent->implementation_type()); // mkr : PAL11273
588 if ( CORBA::is_nil( aNode ) ) {
589 QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
594 aNode->SetAuthor(anAuthor.latin1());
595 SUPERV::FNode::_narrow(aNode)->SetContainer(aContainer.latin1());
596 aNode->SetComment(aComment.latin1());
600 SUPERV::INode_var aDummyEndNode;
601 addNode( aNode, aDummyEndNode, myX, myY );
608 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
614 void SUPERVGUI_Service::addInlineNode() {
615 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
617 MESSAGE("NULL Supervision module!");
621 SUPERVGUI_Main* aMain = aSupMod->getMain();
623 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
625 else if (!aMain->isEditable()) {
626 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
629 int aSel = myTypeCombo->currentItem();
631 case 0: // Computation
634 aMain->getDataflow()->INode(myScriptPane->getFuncName().isEmpty() ? "" : myScriptPane->getFuncName().latin1(),
635 (myScriptPane->getFunction()).in());
636 if (CORBA::is_nil(aNode)) {
637 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
640 SUPERV::INode_var aDummyEndNode;
642 // 1) parse nodes' python function to find ports names
643 // 2) create ports for engine node with found names and "undefined" types
644 // ( aNode->InPort(name,type), aNode->OutPort(name,type) )
645 // P.S. CanvasNode->createPort(...) for create presentation of port
646 // will be called from addNode(...) (inside CanvasNode constructor)
647 addNode( aNode, aDummyEndNode, myX, myY );
653 SUPERV_INode aEndNode;
654 SUPERV_CNode aStartNode =
655 aMain->getDataflow()->SNode(myScriptPane->getFuncName().isEmpty() ? "" : myScriptPane->getFuncName().latin1(),
656 (myScriptPane->getFunction()).in(),
658 if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) {
659 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
662 addNode( aStartNode, aEndNode, myX, myY );
668 SUPERV_INode aEndNode;
669 SUPERV_CNode aStartNode =
670 aMain->getDataflow()->LNode(myInitPane->getFuncName().isEmpty() ? "" : myInitPane->getFuncName().latin1(),
671 (myInitPane->getFunction()).in(),
672 myMorePane->getFuncName().isEmpty() ? "" : myMorePane->getFuncName().latin1(),
673 (myMorePane->getFunction()).in(),
674 myNextPane->getFuncName().isEmpty() ? "" : myNextPane->getFuncName().latin1(),
675 (myNextPane->getFunction()).in(),
677 if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) {
678 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
681 addNode( aStartNode, aEndNode, myX, myY );
687 SUPERV_CNode aGotoNode;
688 if (myScriptPane->isDefined())
689 aGotoNode = aMain->getDataflow()->GNode(myScriptPane->getFuncName().latin1(),
690 (myScriptPane->getFunction()).in(), "");
692 aGotoNode = aMain->getDataflow()->GNode("GoTo", (myScriptPane->getFunction()).in(), "");
693 if (CORBA::is_nil(aGotoNode)) {
694 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
697 SUPERV::INode_var aDummyEndNode;
698 addNode( aGotoNode, aDummyEndNode, myX, myY );
705 void SUPERVGUI_Service::addMacroNode() {
706 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
708 MESSAGE("NULL Supervision module!");
712 SUPERVGUI_Main* aMain = aSupMod->getMain();
714 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
716 else if (!aMain->isEditable()) {
717 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
722 if (aMain->getDataflow()->IsStreamGraph()) {
723 SUPERV_StreamGraph aSGraph = aMain->getDataflow()->ToStreamGraph();
724 if (!SUPERV_isNull(aSGraph))
725 aNode = aSGraph->StreamMNode(myMFile->name().latin1());
726 // TMP: while stream macro nodes doesn't impemented
727 if (CORBA::is_nil(aNode)) {
728 aNode = aSGraph->MNode(myMFile->name().latin1());
732 aNode = aMain->getDataflow()->MNode(myMFile->name().latin1());
733 if (CORBA::is_nil(aNode)) {
734 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
738 SUPERV::INode_var aDummyEndNode;
739 addNode( aNode, aDummyEndNode, myX, myY );
742 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NONODE_TOADD"));
747 void SUPERVGUI_Service::loadGraph() {
748 if ( getenv( "ENABLE_MACRO_NODE" ) == NULL )
749 // error! if ENABLE_MACRO_NODE is set - we should NOT get here by any means..
751 //MESSAGE("Error: ENABLE_MACRO_NODE is not set, but loadGraph() was called!");
755 QString aFileName = SUIT_FileDlg::getFileName(SUIT_Session::session()->activeApplication()->desktop(),
758 tr("MSG_GRAPH_INSERT"),
760 if (aFileName.isEmpty()) return;
762 myMacroPane->clear();
764 myMFile = new QFile(aFileName);
765 if (!myMFile->open(IO_ReadOnly)) {
766 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"),
767 tr("MSG_CANT_LOADSCRIPT"));
768 delete myMFile; myMFile = 0;
772 QTextStream* aStream = new QTextStream(myMFile);
773 if (aStream->atEnd()) {
774 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"),
775 tr("MSG_EMTY_FILE"));
778 delete myMFile; myMFile = 0;
783 // temporary display only file name
784 QFileInfo anInfo(*myMFile);
785 QListViewItem* anItem = new QListViewItem(myMacroPane, anInfo.baseName());
786 anItem->setSelectable(true);
789 void SUPERVGUI_Service::typeNodeSelected(int theRow) {
791 myStackWidget->raiseWidget(myLoopId);
793 myStackWidget->raiseWidget(myOtherId);
798 void SUPERVGUI_Service::choose() {
799 Trace("SUPERVGUI_Service::choose")
805 void SUPERVGUI_Service::showEvent(QShowEvent* theEvent) {
806 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
808 MESSAGE("NULL Supervision module!");
812 SUPERVGUI_Main* aMain = aSupMod->getMain();
813 if (aMain && (!aMain->isArrayShown())) {
814 aMain->getArrayView()->viewportToContents(0, 0, myX, myY);
815 //aMain->getGraph()->viewportToContents(0, 0, myX, myY);
817 QDialog::showEvent(theEvent);
821 void SUPERVGUI_Service::tabChanged(QWidget* theWidget) {
822 myIsInline = (myTabPane->currentPageIndex() == 1);
827 //*****************************************************/
828 // Pane for Python script editing
829 //*****************************************************/
830 SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane( QWidget* theParent, const bool isNodeCreation, int& theX, int& theY )
831 : myIsWithLibrary( isNodeCreation ),
833 myX( theX ), myY( theY )
835 QGridLayout* aEditLayout = new QGridLayout( this, 2, 8, 0, 6 );
838 if ( myIsWithLibrary ) {
839 QPushButton* aLibBtn = new QPushButton(tr("BUT_LIBRARY"), this);
840 connect(aLibBtn, SIGNAL(clicked()), this, SLOT(library()));
841 aEditLayout->addMultiCellWidget( aLibBtn, 0, 0, 1, 2 );
844 QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), this);
845 connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadFile()));
847 aEditLayout->addMultiCellWidget( aLoadBtn, 0, 0, 3, 4 );
849 myFunctionsCombo = new QComboBox( this );
850 connect( myFunctionsCombo, SIGNAL( activated( int ) ), this, SLOT( readFunction( int ) ) );
852 aEditLayout->addMultiCellWidget( myFunctionsCombo, 0, 0, 5, 7 );
855 myText = new QTextEdit(this);
856 myText->setTextFormat( Qt::PlainText ); // NOT rich text, so text() returns plain text
857 myText->setWordWrap( QTextEdit::FixedColumnWidth );
858 myText->setWrapColumnOrWidth( 80 );
859 connect( myText, SIGNAL( returnPressed() ), this, SLOT( autoIndentLine() ) );
861 aEditLayout->addMultiCellWidget( myText, 1, 1, 0, 7 );
862 //aEditLayout->setColStretch( 3, 1 ); // to allow myFunctionsCombo be larger when needed
866 * Return a text between "def" and "("
867 * "def" must begin with position 0, which means that only global function definitions are possible
869 QString getFunctionName( const QString& aLine ) {
870 int aDefPos = aLine.find("def");
871 if ( aDefPos == 0 ) { // only global function definitions!
872 int aStart = aLine.find(" ", aDefPos);
873 int aEnd = aLine.find("(", aStart);
874 QString aName = aLine.mid(aStart, (aEnd-aStart));
875 return aName.stripWhiteSpace();
881 * Searches for text beginning with "def" and ending with any meanful character at
882 * beginning of line. Starts searching with current position of given stream.
883 * Fills the myPyFunctions with strings corresponding to found fucntions.
885 void SUPERVGUI_PythonEditPane::initPyFunctions( QTextStream& theStream ) {
887 if ( theStream.atEnd() )
891 QString aLine = theStream.readLine();
893 while ( !theStream.atEnd() ) { // not EOF
895 // asv : 23.11.04 : fix for PAL6870 : skip empty lines in the beginning or between functions
896 // find("def)==0 -> analizing only global function definitions which start with 0 indentation
897 while ( !aLine.isNull() && aLine.find( "def" ) != 0 )
898 aLine = theStream.readLine();
900 if ( !aLine.isNull() && aLine.find("def") == 0 ) {
901 myFunctionsCombo->insertItem( getFunctionName( aLine ) ); // aLine now == function name
903 aPyFunction += aLine;
906 // read function body
907 aLine = theStream.readLine();
908 // asv : 23.11.04 : added "|| aLine.isEmpty()" - fix for PAL6870. readLine() returns an empty
909 // string for "\n" string, it trails \n caracter. but we accept such lines..
910 // asv : 22.12.04 : aLine[0].isSpace() || aLine[0]=='#' -> line must begin with space or tab
911 // (a normal code with indentation) or comment sign.
912 while ( !aLine.isNull() && ( aLine.isEmpty() || aLine[0].isSpace() || aLine[0] == '#' ) ) {
913 aPyFunction += aLine;
915 aLine = theStream.readLine();
918 myPyFunctions << aPyFunction;
919 aPyFunction.setLength( 0 );
925 * Load existing Python script
927 void SUPERVGUI_PythonEditPane::loadFile() {
928 QString aFileName = SUIT_FileDlg::getFileName(SUIT_Session::session()->activeApplication()->desktop(),
931 tr("TIT_LOADSCRIPT"),
933 if (aFileName.isEmpty()) return;
935 QFile aFile( aFileName );
936 if (!aFile.open(IO_ReadOnly)) {
937 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"),
938 tr("MSG_CANT_LOADSCRIPT"));
942 myPyFunctions.clear();
943 myFunctionsCombo->clear();
946 QTextStream aFileReader(&aFile);
947 if ( aFileReader.atEnd() ) {
948 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_EMTY_FILE"));
953 initPyFunctions( aFileReader );
955 if ( myPyFunctions.size() )
960 * Finds and Reads a function from current position in the opened file
961 * asv : Comment above is old! Present model: just take an already read string = PyFunction
962 * from the list which is filled in loadFile().
964 void SUPERVGUI_PythonEditPane::readFunction( int i ) {
966 if ( i != -1 && myPyFunctions.size() && myPyFunctions.size() > i )
967 myText->append( myPyFunctions[ i ] );
969 // asv : 30.11.04 : 2.7 - Inline node function editor improvement
970 // 2.7.1 - set focus to editor widget on editor window opening
971 // 2.7.2 - scroll to the beginning of function on editor window opening
973 myText->ensureVisible( 0,0 );
977 * Returns the text after "def" and before "(" -- first defined function name
979 QString SUPERVGUI_PythonEditPane::getFuncName() {
980 for (int i=0; i < myText->paragraphs(); i++) {
981 QString aName = getFunctionName( myText->text(i) );
982 if ( !aName.isEmpty() )
989 * Returns the contents of the myText widget without trailing spacing
991 SUPERV_Strings SUPERVGUI_PythonEditPane::getFunction() {
992 SUPERV_Strings aStrings = new SUPERV::ListOfStrings();
993 aStrings->length(myText->paragraphs());
994 for (int i=0; i < myText->paragraphs(); i++) {
995 QString aLine = myText->text(i);
996 // asv : 30.11.04 - why do we have to remove trailing spaces??
997 // it's user's responsibility to enter correct Python code, we don't do anything with it.
998 // if (..) -- initial, while(..) -- my improvement, but also commented out -- needless.
999 //if (!aLine.right(1).compare(" ")) // replaced with the line below -- loop
1000 // uncommented by mkr to fix bugs IPAL12363, IPAL12885 -->
1001 while (aLine.at(aLine.length()-1).isSpace()) // remove trailing spaces
1002 aLine = aLine.remove(aLine.length()-1,1);
1004 aStrings[i] = CORBA::string_dup(aLine.latin1());
1006 return aStrings._retn();
1010 void SUPERVGUI_PythonEditPane::setFunction(SUPERV_Strings theStr) {
1012 for ( int i=0, aLen = theStr->length(); i < aLen; i++ )
1013 myText->append(QString(theStr[i]));
1015 // asv : 30.11.04 : 2.7 - Inline node function editor improvement
1016 // 2.7.1 - set focus to editor widget on editor window opening
1017 // 2.7.2 - scroll to the beginning of function on editor window opening
1019 myText->ensureVisible( 0,0 );
1023 * Automatic indentation rule: if a previous line ended with
1024 * ':', then add N additional spaces in the current line. If no ':' found, then
1025 * the same amount of spaces as in the previous line is added. Connected to
1026 * "returnPressed" signal of myText text edit.
1028 void SUPERVGUI_PythonEditPane::autoIndentLine() {
1029 const int N = 4; // width of indentation "tab"
1030 if ( myText && myText->paragraphs() ) {
1032 // get current cursor position and previous line (the one to be analized)
1035 myText->getCursorPosition( ¶, &pos ); // pos==0, beginning of line
1036 if ( myText->paragraphLength(para-1) > 0 ) { // mkr : IPAL9817
1037 QString line = myText->text( para-1 ); // previous paragraph line
1039 // construct a string containing all leading space characters of previous line (tabs, etc.)
1041 while ( line[++i].isSpace() ) // append all isSpace() characters at beginning of line to spacesStr
1042 spacesStr += line[i];
1044 // if ':' was found -- add more spaces to spacesStr
1045 line = line.stripWhiteSpace();
1046 if ( line[ line.length()-1 ] == ':' ) {
1053 // ok, append spacesStr at the beginning of the current line = make indentation
1054 myText->insertAt( spacesStr, para, pos );
1055 myText->setCursorPosition( para, pos+spacesStr.length() );
1060 * Create a node by loading it from an external XML library file
1061 * This slot opens a dialog box which then "lives" by itself..
1063 void SUPERVGUI_PythonEditPane::library() {
1064 // if CanImport() returns false, it displays an error message box, so there is no need to
1065 // display such message here ("library file not found", etc.).
1066 if ( SUPERVGUI_Library::getLibrary()->CanImport() ) {
1067 SUPERVGUI_LibDlg* aDlg = new SUPERVGUI_LibDlg( this, myX, myY );
1073 * Edit Python dialog
1075 SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg( bool isLoop )
1076 :QDialog(SUIT_Session::session()->activeApplication()->desktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1078 setSizeGripEnabled( true );
1079 setCaption(tr("TIT_FUNC_PYTHON"));
1081 QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 4);
1082 int a,b; // dummies for PythonEditPane, not used, since library = false and myX, myY are not used in PythonEditPane
1083 myIsLoop = isLoop; // mkr : PAL12236
1085 QTabWidget* aLoopTabPane = new QTabWidget(this);
1086 myInitPane = new SUPERVGUI_PythonEditPane( this, false, a, b ); // library == false, since no creation of a node is needed here
1087 aLoopTabPane->addTab(myInitPane, "Init");
1089 myMorePane = new SUPERVGUI_PythonEditPane( this, false, a, b );
1090 aLoopTabPane->addTab(myMorePane, "More");
1092 myNextPane = new SUPERVGUI_PythonEditPane( this, false, a, b );
1093 aLoopTabPane->addTab(myNextPane, "Next");
1095 aMainLayout->addWidget(aLoopTabPane);
1097 myEditPane = new SUPERVGUI_PythonEditPane( this, false, a, b );
1098 aMainLayout->addWidget(myEditPane);
1100 QGroupBox* aBtnBox = new QGroupBox( this );
1101 aBtnBox->setColumnLayout( 0, Qt::Vertical );
1102 aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
1103 QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
1104 aBtnLayout->setAlignment( Qt::AlignTop );
1105 aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
1107 QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
1108 connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
1109 aBtnLayout->addWidget( aOKBtn );
1111 aBtnLayout->addStretch();
1113 QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox );
1114 connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
1115 aBtnLayout->addWidget( aCancelBtn );
1117 aMainLayout->addWidget(aBtnBox);
1120 // mkr : IPAL9817 : to avoid a SIGSEGV when INode_Impl::SetPyFunction(...)
1121 // will call with null python function name
1122 void SUPERVGUI_EditPythonDlg::clickOnOk()
1125 bool hasEmptyName = myIsLoop ?
1126 ( getInitFuncName().isEmpty() || getMoreFuncName().isEmpty() || getNextFuncName().isEmpty() ) :
1127 getFuncName().isEmpty();
1130 QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr( "ERROR" ), tr( "MSG_INCORRECT_INDENT" ) );
1136 * Do the following actions for newly created Engine's CNode:
1137 * 1. Create a presentation for it (CanvasNode)
1138 * 2. Place the CanvasNode to the current top-left corner or the current viewport
1139 * 3. Increment the coordinates of the next CanvasNode (new nodes are "cascaded" when several of them are created at once)
1140 * PS theEndNode is passed only for Loop and Switch nodes (EndLoop and EndSwitch)
1142 void SUPERVGUI_Service::addNode( SUPERV::CNode_var theNode, SUPERV::INode_var theEndNode, int& theX, int& theY ) {
1143 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1145 MESSAGE("NULL Supervision module!");
1149 SUPERVGUI_Main* aMain = aSupMod->getMain();
1151 if ( !CORBA::is_nil( theNode ) && aMain ) {
1153 aMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> PAL7960
1155 int cx, cy; //to appear a new node in the top-left corner of the current viewport
1157 //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
1158 QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
1159 aMain->getCanvasView()->viewportToContents(theX, theY, cx, cy);
1161 //2.8 point of improvements:
1162 cx = (int)((double)cx/aWM.m11());
1163 cy = (int)((double)cy/aWM.m22());
1164 theNode->Coords(cx, cy);
1165 if ( !CORBA::is_nil( theEndNode ) )
1166 theEndNode->Coords(cx + LABEL_WIDTH*2, cy);
1167 theX += (int)(NODE_DX*aWM.m11());
1168 theY += (int)(NODE_DY*aWM.m22());
1170 if ( theNode->IsGOTO() )
1171 aMain->addGOTONode( theNode );
1172 else if ( theNode->IsMacro() )
1173 aMain->addMacroNode( theNode );
1174 else if ( theNode->IsLoop() || theNode->IsSwitch() )
1175 aMain->addControlNode( theNode, SUPERV::CNode::_narrow( theEndNode ), true );
1177 aMain->addComputeNode( theNode );
1178 aSupMod->nullifyInitialVF();
1185 SUPERVGUI_CustomSettings::SUPERVGUI_CustomSettings(QListViewItem* theItem,
1188 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1190 Trace("SUPERVGUI_CustomSettings::SUPERVGUI_CustomSettings");
1192 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1194 MESSAGE("NULL Supervision module!");
1198 SUIT_Desktop* aDesktop = SUIT_Session::session()->activeApplication()->desktop();
1200 setSizeGripEnabled( true );
1202 QGridLayout* TopLayout = new QGridLayout( this );
1203 TopLayout->setSpacing( 6 );
1204 TopLayout->setMargin( 11 );
1206 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1207 TopGroup->setColumnLayout(0, Qt::Vertical );
1208 TopGroup->layout()->setSpacing( 0 );
1209 TopGroup->layout()->setMargin( 0 );
1210 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1211 TopGroupLayout->setAlignment( Qt::AlignTop );
1212 TopGroupLayout->setSpacing( 6 );
1213 TopGroupLayout->setMargin( 11 );
1215 QLabel* authL = new QLabel( tr( "AUTHOR_LBL" ), TopGroup);
1216 authV = new QLineEdit( TopGroup );
1217 authV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1218 authV->setMinimumSize( 200, 0 );
1219 authV->setText( "" );
1221 contL = new QLabel( tr( "CONTAINER_LBL" ), TopGroup );
1222 contV = new QLineEdit( TopGroup );
1223 contV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1224 contV->setMinimumSize( 200, 0 );
1226 QLabel* commL = new QLabel( tr( "COMMENT_LBL" ), TopGroup);
1227 commV = new QMultiLineEdit( TopGroup );
1228 commV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
1229 commV->setMinimumSize( 200, 100 );
1231 if ( !aSupMod->getInterfaceNameMap().contains(theItem->parent()->parent()->text(0)) ) {
1232 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
1235 const char* component = aSupMod->getInterfaceNameMap().find(theItem->parent()->parent()->text(0)).data();
1237 QString aNodeDefComment;
1238 if ( !isMultiSel ) {
1240 const char* service = theItem->text(0).latin1();
1241 aNodeDefComment = QString(service) + QString(tr("COMMENT_FROM")) + QString(component);
1242 setCaption( tr( "TLT_CUSTOMPARAMETERS_SINGLE" ) + aNodeDefComment );
1246 aNodeDefComment = QString("Factory Node");
1247 setCaption( tr( "TLT_CUSTOMPARAMETERS_MULTI" ) );
1251 SUPERVGUI_Main* aMain = aSupMod->getMain();
1253 QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
1256 const char* aContainer = aMain->getDataflow()->ContainerNameForComponent(component);
1257 if ( aContainer && strlen(aContainer) > 0 )
1258 contV->setText( QString(aContainer) );
1259 else if ( isCimpl ) // C++ implementation
1260 contV->setText( QString(aMain->getDataflow()->DefaultCContainerName()) );
1261 else // Python implementation
1262 contV->setText( QString(aMain->getDataflow()->DefaultPythonContainerName()) );
1265 commV->setText( aNodeDefComment );
1267 TopGroupLayout->addWidget( authL, 1, 0 );
1268 TopGroupLayout->addWidget( authV, 1, 1 );
1269 TopGroupLayout->addWidget( contL, 2, 0 );
1270 TopGroupLayout->addWidget( contV, 2, 1 );
1271 TopGroupLayout->addWidget( commL, 7, 0 );
1272 TopGroupLayout->addMultiCellWidget( commV, 7, 8, 1, 1 );
1273 TopGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 8, 0 );
1274 TopGroupLayout->setColStretch( 1, 5 );
1276 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1277 GroupButtons->setColumnLayout(0, Qt::Vertical );
1278 GroupButtons->layout()->setSpacing( 0 );
1279 GroupButtons->layout()->setMargin( 0 );
1280 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1281 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1282 GroupButtonsLayout->setSpacing( 6 );
1283 GroupButtonsLayout->setMargin( 11 );
1285 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1286 connect( okB, SIGNAL( clicked() ), this, SLOT( okButton() ) );
1287 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1288 connect( cancelB, SIGNAL( clicked() ), this, SLOT( koButton() ) );
1290 GroupButtonsLayout->addWidget( okB, 0, 0 );
1291 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1292 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1294 TopLayout->addWidget( TopGroup, 0, 0 );
1295 TopLayout->addWidget( GroupButtons, 1, 0 );
1296 TopLayout->setRowStretch( 0, 1 );
1297 TopLayout->setRowStretch( 1, 0 );
1305 SUPERVGUI_CustomSettings::~SUPERVGUI_CustomSettings() {
1306 Trace("SUPERVGUI_CustomSettings::~SUPERVGUI_CustomSettings");
1312 QString SUPERVGUI_CustomSettings::Author() {
1313 return authV->text();
1319 QString SUPERVGUI_CustomSettings::Container() {
1320 return contV->text();
1326 QString SUPERVGUI_CustomSettings::Comment() {
1327 return commV->text();
1333 void SUPERVGUI_CustomSettings::okButton() {
1334 Trace("SUPERVGUI_CustomSettings::okButton");
1339 <Cancel> button slot
1341 void SUPERVGUI_CustomSettings::koButton() {
1342 Trace("SUPERVGUI_CustomSettings::koButton");