]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx
Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_BrowseNodeDlg.cxx
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SUPERVGUI_BrowseNodeDlg.cxx
8 //  Author : Vitaly SMETANNIKOV
9 //  Module : SUPERV
10
11 using namespace std;
12
13 #include "SALOMEDSClient.hxx"
14 #include "SALOMEDS_SObject.hxx"
15 #include "SALOMEDS_Study.hxx"
16 #include <boost/shared_ptr.hpp>
17 using namespace boost;
18
19 #include "SalomeApp_Application.h"
20 #include "SalomeApp_SelectionMgr.h"
21 #include "SalomeApp_Study.h"
22 #include "SUIT_Session.h"
23
24 #include "SALOME_ListIO.hxx"
25
26 #include "SUPERVGUI_BrowseNodeDlg.h"
27 #include "SUPERVGUI_CanvasNode.h"
28 #include "SUPERVGUI_CanvasPort.h"
29 #include "SUPERVGUI.h"
30
31 #include <qlayout.h>
32 #include <qlabel.h>
33 #include <qlineedit.h>
34 #include <qpushbutton.h>
35 #include <qhbox.h>
36 #include <qgroupbox.h>
37 #include <qvalidator.h>
38
39 /**
40  * Constructor
41  */
42 SUPERVGUI_PortField::SUPERVGUI_PortField( QWidget* theParent, SUPERV_Port thePort ) {
43   myPort = thePort;
44   myIsEditable = myPort->IsInput() && ( !myPort->IsLinked() );
45
46   QString aLabelTxt(myPort->Name());
47
48   SUPERV_CNode aNode = myPort->Node();
49   SALOME_ModuleCatalog::Service* aService = aNode->Service();
50   SALOME_ModuleCatalog::ListOfServicesParameter aList;
51   aList = (myPort->IsInput())? aService->ServiceinParameter : aService->ServiceoutParameter;
52   for (int i = 0; i < aList.length(); i++) {
53     SALOME_ModuleCatalog::ServicesParameter* aParam = &(aList[i]);
54     if (aLabelTxt == aParam->Parametername) {
55       aLabelTxt += QString(" (") + QString(aParam->Parametertype) + QString(")");
56       break;
57     }
58   }
59  
60   aLabelTxt += QString(":");
61   myLabel = new QLabel(aLabelTxt, theParent );
62
63   myValue = new QLineEdit( theParent );
64   myLabel->setBuddy( myValue );
65   if (!myIsEditable) {
66     myValue->setReadOnly( !myIsEditable );
67     QPalette aPalette = myValue->palette();
68     aPalette.setInactive(aPalette.disabled());
69     aPalette.setActive(aPalette.disabled());
70     myValue->setPalette(aPalette);
71   } 
72   myValue->installEventFilter( this );
73 }
74
75 /**
76  * Sets value from text edit control to engine of port
77  */
78 bool SUPERVGUI_PortField::setNewValue() {
79   if ( !myIsEditable ) return false;
80
81   QString aTxt = myValue->text();
82   if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
83   
84   if ( aTxt.find( "Unknown" ) < 0 ) {
85     SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
86     if ( !aSupMod ) {
87       MESSAGE("NULL Supervision module!");
88       return false;
89     }
90     return myPort->Input( aSupMod->getEngine()->StringValue( aTxt ) );
91   }
92   return false;
93 }
94  
95 /** 
96  * Event filter
97  */ 
98 bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e )
99 {
100   if ( o == myValue ) {
101     if ( e->type() == QEvent::FocusIn ) {
102       emit activated();
103     }
104   }
105   return QObject::eventFilter( o, e );
106 }
107
108
109 /**
110  * Constructor (SUPERVGUI_CanvasNode)
111  */
112 SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode )
113   : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
114 {
115   myNodeCanvas = theNode;
116
117   init();
118 }
119
120 void SUPERVGUI_BrowseNodeDlg::init()
121 {
122   myActiveField = 0;
123   setSizeGripEnabled( true );
124   myPortsList.setAutoDelete( true );
125
126   SUPERV_CNode aEngine = myNodeCanvas->getEngine();
127   
128   setName( "SUPERVGUI_BrowseNodeDlg" );
129   setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() );
130
131   QGridLayout* aBaseLayout = new QGridLayout( this );
132   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
133
134   QGroupBox* aInBox = new QGroupBox( 2, Qt::Horizontal, "Input", this );
135   aInBox->setMargin( 11 );
136   aBaseLayout->addWidget( aInBox, 0, 0 );
137
138   QGroupBox* aOutBox = new QGroupBox( 2, Qt::Horizontal, "Output", this);
139   aOutBox->setMargin( 11 );
140   aBaseLayout->addWidget( aOutBox, 0, 1 );
141
142   myIsEditable = false;
143   int                aPIcount = 0;
144   int                aPOcount = 0;
145   SUPERV_Ports       ports = aEngine->Ports();
146   int                n     = ports->length();
147
148   for ( int i = 0; i < n; i++ ) {
149     if ( ports[i]->IsInput() ) {
150       if ( !ports[i]->IsGate() ) { // not a gate
151         SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] );
152         if ( aField->isEditable() ) 
153           myIsEditable = true;
154         myPortsList.append( aField );
155         if ( !myActiveField )
156           myActiveField = aField;
157         connect( aField, SIGNAL( activated() ), this, SLOT( onFieldActivated() ) );
158       }
159       aPIcount++;
160     } 
161     else {
162       if ( !ports[i]->IsGate() ) { // not a gate
163         myPortsList.append( new SUPERVGUI_PortField( aOutBox, ports[i] ) );
164       }
165       aPOcount++;
166     }
167   }
168   
169   QGroupBox* aBtnBox = new QGroupBox( this );
170   aBtnBox->setColumnLayout( 0, Qt::Vertical );
171   aBtnBox->layout()->setSpacing( 0 ); 
172   aBtnBox->layout()->setMargin( 0 );
173   
174   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
175   aBtnLayout->setAlignment( Qt::AlignTop );
176   aBtnLayout->setSpacing( 6 ); 
177   aBtnLayout->setMargin( 11 );
178
179   if ( myIsEditable ) {
180     QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), this );
181     aBaseLayout->addMultiCellWidget( aInfoLab, 1, 1, 0, 1 );
182
183     QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
184     connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
185     aBtnLayout->addWidget( aOkBtn );
186     aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 );
187   } else
188     aBaseLayout->addMultiCellWidget( aBtnBox, 1, 1, 0, 1 );
189
190   aBtnLayout->addStretch();
191   QPushButton* aCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
192   aBtnLayout->addWidget( aCancelBtn );
193   connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
194   
195   if ( !myIsEditable )
196     aBtnLayout->addStretch();
197
198   SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
199   if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(), 
200                           SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
201   else MESSAGE("NULL Supervision module!");
202   
203   myNodeCanvas->getMain()->lockedGraph(true);
204 }
205
206 /**
207  * Destructor
208  */
209 SUPERVGUI_BrowseNodeDlg::~SUPERVGUI_BrowseNodeDlg() {
210 }
211
212 /**
213  * Set current values of editable ports
214  */
215 void SUPERVGUI_BrowseNodeDlg::setValues() {
216   SUPERVGUI_PortField* aField;
217   for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
218     aField->updateGUI();
219   }
220 }
221
222 /** 
223  * Set inputed values of editable ports and then closes and destroys dialog
224  */
225 void SUPERVGUI_BrowseNodeDlg::accept() {
226   myNodeCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
227   if ( myIsEditable ) {
228     SUPERVGUI_PortField* aField;
229     for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
230       aField->setNewValue();
231     }
232     myNodeCanvas->sync();
233     myNodeCanvas->getMain()->getCanvas()->update();
234   }
235   myNodeCanvas->getMain()->lockedGraph(false);
236   QDialog::accept();
237   close();
238 }
239
240
241 /** 
242  * Closes and destroys dialog
243  */
244 void SUPERVGUI_BrowseNodeDlg::reject() {
245   myNodeCanvas->getMain()->lockedGraph(false);
246   QDialog::reject();
247   close();
248 }
249
250 /**
251  * Update current values on show event
252  */
253 void SUPERVGUI_BrowseNodeDlg::showEvent( QShowEvent* theEvent ) {
254   setValues();
255   QDialog::showEvent( theEvent );
256 }
257
258 /**
259  * Slot, called when field is focused
260  */
261 void SUPERVGUI_BrowseNodeDlg::onFieldActivated()
262 {
263   SUPERVGUI_PortField* aField = (SUPERVGUI_PortField*)sender();
264   myActiveField = (aField->isEditable())? aField : 0;
265 }
266
267
268
269 /**
270  * Slot, called when selection is changed
271  */
272 void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
273 {
274   if ( myActiveField ) {
275     
276     SALOME_ListIO aList;
277     aList.Clear();
278
279     SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
280     if ( !aSupMod ) {
281       MESSAGE("NULL Supervision module!");
282       return;
283     }
284
285     (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))
286       ->selectionMgr()->selectedObjects( aList );
287     
288     if( aList.Extent() == 1 ) {
289       Handle( SALOME_InteractiveObject ) anIO = aList.First();
290       if ( anIO->hasEntry() ) {
291         _PTR(SObject) aObj ( dynamic_cast<SalomeApp_Study*>( aSupMod->getActiveStudy() )->
292                              studyDS()->FindObjectID( anIO->getEntry() ) );
293           
294         _PTR(GenericAttribute) anAttr;
295         QString ior("");
296           
297         if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
298           _PTR(AttributeIOR) anIOR ( anAttr );
299           ior = anIOR->Value().c_str();
300         }
301         else {
302           SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aObj->GetStudy().get() );
303           SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aObj.get() );
304           if ( aSStudy && aSSObj )
305             ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
306         }
307         myActiveField->setData( ior );
308       }
309     }
310   }
311 }
312
313
314 /**
315  * Constructor (SUPERVGUI_CanvasPort)
316  */
317 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
318   : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
319 {
320   myPortCanvas = thePort;
321
322   init();
323 }
324
325 void SUPERVGUI_GetValueDlg::init()
326 {
327   myOKBtn = 0;
328   setSizeGripEnabled( true );
329
330   setName( "SUPERVGUI_GetValueDlg" );
331   setCaption( tr( "TIT_SETVALUE_PORT" ) );
332   
333   QGridLayout* aBaseLayout = new QGridLayout( this );
334   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
335   
336   QGroupBox* aBox = new QGroupBox( this );
337   aBox->setColumnLayout( 0, Qt::Vertical );
338   aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 );
339   QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() );
340   aBoxLayout->setAlignment( Qt::AlignTop );
341   aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 );
342   aBaseLayout->addWidget( aBox, 0, 0 );
343   aBox->setMinimumWidth( 200 );
344   
345   QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox );
346   QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt );
347   aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 );
348   SUPERV_Port aEngine = myPortCanvas->getEngine();
349
350   myField = new SUPERVGUI_PortField( aBox, aEngine );
351   bool myIsEditable = myField->isEditable();
352   aBoxLayout->addWidget( myField->myLabel, 1, 0 ); 
353   aBoxLayout->addWidget( myField->myValue, 1, 1 );
354   
355   QGroupBox* aBtnBox = new QGroupBox( this );
356   aBtnBox->setColumnLayout( 0, Qt::Vertical );
357   aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
358   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
359   aBtnLayout->setAlignment( Qt::AlignTop );
360   aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
361
362   aBaseLayout->addWidget( aBtnBox, 1, 0 );
363
364   if ( myIsEditable ) {
365     myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
366     connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
367     aBtnLayout->addWidget( myOKBtn );
368   }
369
370   aBtnLayout->addStretch();
371   myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
372   aBtnLayout->addWidget( myCancelBtn );
373   connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
374   
375   if ( !myIsEditable )
376     aBtnLayout->addStretch();
377
378   myField->updateGUI();
379   
380   SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
381   if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(), 
382                           SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
383   else MESSAGE("NULL Supervision module!");
384  
385   myPortCanvas->getMain()->lockedGraph(true);
386 }
387
388 /**
389  * Destructor
390  */
391 SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() {
392 }
393
394 /** 
395  * Set entered value into port and then closes and destroys dialog
396  */
397 void SUPERVGUI_GetValueDlg::accept() {
398   myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
399   if ( myField->setNewValue() ) {
400     
401     myPortCanvas->sync();
402
403     // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status
404     // asv : 13.12.04 : commented out sync() of Node.  See 2.21.
405     //if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) {
406     //  SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent();
407     //  aNode->sync();
408     //}
409
410     myPortCanvas->getMain()->getCanvas()->update();
411   }
412   else {
413     if ( QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), 
414                                tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
415                                QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
416       return;
417   }
418
419   myPortCanvas->getMain()->lockedGraph(false);
420   
421   QDialog::accept();
422   close();
423 }
424
425 /** 
426  * Closes and destroys dialog
427  */
428 void SUPERVGUI_GetValueDlg::reject() {
429   myPortCanvas->getMain()->lockedGraph(false);
430   QDialog::reject();
431   close();
432 }
433
434 /**
435  * Slot, called when selection is changed
436  */
437 void SUPERVGUI_GetValueDlg::onSelectionChanged()
438 {
439   SALOME_ListIO aList;
440   aList.Clear();
441   
442   SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
443   if ( !aSupMod ) {
444     MESSAGE("NULL Supervision module!");
445     return;
446   }
447   
448   (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))
449     ->selectionMgr()->selectedObjects( aList );
450   
451   if( aList.Extent() == 1 ) {
452     Handle( SALOME_InteractiveObject ) anIO = aList.First();
453     if ( anIO->hasEntry() ) {
454       _PTR(SObject) aObj ( dynamic_cast<SalomeApp_Study*>( aSupMod->getActiveStudy() )->
455                            studyDS()->FindObjectID( anIO->getEntry() ) );
456         
457       _PTR(GenericAttribute) anAttr;
458       QString ior("");
459         
460       if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
461         _PTR(AttributeIOR) anIOR ( anAttr );
462         ior = anIOR->Value().c_str();
463       }
464       else {
465         SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aObj->GetStudy().get() );
466         SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aObj.get() );
467         if ( aSStudy && aSSObj )
468           ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
469       }
470       myField->setData( ior );
471     }
472   }
473 }
474
475
476
477 // ----------------------------
478 // Stream Ports
479 // ----------------------------
480
481 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
482   :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
483 {
484   myPortCanvas = thePort;
485   init();
486 }
487
488 void SUPERVGUI_StreamInDlg::init()
489 {
490   setSizeGripEnabled( true );
491   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
492
493   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
494
495   QFrame* aCtrlPane = new QFrame(this);
496   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
497
498   // Schema
499   QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane);
500   aCtrlLayout->addWidget(aSchemaLbl, 0, 0);
501
502   mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" );
503   mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
504   mySchemaCombo->insertItem("SCHENULL"); 
505   mySchemaCombo->insertItem("TI");  
506   mySchemaCombo->insertItem("TF");
507   mySchemaCombo->insertItem("DELTA");
508   aCtrlLayout->addWidget(mySchemaCombo, 0, 1);
509
510   // Interpolation
511   QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane);
512   aCtrlLayout->addWidget(aInterLbl, 1, 0);
513
514   myInterCombo = new QComboBox(aCtrlPane, "InterBox" );
515   myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
516   myInterCombo->insertItem("INTERNULL"); 
517   myInterCombo->insertItem("L0"); 
518   myInterCombo->insertItem("L1");
519   aCtrlLayout->addWidget(myInterCombo, 1, 1);
520
521   // Extrapolation
522   QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane);
523   aCtrlLayout->addWidget(aExtraLbl, 2, 0);
524
525   myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" );
526   myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
527   myExterCombo->insertItem("EXTRANULL");  
528   myExterCombo->insertItem("E0");
529   myExterCombo->insertItem("E1");
530   aCtrlLayout->addWidget(myExterCombo, 2, 1);
531   
532   TopLayout->addWidget( aCtrlPane );
533
534   // Buttons
535   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
536   GroupButtons->setColumnLayout(0, Qt::Vertical );
537   GroupButtons->layout()->setSpacing( 0 );
538   GroupButtons->layout()->setMargin( 0 );
539   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
540   GroupButtonsLayout->setAlignment( Qt::AlignTop );
541   GroupButtonsLayout->setSpacing( 5 );
542   GroupButtonsLayout->setMargin( 8 );
543   
544   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
545   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
546
547   GroupButtonsLayout->addWidget( okB, 0, 0 );
548   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
549   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
550
551   TopLayout->addWidget( GroupButtons );
552
553   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
554   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
555   setData();
556 }
557
558 void SUPERVGUI_StreamInDlg::setData() {
559   SUPERV::KindOfSchema aSchema;
560   SUPERV::KindOfInterpolation aInterpolat;
561   SUPERV::KindOfExtrapolation aExtrapolat;
562
563   myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
564
565   mySchemaCombo->setCurrentItem((int)aSchema);
566   myInterCombo->setCurrentItem((int)aInterpolat);
567   myExterCombo->setCurrentItem((int)aExtrapolat);
568 }
569
570 void SUPERVGUI_StreamInDlg::accept() {
571   myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
572   myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), 
573                                              (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
574                                              (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
575   QDialog::accept();
576 }
577
578
579 //-------------------------------------------------------------------------
580 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
581   :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
582 {
583   myPortCanvas = thePort;
584   init();
585 }
586
587 void SUPERVGUI_StreamOutDlg::init()
588 {
589   setSizeGripEnabled( true );
590   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
591
592   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
593
594   QFrame* aCtrlPane = new QFrame(this);
595   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
596
597   QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane);
598   aCtrlLayout->addWidget(aLbl, 0, 0);
599
600   myValEdit = new QLineEdit( aCtrlPane, "ValEdit" );
601   myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
602   myValEdit->setValidator( new QIntValidator(this) );
603   SUPERV_StreamPort aEngine = myPortCanvas->getStreamEngine();
604   myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues()));
605   aCtrlLayout->addWidget(myValEdit, 0, 1);
606   TopLayout->addWidget( aCtrlPane );
607   
608   // Buttons
609   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
610   GroupButtons->setColumnLayout(0, Qt::Vertical );
611   GroupButtons->layout()->setSpacing( 0 );
612   GroupButtons->layout()->setMargin( 0 );
613   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
614   GroupButtonsLayout->setAlignment( Qt::AlignTop );
615   GroupButtonsLayout->setSpacing( 5 );
616   GroupButtonsLayout->setMargin( 8 );
617   
618   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
619   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
620
621   GroupButtonsLayout->addWidget( okB, 0, 0 );
622   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
623   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
624
625   TopLayout->addWidget( GroupButtons );
626
627   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
628   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
629 }
630
631 void SUPERVGUI_StreamOutDlg::accept() {
632   int aRes = 0;
633   QString aStr = myValEdit->text();
634   if (!aStr.isEmpty())
635     aRes = aStr.toLong();
636   myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);
637   QDialog::accept();
638 }
639