Salome HOME
d17ccac339f3bea4d1d75fd67d7b458bc1a0a840
[modules/multipr.git] / src / MULTIPRGUI / MULTIPR_GUI_Dlg.cxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_GUI_Dlg.cxx
6  *
7  * \brief   see MULTIPR_GUI_Dlg.h
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13   
14 //*****************************************************************************
15 // Includes section
16 //*****************************************************************************
17
18 #include "MULTIPR_GUI_Dlg.h"
19 #include "MULTIPR_GUI.h"
20
21 // Salome Includes
22 #include <SUIT_MessageBox.h>
23 #include <SUIT_ResourceMgr.h>
24 #include <SUIT_Session.h>
25 #include <SalomeApp_Application.h>
26 #include <SalomeApp_CheckFileDlg.h>
27 #include <LightApp_SelectionMgr.h>
28
29 #include <SALOME_LifeCycleCORBA.hxx>
30
31 // QT Includes
32 #include <qapplication.h>
33 #include <qinputdialog.h>
34 #include <qlayout.h>
35 #include <qpushbutton.h>
36 #include <qgroupbox.h>
37 #include <qvbox.h>
38 #include <qbuttongroup.h>
39 #include <qlabel.h>
40 #include <qcombobox.h>
41 #include <qvariant.h>
42 #include <qlineedit.h>
43 #include <qspinbox.h>
44 #include <qtooltip.h>
45 #include <qwhatsthis.h>
46 #include <qimage.h>
47 #include <qpixmap.h>
48
49
50 using namespace std;
51
52
53 MULTIPR_GUI_Partition1Dlg::MULTIPR_GUI_Partition1Dlg(MULTIPR_GUI* theModule) : 
54         QDialog(
55                 theModule->application()->desktop(), 
56                 0, 
57                 false, 
58                 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
59 {
60         mModule = theModule;
61         
62     buttonGroupProcess = new QButtonGroup( this, "buttonGroupProcess" );
63     buttonGroupProcess->setGeometry( QRect( 10, 110, 450, 60 ) );
64
65         pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" );
66     pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
67         
68     pushButtonCancel = new QPushButton( buttonGroupProcess, "pushButtonCancel" );
69     pushButtonCancel->setGeometry( QRect( 321, 10, 110, 41 ) );
70
71     buttonGroupSelectMesh = new QButtonGroup( this, "buttonGroupSelectMesh" );
72     buttonGroupSelectMesh->setGeometry( QRect( 10, 10, 450, 91 ) );
73
74     comboBoxSelectMesh = new QComboBox( FALSE, buttonGroupSelectMesh, "comboBoxSelectMesh" );
75     comboBoxSelectMesh->setGeometry( QRect( 160, 30, 280, 40 ) );
76         MULTIPR_ORB::string_array* listMeshes = theModule->getMULTIPRObj()->getMeshes();
77         for (int i=0; i<listMeshes->length() ; i++)
78         {
79                 const char* strItem = (*listMeshes)[i];
80                 comboBoxSelectMesh->insertItem(strItem);
81         }
82         comboBoxSelectMesh->setEditable(false);
83
84     textLabelSelectMesh = new QLabel( buttonGroupSelectMesh, "textLabelSelectMesh" );
85     textLabelSelectMesh->setGeometry( QRect( 20, 30, 110, 40 ) );
86     
87         setCaption( tr( "Extract groups from sequential MED file" ) );
88     buttonGroupProcess->setTitle( QString::null );
89     pushButtonCancel->setText( tr( "Cancel" ) );
90     pushButtonOK->setText( tr("OK") );
91     buttonGroupSelectMesh->setTitle( tr( "Select mesh" ) );
92     textLabelSelectMesh->setText( tr( "Mesh name" ) );
93         
94     resize( QSize(471, 185).expandedTo(minimumSizeHint()) );
95     clearWState( WState_Polished );
96         
97         connect(pushButtonOK,     SIGNAL(clicked()), this, SLOT(accept()));
98         connect(pushButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
99 }
100
101
102 /*
103  *  Destroys the object and frees any allocated resources
104  */
105 MULTIPR_GUI_Partition1Dlg::~MULTIPR_GUI_Partition1Dlg()
106 {
107     // no need to delete child widgets, Qt does it all for us
108 }
109
110
111 void MULTIPR_GUI_Partition1Dlg::accept()
112 {
113         const char* meshName = comboBoxSelectMesh->currentText().latin1();
114         
115         try
116         {
117                 mModule->getMULTIPRObj()->setMesh(meshName);
118                 
119                 QApplication::setOverrideCursor(Qt::waitCursor);
120                 mModule->getMULTIPRObj()->partitionneDomaine();
121                 QApplication::restoreOverrideCursor();
122                 
123         }
124         catch(...)
125         {
126                 SUIT_MessageBox::error1( 
127                         mModule->getAppli()->desktop(),
128                         "Import MED file error", 
129                         "Unable to set mesh", 
130                         tr("OK") );
131         }
132
133         QDialog::accept();
134 }
135
136
137 void MULTIPR_GUI_Partition1Dlg::reject()
138 {
139         QDialog::reject();
140 }
141
142
143 MULTIPR_GUI_Partition2Dlg::MULTIPR_GUI_Partition2Dlg(MULTIPR_GUI* theModule) : 
144         QDialog(
145                 theModule->application()->desktop(), 
146                 0, 
147                 false, 
148                 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
149 {
150         mModule = theModule;
151         
152     buttonGroupSplitParameters = new QButtonGroup( this, "buttonGroupSplitParameters" );
153     buttonGroupSplitParameters->setGeometry( QRect( 10, 10, 380, 140 ) );
154
155     textLabelSelectNbParts = new QLabel( buttonGroupSplitParameters, "textLabelSelectNbParts" );
156     textLabelSelectNbParts->setGeometry( QRect( 30, 30, 160, 31 ) );
157
158     textLabelSelectSplitter = new QLabel( buttonGroupSplitParameters, "textLabelSelectSplitter" );
159     textLabelSelectSplitter->setGeometry( QRect( 30, 80, 111, 31 ) );
160
161     comboBoxSelectSplitter = new QComboBox( FALSE, buttonGroupSplitParameters, "comboBoxSelectSplitter" );
162     comboBoxSelectSplitter->setGeometry( QRect( 210, 80, 150, 40 ) );
163         comboBoxSelectSplitter->insertItem("METIS");
164         comboBoxSelectSplitter->insertItem("SCOTCH");
165         comboBoxSelectSplitter->setEditable(false);
166
167     spinBoxNbParts = new QSpinBox( buttonGroupSplitParameters, "spinBoxNbParts" );
168     spinBoxNbParts->setGeometry( QRect( 210, 30, 150, 30 ) );
169     spinBoxNbParts->setMaxValue( 1000 );
170     spinBoxNbParts->setMinValue( 2 );
171     spinBoxNbParts->setValue( 2 );
172
173     buttonGroupProcess = new QButtonGroup( this, "buttonGroupProcess" );
174     buttonGroupProcess->setGeometry( QRect( 10, 160, 380, 60 ) );
175
176     pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" );
177     pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
178
179     pushButtonCancel = new QPushButton( buttonGroupProcess, "pushButtonCancel" );
180     pushButtonCancel->setGeometry( QRect( 250, 10, 110, 41 ) );
181     
182         setCaption( tr( "Split selected part" ) );
183     buttonGroupSplitParameters->setTitle( tr( "Split parameters" ) );
184     textLabelSelectNbParts->setText( tr( "Number of sub-parts" ) );
185     textLabelSelectSplitter->setText( tr( "Splitter" ) );
186     buttonGroupProcess->setTitle( QString::null );
187     pushButtonOK->setText( tr("OK") );
188     pushButtonCancel->setText( tr( "Cancel" ) );
189         
190     resize( QSize(403, 234).expandedTo(minimumSizeHint()) );
191     clearWState( WState_Polished );
192         
193         connect(pushButtonOK,     SIGNAL(clicked()), this, SLOT(accept()));
194         connect(pushButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
195 }
196
197
198 /*
199  *  Destroys the object and frees any allocated resources
200  */
201 MULTIPR_GUI_Partition2Dlg::~MULTIPR_GUI_Partition2Dlg()
202 {
203     // no need to delete child widgets, Qt does it all for us
204 }
205
206
207 void MULTIPR_GUI_Partition2Dlg::accept()
208 {
209         const char* strSplitter = comboBoxSelectSplitter->currentText().latin1();
210         int nbParts = spinBoxNbParts->value();
211         int partitionner = -1;
212         if (strcmp(strSplitter, "METIS") == 0)
213         {
214                 partitionner = 0;
215         }
216         else if (strcmp(strSplitter, "SCOTCH") == 0)
217         {
218                 partitionner = 1;
219         }
220         
221         QApplication::setOverrideCursor(Qt::waitCursor);
222         
223         try
224         {
225                 const QStringList& partsList = mModule->getSelectedParts();
226                 for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
227                 {
228                         const QString& partName = (*it);
229                         //cout << "Split " << partName.latin1() << " #parts=" << nbParts << " splitter=" << strSplitter << endl;
230                         mModule->getMULTIPRObj()->partitionneGrain(partName.latin1(), nbParts, partitionner);
231                 }
232                 
233         }
234         catch(...)
235         {
236                 SUIT_MessageBox::error1( 
237                         mModule->getAppli()->desktop(),
238                         "Split error", 
239                         "Error while splitting selected part(s)", 
240                         tr("OK") );
241         }
242         
243         QApplication::restoreOverrideCursor();
244         QDialog::accept();
245 }
246
247
248 void MULTIPR_GUI_Partition2Dlg::reject()
249 {
250         QDialog::reject();
251 }
252
253
254 MULTIPR_GUI_DecimateDlg::MULTIPR_GUI_DecimateDlg(MULTIPR_GUI* theModule) :
255         QDialog(
256                 theModule->application()->desktop(), 
257                 0, 
258                 false, 
259                 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
260 {
261         mModule = theModule;
262         
263     buttonGroupSelectField = new QButtonGroup( this, "buttonGroupSelectField" );
264     buttonGroupSelectField->setGeometry( QRect( 10, 10, 450, 140 ) );
265
266     textLabelSelectFieldName = new QLabel( buttonGroupSelectField, "textLabelSelectFieldName" );
267     textLabelSelectFieldName->setGeometry( QRect( 30, 30, 141, 31 ) );
268
269     textLabelSelectFieldIteration = new QLabel( buttonGroupSelectField, "textLabelSelectFieldIteration" );
270     textLabelSelectFieldIteration->setGeometry( QRect( 30, 80, 111, 31 ) );
271
272         MULTIPR_ORB::string_array* listFields = theModule->getMULTIPRObj()->getFields();
273         int maxIteration = 0;
274         for (int i=0 ; i<listFields->length() ; i++)
275         {
276                 const char* strItem = (*listFields)[i];
277                 CORBA::Long nbIteration = theModule->getMULTIPRObj()->getTimeStamps(strItem);
278                 if (nbIteration > maxIteration) 
279                 {
280                         maxIteration = nbIteration;
281                 }
282         }
283         
284     comboBoxSelectFieldIteration = new QComboBox( FALSE, buttonGroupSelectField, "comboBoxSelectFieldIteration" );
285     comboBoxSelectFieldIteration->setGeometry( QRect( 150, 80, 280, 40 ) );
286         for (int i=1 ; i<=maxIteration ; i++)
287         {
288                 comboBoxSelectFieldIteration->insertItem(QString::number(i));
289         }
290
291     comboBoxSelectFieldName = new QComboBox( FALSE, buttonGroupSelectField, "comboBoxSelectFieldName" );
292     comboBoxSelectFieldName->setGeometry( QRect( 150, 30, 280, 40 ) );
293         for (int i=0 ; i<listFields->length() ; i++)
294         {
295                 const char* strItem = (*listFields)[i];
296                 comboBoxSelectFieldName->insertItem(strItem);
297         }
298         comboBoxSelectFieldName->setEditable(false);
299         QToolTip::add( comboBoxSelectFieldName, tr( "only scalar fields are listed (multi-component fields are not displayed)" ) );
300
301     buttonGroupSelectFilter = new QButtonGroup( this, "buttonGroupSelectFilter" );
302     buttonGroupSelectFilter->setGeometry( QRect( 10, 160, 450, 90 ) );
303
304     textLabelSelectFilter = new QLabel( buttonGroupSelectFilter, "textLabelSelectFilter" );
305     textLabelSelectFilter->setGeometry( QRect( 30, 30, 101, 31 ) );
306
307     comboBoxSelectFilter = new QComboBox( FALSE, buttonGroupSelectFilter, "comboBoxSelectFilter" );
308     comboBoxSelectFilter->setGeometry( QRect( 150, 30, 280, 40 ) );
309         comboBoxSelectFilter->insertItem("Filtre_GradientMoyen");
310
311     buttonGroupParameters = new QButtonGroup( this, "buttonGroupParameters" );
312     buttonGroupParameters->setGeometry( QRect( 10, 260, 450, 210 ) );
313
314     textLabelTMed = new QLabel( buttonGroupParameters, "textLabelTMed" );
315     textLabelTMed->setGeometry( QRect( 20, 40, 242, 30 ) );
316
317     textLabelTLow = new QLabel( buttonGroupParameters, "textLabelTLow" );
318     textLabelTLow->setGeometry( QRect( 20, 80, 208, 30 ) );
319
320     textLabelRadius = new QLabel( buttonGroupParameters, "textLabelRadius" );
321     textLabelRadius->setGeometry( QRect( 20, 120, 211, 30 ) );
322
323     textLabelBoxing = new QLabel( buttonGroupParameters, "textLabelBoxing" );
324     textLabelBoxing->setGeometry( QRect( 20, 160, 241, 30 ) );
325
326     lineEditTMed = new QLineEdit( buttonGroupParameters, "lineEditTMed" );
327     lineEditTMed->setGeometry( QRect( 320, 40, 111, 30 ) );
328
329     lineEditTLow = new QLineEdit( buttonGroupParameters, "lineEditTLow" );
330     lineEditTLow->setGeometry( QRect( 320, 80, 111, 30 ) );
331
332     lineEditRadius = new QLineEdit( buttonGroupParameters, "lineEditRadius" );
333     lineEditRadius->setGeometry( QRect( 320, 120, 111, 30 ) );
334
335     spinBoxBoxing = new QSpinBox( buttonGroupParameters, "spinBoxBoxing" );
336     spinBoxBoxing->setGeometry( QRect( 320, 160, 111, 30 ) );
337     spinBoxBoxing->setMaxValue( 200 );
338     spinBoxBoxing->setMinValue( 2 );
339     spinBoxBoxing->setValue( 100 );
340         QToolTip::add( spinBoxBoxing, tr( "grid: number of cells along each axis" ) );
341
342     buttonGroupProcess = new QButtonGroup( this, "buttonGroupProcess" );
343     buttonGroupProcess->setGeometry( QRect( 10, 480, 450, 60 ) );
344
345         pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" );
346     pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
347         
348     pushButtonCancel = new QPushButton( buttonGroupProcess, "pushButtonCancel" );
349     pushButtonCancel->setGeometry( QRect( 321, 10, 110, 41 ) );
350         pushButtonCancel->setAccel( QKeySequence( tr( "Esc" ) ) );
351     
352         setCaption( tr( "Decimation" ) );
353     buttonGroupSelectField->setTitle( tr( "Select field" ) );
354     textLabelSelectFieldName->setText( tr( "Field name" ) );
355     textLabelSelectFieldIteration->setText( tr( "Field iteration" ) );
356     buttonGroupSelectFilter->setTitle( tr( "Select filter" ) );
357     textLabelSelectFilter->setText( tr( "Filter name" ) );
358     buttonGroupParameters->setTitle( tr( "Set parameters" ) );
359     textLabelTMed->setText( tr( "Threshold for medium resolution" ) );
360     textLabelTLow->setText( tr( "Threshold for low resolution" ) );
361     textLabelRadius->setText( tr( "Radius (neighborhood)" ) );
362     textLabelBoxing->setText( tr( "Acceleration structure (boxing)" ) );
363     lineEditTMed->setText( tr( "0.1" ) );
364     lineEditTLow->setText( tr( "0.2" ) );
365
366         float defaultRadius = 0.5f;
367     lineEditRadius->setText( QString::number(defaultRadius) );
368     buttonGroupProcess->setTitle( QString::null );
369     pushButtonCancel->setText( tr( "Cancel" ) );
370     pushButtonOK->setText( tr("OK") );
371         
372         pushButtonThresholdAuto = new QPushButton( buttonGroupParameters, "pushButtonThresholdAuto" );
373     pushButtonThresholdAuto->setGeometry( QRect( 260, 80, 50, 30 ) );
374     QFont pushButtonThresholdAuto_font(  pushButtonThresholdAuto->font() );
375     pushButtonThresholdAuto_font.setPointSize( 11 );
376     pushButtonThresholdAuto->setFont( pushButtonThresholdAuto_font ); 
377         pushButtonThresholdAuto->setText( tr( "auto" ) );
378     QToolTip::add( pushButtonThresholdAuto, tr( "compute extremum for gradient (set medium=MIN and low=MAX)" ) );
379
380     pushButtonRadiusAuto = new QPushButton( buttonGroupParameters, "pushButtonRadiusAuto" );
381     pushButtonRadiusAuto->setGeometry( QRect( 260, 120, 50, 30 ) );
382     QFont pushButtonRadiusAuto_font(  pushButtonRadiusAuto->font() );
383     pushButtonRadiusAuto_font.setPointSize( 11 );
384     pushButtonRadiusAuto->setFont( pushButtonRadiusAuto_font ); 
385     pushButtonRadiusAuto->setText( tr( "auto" ) );
386     QToolTip::add( pushButtonRadiusAuto, tr( "set radius automatically (average #neighbours equal to 8)" ) );
387         
388     resize( QSize(470, 554).expandedTo(minimumSizeHint()) );
389     clearWState( WState_Polished );
390         
391         connect(pushButtonOK,            SIGNAL(clicked()), this, SLOT(accept()));
392         connect(pushButtonCancel,        SIGNAL(clicked()), this, SLOT(reject()));
393         connect(pushButtonRadiusAuto,    SIGNAL(clicked()), this, SLOT(OnRadiusAuto()));
394         connect(pushButtonThresholdAuto, SIGNAL(clicked()), this, SLOT(OnThresholdAuto()));
395 }
396
397
398 /*
399  *  Destroys the object and frees any allocated resources
400  */
401 MULTIPR_GUI_DecimateDlg::~MULTIPR_GUI_DecimateDlg()
402 {
403     // no need to delete child widgets, Qt does it all for us
404 }
405
406
407 void MULTIPR_GUI_DecimateDlg::accept()
408 {       
409         const char* strFieldName = comboBoxSelectFieldName->currentText().latin1();
410         const char* strFieldIt   = comboBoxSelectFieldIteration->currentText().latin1();
411         int fieldIteration = atoi(strFieldIt);
412         
413         double thresholdMed;
414         int ret = sscanf(lineEditTMed->text().latin1(), "%lf", &thresholdMed);
415         if ((ret != 1) || (thresholdMed <= 0.0f))
416         {
417                 SUIT_MessageBox::error1( 
418                         mModule->getAppli()->desktop(),
419                         "Decimation parameters error", 
420                         "Invalid medium threshold (should be > 0.0)", 
421                         tr("OK") );
422                         
423                 return;
424         }
425
426         double thresholdLow;
427         ret = sscanf(lineEditTLow->text().latin1(), "%lf", &thresholdLow);
428         if ((ret != 1) || (thresholdLow <= 0.0f))
429         {
430                 SUIT_MessageBox::error1( 
431                         mModule->getAppli()->desktop(),
432                         "Decimation parameters error", 
433                         "Invalid low threshold (should be > 0.0)", 
434                         tr("OK") );
435                         
436                 return;
437         }
438         
439         if (thresholdMed >= thresholdLow)
440         {
441                 SUIT_MessageBox::error1( 
442                         mModule->getAppli()->desktop(),
443                         "Decimation parameters error", 
444                         "Medium threshold must be < low threshold", 
445                         tr("OK") );
446                         
447                 return;
448         }
449
450         double radius;
451         ret = sscanf(lineEditRadius->text().latin1(), "%lf", &radius);
452         if ((ret != 1) || (radius <= 0.0f))
453         {
454                 SUIT_MessageBox::error1( 
455                         mModule->getAppli()->desktop(),
456                         "Decimation parameters error", 
457                         "Invalid radius (should be > 0.0)", 
458                         tr("OK") );
459                         
460                 return;
461         }
462         
463         QApplication::setOverrideCursor(Qt::waitCursor);
464         
465         try
466         {
467                 const QStringList& partsList = mModule->getSelectedParts();
468                 for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
469                 {
470                         const QString& partName = (*it);
471                         
472                         mModule->getMULTIPRObj()->setBoxing(spinBoxBoxing->value());
473                         
474                         mModule->getMULTIPRObj()->decimePartition(
475                                 partName.latin1(),
476                                 strFieldName,
477                                 fieldIteration,
478                                 comboBoxSelectFilter->currentText().latin1(),
479                                 thresholdMed,
480                                 thresholdLow,
481                                 radius);
482                 }
483         }
484         catch(...)
485         {
486                 SUIT_MessageBox::error1( 
487                         mModule->getAppli()->desktop(),
488                         "Decimation error", 
489                         "Error while decimating selected part(s)", 
490                         tr("OK") );
491         }
492         
493         QApplication::restoreOverrideCursor();
494         QDialog::accept();
495 }
496
497
498 void MULTIPR_GUI_DecimateDlg::reject()
499 {
500         QDialog::reject();
501 }
502
503
504 void MULTIPR_GUI_DecimateDlg::OnRadiusAuto()
505 {
506         // evaluates default radius for the first selected part
507         const QStringList& partsList = mModule->getSelectedParts();
508         const char* strFieldIt   = comboBoxSelectFieldIteration->currentText().latin1();
509         int fieldIteration = atoi(strFieldIt);
510         char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].latin1());
511         
512         char   lMeshName[256];
513         int    lId;
514         char   lPartName[256];
515         char   lPath[256];
516         char   lMEDFileName[256];
517         
518         // parse infos
519         int ret = sscanf(strPartInfo0, "%s %d %s %s %s", 
520                 lMeshName,
521                 &lId,
522                 lPartName,
523                 lPath,
524                 lMEDFileName);
525                 
526         if (ret != 5)
527         {
528                 return;
529         }
530         
531         QApplication::setOverrideCursor(Qt::waitCursor);
532         float defaultRadius = 0.5f;
533         try
534         {
535                 char strParams[256];
536                 sprintf(strParams, "2");
537                 
538                 char* res = mModule->getMULTIPRObj()->evalDecimationParams(
539                         lPartName,
540                         comboBoxSelectFieldName->currentText().latin1(),
541                         fieldIteration,
542                         comboBoxSelectFilter->currentText().latin1(),
543                         strParams);
544                 
545                 sscanf(res, "%f", &defaultRadius);
546         }
547         catch (...)
548         {
549         }
550         QApplication::restoreOverrideCursor();
551         
552     lineEditRadius->setText( QString::number(defaultRadius) );
553 }
554
555
556 void MULTIPR_GUI_DecimateDlg::OnThresholdAuto()
557 {
558         // evaluates default radius for the first selected part
559         const QStringList& partsList = mModule->getSelectedParts();
560         const char* strFieldIt  = comboBoxSelectFieldIteration->currentText().latin1();
561         int fieldIteration = atoi(strFieldIt);
562         char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].latin1());
563         
564         char   lMeshName[256];
565         int    lId;
566         char   lPartName[256];
567         char   lPath[256];
568         char   lMEDFileName[256];
569         
570         // parse infos
571         int ret = sscanf(strPartInfo0, "%s %d %s %s %s", 
572                 lMeshName,
573                 &lId,
574                 lPartName,
575                 lPath,
576                 lMEDFileName);
577         
578         QApplication::setOverrideCursor(Qt::waitCursor);
579
580         try
581         {
582                 float radius;
583                 ret = sscanf(lineEditRadius->text().latin1(), "%f", &radius);
584                 if ((ret != 1) || (radius <= 0.0f))
585                 {
586                         SUIT_MessageBox::error1( 
587                                 mModule->getAppli()->desktop(),
588                                 "Decimation parameters error", 
589                                 "Invalid radius (should be > 0.0)", 
590                                 tr("OK") );
591                                 
592                         return;
593                 }
594                 
595                 char strParams[256];            
596                 sprintf(strParams, "1 %f %d", radius, spinBoxBoxing->value());
597                 
598                 char* res = mModule->getMULTIPRObj()->evalDecimationParams(
599                         lPartName,
600                         comboBoxSelectFieldName->currentText().latin1(),
601                         fieldIteration,
602                         comboBoxSelectFilter->currentText().latin1(),
603                         strParams);
604                 
605                 float gradMin, gradAvg, gradMax;
606                 sscanf(res, "%f %f %f", &gradMin, &gradAvg, &gradMax);
607                 
608                 lineEditTMed->setText( QString::number(gradMin) );
609                 lineEditTLow->setText( QString::number(gradMax) );
610         }
611         catch (...)
612         {
613         }
614         
615         QApplication::restoreOverrideCursor();
616 }
617
618
619 //*****************************************************************************
620 // MULTIPR_GUI_ProgressCallbackDlg
621 // QT dialog box used to display progress in time consuming task (e.g. save)
622 //*****************************************************************************
623
624 MULTIPR_GUI_ProgressCallbackDlg::MULTIPR_GUI_ProgressCallbackDlg(QWidget* parent) :
625         QProgressDialog(
626                 parent, 
627                 0, 
628                 false, 
629                 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
630 {
631         setLabel(new QLabel(this, "Please wait"));
632         setLabelText("Please wait");
633         setTotalSteps(100);
634 }
635
636
637 MULTIPR_GUI_ProgressCallbackDlg::~MULTIPR_GUI_ProgressCallbackDlg()
638 {
639         // do nothing
640 }
641
642
643 void MULTIPR_GUI_ProgressCallbackDlg::start(const char* pTaskTitle, int pNumStep)
644 {
645         setCaption(pTaskTitle);
646         MULTIPR_ProgressCallback::init(pNumStep);
647 }
648
649
650 void MULTIPR_GUI_ProgressCallbackDlg::done()
651 {
652         setProgress(100);
653 }
654
655         
656 void MULTIPR_GUI_ProgressCallbackDlg::progress(float pPercent)
657 {
658         setProgress(int(pPercent));
659 }
660
661 // EOF