]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx
Salome HOME
*** empty log message ***
[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         pushButtonCancel->setAccel( QKeySequence( tr( "Esc" ) ) );
345         
346     pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" );
347     pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
348         pushButtonOK->setAccel( QKeySequence( tr( "Return" ) ) );
349     
350         setCaption( tr( "Decimation" ) );
351     buttonGroupSelectField->setTitle( tr( "Select field" ) );
352     textLabelSelectFieldName->setText( tr( "Field name" ) );
353     textLabelSelectFieldIteration->setText( tr( "Iteration" ) );
354     buttonGroupSelectFilter->setTitle( tr( "Select filter" ) );
355     textLabelSelectFilter->setText( tr( "Filter name" ) );
356     buttonGroupParameters->setTitle( tr( "Set parameters" ) );
357     textLabelTMed->setText( tr( "Threshold for medium resolution" ) );
358     textLabelTLow->setText( tr( "Threshold for low resolution" ) );
359     textLabelRadius->setText( tr( "Radius (neighborhood)" ) );
360     textLabelBoxing->setText( tr( "Boxing parameter" ) );
361     lineEditTMed->setText( tr( "0.1" ) );
362     lineEditTLow->setText( tr( "0.2" ) );
363
364         float defaultRadius = 0.5f;
365     lineEditRadius->setText( QString::number(defaultRadius) );
366     buttonGroupProcess->setTitle( QString::null );
367     pushButtonCancel->setText( tr( "Cancel" ) );
368     pushButtonOK->setText( tr("OK") );
369         
370         pushButtonThresholdAuto = new QPushButton( buttonGroupParameters, "pushButtonThresholdAuto" );
371     pushButtonThresholdAuto->setGeometry( QRect( 260, 80, 50, 30 ) );
372     QFont pushButtonThresholdAuto_font(  pushButtonThresholdAuto->font() );
373     pushButtonThresholdAuto_font.setPointSize( 11 );
374     pushButtonThresholdAuto->setFont( pushButtonThresholdAuto_font ); 
375         pushButtonThresholdAuto->setText( tr( "auto" ) );
376     QToolTip::add( pushButtonThresholdAuto, tr( "compute extremum for gradient (set medium=MIN and low=MAX)" ) );
377
378     pushButtonRadiusAuto = new QPushButton( buttonGroupParameters, "pushButtonRadiusAuto" );
379     pushButtonRadiusAuto->setGeometry( QRect( 260, 120, 50, 30 ) );
380     QFont pushButtonRadiusAuto_font(  pushButtonRadiusAuto->font() );
381     pushButtonRadiusAuto_font.setPointSize( 11 );
382     pushButtonRadiusAuto->setFont( pushButtonRadiusAuto_font ); 
383     pushButtonRadiusAuto->setText( tr( "auto" ) );
384     QToolTip::add( pushButtonRadiusAuto, tr( "set radius automatically (average #neighbours equal to 8)" ) );
385         
386     resize( QSize(470, 554).expandedTo(minimumSizeHint()) );
387     clearWState( WState_Polished );
388         
389         connect(pushButtonOK,            SIGNAL(clicked()), this, SLOT(accept()));
390         connect(pushButtonCancel,        SIGNAL(clicked()), this, SLOT(reject()));
391         connect(pushButtonRadiusAuto,    SIGNAL(clicked()), this, SLOT(OnRadiusAuto()));
392         connect(pushButtonThresholdAuto, SIGNAL(clicked()), this, SLOT(OnThresholdAuto()));
393 }
394
395
396 /*
397  *  Destroys the object and frees any allocated resources
398  */
399 MULTIPR_GUI_DecimateDlg::~MULTIPR_GUI_DecimateDlg()
400 {
401     // no need to delete child widgets, Qt does it all for us
402 }
403
404
405 void MULTIPR_GUI_DecimateDlg::accept()
406 {       
407         const char* strFieldName = comboBoxSelectFieldName->currentText().latin1();
408         const char* strFieldIt   = comboBoxSelectFieldIteration->currentText().latin1();
409         int fieldIteration = atoi(strFieldIt);
410         
411         double thresholdMed;
412         int ret = sscanf(lineEditTMed->text().latin1(), "%lf", &thresholdMed);
413         if ((ret != 1) || (thresholdMed <= 0.0f))
414         {
415                 SUIT_MessageBox::error1( 
416                         mModule->getAppli()->desktop(),
417                         "Decimation parameters error", 
418                         "Invalid medium threshold (should be > 0.0)", 
419                         tr("OK") );
420                         
421                 return;
422         }
423
424         double thresholdLow;
425         ret = sscanf(lineEditTLow->text().latin1(), "%lf", &thresholdLow);
426         if ((ret != 1) || (thresholdLow <= 0.0f))
427         {
428                 SUIT_MessageBox::error1( 
429                         mModule->getAppli()->desktop(),
430                         "Decimation parameters error", 
431                         "Invalid low threshold (should be > 0.0)", 
432                         tr("OK") );
433                         
434                 return;
435         }
436         
437         if (thresholdMed >= thresholdLow)
438         {
439                 SUIT_MessageBox::error1( 
440                         mModule->getAppli()->desktop(),
441                         "Decimation parameters error", 
442                         "Medium threshold must be < low threshold", 
443                         tr("OK") );
444                         
445                 return;
446         }
447
448         double radius;
449         ret = sscanf(lineEditRadius->text().latin1(), "%lf", &radius);
450         if ((ret != 1) || (radius <= 0.0f))
451         {
452                 SUIT_MessageBox::error1( 
453                         mModule->getAppli()->desktop(),
454                         "Decimation parameters error", 
455                         "Invalid radius (should be > 0.0)", 
456                         tr("OK") );
457                         
458                 return;
459         }
460         
461         QApplication::setOverrideCursor(Qt::waitCursor);
462         
463         try
464         {
465                 const QStringList& partsList = mModule->getSelectedParts();
466                 for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
467                 {
468                         const QString& partName = (*it);
469                         
470                         mModule->getMULTIPRObj()->setBoxing(spinBoxBoxing->value());
471                         
472                         mModule->getMULTIPRObj()->decimePartition(
473                                 partName.latin1(),
474                                 strFieldName,
475                                 fieldIteration,
476                                 comboBoxSelectFilter->currentText().latin1(),
477                                 thresholdMed,
478                                 thresholdLow,
479                                 radius);
480                 }
481         }
482         catch(...)
483         {
484                 SUIT_MessageBox::error1( 
485                         mModule->getAppli()->desktop(),
486                         "Decimation error", 
487                         "Error while decimating selected part(s)", 
488                         tr("OK") );
489         }
490         
491         QApplication::restoreOverrideCursor();
492         QDialog::accept();
493 }
494
495
496 void MULTIPR_GUI_DecimateDlg::reject()
497 {
498         QDialog::reject();
499 }
500
501
502 void MULTIPR_GUI_DecimateDlg::OnRadiusAuto()
503 {
504         // evaluates default radius for the first selected part
505         const QStringList& partsList = mModule->getSelectedParts();
506         const char* strFieldIt   = comboBoxSelectFieldIteration->currentText().latin1();
507         int fieldIteration = atoi(strFieldIt);
508         char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].latin1());
509         
510         char   lMeshName[256];
511         int    lId;
512         char   lPartName[256];
513         char   lPath[256];
514         char   lMEDFileName[256];
515         
516         // parse infos
517         int ret = sscanf(strPartInfo0, "%s %d %s %s %s", 
518                 lMeshName,
519                 &lId,
520                 lPartName,
521                 lPath,
522                 lMEDFileName);
523         
524         QApplication::setOverrideCursor(Qt::waitCursor);
525         float defaultRadius = 0.5f;
526         try
527         {
528                 char strParams[256];
529                 sprintf(strParams, "2");
530                 
531                 char* res = mModule->getMULTIPRObj()->evalDecimationParams(
532                         lPartName,
533                         comboBoxSelectFieldName->currentText().latin1(),
534                         fieldIteration,
535                         comboBoxSelectFilter->currentText().latin1(),
536                         strParams);
537                 
538                 sscanf(res, "%f", &defaultRadius);
539         }
540         catch (...)
541         {
542         }
543         QApplication::restoreOverrideCursor();
544         
545     lineEditRadius->setText( QString::number(defaultRadius) );
546 }
547
548
549 void MULTIPR_GUI_DecimateDlg::OnThresholdAuto()
550 {
551         // evaluates default radius for the first selected part
552         const QStringList& partsList = mModule->getSelectedParts();
553         const char* strFieldIt  = comboBoxSelectFieldIteration->currentText().latin1();
554         int fieldIteration = atoi(strFieldIt);
555         char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].latin1());
556         
557         char   lMeshName[256];
558         int    lId;
559         char   lPartName[256];
560         char   lPath[256];
561         char   lMEDFileName[256];
562         
563         // parse infos
564         int ret = sscanf(strPartInfo0, "%s %d %s %s %s", 
565                 lMeshName,
566                 &lId,
567                 lPartName,
568                 lPath,
569                 lMEDFileName);
570         
571         QApplication::setOverrideCursor(Qt::waitCursor);
572
573         try
574         {
575                 float radius;
576                 ret = sscanf(lineEditRadius->text().latin1(), "%f", &radius);
577                 if ((ret != 1) || (radius <= 0.0f))
578                 {
579                         SUIT_MessageBox::error1( 
580                                 mModule->getAppli()->desktop(),
581                                 "Decimation parameters error", 
582                                 "Invalid radius (should be > 0.0)", 
583                                 tr("OK") );
584                                 
585                         return;
586                 }
587                 
588                 char strParams[256];            
589                 sprintf(strParams, "1 %f %d", radius, spinBoxBoxing->value());
590                 
591                 char* res = mModule->getMULTIPRObj()->evalDecimationParams(
592                         lPartName,
593                         comboBoxSelectFieldName->currentText().latin1(),
594                         fieldIteration,
595                         comboBoxSelectFilter->currentText().latin1(),
596                         strParams);
597                 
598                 float gradMin, gradAvg, gradMax;
599                 sscanf(res, "%f %f %f", &gradMin, &gradAvg, &gradMax);
600                 
601                 lineEditTMed->setText( QString::number(gradMin) );
602                 lineEditTLow->setText( QString::number(gradMax) );
603         }
604         catch (...)
605         {
606         }
607         
608         QApplication::restoreOverrideCursor();
609 }
610
611
612 //*****************************************************************************
613 // MULTIPR_GUI_ProgressCallbackDlg
614 //*****************************************************************************
615
616 MULTIPR_GUI_ProgressCallbackDlg::MULTIPR_GUI_ProgressCallbackDlg(QWidget* parent) :
617         QProgressDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
618 {
619         setLabel(new QLabel(this, "Please wait"));
620         setLabelText("Please wait");
621         setTotalSteps(100);
622 }
623
624
625 MULTIPR_GUI_ProgressCallbackDlg::~MULTIPR_GUI_ProgressCallbackDlg()
626 {
627 }
628
629
630 void MULTIPR_GUI_ProgressCallbackDlg::start(const char* pTaskTitle, int pNumStep)
631 {
632         setCaption(pTaskTitle);
633         MULTIPR_ProgressCallback::init(pNumStep);
634 }
635
636
637 void MULTIPR_GUI_ProgressCallbackDlg::done()
638 {
639         setProgress(100);
640 }
641
642         
643 void MULTIPR_GUI_ProgressCallbackDlg::progress(float pPercent)
644 {
645         setProgress(int(pPercent));
646 }
647
648 // EOF