1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <PythonNode.hxx>
24 #include <SALOME_ResourcesManager.hxx>
25 #include <SALOME_LifeCycleCORBA.hxx>
27 #include <YACSGui_InputPanel.h>
28 #include <YACSGui_Module.h>
29 #include <YACSGui_PlusMinusGrp.h>
30 #include <YACSGui_Table.h>
31 #include <YACSGui_Graph.h>
32 #include <YACSGui_Executor.h>
33 #include <YACSGui_TreeView.h>
34 #include <YACSGui_TreeViewItem.h>
35 #include <YACSGui_LogViewer.h>
37 #include <YACSPrs_ElementaryNode.h>
39 #include <QxGraph_Canvas.h>
41 #include <LightApp_Application.h>
42 #include <CAM_Application.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_Application.h>
45 #include <SUIT_MessageBox.h>
46 #include <LogWindow.h>
49 #include <OutPort.hxx>
50 #include <InputPort.hxx>
51 #include <OutputPort.hxx>
52 #include <CalStreamPort.hxx>
53 #include <ConditionInputPort.hxx>
54 #include <ForLoop.hxx>
55 #include <ForEachLoop.hxx>
56 #include <WhileLoop.hxx>
58 #include <CORBAPorts.hxx>
59 #include <PythonPorts.hxx>
60 #include <XMLPorts.hxx>
61 #include <DataNode.hxx>
62 #include <PresetNode.hxx>
63 #include <OutNode.hxx>
64 #include <StudyNodes.hxx>
65 #include <InlineNode.hxx>
66 #include <ServiceNode.hxx>
67 #include <ServiceInlineNode.hxx>
68 #include <CORBANode.hxx>
69 #include <SalomePythonNode.hxx>
70 #include <CppNode.hxx>
71 #include <XMLNode.hxx>
72 #include <Exception.hxx>
73 #include <Catalog.hxx>
74 #include <ComponentDefinition.hxx>
75 #include <CORBAComponent.hxx>
76 #include <CppComponent.hxx>
77 #include <SalomeComponent.hxx>
78 #include <SalomePythonComponent.hxx>
79 #include <RuntimeSALOME.hxx>
81 #include <qwindowsstyle.h>
82 #include <qpushbutton.h>
86 #include <qlineedit.h>
87 #include <qbuttongroup.h>
88 #include <qradiobutton.h>
89 #include <qcombobox.h>
90 #include <qtextedit.h>
91 #include <qtoolbutton.h>
93 #include <qprogressbar.h>
94 #include <qobjectlist.h>
95 #include <qfiledialog.h>
96 #include <qcheckbox.h>
101 #include "YacsTrace.hxx"
106 using namespace YACS;
107 using namespace YACS::ENGINE;
108 using namespace YACS::HMI;
112 QColor getColor( int theStatus )
117 case UNDEFINED: aColor = Qt::lightGray; break;
118 case INVALID: aColor = Qt::red; break;
119 case READY: aColor = Qt::green; break;
120 case TOLOAD: aColor = Qt::darkYellow; break;
121 case LOADED: aColor = Qt::darkMagenta; break;
122 case TOACTIVATE: aColor = Qt::darkCyan; break;
123 case ACTIVATED: aColor = Qt::darkBlue; break;
124 case DESACTIVATED: aColor = Qt::gray; break;
125 case DONE: aColor = Qt::darkGreen; break;
126 case SUSPENDED: aColor = Qt::gray; break;
127 case LOADFAILED: aColor.setHsv(320,255,255); break;
128 case EXECFAILED: aColor.setHsv( 20,255,255); break;
129 case PAUSE: aColor.setHsv(180,255,255); break;
130 case INTERNALERR: aColor.setHsv(340,255,255); break;
131 case DISABLED: aColor.setHsv( 40,255,255); break;
132 case FAILED: aColor.setHsv( 20,255,255); break;
133 case ERROR: aColor.setHsv( 0,255,255); break;
134 default: aColor = Qt::lightGray;
139 std::string portValueType( YACS::ENGINE::TypeCode* theTC )
141 std::string aType = "";
142 switch ( theTC->kind() )
144 case Double: aType = "double"; break;
145 case Int: aType = "int"; break;
146 case String: aType = "string"; break;
147 case Bool: aType = "bool"; break;
148 case Objref: aType = "objref"; break;
149 case Sequence: aType = "sequence"; break;
150 case Array: aType = "array"; break;
151 case Struct: aType = "struct"; break;
157 QString getText( int theStatus )
162 case UNDEFINED: aText = "UNDEFINED"; break;
163 case INVALID: aText = "INVALID"; break;
164 case READY: aText = "READY"; break;
165 case TOLOAD: aText = "TOLOAD"; break;
166 case LOADED: aText = "LOADED"; break;
167 case TOACTIVATE: aText = "TOACTIVATE"; break;
168 case ACTIVATED: aText = "ACTIVATED"; break;
169 case DESACTIVATED: aText = "DESACTIVATED"; break;
170 case DONE: aText = "DONE"; break;
171 case SUSPENDED: aText = "SUSPENDED"; break;
172 case LOADFAILED: aText = "LOADFAILED"; break;
173 case EXECFAILED: aText = "EXECFAILED"; break;
174 case PAUSE: aText = "PAUSE"; break;
175 case INTERNALERR: aText = "INTERNALERR"; break;
176 case DISABLED: aText = "DISABLED"; break;
177 case FAILED: aText = "FAILED"; break;
178 case ERROR: aText = "ERROR"; break;
185 Class : YACSGui_InputPanel::BtnStyle
186 Description : Style for buttons with text aligned to the left border
189 class YACSGui_InputPanel::BtnStyle : public QWindowsStyle
193 virtual void drawControl( ControlElement element,
195 const QWidget *widget,
197 const QColorGroup &cg,
198 SFlags how = Style_Default,
199 const QStyleOption& = QStyleOption::Default ) const;
202 void YACSGui_InputPanel::BtnStyle::drawControl( ControlElement element,
204 const QWidget *widget,
206 const QColorGroup &cg,
208 const QStyleOption& opt ) const
210 if ( element != CE_PushButtonLabel )
211 QWindowsStyle::drawControl( element, p, widget, r, cg, flags, opt );
214 #ifndef QT_NO_PUSHBUTTON
215 const QPushButton *button = (const QPushButton *) widget;
218 if ( button->isDown() || button->isOn() )
220 flags |= Style_Sunken;
221 ir.moveBy(pixelMetric(PM_ButtonShiftHorizontal, widget),
222 pixelMetric(PM_ButtonShiftVertical, widget));
225 int tf=AlignVCenter | ShowPrefix;
226 if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
231 drawItem(p, ir, tf, cg,
232 flags & Style_Enabled, button->pixmap(), button->text(),
233 button->text().length(), &(cg.buttonText()) );
236 PrimitiveElement aPE = button->isOn() ? PE_ArrowUp : PE_ArrowDown;
238 QRect aRect( r.right() - h, r.top(), h, h );
239 SFlags aFlags = Style_Default | Style_Enabled;
240 drawPrimitive( aPE, p, aRect, cg, aFlags, QStyleOption( QColor( 0, 0, 255 ) ) );
242 if (flags & Style_HasFocus)
243 drawPrimitive( PE_FocusRect, p, subRect( SR_PushButtonFocusRect, widget ), cg, flags );
250 Class : YACSGui_InputPanel
251 Description : Dockable window containing push buttons and corresponding widgets
254 //=======================================================================
255 // name : YACSGui_InputPanel
256 // Purpose : Constructor
257 //=======================================================================
258 YACSGui_InputPanel::YACSGui_InputPanel( YACSGui_Module* theModule )
259 : QDockWindow( QDockWindow::InDock, theModule && theModule->getApp() ? theModule->application()->desktop() : 0 ),
264 QScrollView* scrollView = new QScrollView( this );
266 // Create main frame and main layout
267 QFrame* aMainFrame = new QFrame( scrollView->viewport() );
268 scrollView->addChild( aMainFrame );
269 scrollView->setResizePolicy( QScrollView::AutoOneFit );
271 myMainLayout = new QVBoxLayout( aMainFrame, MARGIN, SPACING);
273 // create an empty property pages
274 createPage( YACSGui_InputPanel::ContainerId );
275 createPage( YACSGui_InputPanel::ComponentId );
276 createPage( YACSGui_InputPanel::SchemaId );
277 createPage( YACSGui_InputPanel::InDataNodeId );
278 createPage( YACSGui_InputPanel::OutDataNodeId );
279 createPage( YACSGui_InputPanel::InStudyNodeId );
280 createPage( YACSGui_InputPanel::OutStudyNodeId );
281 createPage( YACSGui_InputPanel::InlineNodeId );
282 createPage( YACSGui_InputPanel::ServiceNodeId );
283 createPage( YACSGui_InputPanel::ForLoopNodeId );
284 createPage( YACSGui_InputPanel::ForEachLoopNodeId );
285 createPage( YACSGui_InputPanel::WhileLoopNodeId );
286 createPage( YACSGui_InputPanel::SwitchNodeId );
287 createPage( YACSGui_InputPanel::BlockNodeId );
288 createPage( YACSGui_InputPanel::LinkId );
289 createPage( YACSGui_InputPanel::DataTypeId );
291 // myMainLayout->addStretch( 1 );
293 // Add "Apply" and "Close" buttons
294 QGroupBox* aGrpBtns = new QGroupBox( aMainFrame, "GroupButtons" );
295 aGrpBtns->setColumnLayout(0, Qt::Vertical );
296 aGrpBtns->layout()->setSpacing( 0 ); aGrpBtns->layout()->setMargin( 0 );
297 aGrpBtns->setFrameStyle( QFrame::NoFrame );
298 //aGrpBtns->setFrameStyle( QFrame::StyledPanel );
299 QHBoxLayout* aGrpBtnsLayout = new QHBoxLayout( aGrpBtns->layout() );
300 aGrpBtnsLayout->setAlignment( Qt::AlignTop );
301 aGrpBtnsLayout->setSpacing( 0 ); aGrpBtnsLayout->setMargin( 0 );
303 myApplyBtn = new QPushButton( tr( "APPLY_BTN" ), aGrpBtns );
304 connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
306 myCancelBtn = new QPushButton( tr( "CLOSE_BTN" ), aGrpBtns );
307 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onClose() ) );
309 aGrpBtnsLayout->addWidget( myApplyBtn );
310 aGrpBtnsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
311 aGrpBtnsLayout->addWidget( myCancelBtn );
313 myMainLayout->addWidget( aGrpBtns );
314 myMainLayout->addSpacing( SPACING );
318 setWidget( scrollView );
322 //=======================================================================
323 // name : ~YACSGui_InputPanel
324 // Purpose : Destructor
325 //=======================================================================
326 YACSGui_InputPanel::~YACSGui_InputPanel()
332 //================================================================
333 // Function : setBtnText
335 //================================================================
336 void YACSGui_InputPanel::setBtnText( const QString& theText, const int thePageId )
338 if ( myMainBtns.contains( thePageId ) )
339 myMainBtns[ thePageId ]->setText( theText );
342 //=======================================================================
345 //=======================================================================
346 QWidget* YACSGui_InputPanel::getPage( const int thePageId,
347 const bool theWithCreate )
349 if ( myPages.contains( thePageId ) )
350 return myPages[ thePageId ];
351 else if ( theWithCreate )
353 createPage( thePageId );
354 return myPages.contains( thePageId ) ? myPages[ thePageId ] : 0;
361 //=============================================================================
362 // Function : getPageId
364 //=============================================================================
365 int YACSGui_InputPanel::getPageId( QWidget* thePage ) const
370 QMap< int, QWidget* >::const_iterator anIter;
371 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
373 QWidget* aPage = anIter.data();
374 if ( aPage == thePage )
385 //=============================================================================
386 // Function : insertPage
387 // Purpose : Insert page in input panel. If this is already present in input panel
388 // then it is not inserted. if theBeforePageId == -1 then page is added
389 // at the end. Method returns identifier of inserted page or -1 if page
391 //=============================================================================
392 int YACSGui_InputPanel::insertPage( QWidget*,
394 const int theBeforePageId,
395 const int theStretch ) const
400 //=======================================================================
403 //=======================================================================
404 void YACSGui_InputPanel::removePage( QWidget* thePage )
406 if ( !thePage ) return;
408 int anId = getPageId(thePage);
410 if ( myMainBtns.find(anId) != myMainBtns.end() )
412 QPushButton* aBtn = myMainBtns[anId];
413 myMainBtns.erase(anId);
417 if ( myPages.find(anId) != myPages.end() )
421 //=======================================================================
424 //=======================================================================
425 QSize YACSGui_InputPanel::sizeHint() const
427 int w = QFontMetrics( font() ).width( QString("0"), 1 ) * 30;
428 return QSize( w, QDockWindow::sizeHint().height() );
429 //return QDockWindow::sizeHint();
432 //=======================================================================
435 //=======================================================================
436 bool YACSGui_InputPanel::isOn( const int i ) const
439 if ( myMainBtns.contains( i ) )
440 res = myMainBtns[i]->isOn();
444 //=======================================================================
447 //=======================================================================
448 void YACSGui_InputPanel::setOn( const bool on, const int i )
450 if ( myMainBtns.contains( i ) )
451 myMainBtns[i]->setOn( on );
454 //=======================================================================
457 //=======================================================================
458 bool YACSGui_InputPanel::isVisible( const int i ) const
460 DEBTRACE("YACSGui_InputPanel::isVisible " << i);
462 if ( myMainBtns.contains( i ) )
463 res = myMainBtns[i]->isVisibleTo( myMainBtns[i]->parentWidget() );
467 //=======================================================================
470 //=======================================================================
471 void YACSGui_InputPanel::setVisible( const bool on, const int i )
473 if ( myMainBtns.contains( i ) )
474 myMainBtns[i]->setShown( on );
475 if ( myPages.contains( i ) )
476 myPages[i]->setShown( on && myMainBtns[i]->isOn() );
479 //=======================================================================
480 // name : setExclusiveVisible
482 //=======================================================================
483 void YACSGui_InputPanel::setExclusiveVisible( const bool on, const std::list<int> ids )
485 QMap< int, QWidget* >::const_iterator anIter;
486 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
488 int anId = anIter.key();
490 bool aVisibility = on;
491 if ( std::find(ids.begin(), ids.end(), anId) == ids.end() )
494 if ( myMainBtns.contains( anId ) ) myMainBtns[anId]->setShown( aVisibility );
495 myPages[anId]->setShown( aVisibility && myMainBtns[anId]->isOn() );
499 //=======================================================================
500 // name : getVisiblePagesIds
502 //=======================================================================
503 std::list<int> YACSGui_InputPanel::getVisiblePagesIds()
507 for ( QMap< int, QWidget* >::const_iterator anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
509 int anId = anIter.key();
510 if ( isVisible(anId) ) aRetList.push_back(anId);
516 //=======================================================================
519 //=======================================================================
520 void YACSGui_InputPanel::setMode( const YACSGui_InputPanel::PageMode theMode, const int thePageId )
526 if ( YACSGui_SchemaPage* page = dynamic_cast<YACSGui_SchemaPage*>(myPages[thePageId]) )
527 page->setMode( theMode );
537 case ForEachLoopNodeId:
538 case WhileLoopNodeId:
542 if ( YACSGui_NodePage* page = dynamic_cast<YACSGui_NodePage*>(myPages[thePageId]) )
543 page->setMode( theMode );
548 if ( YACSGui_DataTypePage* page = dynamic_cast<YACSGui_DataTypePage*>(myPages[thePageId]) )
549 page->setMode( theMode );
557 //================================================================
558 // Function : getPrefferedSize
560 //================================================================
561 QSize YACSGui_InputPanel::getPrefferedSize()
563 setUpdatesEnabled( false );
565 QMap< int, QWidget* >::const_iterator anIter;
566 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
567 if ( isVisible(anIter.key()) )
568 anIter.data()->updateGeometry();
570 QSize aSize = this->sizeHint() * 1.44;
571 setUpdatesEnabled( true );
576 //================================================================
577 // Function : emitApply
579 //================================================================
580 void YACSGui_InputPanel::emitApply( const int theId )
585 //=======================================================================
587 // Purpose : SLOT. Called when main button ( i.e. button used for show/hide
588 // windows of input panel clicked )
589 //=======================================================================
590 void YACSGui_InputPanel::onMainBtn( bool )
595 //=======================================================================
596 // name : onApplyEnabled
597 // Purpose : SLOT. Called when "Apply" button should be disabled or enabled.
598 //=======================================================================
599 void YACSGui_InputPanel::onApplyEnabled( bool enable )
601 myApplyBtn->setEnabled(enable);
604 //=======================================================================
606 // Purpose : SLOT. Called when "Apply" button clicked. Emit signal with
608 //=======================================================================
609 void YACSGui_InputPanel::onApply()
611 DEBTRACE("YACSGui_InputPanel::onApply");
612 QMap< int, QWidget* >::const_iterator anIter;
613 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
615 int anId = anIter.key();
616 if ( isVisible(anId) )
620 YACSGui_ContainerPage* page = dynamic_cast<YACSGui_ContainerPage*>(myPages[anId]);
626 YACSGui_ComponentPage* page = dynamic_cast<YACSGui_ComponentPage*>(myPages[anId]);
632 YACSGui_SchemaPage* page = dynamic_cast<YACSGui_SchemaPage*>(myPages[anId]);
640 case OutStudyNodeId: {
641 DEBTRACE("YACSGui_InputPanel::onApply");
642 YACSGui_DataNodePage* page = dynamic_cast<YACSGui_DataNodePage*>(myPages[anId]);
648 DEBTRACE("YACSGui_InputPanel::onApply");
649 YACSGui_InlineNodePage* page = dynamic_cast<YACSGui_InlineNodePage*>(myPages[anId]);
654 case ServiceNodeId: {
655 YACSGui_ServiceNodePage* page = dynamic_cast<YACSGui_ServiceNodePage*>(myPages[anId]);
660 case ForLoopNodeId: {
661 YACSGui_ForLoopNodePage* page = dynamic_cast<YACSGui_ForLoopNodePage*>(myPages[anId]);
666 case ForEachLoopNodeId: {
667 YACSGui_ForEachLoopNodePage* page = dynamic_cast<YACSGui_ForEachLoopNodePage*>(myPages[anId]);
672 case WhileLoopNodeId: {
673 YACSGui_WhileLoopNodePage* page = dynamic_cast<YACSGui_WhileLoopNodePage*>(myPages[anId]);
679 YACSGui_SwitchNodePage* page = dynamic_cast<YACSGui_SwitchNodePage*>(myPages[anId]);
685 YACSGui_BlockNodePage* page = dynamic_cast<YACSGui_BlockNodePage*>(myPages[anId]);
692 YACSGui_LinkPage* page = dynamic_cast<YACSGui_LinkPage*>(myPages[anId]);
698 YACSGui_DataTypePage* page = dynamic_cast<YACSGui_DataTypePage*>(myPages[anId]);
710 // export the modified schema (i.e. an active schema!) into
711 // the temporary XML file, which will be used for create execution objects
712 myModule->temporaryExport();
715 //=======================================================================
717 // Purpose : SLOT. Called when "Close" button clicked.
718 //=======================================================================
719 void YACSGui_InputPanel::onClose()
722 if(getModule()->getGuiMode() == YACSGui_Module::NewMode) {
723 getModule()->setGuiMode(YACSGui_Module::EditMode);
724 if(getModule()->activeTreeView())
725 getModule()->activeTreeView()->syncPageTypeWithSelection();
727 onApplyEnabled(true);
730 //=======================================================================
731 // name : onNotifyNodeStatus
733 //=======================================================================
734 void YACSGui_InputPanel::onNotifyNodeStatus( int theNodeId, int theStatus )
736 DEBTRACE("YACSGui_InputPanel::onNotifyNodeStatus: " << theNodeId << " " << theStatus);
737 if ( Node::idMap.count(theNodeId) == 0 ) return;
738 Node* aNode= Node::idMap[theNodeId];
740 QMap< int, QWidget* >::const_iterator anIter;
741 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
743 int anId = anIter.key();
744 if ( isVisible(anId) )
750 case OutStudyNodeId: {
751 YACSGui_DataNodePage* page = dynamic_cast<YACSGui_DataNodePage*>(myPages[anId]);
752 if(page && page->getNode() == aNode)
753 page->notifyNodeStatus(theStatus);
757 YACSGui_InlineNodePage* page = dynamic_cast<YACSGui_InlineNodePage*>(myPages[anId]);
758 if(page && page->getNode() == aNode)
759 page->notifyNodeStatus(theStatus);
762 case ServiceNodeId: {
763 YACSGui_ServiceNodePage* page = dynamic_cast<YACSGui_ServiceNodePage*>(myPages[anId]);
764 if(page && page->getNode() == aNode)
765 page->notifyNodeStatus(theStatus);
768 case ForLoopNodeId: {
769 YACSGui_ForLoopNodePage* page = dynamic_cast<YACSGui_ForLoopNodePage*>(myPages[anId]);
770 if(page && page->getNode() == aNode)
771 page->notifyNodeStatus(theStatus);
774 case ForEachLoopNodeId: {
775 YACSGui_ForEachLoopNodePage* page = dynamic_cast<YACSGui_ForEachLoopNodePage*>(myPages[anId]);
776 if(page && page->getNode() == aNode)
777 page->notifyNodeStatus(theStatus);
780 case WhileLoopNodeId: {
781 YACSGui_WhileLoopNodePage* page = dynamic_cast<YACSGui_WhileLoopNodePage*>(myPages[anId]);
782 if(page && page->getNode() == aNode)
783 page->notifyNodeStatus(theStatus);
787 YACSGui_SwitchNodePage* page = dynamic_cast<YACSGui_SwitchNodePage*>(myPages[anId]);
788 if(page && page->getNode() == aNode)
789 page->notifyNodeStatus(theStatus);
793 YACSGui_BlockNodePage* page = dynamic_cast<YACSGui_BlockNodePage*>(myPages[anId]);
794 if(page && page->getNode() == aNode)
795 page->notifyNodeStatus(theStatus);
805 //=======================================================================
806 // name : onNotifyInPortValues
808 //=======================================================================
809 void YACSGui_InputPanel::onNotifyInPortValues( int theNodeId,
810 std::map<std::string,std::string> theInPortName2Value )
812 DEBTRACE("onNotifyInPortValues: " << theNodeId);
813 if ( Node::idMap.count(theNodeId) == 0 ) return;
814 Node* aNode= Node::idMap[theNodeId];
816 QMap< int, QWidget* >::const_iterator anIter;
817 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
819 int anId = anIter.key();
820 if ( isVisible(anId) )
826 case OutStudyNodeId: {
827 YACSGui_DataNodePage* page = dynamic_cast<YACSGui_DataNodePage*>(myPages[anId]);
828 if(page && page->getNode() == aNode)
829 page->notifyInPortValues(theInPortName2Value);
833 YACSGui_InlineNodePage* page = dynamic_cast<YACSGui_InlineNodePage*>(myPages[anId]);
834 if(page && page->getNode() == aNode)
835 page->notifyInPortValues(theInPortName2Value);
838 case ServiceNodeId: {
839 YACSGui_ServiceNodePage* page = dynamic_cast<YACSGui_ServiceNodePage*>(myPages[anId]);
840 if(page && page->getNode() == aNode)
841 page->notifyInPortValues(theInPortName2Value);
844 case ForLoopNodeId: {
845 YACSGui_ForLoopNodePage* page = dynamic_cast<YACSGui_ForLoopNodePage*>(myPages[anId]);
846 if(page && page->getNode() == aNode)
847 page->notifyInPortValues(theInPortName2Value);
850 case ForEachLoopNodeId: {
851 YACSGui_ForEachLoopNodePage* page = dynamic_cast<YACSGui_ForEachLoopNodePage*>(myPages[anId]);
852 if(page && page->getNode() == aNode)
853 page->notifyInPortValues(theInPortName2Value);
856 case WhileLoopNodeId: {
857 YACSGui_WhileLoopNodePage* page = dynamic_cast<YACSGui_WhileLoopNodePage*>(myPages[anId]);
858 if(page && page->getNode() == aNode)
859 page->notifyInPortValues(theInPortName2Value);
863 YACSGui_SwitchNodePage* page = dynamic_cast<YACSGui_SwitchNodePage*>(myPages[anId]);
864 if(page && page->getNode() == aNode)
865 page->notifyInPortValues(theInPortName2Value);
869 YACSGui_BlockNodePage* page = dynamic_cast<YACSGui_BlockNodePage*>(myPages[anId]);
870 if(page && page->getNode() == aNode)
871 page->notifyInPortValues(theInPortName2Value);
881 //=======================================================================
882 // name : onNotifyOutPortValues
884 //=======================================================================
885 void YACSGui_InputPanel::onNotifyOutPortValues( int theNodeId,
886 std::map<std::string,std::string> theOutPortName2Value )
888 DEBTRACE("YACSGui_InputPanel::onNotifyOutPortValues" << theNodeId);
889 if ( Node::idMap.count(theNodeId) == 0 ) return;
890 Node* aNode= Node::idMap[theNodeId];
892 QMap< int, QWidget* >::const_iterator anIter;
893 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
895 int anId = anIter.key();
896 if ( isVisible(anId) )
902 case OutStudyNodeId: {
903 YACSGui_DataNodePage* page = dynamic_cast<YACSGui_DataNodePage*>(myPages[anId]);
905 if(page && page->getNode() == aNode)
906 page->notifyOutPortValues(theOutPortName2Value);
910 YACSGui_InlineNodePage* page = dynamic_cast<YACSGui_InlineNodePage*>(myPages[anId]);
912 if(page && page->getNode() == aNode)
913 page->notifyOutPortValues(theOutPortName2Value);
916 case ServiceNodeId: {
917 YACSGui_ServiceNodePage* page = dynamic_cast<YACSGui_ServiceNodePage*>(myPages[anId]);
919 if(page && page->getNode() == aNode)
920 page->notifyOutPortValues(theOutPortName2Value);
923 case ForLoopNodeId: {
924 YACSGui_ForLoopNodePage* page = dynamic_cast<YACSGui_ForLoopNodePage*>(myPages[anId]);
925 if(page && page->getNode() == aNode)
926 page->notifyOutPortValues(theOutPortName2Value);
929 case ForEachLoopNodeId: {
930 YACSGui_ForEachLoopNodePage* page = dynamic_cast<YACSGui_ForEachLoopNodePage*>(myPages[anId]);
931 if(page && page->getNode() == aNode)
932 page->notifyOutPortValues(theOutPortName2Value);
935 case WhileLoopNodeId: {
936 YACSGui_WhileLoopNodePage* page = dynamic_cast<YACSGui_WhileLoopNodePage*>(myPages[anId]);
937 if(page && page->getNode() == aNode)
938 page->notifyOutPortValues(theOutPortName2Value);
942 YACSGui_SwitchNodePage* page = dynamic_cast<YACSGui_SwitchNodePage*>(myPages[anId]);
943 if(page && page->getNode() == aNode)
944 page->notifyOutPortValues(theOutPortName2Value);
948 YACSGui_BlockNodePage* page = dynamic_cast<YACSGui_BlockNodePage*>(myPages[anId]);
950 if(page && page->getNode() == aNode)
951 page->notifyOutPortValues(theOutPortName2Value);
961 //=======================================================================
962 // name : updateState
964 //=======================================================================
965 void YACSGui_InputPanel::updateState()
967 DEBTRACE("YACSGui_InputPanel::updateState()");
968 QMap< int, QWidget* >::const_iterator anIter;
969 for ( anIter = myPages.begin(); anIter != myPages.end(); ++anIter )
971 int anId = anIter.key();
972 QPushButton* b = myMainBtns.contains( anId ) ? myMainBtns[ anId ] : 0;
973 QWidget* page = myPages.contains( anId ) ? myPages[ anId ] : 0;
975 page->setShown( b->isVisibleTo( b->parentWidget() ) && b->isOn() );
979 //=======================================================================
982 //=======================================================================
983 void YACSGui_InputPanel::createPage( const int thePageId )
985 DEBTRACE("YACSGui_InputPanel::createPage");
986 // Create buttons and frames inside the main frame
987 if ( !myMainLayout ) return;
988 QFrame* aMainFrame = dynamic_cast<QFrame*>( myMainLayout->parent() );
989 if ( !aMainFrame ) return;
991 // Create a drop down button
992 QPushButton* button = new QPushButton( aMainFrame );
998 page = new YACSGui_ContainerPage( aMainFrame );
1001 page = new YACSGui_ComponentPage( aMainFrame );
1004 page = new YACSGui_SchemaPage( aMainFrame );
1009 case OutStudyNodeId:
1010 page = new YACSGui_DataNodePage(thePageId, aMainFrame );
1013 page = new YACSGui_InlineNodePage( aMainFrame );
1016 page = new YACSGui_ServiceNodePage( aMainFrame );
1019 page = new YACSGui_ForLoopNodePage( aMainFrame );
1021 case ForEachLoopNodeId:
1022 page = new YACSGui_ForEachLoopNodePage( aMainFrame );
1024 case WhileLoopNodeId:
1025 page = new YACSGui_WhileLoopNodePage( aMainFrame );
1028 page = new YACSGui_SwitchNodePage( aMainFrame );
1031 page = new YACSGui_BlockNodePage( aMainFrame );
1036 page = new YACSGui_DataTypePage( aMainFrame );
1042 // Use only if the drop down button is created for each property page
1049 if ( myApplyBtn && myCancelBtn )
1052 if ( thePageId == ContainerId ) anIndex = 0;
1053 if ( thePageId == ComponentId ) anIndex = 2;
1054 else anIndex = myMainLayout->findWidget(myApplyBtn->parentWidget()) - 1;
1056 myMainLayout->insertWidget( anIndex, page );
1057 myMainLayout->insertWidget( anIndex, button );
1061 myMainLayout->insertWidget( -1, button );
1062 myMainLayout->insertWidget( -1, page );
1065 myMainBtns.insert( thePageId, button );
1066 myPages.insert( thePageId, page );
1068 // Set custom style for drawing buttons with text aligned to the left border
1069 static BtnStyle aStyle;
1070 button->setStyle( &aStyle );
1072 QFont aFont = button->font();
1073 aFont.setBold( true );
1074 button->setFont( aFont );
1075 button->setPaletteForegroundColor( QColor( 0, 0, 0 ) );
1076 button->setToggleButton( true );
1077 button->setOn(true);
1079 // Set titles for property pages as the text on the drop down button
1080 switch ( thePageId )
1083 myMainBtns[ContainerId]->setText(tr( "Container Properties" ));
1086 myMainBtns[ComponentId]->setText(tr( "Component Properties" ));
1089 myMainBtns[SchemaId]->setText( tr( "Schema Properties" ) );
1094 case OutStudyNodeId:
1098 case ForEachLoopNodeId:
1099 case WhileLoopNodeId:
1102 myMainBtns[thePageId]->setText( tr( "Node Properties" ) );
1107 myMainBtns[thePageId]->setText( tr( "Data Type Properties" ) );
1113 // Connect signals and slots
1114 if ( myMainBtns.contains( thePageId ) )
1115 connect( myMainBtns[ thePageId ], SIGNAL( toggled( bool ) ), SLOT( onMainBtn( bool ) ) );