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