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