Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_BrowseNodeDlg.cxx
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  SUPERV SUPERVGUI : GUI for Supervisor component
21 //
22 //  File   : SUPERVGUI_BrowseNodeDlg.cxx
23 //  Author : Vitaly SMETANNIKOV
24 //  Module : SUPERV
25
26 #include "SALOMEDSClient.hxx"
27 #include "SALOMEDS_SObject.hxx"
28 #include "SALOMEDS_Study.hxx"
29
30 #include "SalomeApp_Application.h"
31 #include "LightApp_SelectionMgr.h"
32 #include "SalomeApp_Study.h"
33 #include "SUIT_Session.h"
34
35 #include "SALOME_ListIO.hxx"
36
37 #include "SUPERVGUI_BrowseNodeDlg.h"
38 #include "SUPERVGUI_CanvasNode.h"
39 #include "SUPERVGUI_CanvasPort.h"
40 #include "SUPERVGUI.h"
41
42 #include <qlayout.h>
43 #include <qlabel.h>
44 #include <qlineedit.h>
45 #include <qpushbutton.h>
46 #include <qhbox.h>
47 #include <qgroupbox.h>
48 #include <qvalidator.h>
49
50 #include <boost/shared_ptr.hpp>
51 using namespace boost;
52
53 /**
54  * Constructor
55  */
56 SUPERVGUI_PortField::SUPERVGUI_PortField( QWidget* theParent, SUPERV_Port thePort ) {
57   myPort = thePort;
58   myIsEditable = myPort->IsInput() && ( !myPort->IsLinked() );
59
60   QString aLabelTxt(myPort->Name());
61
62   /*SUPERV_CNode aNode = myPort->Node();
63   SALOME_ModuleCatalog::Service* aService = aNode->Service();
64   SALOME_ModuleCatalog::ListOfServicesParameter aList;
65   aList = (myPort->IsInput())? aService->ServiceinParameter : aService->ServiceoutParameter;
66   for (int i = 0; i < aList.length(); i++) {
67     SALOME_ModuleCatalog::ServicesParameter* aParam = &(aList[i]);
68     if (aLabelTxt == aParam->Parametername) {
69       aLabelTxt += QString(" (") + QString(aParam->Parametertype) + QString(")");
70       break;
71     }
72   }
73   aLabelTxt += QString(":");*/
74
75   // mkr : the following way is easyer to get ports' type than commented above
76   QString aPortType = QString(myPort->Type());
77   aLabelTxt += QString(" (") + aPortType + QString("):");
78
79   myLabel = new QLabel(aLabelTxt, theParent );
80
81   myValue = new QLineEdit( theParent );
82   myLabel->setBuddy( myValue );
83   if (!myIsEditable) {
84     myValue->setReadOnly( !myIsEditable );
85     QPalette aPalette = myValue->palette();
86     aPalette.setInactive(aPalette.disabled());
87     aPalette.setActive(aPalette.disabled());
88     myValue->setPalette(aPalette);
89   }
90   // mkr : PAL6276 -->
91   else {
92     if ( !aPortType.compare(QString("boolean")) )
93       myValue->setValidator( new QIntValidator( 0, 1, theParent ) );
94
95     if ( !aPortType.compare(QString("short")) || !aPortType.compare(QString("int")) || !aPortType.compare(QString("long")) )
96       myValue->setValidator( new QIntValidator( theParent ) );
97     
98     if ( !aPortType.compare(QString("float")) || !aPortType.compare(QString("double")) )
99       myValue->setValidator( new QDoubleValidator( theParent ) );
100
101     if ( !aPortType.compare(QString("char")) ) {
102       QRegExp aRX( "." );
103       myValue->setValidator( new QRegExpValidator( aRX, theParent ) );
104
105     }
106   }
107   // mkr : PAL6276 <--
108   myValue->installEventFilter( this );
109 }
110
111 /**
112  * Sets value from text edit control to engine of port
113  */
114 bool SUPERVGUI_PortField::setNewValue() {
115   if ( !myIsEditable ) return false;
116
117   QString aTxt = myValue->text();
118   //mkr : fix for bug IPAL9441
119   //if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
120   
121   if ( aTxt.find( "Unknown" ) < 0 ) {
122     SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
123     if ( !aSupMod ) {
124       MESSAGE("NULL Supervision module!");
125       return false;
126     }
127     return myPort->Input( aSupMod->getEngine()->StringValue( aTxt ) );
128   }
129   return false;
130 }
131  
132 /** 
133  * Event filter
134  */ 
135 bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e )
136 {
137   if ( o == myValue ) {
138     if ( e->type() == QEvent::FocusIn ) {
139       emit activated();
140     }
141   }
142   return QObject::eventFilter( o, e );
143 }
144
145
146 /**
147  * Constructor (SUPERVGUI_CanvasNode)
148  */
149 SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode )
150   : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
151 {
152   myNodeCanvas = theNode;
153
154   init();
155 }
156
157 void SUPERVGUI_BrowseNodeDlg::init()
158 {
159   myActiveField = 0;
160   setSizeGripEnabled( true );
161   myPortsList.setAutoDelete( true );
162
163   SUPERV_CNode aEngine = myNodeCanvas->getEngine();
164   
165   setName( "SUPERVGUI_BrowseNodeDlg" );
166   setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() );
167
168   QGridLayout* aBaseLayout = new QGridLayout( this );
169   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
170
171   QGroupBox* aInBox = new QGroupBox( 2, Qt::Horizontal, "Input", this );
172   aInBox->setMargin( 11 );
173   aBaseLayout->addWidget( aInBox, 0, 0 );
174
175   QGroupBox* aOutBox = new QGroupBox( 2, Qt::Horizontal, "Output", this);
176   aOutBox->setMargin( 11 );
177   aBaseLayout->addWidget( aOutBox, 0, 1 );
178
179   myIsEditable = false;
180   int                aPIcount = 0;
181   int                aPOcount = 0;
182   SUPERV_Ports       ports = aEngine->Ports();
183   int                n     = ports->length();
184
185   for ( int i = 0; i < n; i++ ) {
186     if ( ports[i]->IsInput() ) {
187       if ( !ports[i]->IsGate() ) { // not a gate
188         SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] );
189         if ( aField->isEditable() ) 
190           myIsEditable = true;
191         myPortsList.append( aField );
192         if ( !myActiveField )
193           myActiveField = aField;
194         connect( aField, SIGNAL( activated() ), this, SLOT( onFieldActivated() ) );
195       }
196       aPIcount++;
197     } 
198     else {
199       if ( !ports[i]->IsGate() ) { // not a gate
200         myPortsList.append( new SUPERVGUI_PortField( aOutBox, ports[i] ) );
201       }
202       aPOcount++;
203     }
204   }
205   
206   QGroupBox* aBtnBox = new QGroupBox( this );
207   aBtnBox->setColumnLayout( 0, Qt::Vertical );
208   aBtnBox->layout()->setSpacing( 0 ); 
209   aBtnBox->layout()->setMargin( 0 );
210   
211   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
212   aBtnLayout->setAlignment( Qt::AlignTop );
213   aBtnLayout->setSpacing( 6 ); 
214   aBtnLayout->setMargin( 11 );
215
216   if ( myIsEditable ) {
217     QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), this );
218     aBaseLayout->addMultiCellWidget( aInfoLab, 1, 1, 0, 1 );
219
220     QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
221     connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
222     aBtnLayout->addWidget( aOkBtn );
223     aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 );
224   } else
225     aBaseLayout->addMultiCellWidget( aBtnBox, 1, 1, 0, 1 );
226
227   aBtnLayout->addStretch();
228   QPushButton* aCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
229   aBtnLayout->addWidget( aCancelBtn );
230   connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
231   
232   if ( !myIsEditable )
233     aBtnLayout->addStretch();
234
235   SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
236   if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(), 
237                           SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
238   else MESSAGE("NULL Supervision module!");
239   
240   myNodeCanvas->getMain()->lockedGraph(true);
241 }
242
243 /**
244  * Destructor
245  */
246 SUPERVGUI_BrowseNodeDlg::~SUPERVGUI_BrowseNodeDlg() {
247 }
248
249 /**
250  * Set current values of editable ports
251  */
252 void SUPERVGUI_BrowseNodeDlg::setValues() {
253   SUPERVGUI_PortField* aField;
254   for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
255     if ( aField->getData().isEmpty() || aField->getData().isNull() ) // mkr : PAL11406
256       aField->updateGUI();
257   }
258 }
259
260 /** 
261  * Set inputed values of editable ports and then closes and destroys dialog
262  */
263 void SUPERVGUI_BrowseNodeDlg::accept() {
264   myNodeCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
265   if ( myIsEditable ) {
266     SUPERVGUI_PortField* aField;
267     for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
268       aField->setNewValue();
269     }
270     myNodeCanvas->sync();
271     myNodeCanvas->getMain()->getCanvas()->update();
272   }
273   myNodeCanvas->getMain()->lockedGraph(false);
274   QDialog::accept();
275   close();
276 }
277
278
279 /** 
280  * Closes and destroys dialog
281  */
282 void SUPERVGUI_BrowseNodeDlg::reject() {
283   myNodeCanvas->getMain()->lockedGraph(false);
284   QDialog::reject();
285   close();
286 }
287
288 /**
289  * Update current values on show event
290  */
291 void SUPERVGUI_BrowseNodeDlg::showEvent( QShowEvent* theEvent ) {
292   setValues();
293   QDialog::showEvent( theEvent );
294 }
295
296 /**
297  * Slot, called when field is focused
298  */
299 void SUPERVGUI_BrowseNodeDlg::onFieldActivated()
300 {
301   SUPERVGUI_PortField* aField = (SUPERVGUI_PortField*)sender();
302   myActiveField = (aField->isEditable())? aField : 0;
303 }
304
305 namespace {
306
307   QString getIORfromIO (const Handle(SALOME_InteractiveObject)& theIO,
308                         SUPERVGUI * theModule)
309   {
310     QString ior ("");
311     if (!theIO->hasEntry()) return ior;
312
313     SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(theModule->getActiveStudy());
314     _PTR(SObject) aSObj (anAppStudy->studyDS()->FindObjectID(theIO->getEntry()));
315
316     _PTR(GenericAttribute) anAttr;
317     if (aSObj->FindAttribute(anAttr, "AttributeIOR")) {
318       _PTR(AttributeIOR) anIOR (anAttr);
319       ior = anIOR->Value().c_str();
320       return ior;
321     }
322
323     // old code, it is useless, because <aSSObj->GetObject()> here will be NULL
324     // (because it is retrieved from <aSSObj> by stored IOR)
325     /*
326       SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aSObj->GetStudy().get() );
327       SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aSObj.get() );
328       if ( aSStudy && aSSObj )
329       ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
330     //*/
331
332     // new code
333
334     // default value: null IOR (IOR:01000000010000000000...)
335     SalomeApp_Application* anApp = theModule->getApp();
336     CORBA::Object_var aNullObj;
337     ior = anApp->orb()->object_to_string(aNullObj);
338
339     // try to load a component data from an opened (presumably) study
340     _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
341     std::string aCompIOR;
342     if (!aSComp->ComponentIOR(aCompIOR)) {
343       std::string aCompDataType = aSComp->ComponentDataType();
344
345       // obtain a driver by a component data type
346       // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType
347       SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil();
348       SALOME_LifeCycleCORBA * LCC = anApp->lcc();
349       try {
350         CORBA::Object_var
351           anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType.c_str());
352         if (CORBA::is_nil(anEngineObj))
353           anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType.c_str());
354
355         if (!CORBA::is_nil(anEngineObj))
356           anEngine = SALOMEDS::Driver::_narrow(anEngineObj);
357       }
358       catch (...) {
359       }
360
361       if (!CORBA::is_nil(anEngine)) {
362         // try to load
363         _PTR(StudyBuilder) aStudyBuilder = aSObj->GetStudy()->NewBuilder();
364         bool isOk = true;
365         try {
366           CORBA::String_var aDriverIOR = anApp->orb()->object_to_string(anEngine);
367           aStudyBuilder->LoadWith(aSComp, aDriverIOR.in());
368         }
369         catch (...) {
370           isOk = false;
371         }
372
373         if (isOk) {
374           // now try to obtain the IOR once again (after successfull component data loading)
375           if (aSObj->FindAttribute( anAttr, "AttributeIOR" )) {
376             _PTR(AttributeIOR) anIOR ( anAttr );
377             ior = anIOR->Value().c_str();
378           }
379         }
380       } // if (!CORBA::is_nil(anEngine))
381     } // if (!aSComp->ComponentIOR(aCompIOR))
382
383     return ior;
384   }
385
386 } // no name namespace
387
388 /**
389  * Slot, called when selection is changed
390  */
391 void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
392 {
393   if ( myActiveField ) {
394
395     SALOME_ListIO aList;
396     aList.Clear();
397
398     SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
399     if ( !aSupMod ) {
400       MESSAGE("NULL Supervision module!");
401       return;
402     }
403
404     SalomeApp_Application* anApp = aSupMod->getApp();
405     anApp->selectionMgr()->selectedObjects( aList );
406
407     if ( aList.Extent() == 1 ) {
408       Handle( SALOME_InteractiveObject ) anIO = aList.First();
409       if ( anIO->hasEntry() ) {
410         QString ior = ::getIORfromIO(anIO, aSupMod);
411         myActiveField->setData( ior );
412       }
413     }
414   }
415 }
416
417
418 /**
419  * Constructor (SUPERVGUI_CanvasPort)
420  */
421 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
422   : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
423 {
424   myPortCanvas = thePort;
425
426   init();
427 }
428
429 void SUPERVGUI_GetValueDlg::init()
430 {
431   myOKBtn = 0;
432   setSizeGripEnabled( true );
433
434   setName( "SUPERVGUI_GetValueDlg" );
435   setCaption( tr( "TIT_SETVALUE_PORT" ) );
436   
437   QGridLayout* aBaseLayout = new QGridLayout( this );
438   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
439   
440   QGroupBox* aBox = new QGroupBox( this );
441   aBox->setColumnLayout( 0, Qt::Vertical );
442   aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 );
443   QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() );
444   aBoxLayout->setAlignment( Qt::AlignTop );
445   aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 );
446   aBaseLayout->addWidget( aBox, 0, 0 );
447   aBox->setMinimumWidth( 200 );
448   
449   QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox );
450   QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt );
451   aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 );
452   SUPERV_Port aEngine = myPortCanvas->getEngine();
453
454   myField = new SUPERVGUI_PortField( aBox, aEngine );
455   bool myIsEditable = myField->isEditable();
456   aBoxLayout->addWidget( myField->myLabel, 1, 0 ); 
457   aBoxLayout->addWidget( myField->myValue, 1, 1 );
458   
459   QGroupBox* aBtnBox = new QGroupBox( this );
460   aBtnBox->setColumnLayout( 0, Qt::Vertical );
461   aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
462   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
463   aBtnLayout->setAlignment( Qt::AlignTop );
464   aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
465
466   aBaseLayout->addWidget( aBtnBox, 1, 0 );
467
468   if ( myIsEditable ) {
469     myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
470     connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
471     aBtnLayout->addWidget( myOKBtn );
472   }
473
474   aBtnLayout->addStretch();
475   myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox );
476   aBtnLayout->addWidget( myCancelBtn );
477   connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
478   
479   if ( !myIsEditable )
480     aBtnLayout->addStretch();
481
482   myField->updateGUI();
483   
484   SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
485   if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(), 
486                           SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
487   else MESSAGE("NULL Supervision module!");
488  
489   myPortCanvas->getMain()->lockedGraph(true);
490 }
491
492 /**
493  * Destructor
494  */
495 SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() {
496 }
497
498 /** 
499  * Set entered value into port and then closes and destroys dialog
500  */
501 void SUPERVGUI_GetValueDlg::accept() {
502   myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
503   if ( myField->setNewValue() ) {
504     
505     myPortCanvas->sync();
506
507     // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status
508     // asv : 13.12.04 : commented out sync() of Node.  See 2.21.
509     //if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) {
510     //  SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent();
511     //  aNode->sync();
512     //}
513
514     myPortCanvas->getMain()->getCanvas()->update();
515   }
516   else {
517     if ( QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), 
518                                tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
519                                QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
520       return;
521   }
522
523   myPortCanvas->getMain()->lockedGraph(false);
524   
525   QDialog::accept();
526   close();
527 }
528
529 /** 
530  * Closes and destroys dialog
531  */
532 void SUPERVGUI_GetValueDlg::reject() {
533   myPortCanvas->getMain()->lockedGraph(false);
534   QDialog::reject();
535   close();
536 }
537
538 /**
539  * Slot, called when selection is changed
540  */
541 void SUPERVGUI_GetValueDlg::onSelectionChanged()
542 {
543   SALOME_ListIO aList;
544   aList.Clear();
545
546   SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
547   if ( !aSupMod ) {
548     MESSAGE("NULL Supervision module!");
549     return;
550   }
551
552   SalomeApp_Application* anApp = aSupMod->getApp();
553   anApp->selectionMgr()->selectedObjects( aList );
554
555   if ( aList.Extent() == 1 ) {
556     Handle( SALOME_InteractiveObject ) anIO = aList.First();
557     if ( anIO->hasEntry() ) {
558       QString ior = ::getIORfromIO(anIO, aSupMod);
559       myField->setData( ior );
560     }
561   }
562 }
563
564
565
566 // ----------------------------
567 // Stream Ports
568 // ----------------------------
569
570 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
571   :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
572 {
573   myPortCanvas = thePort;
574   init();
575 }
576
577 void SUPERVGUI_StreamInDlg::init()
578 {
579   setSizeGripEnabled( true );
580   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
581
582   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
583
584   QFrame* aCtrlPane = new QFrame(this);
585   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
586
587   // Schema
588   QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane);
589   aCtrlLayout->addWidget(aSchemaLbl, 0, 0);
590
591   mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" );
592   mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
593   mySchemaCombo->insertItem("SCHENULL"); 
594   mySchemaCombo->insertItem("TI");  
595   mySchemaCombo->insertItem("TF");
596   mySchemaCombo->insertItem("DELTA");
597   aCtrlLayout->addWidget(mySchemaCombo, 0, 1);
598
599   // Interpolation
600   QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane);
601   aCtrlLayout->addWidget(aInterLbl, 1, 0);
602
603   myInterCombo = new QComboBox(aCtrlPane, "InterBox" );
604   myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
605   myInterCombo->insertItem("INTERNULL"); 
606   myInterCombo->insertItem("L0"); 
607   myInterCombo->insertItem("L1");
608   aCtrlLayout->addWidget(myInterCombo, 1, 1);
609
610   // Extrapolation
611   QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane);
612   aCtrlLayout->addWidget(aExtraLbl, 2, 0);
613
614   myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" );
615   myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
616   myExterCombo->insertItem("EXTRANULL");  
617   myExterCombo->insertItem("E0");
618   myExterCombo->insertItem("E1");
619   aCtrlLayout->addWidget(myExterCombo, 2, 1);
620   
621   TopLayout->addWidget( aCtrlPane );
622
623   // Buttons
624   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
625   GroupButtons->setColumnLayout(0, Qt::Vertical );
626   GroupButtons->layout()->setSpacing( 0 );
627   GroupButtons->layout()->setMargin( 0 );
628   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
629   GroupButtonsLayout->setAlignment( Qt::AlignTop );
630   GroupButtonsLayout->setSpacing( 5 );
631   GroupButtonsLayout->setMargin( 8 );
632   
633   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
634   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
635
636   GroupButtonsLayout->addWidget( okB, 0, 0 );
637   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
638   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
639
640   TopLayout->addWidget( GroupButtons );
641
642   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
643   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
644   setData();
645 }
646
647 void SUPERVGUI_StreamInDlg::setData() {
648   SUPERV::KindOfSchema aSchema;
649   SUPERV::KindOfInterpolation aInterpolat;
650   SUPERV::KindOfExtrapolation aExtrapolat;
651
652   myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
653
654   mySchemaCombo->setCurrentItem((int)aSchema);
655   myInterCombo->setCurrentItem((int)aInterpolat);
656   myExterCombo->setCurrentItem((int)aExtrapolat);
657 }
658
659 void SUPERVGUI_StreamInDlg::accept() {
660   myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
661   myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), 
662                                              (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
663                                              (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
664   QDialog::accept();
665 }
666
667
668 //-------------------------------------------------------------------------
669 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
670   :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
671 {
672   myPortCanvas = thePort;
673   init();
674 }
675
676 void SUPERVGUI_StreamOutDlg::init()
677 {
678   setSizeGripEnabled( true );
679   setCaption( tr( "MSG_STREAM_DLG_TIT" ) );
680
681   QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 );
682
683   QFrame* aCtrlPane = new QFrame(this);
684   QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 );
685
686   QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane);
687   aCtrlLayout->addWidget(aLbl, 0, 0);
688
689   myValEdit = new QLineEdit( aCtrlPane, "ValEdit" );
690   myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
691   myValEdit->setValidator( new QIntValidator(this) );
692   SUPERV_StreamPort aEngine = myPortCanvas->getStreamEngine();
693   myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues()));
694   aCtrlLayout->addWidget(myValEdit, 0, 1);
695   TopLayout->addWidget( aCtrlPane );
696   
697   // Buttons
698   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
699   GroupButtons->setColumnLayout(0, Qt::Vertical );
700   GroupButtons->layout()->setSpacing( 0 );
701   GroupButtons->layout()->setMargin( 0 );
702   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
703   GroupButtonsLayout->setAlignment( Qt::AlignTop );
704   GroupButtonsLayout->setSpacing( 5 );
705   GroupButtonsLayout->setMargin( 8 );
706   
707   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
708   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
709
710   GroupButtonsLayout->addWidget( okB, 0, 0 );
711   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
712   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
713
714   TopLayout->addWidget( GroupButtons );
715
716   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
717   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
718 }
719
720 void SUPERVGUI_StreamOutDlg::accept() {
721   int aRes = 0;
722   QString aStr = myValEdit->text();
723   if (!aStr.isEmpty())
724     aRes = aStr.toLong();
725   myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);
726   QDialog::accept();
727 }
728