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