Salome HOME
DCQ:prepare 2.0.0
[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 #include "SUPERVGUI_BrowseNodeDlg.h"
13 #include "SUPERVGUI_Node.h"
14 #include "SUPERVGUI_CanvasNode.h"
15 #include "SUPERVGUI_Port.h"
16 #include "SUPERVGUI_CanvasPort.h"
17 #include "SUPERVGUI.h"
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   //cout<<" ===>  Set new value!"<<endl;
73     return myPort->Input( Supervision.getEngine()->StringValue( aTxt ) );
74   }
75   return false;
76 }
77  
78 /** 
79  * Event filter
80  */ 
81 bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e )
82 {
83   if ( o == myValue ) {
84     if ( e->type() == QEvent::FocusIn ) {
85       emit activated();
86     }
87   }
88   return QObject::eventFilter( o, e );
89 }
90
91
92 /**
93  * Constructor (SUPERVGUI_Node)
94  */
95 SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode )
96   : QDialog( theNode, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
97 {
98   myNode = theNode;
99   myNodeCanvas = 0;
100
101   init();
102 }
103
104 /**
105  * Constructor (SUPERVGUI_CanvasNode)
106  */
107 SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode )
108   : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
109 {
110   myNode = 0;
111   myNodeCanvas = theNode;
112
113   init();
114 }
115
116 void SUPERVGUI_BrowseNodeDlg::init()
117 {
118   myActiveField = 0;
119   setSizeGripEnabled( true );
120   myPortsList.setAutoDelete( true );
121
122   SUPERV_CNode aEngine;
123   if (myNode != 0)
124     aEngine = myNode->getEngine();
125   else
126     aEngine = myNodeCanvas->getEngine();
127   
128   mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
129 //  mySelection->ClearIObjects();
130
131   setName( "SUPERVGUI_BrowseNodeDlg" );
132   setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() );
133
134   QGridLayout* aBaseLayout = new QGridLayout( this );
135   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
136
137   QGroupBox* aInBox = new QGroupBox( 2, Qt::Horizontal, "Input", this );
138   aInBox->setMargin( 11 );
139   aBaseLayout->addWidget( aInBox, 0, 0 );
140
141   QGroupBox* aOutBox = new QGroupBox( 2, Qt::Horizontal, "Output", this);
142   aOutBox->setMargin( 11 );
143   aBaseLayout->addWidget( aOutBox, 0, 1 );
144
145   myIsEditable = false;
146   int                aPIcount = 0;
147   int                aPOcount = 0;
148   SUPERV_Ports       ports = aEngine->Ports();
149   int                n     = ports->length();
150
151   for ( int i = 0; i < n; i++ ) {
152     if ( ports[i]->IsInput() ) {
153       if ( !ports[i]->IsGate() ) { // not a gate
154         SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] );
155         if ( aField->isEditable() ) myIsEditable = true;
156         myPortsList.append( aField );
157         if ( !myActiveField )
158           myActiveField = aField;
159         connect( aField, SIGNAL( activated() ), this, SLOT( onFieldActivated() ) );
160       }
161       aPIcount++;
162     } 
163     else {
164       if ( !ports[i]->IsGate() ) { // not a gate
165         myPortsList.append( new SUPERVGUI_PortField( aOutBox, ports[i] ) );
166       }
167       aPOcount++;
168     }
169   }
170   
171   QGroupBox* aBtnBox = new QGroupBox( this );
172   aBtnBox->setColumnLayout( 0, Qt::Vertical );
173   aBtnBox->layout()->setSpacing( 0 ); 
174   aBtnBox->layout()->setMargin( 0 );
175   
176   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
177   aBtnLayout->setAlignment( Qt::AlignTop );
178   aBtnLayout->setSpacing( 6 ); 
179   aBtnLayout->setMargin( 11 );
180
181   if ( myIsEditable ) {
182     QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), this );
183     aBaseLayout->addMultiCellWidget( aInfoLab, 1, 1, 0, 1 );
184
185     QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
186     connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
187     aBtnLayout->addWidget( aOkBtn );
188     aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 );
189   } else
190     aBaseLayout->addMultiCellWidget( aBtnBox, 1, 1, 0, 1 );
191
192   aBtnLayout->addStretch();
193   QPushButton* aCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
194   aBtnLayout->addWidget( aCancelBtn );
195   connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
196   
197   if ( !myIsEditable )
198     aBtnLayout->addStretch();
199
200   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
201   if (myNode != 0)
202     myNode->getMain()->lockedGraph(true);
203   else
204     myNodeCanvas->getMain()->lockedGraph(true);
205 }
206
207 /**
208  * Destructor
209  */
210 SUPERVGUI_BrowseNodeDlg::~SUPERVGUI_BrowseNodeDlg() {
211 }
212
213 /**
214  * Set current values of editable ports
215  */
216 void SUPERVGUI_BrowseNodeDlg::setValues() {
217   SUPERVGUI_PortField* aField;
218   for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
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   if ( myIsEditable ) {
228     SUPERVGUI_PortField* aField;
229     for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
230       aField->setNewValue();
231     }
232     if (myNode != 0)
233       myNode->sync();
234     else {
235       myNodeCanvas->sync();
236       myNodeCanvas->getMain()->getCanvas()->update();
237     }
238   }
239   if (myNode != 0)
240     myNode->getMain()->lockedGraph(false);
241   else
242     myNodeCanvas->getMain()->lockedGraph(false);
243   QDialog::accept();
244   close();
245 }
246
247
248 /** 
249  * Closes and destroys dialog
250  */
251 void SUPERVGUI_BrowseNodeDlg::reject() {
252   if (myNode != 0)
253     myNode->getMain()->lockedGraph(false);
254   else
255     myNodeCanvas->getMain()->lockedGraph(false);
256   QDialog::reject();
257   close();
258 }
259
260 /**
261  * Update current values on show event
262  */
263 void SUPERVGUI_BrowseNodeDlg::showEvent( QShowEvent* theEvent ) {
264   setValues();
265   QDialog::showEvent( theEvent );
266 }
267
268 /**
269  * Slot, called when field is focused
270  */
271 void SUPERVGUI_BrowseNodeDlg::onFieldActivated()
272 {
273   SUPERVGUI_PortField* aField = (SUPERVGUI_PortField*)sender();
274   myActiveField = (aField->isEditable())? aField : 0;
275 }
276
277
278
279 /**
280  * Slot, called when selection is changed
281  */
282 void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
283 {
284   if ( myActiveField ) {
285     if( mySelection->IObjectCount() == 1 ) {
286       Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
287       if ( anIO->hasEntry() ) {
288         SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
289         getStudyDocument()->FindObjectID( anIO->getEntry() );
290           
291         SALOMEDS::GenericAttribute_var anAttr;
292         SALOMEDS::AttributeIOR_var     anIOR;
293         Standard_CString               ior = "";
294           
295         if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
296           anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
297           ior = anIOR->Value();
298         }
299         else {
300           ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
301         }
302         myActiveField->setData( ior );
303       }
304     }
305   }
306 }
307
308 /**
309  * Constructor (SUPERVGUI_PortIn)
310  */
311 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort )
312   : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
313 {
314   myPort = thePort;
315   myPortESNode = 0;
316   myPortCanvas = 0;
317
318   init();
319 }
320
321 /**
322  * Constructor (SUPERVGUI_PortInESNode)
323  */
324 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort )
325   : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
326 {
327   myPort = 0;
328   myPortESNode = thePort;
329   myPortCanvas = 0;
330
331   init();
332 }
333
334 /**
335  * Constructor (SUPERVGUI_CanvasPort)
336  */
337 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
338   : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
339 {
340   myPort = 0;
341   myPortESNode = 0;
342   myPortCanvas = thePort;
343
344   init();
345 }
346
347 void SUPERVGUI_GetValueDlg::init()
348 {
349   myOKBtn = 0;
350   setSizeGripEnabled( true );
351
352   mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
353 //  mySelection->ClearIObjects();
354
355   setName( "SUPERVGUI_GetValueDlg" );
356   setCaption( tr( "TIT_SETVALUE_PORT" ) );
357   
358   QGridLayout* aBaseLayout = new QGridLayout( this );
359   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
360   
361   QGroupBox* aBox = new QGroupBox( this );
362   aBox->setColumnLayout( 0, Qt::Vertical );
363   aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 );
364   QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() );
365   aBoxLayout->setAlignment( Qt::AlignTop );
366   aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 );
367   aBaseLayout->addWidget( aBox, 0, 0 );
368   aBox->setMinimumWidth( 200 );
369   
370   QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox );
371   QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt );
372   aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 );
373   SUPERV_Port aEngine;
374   if (myPort != 0)
375     aEngine = myPort->getPort();
376   else if (myPortESNode != 0)
377     aEngine = myPortESNode->getPort();
378   else {
379     aEngine = myPortCanvas->getEngine();
380   }
381   myField = new SUPERVGUI_PortField( aBox, aEngine );
382   bool myIsEditable = myField->isEditable();
383   aBoxLayout->addWidget( myField->myLabel, 1, 0 ); 
384   aBoxLayout->addWidget( myField->myValue, 1, 1 );
385   
386   QGroupBox* aBtnBox = new QGroupBox( this );
387   aBtnBox->setColumnLayout( 0, Qt::Vertical );
388   aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
389   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
390   aBtnLayout->setAlignment( Qt::AlignTop );
391   aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
392
393   aBaseLayout->addWidget( aBtnBox, 1, 0 );
394
395   if ( myIsEditable ) {
396     myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
397     connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
398     aBtnLayout->addWidget( myOKBtn );
399   }
400
401   aBtnLayout->addStretch();
402   myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
403   aBtnLayout->addWidget( myCancelBtn );
404   connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
405   
406   if ( !myIsEditable )
407     aBtnLayout->addStretch();
408
409   myField->updateGUI();
410   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
411   if (myPort != 0)
412     myPort->getMain()->lockedGraph(true);
413   else if (myPortESNode != 0)
414     myPortESNode->getMain()->lockedGraph(true);
415   else
416     myPortCanvas->getMain()->lockedGraph(true);
417 }
418
419 /**
420  * Destructor
421  */
422 SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() {
423 }
424
425 /** 
426  * Set entered value into port and then closes and destroys dialog
427  */
428 void SUPERVGUI_GetValueDlg::accept() {
429   if ( myField->setNewValue() ) {
430     
431     if (myPort != 0)
432       myPort->sync();
433     else if (myPortESNode != 0)
434       myPortESNode->sync();
435     else {
436       myPortCanvas->sync();
437       myPortCanvas->getMain()->getCanvas()->update();
438     }
439   }
440   else {
441     if ( QMessageBox::warning( QAD_Application::getDesktop(), 
442                                tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
443                                QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
444       return;
445   }
446
447   if (myPort != 0)
448     myPort->getMain()->lockedGraph(false);
449   else if (myPortESNode != 0)
450     myPortESNode->getMain()->lockedGraph(false);
451   else
452     myPortCanvas->getMain()->lockedGraph(false);
453   QDialog::accept();
454   close();
455 }
456
457 /** 
458  * Closes and destroys dialog
459  */
460 void SUPERVGUI_GetValueDlg::reject() {
461   if (myPort != 0)
462     myPort->getMain()->lockedGraph(false);
463   else if (myPortESNode != 0)
464     myPortESNode->getMain()->lockedGraph(false);
465   else
466     myPortCanvas->getMain()->lockedGraph(false);
467   QDialog::reject();
468   close();
469 }
470
471 /**
472  * Slot, called when selection is changed
473  */
474 void SUPERVGUI_GetValueDlg::onSelectionChanged()
475 {
476   if( mySelection->IObjectCount() == 1 ) {
477     Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
478     if ( anIO->hasEntry() ) {
479       SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
480       getStudyDocument()->FindObjectID( anIO->getEntry() );
481         
482       SALOMEDS::GenericAttribute_var anAttr;
483       SALOMEDS::AttributeIOR_var     anIOR;
484       Standard_CString               ior = "";
485         
486       if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
487         anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
488         ior = anIOR->Value();
489       }
490       else {
491         ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
492       }
493       myField->setData( ior );
494     }
495   }
496 }
497
498
499
500 // ----------------------------
501 // Stream Ports
502 // ----------------------------
503
504 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort)
505   :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
506 {
507   myPort = thePort;
508   myPortCanvas = 0;
509   init();
510 }
511
512 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
513   :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
514 {
515   myPort = 0;
516   myPortCanvas = thePort;
517   init();
518 }
519
520 void SUPERVGUI_StreamInDlg::init()
521 {
522   setSizeGripEnabled( true );
523   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
524
525   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
526
527   QFrame* aCtrlPane = new QFrame(this);
528   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
529
530   // Schema
531   QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane);
532   aCtrlLayout->addWidget(aSchemaLbl, 0, 0);
533
534   mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" );
535   mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
536   mySchemaCombo->insertItem("SCHENULL"); 
537   mySchemaCombo->insertItem("TI");  
538   mySchemaCombo->insertItem("TF");
539   mySchemaCombo->insertItem("DELTA");
540   aCtrlLayout->addWidget(mySchemaCombo, 0, 1);
541
542   // Interpolation
543   QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane);
544   aCtrlLayout->addWidget(aInterLbl, 1, 0);
545
546   myInterCombo = new QComboBox(aCtrlPane, "InterBox" );
547   myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
548   myInterCombo->insertItem("INTERNULL"); 
549   myInterCombo->insertItem("L0"); 
550   myInterCombo->insertItem("L1");
551   aCtrlLayout->addWidget(myInterCombo, 1, 1);
552
553   // Extrapolation
554   QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane);
555   aCtrlLayout->addWidget(aExtraLbl, 2, 0);
556
557   myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" );
558   myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
559   myExterCombo->insertItem("EXTRANULL");  
560   myExterCombo->insertItem("E0");
561   myExterCombo->insertItem("E1");
562   aCtrlLayout->addWidget(myExterCombo, 2, 1);
563   
564   TopLayout->addWidget( aCtrlPane );
565
566   // Buttons
567   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
568   GroupButtons->setColumnLayout(0, Qt::Vertical );
569   GroupButtons->layout()->setSpacing( 0 );
570   GroupButtons->layout()->setMargin( 0 );
571   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
572   GroupButtonsLayout->setAlignment( Qt::AlignTop );
573   GroupButtonsLayout->setSpacing( 5 );
574   GroupButtonsLayout->setMargin( 8 );
575   
576   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
577   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
578
579   GroupButtonsLayout->addWidget( okB, 0, 0 );
580   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
581   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
582
583   TopLayout->addWidget( GroupButtons );
584
585   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
586   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
587   setData();
588 }
589
590 void SUPERVGUI_StreamInDlg::setData() {
591   SUPERV::KindOfSchema aSchema;
592   SUPERV::KindOfInterpolation aInterpolat;
593   SUPERV::KindOfExtrapolation aExtrapolat;
594
595   if (myPort != 0)
596     myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat);
597   else
598     myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
599
600   mySchemaCombo->setCurrentItem((int)aSchema);
601   myInterCombo->setCurrentItem((int)aInterpolat);
602   myExterCombo->setCurrentItem((int)aExtrapolat);
603 }
604
605 void SUPERVGUI_StreamInDlg::accept() {
606   if (myPort != 0)
607     myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), 
608                                        (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
609                                        (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
610   else
611     myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), 
612                                                (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
613                                                (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
614   QDialog::accept();
615 }
616
617
618 //-------------------------------------------------------------------------
619 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort)
620   :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
621 {
622   myPort = thePort;
623   myPortCanvas = 0;
624   init();
625 }
626 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
627   :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
628 {
629   myPort = 0;
630   myPortCanvas = thePort;
631   init();
632 }
633
634 void SUPERVGUI_StreamOutDlg::init()
635 {
636   setSizeGripEnabled( true );
637   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
638
639   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
640
641   QFrame* aCtrlPane = new QFrame(this);
642   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
643
644   QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane);
645   aCtrlLayout->addWidget(aLbl, 0, 0);
646
647   myValEdit = new QLineEdit( aCtrlPane, "ValEdit" );
648   myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
649   myValEdit->setValidator( new QIntValidator(this) );
650   SUPERV_StreamPort aEngine;
651   if (myPort != 0)
652     aEngine = myPort->getStreamPort();
653   else
654     aEngine = myPortCanvas->getStreamEngine();
655   myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues()));
656   aCtrlLayout->addWidget(myValEdit, 0, 1);
657   TopLayout->addWidget( aCtrlPane );
658   
659   // Buttons
660   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
661   GroupButtons->setColumnLayout(0, Qt::Vertical );
662   GroupButtons->layout()->setSpacing( 0 );
663   GroupButtons->layout()->setMargin( 0 );
664   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
665   GroupButtonsLayout->setAlignment( Qt::AlignTop );
666   GroupButtonsLayout->setSpacing( 5 );
667   GroupButtonsLayout->setMargin( 8 );
668   
669   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
670   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
671
672   GroupButtonsLayout->addWidget( okB, 0, 0 );
673   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
674   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
675
676   TopLayout->addWidget( GroupButtons );
677
678   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
679   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
680 }
681
682 void SUPERVGUI_StreamOutDlg::accept() {
683   int aRes = 0;
684   QString aStr = myValEdit->text();
685   if (!aStr.isEmpty())
686     aRes = aStr.toLong();
687   if (myPort != 0) 
688     myPort->getStreamPort()->SetNumberOfValues(aRes);
689   else
690     myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);
691   QDialog::accept();
692 }
693