1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Partitioning/decimation module for the SALOME v3.2 platform
23 * \file MULTIPR_GUI_Dlg.cxx
25 * \brief see MULTIPR_GUI_Dlg.h
27 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
32 //*****************************************************************************
34 //*****************************************************************************
36 #include "MULTIPR_GUI_Dlg.h"
37 #include "MULTIPR_GUI.h"
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Session.h>
43 #include <SalomeApp_Application.h>
44 #include <SalomeApp_CheckFileDlg.h>
45 #include <LightApp_SelectionMgr.h>
47 #include <SALOME_LifeCycleCORBA.hxx>
50 #include <QApplication>
51 #include <QInputDialog>
53 #include <QPushButton>
55 #include <QVBoxLayout>
73 MULTIPR_GUI_Partition1Dlg::MULTIPR_GUI_Partition1Dlg(MULTIPR_GUI* theModule) :
75 (QWidget*)theModule->application()->desktop(),
76 Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
80 groupBoxProcess = new QGroupBox( "groupBoxProcess",this );
81 groupBoxProcess->setGeometry( QRect( 10, 110, 450, 60 ) );
83 pushButtonOK = new QPushButton( QString("pushButtonOK"),groupBoxProcess );
84 pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
86 pushButtonCancel = new QPushButton( QString("pushButtonCancel"),groupBoxProcess );
87 pushButtonCancel->setGeometry( QRect( 321, 10, 110, 41 ) );
89 groupBoxSelectMesh = new QGroupBox( "groupBoxSelectMesh",this );
90 groupBoxSelectMesh->setGeometry( QRect( 10, 10, 450, 91 ) );
92 comboBoxSelectMesh = new QComboBox( groupBoxSelectMesh );
93 comboBoxSelectMesh->setGeometry( QRect( 160, 30, 280, 40 ) );
94 MULTIPR_ORB::string_array* listMeshes = theModule->getMULTIPRObj()->getMeshes();
95 for (int i=0; i<listMeshes->length() ; i++)
97 const char* strItem = (*listMeshes)[i];
98 comboBoxSelectMesh->insertItem(0,strItem);
100 comboBoxSelectMesh->setEditable(false);
102 textLabelSelectMesh = new QLabel( "textLabelSelectMesh",groupBoxSelectMesh );
103 textLabelSelectMesh->setGeometry( QRect( 20, 30, 110, 40 ) );
105 setWindowTitle( tr( "Extract groups from sequential MED file" ) );
106 groupBoxProcess->setTitle( QString::null );
107 pushButtonCancel->setText( tr( "Cancel" ) );
108 pushButtonOK->setText( tr("OK") );
109 groupBoxSelectMesh->setTitle( tr( "Select mesh" ) );
110 textLabelSelectMesh->setText( tr( "Mesh name" ) );
112 resize( QSize(471, 185).expandedTo(minimumSizeHint()) );
113 //clearWState( WState_Polished );
115 connect(pushButtonOK, SIGNAL(clicked()), this, SLOT(accept()));
116 connect(pushButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
121 * Destroys the object and frees any allocated resources
123 MULTIPR_GUI_Partition1Dlg::~MULTIPR_GUI_Partition1Dlg()
125 // no need to delete child widgets, Qt does it all for us
129 void MULTIPR_GUI_Partition1Dlg::accept()
131 const char* meshName = comboBoxSelectMesh->currentText().toLatin1();
135 mModule->getMULTIPRObj()->setMesh(meshName);
137 QApplication::setOverrideCursor(Qt::WaitCursor);
138 mModule->getMULTIPRObj()->partitionneDomaine();
139 QApplication::restoreOverrideCursor();
144 SUIT_MessageBox::critical(
145 (QWidget*)mModule->getAppli()->desktop(),
146 QString("Import MED file error"),
147 QString("Unable to set mesh"));
154 void MULTIPR_GUI_Partition1Dlg::reject()
160 MULTIPR_GUI_Partition2Dlg::MULTIPR_GUI_Partition2Dlg(MULTIPR_GUI* theModule) :
162 (QWidget*)theModule->application()->desktop(),
163 Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
167 groupBoxSplitParameters = new QGroupBox( "groupBoxSplitParameters",this );
168 groupBoxSplitParameters->setGeometry( QRect( 10, 10, 380, 140 ) );
170 textLabelSelectNbParts = new QLabel( "textLabelSelectNbParts",groupBoxSplitParameters );
171 textLabelSelectNbParts->setGeometry( QRect( 30, 30, 160, 31 ) );
173 textLabelSelectSplitter = new QLabel( "textLabelSelectSplitter",groupBoxSplitParameters );
174 textLabelSelectSplitter->setGeometry( QRect( 30, 80, 111, 31 ) );
176 comboBoxSelectSplitter = new QComboBox(groupBoxSplitParameters);
177 comboBoxSelectSplitter->setGeometry( QRect( 210, 80, 150, 40 ) );
178 comboBoxSelectSplitter->insertItem(0,"METIS");
179 comboBoxSelectSplitter->insertItem(0,"SCOTCH");
180 comboBoxSelectSplitter->setEditable(false);
182 spinBoxNbParts = new QSpinBox( groupBoxSplitParameters);
183 spinBoxNbParts->setGeometry( QRect( 210, 30, 150, 30 ) );
184 spinBoxNbParts->setMaximum( 1000 );
185 spinBoxNbParts->setMinimum( 2 );
186 spinBoxNbParts->setValue( 2 );
188 groupBoxProcess = new QGroupBox( "groupBoxProcess",this );
189 groupBoxProcess->setGeometry( QRect( 10, 160, 380, 60 ) );
191 pushButtonOK = new QPushButton( QString("pushButtonOK"),groupBoxProcess );
192 pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
194 pushButtonCancel = new QPushButton( QString("pushButtonCancel"),groupBoxProcess );
195 pushButtonCancel->setGeometry( QRect( 250, 10, 110, 41 ) );
197 setWindowTitle( tr( "Split selected part" ) );
198 groupBoxSplitParameters->setTitle( tr( "Split parameters" ) );
199 textLabelSelectNbParts->setText( tr( "Number of sub-parts" ) );
200 textLabelSelectSplitter->setText( tr( "Splitter" ) );
201 groupBoxProcess->setTitle( QString::null );
202 pushButtonOK->setText( tr("OK") );
203 pushButtonCancel->setText( tr( "Cancel" ) );
205 resize( QSize(403, 234).expandedTo(minimumSizeHint()) );
206 //clearWState( WState_Polished );
208 connect(pushButtonOK, SIGNAL(clicked()), this, SLOT(accept()));
209 connect(pushButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
214 * Destroys the object and frees any allocated resources
216 MULTIPR_GUI_Partition2Dlg::~MULTIPR_GUI_Partition2Dlg()
218 // no need to delete child widgets, Qt does it all for us
222 void MULTIPR_GUI_Partition2Dlg::accept()
224 const char* strSplitter = comboBoxSelectSplitter->currentText().toLatin1();
225 int nbParts = spinBoxNbParts->value();
226 int partitionner = -1;
227 if (strcmp(strSplitter, "METIS") == 0)
231 else if (strcmp(strSplitter, "SCOTCH") == 0)
236 QApplication::setOverrideCursor(Qt::WaitCursor);
240 const QStringList& partsList = mModule->getSelectedParts();
241 for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
243 const QString& partName = (*it);
244 //cout << "Split " << partName.toLatin1() << " #parts=" << nbParts << " splitter=" << strSplitter << endl;
245 mModule->getMULTIPRObj()->partitionneGroupe(partName.toLatin1(), nbParts, partitionner);
251 SUIT_MessageBox::critical(
252 (QWidget*)mModule->getAppli()->desktop(),
254 "Error while splitting selected part(s)");
257 QApplication::restoreOverrideCursor();
262 void MULTIPR_GUI_Partition2Dlg::reject()
268 MULTIPR_GUI_DecimateDlg::MULTIPR_GUI_DecimateDlg(MULTIPR_GUI* theModule) :
270 (QWidget*)theModule->application()->desktop(),
271 Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
274 groupBoxSelectField = new QGroupBox("groupBoxSelectField",this );
275 groupBoxSelectField->setGeometry( QRect( 10, 10, 710, 140 ) );
277 textLabelSelectFieldName = new QLabel( "textLabelSelectFieldName",groupBoxSelectField );
278 textLabelSelectFieldName->setGeometry( QRect( 30, 30, 141, 31 ) );
280 textLabelSelectFieldIteration = new QLabel( "textLabelSelectFieldIteration",groupBoxSelectField );
281 textLabelSelectFieldIteration->setGeometry( QRect( 30, 80, 111, 31 ) );
283 const QStringList& partsList = mModule->getSelectedParts();
284 // Lets get the fields !.
285 QString allParts = partsList.join("|");
286 MULTIPR_ORB::string_array* listFields = theModule->getMULTIPRObj()->getFields(allParts.toLatin1());
287 int maxIteration = 0;
289 for (i = 0 ; i < listFields->length() ; ++i)
291 char* strItem = (*listFields)[i];
292 for (j = 0; strItem[j] && strItem[j] != ' '; ++j);
294 CORBA::Long nbIteration = theModule->getMULTIPRObj()->getTimeStamps(allParts.toLatin1(), strItem);
296 if (nbIteration > maxIteration)
298 maxIteration = nbIteration;
302 comboBoxSelectFieldIteration = new QComboBox( groupBoxSelectField );
303 comboBoxSelectFieldIteration->setGeometry( QRect( 150, 80, 540, 40 ) );
304 for (int i=1 ; i<=maxIteration ; i++)
306 comboBoxSelectFieldIteration->insertItem(0,QString::number(i));
309 comboBoxSelectFieldName = new QComboBox(groupBoxSelectField );
310 comboBoxSelectFieldName->setGeometry( QRect( 150, 30, 540, 40 ) );
311 for (int i=0 ; i<listFields->length() ; i++)
313 const char* strItem = (*listFields)[i];
314 comboBoxSelectFieldName->insertItem(0,strItem);
316 comboBoxSelectFieldName->setEditable(false);
317 comboBoxSelectFieldName->setToolTip(tr( "only scalar fields are listed (multi-component fields are not displayed)" ));
319 groupBoxSelectFilter = new QGroupBox("groupBoxSelectFilter",this );
320 groupBoxSelectFilter->setGeometry( QRect( 10, 160, 710, 90 ) );
322 textLabelSelectFilter = new QLabel( "textLabelSelectFilter",groupBoxSelectFilter );
323 textLabelSelectFilter->setGeometry( QRect( 30, 30, 101, 31 ) );
325 comboBoxSelectFilter = new QComboBox( groupBoxSelectFilter );
326 comboBoxSelectFilter->setGeometry( QRect( 150, 30, 540, 40 ) );
327 comboBoxSelectFilter->insertItem(0,"Filtre_GradientMoyen");
328 comboBoxSelectFilter->insertItem(0,"Filtre_Direct");
330 groupBoxParameters = new QGroupBox( "groupBoxParameters" ,this);
331 groupBoxParameters->setGeometry( QRect( 10, 260, 710, 210 ) );
333 textLabelTMed = new QLabel( "textLabelTMed",groupBoxParameters );
334 textLabelTMed->setGeometry( QRect( 20, 40, 242, 30 ) );
336 textLabelTLow = new QLabel( "textLabelTLow",groupBoxParameters );
337 textLabelTLow->setGeometry( QRect( 20, 80, 208, 30 ) );
339 textLabelRadius = new QLabel( "textLabelRadius",groupBoxParameters );
340 textLabelRadius->setGeometry( QRect( 20, 120, 211, 30 ) );
342 textLabelBoxing = new QLabel( "textLabelBoxing",groupBoxParameters );
343 textLabelBoxing->setGeometry( QRect( 20, 160, 241, 30 ) );
345 lineEditTMed = new QLineEdit( groupBoxParameters );
346 lineEditTMed->setGeometry( QRect( 580, 40, 111, 30 ) );
348 lineEditTLow = new QLineEdit( groupBoxParameters );
349 lineEditTLow->setGeometry( QRect( 580, 80, 111, 30 ) );
351 lineEditRadius = new QLineEdit( groupBoxParameters );
352 lineEditRadius->setGeometry( QRect( 580, 120, 111, 30 ) );
354 spinBoxBoxing = new QSpinBox( groupBoxParameters );
355 spinBoxBoxing->setGeometry( QRect( 580, 160, 111, 30 ) );
356 spinBoxBoxing->setMaximum( 200 );
357 spinBoxBoxing->setMinimum( 2 );
358 spinBoxBoxing->setValue( 100 );
359 spinBoxBoxing->setToolTip(tr( "grid: number of cells along each axis" ) );
361 infoGroup = new QGroupBox("infoGroup",this);
362 infoGroup->setGeometry( QRect( 10, 480, 710, 60 ) );
366 // Accumulator used to display the number of meshes in the current selection.
368 for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
370 const QString& partName = (*it);
371 stats = theModule->getMULTIPRObj()->getMEDInfo(partName.toLatin1());
372 sscanf(stats, "%d", &tmp);
377 sprintf(buf, "%d", acum);
378 textLabelInfo = new QLabel( "textLabelInfo",infoGroup);
379 textLabelInfo->setText("Number of cells:");
380 textLabelInfo->setGeometry( QRect( 20, 10, 242, 30 ) );
381 textLabelInfoValue = new QLabel( "textLabelInfoValue",infoGroup);
382 textLabelInfoValue->setAlignment(Qt::AlignRight);
383 textLabelInfoValue->setText(buf);
384 textLabelInfoValue->setGeometry( QRect( 400, 10, 290, 30 ) );
386 groupBoxProcess = new QGroupBox("groupBoxProcess",this );
387 groupBoxProcess->setGeometry( QRect( 10, 580, 710, 60 ) );
389 pushButtonOK = new QPushButton( QString( "pushButtonOK"),groupBoxProcess );
390 pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) );
392 pushButtonCancel = new QPushButton( QString("pushButtonCancel"),groupBoxProcess );
393 pushButtonCancel->setGeometry( QRect( 581, 10, 110, 41 ) );
394 pushButtonCancel->setShortcut( QKeySequence( tr( "Esc" ) ) );
396 setWindowTitle( tr( "Decimation" ) );
397 groupBoxSelectField->setTitle( tr( "Select field" ) );
398 textLabelSelectFieldName->setText( tr( "Field name" ) );
399 textLabelSelectFieldIteration->setText( tr( "Field iteration" ) );
400 groupBoxSelectFilter->setTitle( tr( "Select filter" ) );
401 textLabelSelectFilter->setText( tr( "Filter name" ) );
402 groupBoxParameters->setTitle( tr( "Set parameters" ) );
403 textLabelTMed->setText( tr( "Threshold for medium resolution" ) );
404 textLabelTLow->setText( tr( "Threshold for low resolution" ) );
405 textLabelRadius->setText( tr( "Radius (neighborhood)" ) );
406 textLabelBoxing->setText( tr( "Acceleration structure (boxing)" ) );
407 lineEditTMed->setText( tr( "0.1" ) );
408 lineEditTLow->setText( tr( "0.2" ) );
410 float defaultRadius = 0.5f;
411 lineEditRadius->setText( QString::number(defaultRadius) );
412 groupBoxProcess->setTitle( QString::null );
413 pushButtonCancel->setText( tr( "Cancel" ) );
414 pushButtonOK->setText( tr("OK") );
416 pushButtonThresholdAuto = new QPushButton( QString("pushButtonThresholdAuto"),groupBoxParameters );
417 pushButtonThresholdAuto->setGeometry( QRect( 520, 80, 50, 30 ) );
418 QFont pushButtonThresholdAuto_font( pushButtonThresholdAuto->font() );
419 pushButtonThresholdAuto_font.setPointSize( 11 );
420 pushButtonThresholdAuto->setFont( pushButtonThresholdAuto_font );
421 pushButtonThresholdAuto->setText( tr( "auto" ) );
422 pushButtonThresholdAuto->setToolTip(tr( "compute extremum for gradient (set medium=MIN and low=MAX)" ) );
424 pushButtonRadiusAuto = new QPushButton( QString("pushButtonRadiusAuto"),groupBoxParameters );
425 pushButtonRadiusAuto->setGeometry( QRect( 520, 120, 50, 30 ) );
426 QFont pushButtonRadiusAuto_font( pushButtonRadiusAuto->font() );
427 pushButtonRadiusAuto_font.setPointSize( 11 );
428 pushButtonRadiusAuto->setFont( pushButtonRadiusAuto_font );
429 pushButtonRadiusAuto->setText( tr( "auto" ) );
430 pushButtonRadiusAuto->setToolTip(tr( "set radius automatically (average #neighbours equal to 8)" ));
432 resize( QSize(730, 654).expandedTo(minimumSizeHint()) );
433 //clearWState( WState_Polished );
435 connect(pushButtonOK, SIGNAL(clicked()), this, SLOT(accept()));
436 connect(pushButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
437 connect(pushButtonRadiusAuto, SIGNAL(clicked()), this, SLOT(OnRadiusAuto()));
438 connect(pushButtonThresholdAuto, SIGNAL(clicked()), this, SLOT(OnThresholdAuto()));
439 connect(comboBoxSelectFilter, SIGNAL(activated(const QString &)), this, SLOT(selectField(const QString &)));
444 * Destroys the object and frees any allocated resources
446 MULTIPR_GUI_DecimateDlg::~MULTIPR_GUI_DecimateDlg()
448 // no need to delete child widgets, Qt does it all for us
452 void MULTIPR_GUI_DecimateDlg::accept()
454 const char* strFieldNameTmp = comboBoxSelectFieldName->currentText().toLatin1();
455 const char* strFieldIt = comboBoxSelectFieldIteration->currentText().toLatin1();
456 int fieldIteration = atoi(strFieldIt);
458 char strFieldName[MED_TAILLE_NOM + 1];
459 const char* filterName = comboBoxSelectFilter->currentText().toLatin1();
460 char params[MULTIPR_GUI_MAX_PARAMS_LENGTH];
463 // Get the field name.
464 strncpy(strFieldName, strFieldNameTmp, MED_TAILLE_NOM);
465 strFieldName[MED_TAILLE_NOM] = '\0';
466 for (i = 0; strFieldName[i] && strFieldName[i] != ' '; ++i);
469 // Fill the corresponding filter parameters string.
470 if (strcmp(filterName, "Filtre_GradientMoyen") == 0)
472 if (this->setGradAvgFilterParams(params) == false)
477 else if (strcmp(filterName, "Filtre_Direct") == 0)
479 if (this->setDirectFilterParams(params) == false)
486 SUIT_MessageBox::critical(
487 (QWidget*)mModule->getAppli()->desktop(),
489 "Unknown filter name.");
492 QApplication::setOverrideCursor(Qt::WaitCursor);
494 MULTIPR_ORB::string_array* list = NULL;
497 const QStringList& partsList = mModule->getSelectedParts();
498 for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
500 const QString& partName = (*it);
502 list = mModule->getMULTIPRObj()->decimePartition(partName.toLatin1(),
511 SUIT_MessageBox::critical(
512 (QWidget*)mModule->getAppli()->desktop(),
514 "Error while decimating selected part(s)");
517 if (list != NULL && list->length() >= 4)
519 const char* rate = (*list)[list->length() - 1];
520 SUIT_MessageBox::information((QWidget*)mModule->getAppli()->desktop(),
524 QApplication::restoreOverrideCursor();
528 bool MULTIPR_GUI_DecimateDlg::setGradAvgFilterParams(char* pParams)
530 int boxing = spinBoxBoxing->value();
533 int ret = sscanf(lineEditTMed->text().toLatin1(), "%lf", &thresholdMed);
534 if ((ret != 1) || (thresholdMed <= 0.0f))
536 SUIT_MessageBox::critical(
537 (QWidget*)mModule->getAppli()->desktop(),
538 "Decimation parameters error",
539 "Invalid medium threshold (should be > 0.0)");
545 ret = sscanf(lineEditTLow->text().toLatin1(), "%lf", &thresholdLow);
546 if ((ret != 1) || (thresholdLow <= 0.0f))
548 SUIT_MessageBox::critical(
549 (QWidget*)mModule->getAppli()->desktop(),
550 "Decimation parameters error",
551 "Invalid low threshold (should be > 0.0)");
556 if (thresholdMed >= thresholdLow)
558 SUIT_MessageBox::critical(
559 (QWidget*)mModule->getAppli()->desktop(),
560 "Decimation parameters error",
561 "Medium threshold must be < low threshold");
567 ret = sscanf(lineEditRadius->text().toLatin1(), "%lf", &radius);
568 if ((ret != 1) || (radius <= 0.0f))
570 SUIT_MessageBox::critical(
571 (QWidget*)mModule->getAppli()->desktop(),
572 "Decimation parameters error",
573 "Invalid radius (should be > 0.0)");
578 sprintf(pParams, "%lf %lf %lf %d", thresholdMed, thresholdLow, radius, boxing);
583 bool MULTIPR_GUI_DecimateDlg::setDirectFilterParams(char* pParams)
586 int ret = sscanf(lineEditTMed->text().toLatin1(), "%lf", &thresholdMed);
589 SUIT_MessageBox::critical(
590 (QWidget*)mModule->getAppli()->desktop(),
591 "Decimation parameters error",
592 "Invalid medium threshold.");
598 ret = sscanf(lineEditTLow->text().toLatin1(), "%lf", &thresholdLow);
601 SUIT_MessageBox::critical(
602 (QWidget*)mModule->getAppli()->desktop(),
603 "Decimation parameters error",
604 "Invalid low threshold.");
609 if (thresholdMed >= thresholdLow)
611 SUIT_MessageBox::critical(
612 (QWidget*)mModule->getAppli()->desktop(),
613 "Decimation parameters error",
614 "Medium threshold must be < low threshold");
619 sprintf(pParams, "%lf %lf", thresholdMed, thresholdLow);
624 void MULTIPR_GUI_DecimateDlg::selectField(const QString& valueText)
626 if (valueText == "Filtre_GradientMoyen")
628 lineEditRadius->show();
629 spinBoxBoxing->show();
630 pushButtonRadiusAuto->show();
631 textLabelRadius->show();
632 textLabelBoxing->show();
633 //pushButtonThresholdAuto->show();
635 else if (valueText == "Filtre_Direct")
637 lineEditRadius->hide();
638 spinBoxBoxing->hide();
639 pushButtonRadiusAuto->hide();
640 textLabelRadius->hide();
641 textLabelBoxing->hide();
642 //pushButtonThresholdAuto->hide();
646 SUIT_MessageBox::critical(
647 (QWidget*)mModule->getAppli()->desktop(),
649 "Unknown filter name.");
653 void MULTIPR_GUI_DecimateDlg::reject()
659 void MULTIPR_GUI_DecimateDlg::OnRadiusAuto()
661 // evaluates default radius for the first selected part
662 const QStringList& partsList = mModule->getSelectedParts();
663 const char* strFieldIt = comboBoxSelectFieldIteration->currentText().toLatin1();
664 int fieldIteration = atoi(strFieldIt);
665 char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].toLatin1());
671 char lMEDFileName[256];
674 int ret = sscanf(strPartInfo0, "%s %d %s %s %s",
686 QApplication::setOverrideCursor(Qt::WaitCursor);
687 float defaultRadius = 0.5f;
691 sprintf(strParams, "2");
693 char* res = mModule->getMULTIPRObj()->evalDecimationParams(
695 comboBoxSelectFieldName->currentText().toLatin1(),
697 comboBoxSelectFilter->currentText().toLatin1(),
700 sscanf(res, "%f", &defaultRadius);
705 QApplication::restoreOverrideCursor();
707 lineEditRadius->setText( QString::number(defaultRadius) );
711 void MULTIPR_GUI_DecimateDlg::OnThresholdAuto()
713 // evaluates default radius for the first selected part
714 const QStringList& partsList = mModule->getSelectedParts();
715 const char* strFieldIt = comboBoxSelectFieldIteration->currentText().toLatin1();
716 int fieldIteration = atoi(strFieldIt);
717 char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].toLatin1());
718 QString filterName = comboBoxSelectFilter->currentText();
724 char lMEDFileName[256];
727 int ret = sscanf(strPartInfo0, "%s %d %s %s %s",
734 QApplication::setOverrideCursor(Qt::WaitCursor);
735 if (filterName == "Filtre_GradientMoyen")
740 ret = sscanf(lineEditRadius->text().toLatin1(), "%f", &radius);
741 if ((ret != 1) || (radius <= 0.0f))
743 SUIT_MessageBox::critical(
744 (QWidget*)mModule->getAppli()->desktop(),
745 "Decimation parameters error",
746 "Invalid radius (should be > 0.0)");
752 sprintf(strParams, "1 %f %d", radius, spinBoxBoxing->value());
754 char* res = mModule->getMULTIPRObj()->evalDecimationParams(
756 comboBoxSelectFieldName->currentText().toLatin1(),
758 comboBoxSelectFilter->currentText().toLatin1(),
761 float gradMin, gradAvg, gradMax;
762 sscanf(res, "%f %f %f", &gradMin, &gradAvg, &gradMax);
764 lineEditTMed->setText( QString::number(gradMin) );
765 lineEditTLow->setText( QString::number(gradMax) );
771 else if (filterName == "Filtre_Direct")
776 mModule->getMULTIPRObj()->getFieldMinMax(lPartName, comboBoxSelectFieldName->currentText().toLatin1(), lMin, lMax);
777 lineEditTMed->setText(QString::number(lMin));
778 lineEditTLow->setText(QString::number(lMax));
782 SUIT_MessageBox::critical(
783 (QWidget*)mModule->getAppli()->desktop(),
785 "Unknown filter name.");
787 QApplication::restoreOverrideCursor();
790 //*****************************************************************************
791 // MULTIPR_GUI_ProgressCallbackDlg
792 // QT dialog box used to display progress in time consuming task (e.g. save)
793 //*****************************************************************************
795 MULTIPR_GUI_ProgressCallbackDlg::MULTIPR_GUI_ProgressCallbackDlg(QWidget* parent) :
798 Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
800 setLabel(new QLabel(QString("Please wait"),this));
801 setLabelText("Please wait");
802 // setTotalSteps(100);
806 MULTIPR_GUI_ProgressCallbackDlg::~MULTIPR_GUI_ProgressCallbackDlg()
812 void MULTIPR_GUI_ProgressCallbackDlg::start(const char* pTaskTitle, int pNumStep)
814 setWindowTitle(pTaskTitle);
815 MULTIPR_ProgressCallback::init(pNumStep);
819 void MULTIPR_GUI_ProgressCallbackDlg::done()
825 void MULTIPR_GUI_ProgressCallbackDlg::progress(float pPercent)
827 setValue(int(pPercent));
831 //*****************************************************************************
832 // MULTIPR_GUI_EmptyMeshCallbackDlg
833 // QT dialog box used to inform about empty meshes
834 //*****************************************************************************
836 MULTIPR_GUI_EmptyMeshCallbackDlg::MULTIPR_GUI_EmptyMeshCallbackDlg(QWidget* parent)
842 MULTIPR_GUI_EmptyMeshCallbackDlg::~MULTIPR_GUI_EmptyMeshCallbackDlg()
848 void MULTIPR_GUI_EmptyMeshCallbackDlg::reportEmptyMesh(string pInfo)
851 sprintf(msg, "Empty mesh detected (%s)", pInfo.c_str());
853 SUIT_MessageBox::warning(
855 "Empty mesh detected",