1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SUPERV SUPERVGUI : GUI for Supervisor component
23 // File : SUPERVGUI_BrowseNodeDlg.cxx
24 // Author : Vitaly SMETANNIKOV
27 #include "SALOMEDSClient.hxx"
28 #include "SALOMEDS_SObject.hxx"
29 #include "SALOMEDS_Study.hxx"
31 #include "SalomeApp_Application.h"
32 #include "LightApp_SelectionMgr.h"
33 #include "SalomeApp_Study.h"
34 #include "SUIT_Session.h"
36 #include "SALOME_ListIO.hxx"
38 #include "SUPERVGUI_BrowseNodeDlg.h"
39 #include "SUPERVGUI_CanvasNode.h"
40 #include "SUPERVGUI_CanvasPort.h"
41 #include "SUPERVGUI.h"
45 #include <qlineedit.h>
46 #include <qpushbutton.h>
48 #include <qgroupbox.h>
49 #include <qvalidator.h>
51 #include <boost/shared_ptr.hpp>
52 using namespace boost;
57 SUPERVGUI_PortField::SUPERVGUI_PortField( QWidget* theParent, SUPERV_Port thePort ) {
59 myIsEditable = myPort->IsInput() && ( !myPort->IsLinked() );
61 QString aLabelTxt(myPort->Name());
63 /*SUPERV_CNode aNode = myPort->Node();
64 SALOME_ModuleCatalog::Service* aService = aNode->Service();
65 SALOME_ModuleCatalog::ListOfServicesParameter aList;
66 aList = (myPort->IsInput())? aService->ServiceinParameter : aService->ServiceoutParameter;
67 for (int i = 0; i < aList.length(); i++) {
68 SALOME_ModuleCatalog::ServicesParameter* aParam = &(aList[i]);
69 if (aLabelTxt == aParam->Parametername) {
70 aLabelTxt += QString(" (") + QString(aParam->Parametertype) + QString(")");
74 aLabelTxt += QString(":");*/
76 // mkr : the following way is easyer to get ports' type than commented above
77 QString aPortType = QString(myPort->Type());
78 aLabelTxt += QString(" (") + aPortType + QString("):");
80 myLabel = new QLabel(aLabelTxt, theParent );
82 myValue = new QLineEdit( theParent );
83 myLabel->setBuddy( myValue );
85 myValue->setReadOnly( !myIsEditable );
86 QPalette aPalette = myValue->palette();
87 aPalette.setInactive(aPalette.disabled());
88 aPalette.setActive(aPalette.disabled());
89 myValue->setPalette(aPalette);
93 if ( !aPortType.compare(QString("boolean")) )
94 myValue->setValidator( new QIntValidator( 0, 1, theParent ) );
96 if ( !aPortType.compare(QString("short")) || !aPortType.compare(QString("int")) || !aPortType.compare(QString("long")) )
97 myValue->setValidator( new QIntValidator( theParent ) );
99 if ( !aPortType.compare(QString("float")) || !aPortType.compare(QString("double")) )
100 myValue->setValidator( new QDoubleValidator( theParent ) );
102 if ( !aPortType.compare(QString("char")) ) {
104 myValue->setValidator( new QRegExpValidator( aRX, theParent ) );
109 myValue->installEventFilter( this );
113 * Sets value from text edit control to engine of port
115 bool SUPERVGUI_PortField::setNewValue() {
116 if ( !myIsEditable ) return false;
118 QString aTxt = myValue->text();
119 //mkr : fix for bug IPAL9441
120 //if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
122 if ( aTxt.find( "Unknown" ) < 0 ) {
123 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
125 MESSAGE("NULL Supervision module!");
128 return myPort->Input( aSupMod->getEngine()->StringValue( aTxt ) );
136 bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e )
138 if ( o == myValue ) {
139 if ( e->type() == QEvent::FocusIn ) {
143 return QObject::eventFilter( o, e );
148 * Constructor (SUPERVGUI_CanvasNode)
150 SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode )
151 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
153 myNodeCanvas = theNode;
158 void SUPERVGUI_BrowseNodeDlg::init()
161 setSizeGripEnabled( true );
162 myPortsList.setAutoDelete( true );
164 SUPERV_CNode aEngine = myNodeCanvas->getEngine();
166 setName( "SUPERVGUI_BrowseNodeDlg" );
167 setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() );
169 QGridLayout* aBaseLayout = new QGridLayout( this );
170 aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
172 QGroupBox* aInBox = new QGroupBox( 2, Qt::Horizontal, "Input", this );
173 aInBox->setMargin( 11 );
174 aBaseLayout->addWidget( aInBox, 0, 0 );
176 QGroupBox* aOutBox = new QGroupBox( 2, Qt::Horizontal, "Output", this);
177 aOutBox->setMargin( 11 );
178 aBaseLayout->addWidget( aOutBox, 0, 1 );
180 myIsEditable = false;
183 SUPERV_Ports ports = aEngine->Ports();
184 int n = ports->length();
186 for ( int i = 0; i < n; i++ ) {
187 if ( ports[i]->IsInput() ) {
188 if ( !ports[i]->IsGate() ) { // not a gate
189 SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] );
190 if ( aField->isEditable() )
192 myPortsList.append( aField );
193 if ( !myActiveField )
194 myActiveField = aField;
195 connect( aField, SIGNAL( activated() ), this, SLOT( onFieldActivated() ) );
200 if ( !ports[i]->IsGate() ) { // not a gate
201 myPortsList.append( new SUPERVGUI_PortField( aOutBox, ports[i] ) );
207 QGroupBox* aBtnBox = new QGroupBox( this );
208 aBtnBox->setColumnLayout( 0, Qt::Vertical );
209 aBtnBox->layout()->setSpacing( 0 );
210 aBtnBox->layout()->setMargin( 0 );
212 QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
213 aBtnLayout->setAlignment( Qt::AlignTop );
214 aBtnLayout->setSpacing( 6 );
215 aBtnLayout->setMargin( 11 );
217 if ( myIsEditable ) {
218 QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), this );
219 aBaseLayout->addMultiCellWidget( aInfoLab, 1, 1, 0, 1 );
221 QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
222 connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
223 aBtnLayout->addWidget( aOkBtn );
224 aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 );
226 aBaseLayout->addMultiCellWidget( aBtnBox, 1, 1, 0, 1 );
228 aBtnLayout->addStretch();
229 QPushButton* aCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
230 aBtnLayout->addWidget( aCancelBtn );
231 connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
234 aBtnLayout->addStretch();
236 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
237 if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(),
238 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
239 else MESSAGE("NULL Supervision module!");
241 myNodeCanvas->getMain()->lockedGraph(true);
247 SUPERVGUI_BrowseNodeDlg::~SUPERVGUI_BrowseNodeDlg() {
251 * Set current values of editable ports
253 void SUPERVGUI_BrowseNodeDlg::setValues() {
254 SUPERVGUI_PortField* aField;
255 for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
256 if ( aField->getData().isEmpty() || aField->getData().isNull() ) // mkr : PAL11406
262 * Set inputed values of editable ports and then closes and destroys dialog
264 void SUPERVGUI_BrowseNodeDlg::accept() {
265 myNodeCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
266 if ( myIsEditable ) {
267 SUPERVGUI_PortField* aField;
268 for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
269 aField->setNewValue();
271 myNodeCanvas->sync();
272 myNodeCanvas->getMain()->getCanvas()->update();
274 myNodeCanvas->getMain()->lockedGraph(false);
281 * Closes and destroys dialog
283 void SUPERVGUI_BrowseNodeDlg::reject() {
284 myNodeCanvas->getMain()->lockedGraph(false);
290 * Update current values on show event
292 void SUPERVGUI_BrowseNodeDlg::showEvent( QShowEvent* theEvent ) {
294 QDialog::showEvent( theEvent );
298 * Slot, called when field is focused
300 void SUPERVGUI_BrowseNodeDlg::onFieldActivated()
302 SUPERVGUI_PortField* aField = (SUPERVGUI_PortField*)sender();
303 myActiveField = (aField->isEditable())? aField : 0;
308 QString getIORfromIO (const Handle(SALOME_InteractiveObject)& theIO,
309 SUPERVGUI * theModule)
312 if (!theIO->hasEntry()) return ior;
314 SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(theModule->getActiveStudy());
315 _PTR(SObject) aSObj (anAppStudy->studyDS()->FindObjectID(theIO->getEntry()));
317 _PTR(GenericAttribute) anAttr;
318 if (aSObj->FindAttribute(anAttr, "AttributeIOR")) {
319 _PTR(AttributeIOR) anIOR (anAttr);
320 ior = anIOR->Value().c_str();
324 // old code, it is useless, because <aSSObj->GetObject()> here will be NULL
325 // (because it is retrieved from <aSSObj> by stored IOR)
327 SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aSObj->GetStudy().get() );
328 SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aSObj.get() );
329 if ( aSStudy && aSSObj )
330 ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
335 // default value: null IOR (IOR:01000000010000000000...)
336 SalomeApp_Application* anApp = theModule->getApp();
337 CORBA::Object_var aNullObj;
338 ior = anApp->orb()->object_to_string(aNullObj);
340 // try to load a component data from an opened (presumably) study
341 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
342 std::string aCompIOR;
343 if (!aSComp->ComponentIOR(aCompIOR)) {
344 std::string aCompDataType = aSComp->ComponentDataType();
346 // obtain a driver by a component data type
347 // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType
348 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil();
349 SALOME_LifeCycleCORBA * LCC = anApp->lcc();
352 anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType.c_str());
353 if (CORBA::is_nil(anEngineObj))
354 anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType.c_str());
356 if (!CORBA::is_nil(anEngineObj))
357 anEngine = SALOMEDS::Driver::_narrow(anEngineObj);
362 if (!CORBA::is_nil(anEngine)) {
364 _PTR(StudyBuilder) aStudyBuilder = aSObj->GetStudy()->NewBuilder();
367 CORBA::String_var aDriverIOR = anApp->orb()->object_to_string(anEngine);
368 aStudyBuilder->LoadWith(aSComp, aDriverIOR.in());
375 // now try to obtain the IOR once again (after successfull component data loading)
376 if (aSObj->FindAttribute( anAttr, "AttributeIOR" )) {
377 _PTR(AttributeIOR) anIOR ( anAttr );
378 ior = anIOR->Value().c_str();
381 } // if (!CORBA::is_nil(anEngine))
382 } // if (!aSComp->ComponentIOR(aCompIOR))
387 } // no name namespace
390 * Slot, called when selection is changed
392 void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
394 if ( myActiveField ) {
399 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
401 MESSAGE("NULL Supervision module!");
405 SalomeApp_Application* anApp = aSupMod->getApp();
406 anApp->selectionMgr()->selectedObjects( aList );
408 if ( aList.Extent() == 1 ) {
409 Handle( SALOME_InteractiveObject ) anIO = aList.First();
410 if ( anIO->hasEntry() ) {
411 QString ior = ::getIORfromIO(anIO, aSupMod);
412 myActiveField->setData( ior );
420 * Constructor (SUPERVGUI_CanvasPort)
422 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
423 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
425 myPortCanvas = thePort;
430 void SUPERVGUI_GetValueDlg::init()
433 setSizeGripEnabled( true );
435 setName( "SUPERVGUI_GetValueDlg" );
436 setCaption( tr( "TIT_SETVALUE_PORT" ) );
438 QGridLayout* aBaseLayout = new QGridLayout( this );
439 aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
441 QGroupBox* aBox = new QGroupBox( this );
442 aBox->setColumnLayout( 0, Qt::Vertical );
443 aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 );
444 QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() );
445 aBoxLayout->setAlignment( Qt::AlignTop );
446 aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 );
447 aBaseLayout->addWidget( aBox, 0, 0 );
448 aBox->setMinimumWidth( 200 );
450 QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox );
451 QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt );
452 aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 );
453 SUPERV_Port aEngine = myPortCanvas->getEngine();
455 myField = new SUPERVGUI_PortField( aBox, aEngine );
456 bool myIsEditable = myField->isEditable();
457 aBoxLayout->addWidget( myField->myLabel, 1, 0 );
458 aBoxLayout->addWidget( myField->myValue, 1, 1 );
460 QGroupBox* aBtnBox = new QGroupBox( this );
461 aBtnBox->setColumnLayout( 0, Qt::Vertical );
462 aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
463 QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
464 aBtnLayout->setAlignment( Qt::AlignTop );
465 aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
467 aBaseLayout->addWidget( aBtnBox, 1, 0 );
469 if ( myIsEditable ) {
470 myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
471 connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
472 aBtnLayout->addWidget( myOKBtn );
475 aBtnLayout->addStretch();
476 myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
477 aBtnLayout->addWidget( myCancelBtn );
478 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
481 aBtnLayout->addStretch();
483 myField->updateGUI();
485 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
486 if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(),
487 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
488 else MESSAGE("NULL Supervision module!");
490 myPortCanvas->getMain()->lockedGraph(true);
496 SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() {
500 * Set entered value into port and then closes and destroys dialog
502 void SUPERVGUI_GetValueDlg::accept() {
503 myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
504 if ( myField->setNewValue() ) {
506 myPortCanvas->sync();
508 // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status
509 // asv : 13.12.04 : commented out sync() of Node. See 2.21.
510 //if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) {
511 // SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent();
515 myPortCanvas->getMain()->getCanvas()->update();
518 if ( QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),
519 tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
520 QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
524 myPortCanvas->getMain()->lockedGraph(false);
531 * Closes and destroys dialog
533 void SUPERVGUI_GetValueDlg::reject() {
534 myPortCanvas->getMain()->lockedGraph(false);
540 * Slot, called when selection is changed
542 void SUPERVGUI_GetValueDlg::onSelectionChanged()
547 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
549 MESSAGE("NULL Supervision module!");
553 SalomeApp_Application* anApp = aSupMod->getApp();
554 anApp->selectionMgr()->selectedObjects( aList );
556 if ( aList.Extent() == 1 ) {
557 Handle( SALOME_InteractiveObject ) anIO = aList.First();
558 if ( anIO->hasEntry() ) {
559 QString ior = ::getIORfromIO(anIO, aSupMod);
560 myField->setData( ior );
567 // ----------------------------
569 // ----------------------------
571 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
572 :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
574 myPortCanvas = thePort;
578 void SUPERVGUI_StreamInDlg::init()
580 setSizeGripEnabled( true );
581 setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
583 QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
585 QFrame* aCtrlPane = new QFrame(this);
586 QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
589 QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane);
590 aCtrlLayout->addWidget(aSchemaLbl, 0, 0);
592 mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" );
593 mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
594 mySchemaCombo->insertItem("SCHENULL");
595 mySchemaCombo->insertItem("TI");
596 mySchemaCombo->insertItem("TF");
597 mySchemaCombo->insertItem("DELTA");
598 aCtrlLayout->addWidget(mySchemaCombo, 0, 1);
601 QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane);
602 aCtrlLayout->addWidget(aInterLbl, 1, 0);
604 myInterCombo = new QComboBox(aCtrlPane, "InterBox" );
605 myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
606 myInterCombo->insertItem("INTERNULL");
607 myInterCombo->insertItem("L0");
608 myInterCombo->insertItem("L1");
609 aCtrlLayout->addWidget(myInterCombo, 1, 1);
612 QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane);
613 aCtrlLayout->addWidget(aExtraLbl, 2, 0);
615 myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" );
616 myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
617 myExterCombo->insertItem("EXTRANULL");
618 myExterCombo->insertItem("E0");
619 myExterCombo->insertItem("E1");
620 aCtrlLayout->addWidget(myExterCombo, 2, 1);
622 TopLayout->addWidget( aCtrlPane );
625 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
626 GroupButtons->setColumnLayout(0, Qt::Vertical );
627 GroupButtons->layout()->setSpacing( 0 );
628 GroupButtons->layout()->setMargin( 0 );
629 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
630 GroupButtonsLayout->setAlignment( Qt::AlignTop );
631 GroupButtonsLayout->setSpacing( 5 );
632 GroupButtonsLayout->setMargin( 8 );
634 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
635 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
637 GroupButtonsLayout->addWidget( okB, 0, 0 );
638 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
639 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
641 TopLayout->addWidget( GroupButtons );
643 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
644 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
648 void SUPERVGUI_StreamInDlg::setData() {
649 SUPERV::KindOfSchema aSchema;
650 SUPERV::KindOfInterpolation aInterpolat;
651 SUPERV::KindOfExtrapolation aExtrapolat;
653 myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
655 mySchemaCombo->setCurrentItem((int)aSchema);
656 myInterCombo->setCurrentItem((int)aInterpolat);
657 myExterCombo->setCurrentItem((int)aExtrapolat);
660 void SUPERVGUI_StreamInDlg::accept() {
661 myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
662 myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(),
663 (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
664 (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
669 //-------------------------------------------------------------------------
670 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
671 :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
673 myPortCanvas = thePort;
677 void SUPERVGUI_StreamOutDlg::init()
679 setSizeGripEnabled( true );
680 setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
682 QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
684 QFrame* aCtrlPane = new QFrame(this);
685 QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
687 QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane);
688 aCtrlLayout->addWidget(aLbl, 0, 0);
690 myValEdit = new QLineEdit( aCtrlPane, "ValEdit" );
691 myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
692 myValEdit->setValidator( new QIntValidator(this) );
693 SUPERV_StreamPort aEngine = myPortCanvas->getStreamEngine();
694 myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues()));
695 aCtrlLayout->addWidget(myValEdit, 0, 1);
696 TopLayout->addWidget( aCtrlPane );
699 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
700 GroupButtons->setColumnLayout(0, Qt::Vertical );
701 GroupButtons->layout()->setSpacing( 0 );
702 GroupButtons->layout()->setMargin( 0 );
703 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
704 GroupButtonsLayout->setAlignment( Qt::AlignTop );
705 GroupButtonsLayout->setSpacing( 5 );
706 GroupButtonsLayout->setMargin( 8 );
708 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
709 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
711 GroupButtonsLayout->addWidget( okB, 0, 0 );
712 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
713 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
715 TopLayout->addWidget( GroupButtons );
717 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
718 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
721 void SUPERVGUI_StreamOutDlg::accept() {
723 QString aStr = myValEdit->text();
725 aRes = aStr.toLong();
726 myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);