Salome HOME
Fix for bug PAL7845: main->Editing() is called NOT before opening "Browse" node dialo...
[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   myNodeCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
208   if ( myIsEditable ) {
209     SUPERVGUI_PortField* aField;
210     for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
211       aField->setNewValue();
212     }
213     myNodeCanvas->sync();
214     myNodeCanvas->getMain()->getCanvas()->update();
215   }
216   myNodeCanvas->getMain()->lockedGraph(false);
217   QDialog::accept();
218   close();
219 }
220
221
222 /** 
223  * Closes and destroys dialog
224  */
225 void SUPERVGUI_BrowseNodeDlg::reject() {
226   myNodeCanvas->getMain()->lockedGraph(false);
227   QDialog::reject();
228   close();
229 }
230
231 /**
232  * Update current values on show event
233  */
234 void SUPERVGUI_BrowseNodeDlg::showEvent( QShowEvent* theEvent ) {
235   setValues();
236   QDialog::showEvent( theEvent );
237 }
238
239 /**
240  * Slot, called when field is focused
241  */
242 void SUPERVGUI_BrowseNodeDlg::onFieldActivated()
243 {
244   SUPERVGUI_PortField* aField = (SUPERVGUI_PortField*)sender();
245   myActiveField = (aField->isEditable())? aField : 0;
246 }
247
248
249
250 /**
251  * Slot, called when selection is changed
252  */
253 void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
254 {
255   if ( myActiveField ) {
256     if( mySelection->IObjectCount() == 1 ) {
257       Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
258       if ( anIO->hasEntry() ) {
259         SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
260         getStudyDocument()->FindObjectID( anIO->getEntry() );
261           
262         SALOMEDS::GenericAttribute_var anAttr;
263         SALOMEDS::AttributeIOR_var     anIOR;
264         Standard_CString               ior = "";
265           
266         if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
267           anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
268           ior = anIOR->Value();
269         }
270         else {
271           ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
272         }
273         myActiveField->setData( ior );
274       }
275     }
276   }
277 }
278
279
280 /**
281  * Constructor (SUPERVGUI_CanvasPort)
282  */
283 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
284   : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
285 {
286   myPortCanvas = thePort;
287
288   init();
289 }
290
291 void SUPERVGUI_GetValueDlg::init()
292 {
293   myOKBtn = 0;
294   setSizeGripEnabled( true );
295
296   mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
297 //  mySelection->ClearIObjects();
298
299   setName( "SUPERVGUI_GetValueDlg" );
300   setCaption( tr( "TIT_SETVALUE_PORT" ) );
301   
302   QGridLayout* aBaseLayout = new QGridLayout( this );
303   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
304   
305   QGroupBox* aBox = new QGroupBox( this );
306   aBox->setColumnLayout( 0, Qt::Vertical );
307   aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 );
308   QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() );
309   aBoxLayout->setAlignment( Qt::AlignTop );
310   aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 );
311   aBaseLayout->addWidget( aBox, 0, 0 );
312   aBox->setMinimumWidth( 200 );
313   
314   QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox );
315   QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt );
316   aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 );
317   SUPERV_Port aEngine = myPortCanvas->getEngine();
318
319   myField = new SUPERVGUI_PortField( aBox, aEngine );
320   bool myIsEditable = myField->isEditable();
321   aBoxLayout->addWidget( myField->myLabel, 1, 0 ); 
322   aBoxLayout->addWidget( myField->myValue, 1, 1 );
323   
324   QGroupBox* aBtnBox = new QGroupBox( this );
325   aBtnBox->setColumnLayout( 0, Qt::Vertical );
326   aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
327   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
328   aBtnLayout->setAlignment( Qt::AlignTop );
329   aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
330
331   aBaseLayout->addWidget( aBtnBox, 1, 0 );
332
333   if ( myIsEditable ) {
334     myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
335     connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
336     aBtnLayout->addWidget( myOKBtn );
337   }
338
339   aBtnLayout->addStretch();
340   myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
341   aBtnLayout->addWidget( myCancelBtn );
342   connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
343   
344   if ( !myIsEditable )
345     aBtnLayout->addStretch();
346
347   myField->updateGUI();
348   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
349   
350   myPortCanvas->getMain()->lockedGraph(true);
351 }
352
353 /**
354  * Destructor
355  */
356 SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() {
357 }
358
359 /** 
360  * Set entered value into port and then closes and destroys dialog
361  */
362 void SUPERVGUI_GetValueDlg::accept() {
363   myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
364   if ( myField->setNewValue() ) {
365     
366     myPortCanvas->sync();
367
368     // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status
369     // asv : 13.12.04 : commented out sync() of Node.  See 2.21.
370     //if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) {
371     //  SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent();
372     //  aNode->sync();
373     //}
374
375     myPortCanvas->getMain()->getCanvas()->update();
376   }
377   else {
378     if ( QMessageBox::warning( QAD_Application::getDesktop(), 
379                                tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
380                                QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
381       return;
382   }
383
384   myPortCanvas->getMain()->lockedGraph(false);
385   
386   QDialog::accept();
387   close();
388 }
389
390 /** 
391  * Closes and destroys dialog
392  */
393 void SUPERVGUI_GetValueDlg::reject() {
394   myPortCanvas->getMain()->lockedGraph(false);
395   QDialog::reject();
396   close();
397 }
398
399 /**
400  * Slot, called when selection is changed
401  */
402 void SUPERVGUI_GetValueDlg::onSelectionChanged()
403 {
404   if( mySelection->IObjectCount() == 1 ) {
405     Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
406     if ( anIO->hasEntry() ) {
407       SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
408       getStudyDocument()->FindObjectID( anIO->getEntry() );
409         
410       SALOMEDS::GenericAttribute_var anAttr;
411       SALOMEDS::AttributeIOR_var     anIOR;
412       Standard_CString               ior = "";
413         
414       if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
415         anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
416         ior = anIOR->Value();
417       }
418       else {
419         ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
420       }
421       myField->setData( ior );
422     }
423   }
424 }
425
426
427
428 // ----------------------------
429 // Stream Ports
430 // ----------------------------
431
432 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
433   :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
434 {
435   myPortCanvas = thePort;
436   init();
437 }
438
439 void SUPERVGUI_StreamInDlg::init()
440 {
441   setSizeGripEnabled( true );
442   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
443
444   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
445
446   QFrame* aCtrlPane = new QFrame(this);
447   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
448
449   // Schema
450   QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane);
451   aCtrlLayout->addWidget(aSchemaLbl, 0, 0);
452
453   mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" );
454   mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
455   mySchemaCombo->insertItem("SCHENULL"); 
456   mySchemaCombo->insertItem("TI");  
457   mySchemaCombo->insertItem("TF");
458   mySchemaCombo->insertItem("DELTA");
459   aCtrlLayout->addWidget(mySchemaCombo, 0, 1);
460
461   // Interpolation
462   QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane);
463   aCtrlLayout->addWidget(aInterLbl, 1, 0);
464
465   myInterCombo = new QComboBox(aCtrlPane, "InterBox" );
466   myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
467   myInterCombo->insertItem("INTERNULL"); 
468   myInterCombo->insertItem("L0"); 
469   myInterCombo->insertItem("L1");
470   aCtrlLayout->addWidget(myInterCombo, 1, 1);
471
472   // Extrapolation
473   QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane);
474   aCtrlLayout->addWidget(aExtraLbl, 2, 0);
475
476   myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" );
477   myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
478   myExterCombo->insertItem("EXTRANULL");  
479   myExterCombo->insertItem("E0");
480   myExterCombo->insertItem("E1");
481   aCtrlLayout->addWidget(myExterCombo, 2, 1);
482   
483   TopLayout->addWidget( aCtrlPane );
484
485   // Buttons
486   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
487   GroupButtons->setColumnLayout(0, Qt::Vertical );
488   GroupButtons->layout()->setSpacing( 0 );
489   GroupButtons->layout()->setMargin( 0 );
490   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
491   GroupButtonsLayout->setAlignment( Qt::AlignTop );
492   GroupButtonsLayout->setSpacing( 5 );
493   GroupButtonsLayout->setMargin( 8 );
494   
495   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
496   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
497
498   GroupButtonsLayout->addWidget( okB, 0, 0 );
499   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
500   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
501
502   TopLayout->addWidget( GroupButtons );
503
504   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
505   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
506   setData();
507 }
508
509 void SUPERVGUI_StreamInDlg::setData() {
510   SUPERV::KindOfSchema aSchema;
511   SUPERV::KindOfInterpolation aInterpolat;
512   SUPERV::KindOfExtrapolation aExtrapolat;
513
514   myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
515
516   mySchemaCombo->setCurrentItem((int)aSchema);
517   myInterCombo->setCurrentItem((int)aInterpolat);
518   myExterCombo->setCurrentItem((int)aExtrapolat);
519 }
520
521 void SUPERVGUI_StreamInDlg::accept() {
522   myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
523   myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), 
524                                              (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
525                                              (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
526   QDialog::accept();
527 }
528
529
530 //-------------------------------------------------------------------------
531 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
532   :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
533 {
534   myPortCanvas = thePort;
535   init();
536 }
537
538 void SUPERVGUI_StreamOutDlg::init()
539 {
540   setSizeGripEnabled( true );
541   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
542
543   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
544
545   QFrame* aCtrlPane = new QFrame(this);
546   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
547
548   QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane);
549   aCtrlLayout->addWidget(aLbl, 0, 0);
550
551   myValEdit = new QLineEdit( aCtrlPane, "ValEdit" );
552   myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
553   myValEdit->setValidator( new QIntValidator(this) );
554   SUPERV_StreamPort aEngine = myPortCanvas->getStreamEngine();
555   myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues()));
556   aCtrlLayout->addWidget(myValEdit, 0, 1);
557   TopLayout->addWidget( aCtrlPane );
558   
559   // Buttons
560   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
561   GroupButtons->setColumnLayout(0, Qt::Vertical );
562   GroupButtons->layout()->setSpacing( 0 );
563   GroupButtons->layout()->setMargin( 0 );
564   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
565   GroupButtonsLayout->setAlignment( Qt::AlignTop );
566   GroupButtonsLayout->setSpacing( 5 );
567   GroupButtonsLayout->setMargin( 8 );
568   
569   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
570   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
571
572   GroupButtonsLayout->addWidget( okB, 0, 0 );
573   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
574   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
575
576   TopLayout->addWidget( GroupButtons );
577
578   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
579   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
580 }
581
582 void SUPERVGUI_StreamOutDlg::accept() {
583   int aRes = 0;
584   QString aStr = myValEdit->text();
585   if (!aStr.isEmpty())
586     aRes = aStr.toLong();
587   myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);
588   QDialog::accept();
589 }
590