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