Salome HOME
updated copyright message
[plugins/gmshplugin.git] / src / GUI / GMSHPluginGUI_HypothesisCreator.cxx
1 // Copyright (C) 2012-2015  ALNEOS
2 // Copyright (C) 2016-2023  EDF
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 //
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.alneos.com/ or email : contact@alneos.fr
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 #include "GMSHPluginGUI_HypothesisCreator.h"
22
23 #include <SMESHGUI_Utils.h>
24 #include <SMESHGUI_HypothesesUtils.h>
25 #include <SMESHGUI_SpinBox.h>
26 #include <GeomSelectionTools.h>
27
28 #include CORBA_SERVER_HEADER(GMSHPlugin_Algorithm)
29
30 #include <SUIT_Session.h>
31 #include <SUIT_ResourceMgr.h>
32
33 #include <SalomeApp_Tools.h>
34 #include <LightApp_SelectionMgr.h>
35 #include <SALOME_ListIO.hxx>
36
37 #include <QComboBox>
38 #include <QLabel>
39 #include <QGroupBox>
40 #include <QFrame>
41 #include <QLayout>
42 #include <QLineEdit>
43 #include <QCheckBox>
44 #include <QPixmap>
45 #include <QTableWidget>
46 #include <QHeaderView>
47 #include <QPushButton>
48
49 enum Algo2D
50   {
51    automatic,
52    meshadapt,
53    delaunay,
54    frontal,
55    delaunayforquad,
56 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
57    packingparallelograms,
58    quadqs
59 #else
60    packingparallelograms
61 #endif
62   };
63
64   enum Algo3D
65   {
66    delaunay3,
67    frontal3,
68    mmg3d,
69    rtree,
70    hxt
71   };
72
73 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
74   enum Recomb2DAlgo
75   {
76    simple,
77    blossom,
78    simplefullquads,
79    blossomfullquads
80   };
81 #else
82   enum Recomb2DAlgo
83   {
84    standard,
85    blossom
86   };
87 #endif
88
89 enum SubdivAlgo
90   {
91    none,
92    allquads,
93    allhexas
94   };
95
96 enum RemeshAlgo
97   {
98    nosplit,
99    automaticR,
100    automaticmetis
101   };
102
103 enum RemeshPara
104   {
105    harmonic,
106    conformal,
107    rbfharmonic
108   };
109
110
111 GMSHPluginGUI_HypothesisCreator::GMSHPluginGUI_HypothesisCreator( const QString& theHypType )
112   : SMESHGUI_GenericHypothesisCreator( theHypType )
113 {
114   myGeomSelectionTools = NULL;
115   myCompoundSet.clear();
116   myIs2D = ( theHypType.endsWith("2D"));
117   myIs3D = (theHypType.endsWith("3D"));
118 }
119
120 GMSHPluginGUI_HypothesisCreator::~GMSHPluginGUI_HypothesisCreator()
121 {
122 }
123
124 bool GMSHPluginGUI_HypothesisCreator::checkParams(QString& msg) const
125 {
126   GmshHypothesisData data_old, data_new;
127   readParamsFromHypo( data_old );
128   readParamsFromWidgets( data_new );
129   bool res = storeParamsToHypo( data_new );
130   msg = data_new.myErrorMsg;
131   storeParamsToHypo( data_old );
132   return res;
133 }
134
135 QFrame* GMSHPluginGUI_HypothesisCreator::buildFrame()
136 {
137   QFrame* fr = new QFrame( 0 );
138   fr->setObjectName( "myframe" );
139   QVBoxLayout* lay = new QVBoxLayout( fr );
140   lay->setMargin( 5 );
141   lay->setSpacing( 0 );
142
143   QTabWidget* tab = new QTabWidget( fr );
144   tab->setTabShape( QTabWidget::Rounded );
145   tab->setTabPosition( QTabWidget::North );
146   lay->addWidget( tab );
147   QWidget* GroupC1 = new QWidget();
148   tab->insertTab( 0, GroupC1, tr( "SMESH_ARGUMENTS" ) );
149
150   QGridLayout* aGroupLayout = new QGridLayout( GroupC1 );
151   aGroupLayout->setSpacing( 6 );
152   aGroupLayout->setMargin( 11 );
153
154   int row = 0;
155   myName = 0;
156   if( isCreation() )
157   {
158     aGroupLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), GroupC1 ), row, 0 );
159     myName = new QLineEdit( GroupC1 );
160     myName->setMinimumWidth(160);
161     aGroupLayout->addWidget( myName, row, 1 );
162     row++;
163   }
164
165   my2DAlgo = 0;
166   if (!myIs3D)
167   {
168     aGroupLayout->addWidget(new QLabel(tr("GMSH_2D_ALGO"), GroupC1), row, 0);
169     my2DAlgo = new QComboBox(GroupC1);
170     QStringList types2DAlgo;
171     types2DAlgo << tr("GMSH_AUTOMATIC")
172       << tr("GMSH_MESH_ADAPT")
173       << tr("GMSH_DELAUNAY")
174       << tr("GMSH_FRONTAL")
175       << tr("GMSH_DELAUNAY_FOR_QUAD")
176 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
177       << tr("GMSH_PACKING_OF_PARALLELOGRAMS")
178       << tr("GMSH_QUASI_STRUCTURED_QUAD");
179 #else
180       << tr("GMSH_PACKING_OF_PARALLELOGRAMS");
181 #endif
182     my2DAlgo->addItems(types2DAlgo);
183     aGroupLayout->addWidget(my2DAlgo, row, 1);
184     row++;
185   }
186
187   my3DAlgo = 0;
188   if ( !myIs2D )
189   {
190     aGroupLayout->addWidget( new QLabel( tr( "GMSH_3D_ALGO" ), GroupC1 ), row, 0 );
191     my3DAlgo = new QComboBox( GroupC1 );
192     QStringList types3DAlgo;
193     types3DAlgo << tr( "GMSH_DELAUNAY3" ) << tr( "GMSH_FRONTAL_DELAUNAY" ) << tr( "GMSH_MMG3D" ) <<
194                    tr( "GMSH_R_TREE" ) << tr( "GMSH_HXT" );
195     my3DAlgo->addItems( types3DAlgo );
196     aGroupLayout->addWidget( my3DAlgo, row, 1 );
197     row++;
198   }
199
200   myRecomb2DAlgo = 0;
201   if (!myIs3D)
202   {
203     aGroupLayout->addWidget(new QLabel(tr("GMSH_2D_RECOMB_ALGO"), GroupC1), row, 0);
204     myRecomb2DAlgo = new QComboBox(GroupC1);
205     QStringList typesRecomb2DAlgo;
206 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
207     typesRecomb2DAlgo << tr("GMSH_SIMPLE") << tr("GMSH_BLOSSOM") << tr("GMSH_SIMPLE_FULL_QUADS") << tr("GMSH_BLOSSOM_FULL_QUADS");
208 #else
209     typesRecomb2DAlgo << tr("GMSH_STANDARD") << tr("GMSH_BLOSSOM");
210 #endif
211     myRecomb2DAlgo->addItems(typesRecomb2DAlgo);
212     aGroupLayout->addWidget(myRecomb2DAlgo, row, 1);
213     row++;
214   }
215   myRecombineAll = new QCheckBox( tr( "GMSH_RECOMBINE_ALL" ), GroupC1 );
216   aGroupLayout->addWidget( myRecombineAll, row, 0 );
217   row++;
218
219   mySubdivAlgo = 0;
220   
221   aGroupLayout->addWidget(new QLabel(tr("GMSH_SUBDIV_ALGO"), GroupC1), row, 0);
222   mySubdivAlgo = new QComboBox(GroupC1);
223   QStringList typesSubdivAlgo;
224   typesSubdivAlgo << tr("GMSH_NONE") << tr("GMSH_ALL_QUADS") << tr("GMSH_ALL_HEXAS");
225   mySubdivAlgo->addItems(typesSubdivAlgo);
226   aGroupLayout->addWidget(mySubdivAlgo, row, 1);
227   row++;
228
229   myRemeshAlgo = 0;
230   myRemeshPara = 0;
231   if (!myIs3D)
232   {
233     aGroupLayout->addWidget(new QLabel(tr("GMSH_REMESH_ALGO"), GroupC1), row, 0);
234     myRemeshAlgo = new QComboBox(GroupC1);
235     QStringList typesRemeshAlgo;
236     typesRemeshAlgo << tr("GMSH_NO_SPLIT") << tr("GMSH_AUTO") << tr("GMSH_AUTO_ONLY_WITH_METIS");
237     myRemeshAlgo->addItems(typesRemeshAlgo);
238     aGroupLayout->addWidget(myRemeshAlgo, row, 1);
239     row++;
240
241     aGroupLayout->addWidget(new QLabel(tr("GMSH_REMESH_PARA"), GroupC1), row, 0);
242     myRemeshPara = new QComboBox(GroupC1);
243     QStringList typesRemeshPara;
244     typesRemeshPara << tr("GMSH_HARMONIC") << tr("GMSH_CONFORMAL") << tr("GMSH_RBF_HARMONIC");
245     myRemeshPara->addItems(typesRemeshPara);
246     aGroupLayout->addWidget(myRemeshPara, row, 1);
247     row++;
248   }
249
250   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SMOOTHING_STEPS" ), GroupC1 ), row, 0 );
251   mySmouthSteps = new SMESHGUI_SpinBox( GroupC1 );
252   mySmouthSteps->RangeStepAndValidator( 1, 1000, 1, "length_precision" );
253   aGroupLayout->addWidget( mySmouthSteps, row, 1 );
254   row++;
255
256   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SIZE_FACTOR" ), GroupC1 ), row, 0 );
257   mySizeFactor = new SMESHGUI_SpinBox( GroupC1 );
258   mySizeFactor->RangeStepAndValidator( 1e-06, 1e+06, 0.1, "length_precision" );
259   aGroupLayout->addWidget( mySizeFactor, row, 1 );
260   row++;
261
262 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
263   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SIZE_FROM_CURVATURE" ), GroupC1 ), row, 0 );
264   myMeshCurvatureSize = new SMESHGUI_SpinBox( GroupC1 );
265   myMeshCurvatureSize->RangeStepAndValidator( 0.0, 1e+22, 1.0, "length_precision" );
266   aGroupLayout->addWidget( myMeshCurvatureSize, row, 1 );
267   row++;
268 #endif
269
270   aGroupLayout->addWidget( new QLabel( tr( "GMSH_MIN_SIZE" ), GroupC1 ), row, 0 );
271   myMinSize = new SMESHGUI_SpinBox( GroupC1 );
272   myMinSize->RangeStepAndValidator( 0.0, 1e+22, 1., "length_precision" );
273   aGroupLayout->addWidget( myMinSize, row, 1 );
274   row++;
275
276   aGroupLayout->addWidget( new QLabel( tr( "GMSH_MAX_SIZE" ), GroupC1 ), row, 0 );
277   myMaxSize = new SMESHGUI_SpinBox( GroupC1 );
278   myMaxSize->RangeStepAndValidator( 0.0, 1e+22, 1e+21, "length_precision" );
279   aGroupLayout->addWidget( myMaxSize, row, 1 );
280   row++;
281
282   mySecondOrder = new QCheckBox( tr( "GMSH_SECOND_ORDER" ), GroupC1 );
283   aGroupLayout->addWidget( mySecondOrder, row, 0 );
284
285   myUseIncomplElem = new QCheckBox( tr( "GMSH_USE_INCOMPLETE_ELEMENT" ), GroupC1 );
286   aGroupLayout->addWidget( myUseIncomplElem, row, 1 );
287   row++;
288
289   connect( mySecondOrder, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
290
291   // Compounds
292   if (!myIs3D)
293   {
294     QWidget* compoundGroup = new QWidget();
295     tab->insertTab(1, compoundGroup, tr("GMSH_COMPOUND"));
296
297     myCompoundTable = new QTableWidget(0, 2, compoundGroup);
298     QGridLayout* compoundLayout = new QGridLayout(compoundGroup);
299     compoundLayout->addWidget(myCompoundTable, 1, 0, 8, 1);
300
301     QStringList compoundHeaders;
302     compoundHeaders << tr("GMSH_COMPOUND_ENTRY_COLUMN") << tr("GMSH_COMPOUND_NAME_COLUMN");
303     myCompoundTable->setHorizontalHeaderLabels(compoundHeaders);
304     myCompoundTable->horizontalHeader()->hideSection(0);
305     myCompoundTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
306     myCompoundTable->resizeColumnToContents(1);
307     myCompoundTable->setAlternatingRowColors(true);
308     myCompoundTable->verticalHeader()->hide();
309
310     QPushButton* addCompoundButton = new QPushButton(tr("GMSH_COMPOUND_ADD"), compoundGroup);
311     compoundLayout->addWidget(addCompoundButton, 1, 1, 1, 1);
312     QFrame *line2 = new QFrame(compoundGroup);
313
314     line2->setFrameShape(QFrame::HLine);
315     line2->setFrameShadow(QFrame::Sunken);
316     compoundLayout->addWidget(line2, 2, 1, 1, 1);
317
318     QPushButton* removeButton = new QPushButton(tr("GMSH_COMPOUND_REMOVE"), compoundGroup);
319     compoundLayout->addWidget(removeButton, 3, 1, 1, 1);
320
321     connect(addCompoundButton, SIGNAL(clicked()), this, SLOT(onAddCompound()));
322     connect(removeButton, SIGNAL(clicked()), this, SLOT(onRemoveCompound()));
323   }
324   return fr;
325 }
326
327 void GMSHPluginGUI_HypothesisCreator::updateWidgets()
328 {
329   myUseIncomplElem->setEnabled(mySecondOrder->isChecked());
330 }
331
332 void GMSHPluginGUI_HypothesisCreator::onAddCompound()
333 {
334   GMSHPlugin::GMSHPlugin_Hypothesis_var h = GMSHPlugin::GMSHPlugin_Hypothesis::_narrow(initParamsHypothesis());
335   GeomSelectionTools* geomSelectionTools = getGeomSelectionTools();
336   LightApp_SelectionMgr* mySel = geomSelectionTools->selectionMgr();
337   SALOME_ListIO ListSelectedObjects;
338   mySel->selectedObjects(ListSelectedObjects, NULL, false );
339   SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
340   for ( ; Object_It.More() ; Object_It.Next())
341   {
342     Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
343     std::string entry, shapeName;
344     entry = geomSelectionTools->getEntryOfObject(anObject);
345     shapeName = anObject->getName();
346     TopAbs_ShapeEnum shapeType;
347     shapeType = geomSelectionTools->entryToShapeType(entry);
348     if ((shapeType == TopAbs_SHAPE) || (shapeType != TopAbs_EDGE && shapeType != TopAbs_FACE))
349       continue;
350     myCompoundTable->setFocus();
351     QString shapeEntry;
352     shapeEntry = QString::fromStdString(entry);
353     if (myCompoundSet.contains(shapeEntry))
354       continue;
355     int row = myCompoundTable->rowCount() ;
356     myCompoundTable->setRowCount(row+1);
357     myCompoundTable->setItem(row, 0, new QTableWidgetItem(shapeEntry));
358     myCompoundTable->item(row, 0 )->setFlags(0);
359     myCompoundTable->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(shapeName)));
360     myCompoundTable->item(row, 1 )->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
361     myCompoundTable->resizeColumnToContents(1);
362     myCompoundTable->clearSelection();
363     myCompoundTable->scrollToItem( myCompoundTable->item( row, 1 ) );
364     myCompoundSet.insert(shapeEntry);
365     myCompoundToRemove.remove(shapeEntry);
366   }
367 }
368
369 void GMSHPluginGUI_HypothesisCreator::onRemoveCompound()
370 {
371   QList<int> selectedRows;
372   QList<QTableWidgetItem*> selected = myCompoundTable->selectedItems();
373   QTableWidgetItem* item;
374   int row;
375   foreach(item, selected)
376   {
377     row = item->row();
378     if (!selectedRows.contains(row))
379       selectedRows.append( row );
380   }
381   qSort( selectedRows );
382   QListIterator<int> it( selectedRows );
383   it.toBack();
384   while (it.hasPrevious())
385   {
386     row = it.previous();
387     QString entry = myCompoundTable->item(row,0)->text();
388     if (myCompoundSet.contains(entry))
389     {
390       myCompoundSet.remove(entry);
391       myCompoundToRemove.insert(entry);
392     }
393     myCompoundTable->removeRow(row );
394   }
395   myCompoundTable->resizeColumnToContents(1);
396 }
397
398 void GMSHPluginGUI_HypothesisCreator::retrieveParams() const
399 {
400   GmshHypothesisData data;
401   readParamsFromHypo( data );
402
403   if( myName )
404     myName->setText( data.myName );
405   if (!myIs3D)
406     my2DAlgo->setCurrentIndex( data.my2DAlgo );
407   if ( !myIs2D )
408     my3DAlgo->setCurrentIndex( data.my3DAlgo );
409   if(!myIs3D)
410     myRecomb2DAlgo->setCurrentIndex( data.myRecomb2DAlgo );
411   if ( myRecombineAll )
412     myRecombineAll->setChecked( data.myRecombineAll );
413   if ( mySubdivAlgo )
414   mySubdivAlgo->setCurrentIndex( data.mySubdivAlgo );
415   if (!myIs3D)
416   {
417     myRemeshAlgo->setCurrentIndex(data.myRemeshAlgo);
418     myRemeshPara->setCurrentIndex(data.myRemeshPara);
419   }
420   if(data.mySmouthStepsVar.isEmpty())
421     mySmouthSteps->setValue( data.mySmouthSteps );
422   else
423     mySmouthSteps->setText( data.mySmouthStepsVar );
424   if(data.mySizeFactorVar.isEmpty())
425     mySizeFactor->setValue( data.mySizeFactor );
426   else
427     mySizeFactor->setText( data.mySizeFactorVar );
428 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
429   if(data.myMeshCurvatureSizeVar.isEmpty())
430     myMeshCurvatureSize->setValue( data.myMeshCurvatureSize );
431   else
432     myMeshCurvatureSize->setText( data.myMeshCurvatureSizeVar );
433 #endif
434   if(data.myMaxSizeVar.isEmpty())
435     myMaxSize->setValue( data.myMaxSize );
436   else
437     myMaxSize->setText( data.myMaxSizeVar );
438   if(data.myMinSizeVar.isEmpty())
439     myMinSize->setValue( data.myMinSize );
440   else
441     myMinSize->setText( data.myMinSizeVar );
442   if ( mySecondOrder )
443     mySecondOrder->setChecked( data.mySecondOrder );
444   if ( myUseIncomplElem )
445     myUseIncomplElem->setChecked( data.myUseIncomplElem );
446
447   GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this;
448   that->updateWidgets();
449
450   if (!myIs3D)
451   {
452     GeomSelectionTools* geomSelectionTools = that->getGeomSelectionTools();
453     for (QSet<QString>::const_iterator i = myCompoundSet.begin(); i != myCompoundSet.end(); ++i)
454     {
455       const QString entry = *i;
456       std::string shapeName = geomSelectionTools->getNameFromEntry(entry.toStdString());
457       int row = myCompoundTable->rowCount();
458       myCompoundTable->setRowCount(row + 1);
459       myCompoundTable->setItem(row, 0, new QTableWidgetItem(entry));
460       myCompoundTable->item(row, 0)->setFlags(0);
461       myCompoundTable->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(shapeName)));
462       myCompoundTable->item(row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
463     }
464     myCompoundTable->resizeColumnToContents(1);
465   }
466 }
467
468 QString GMSHPluginGUI_HypothesisCreator::storeParams() const
469 {
470   GmshHypothesisData data;
471   readParamsFromWidgets( data );
472   storeParamsToHypo( data );
473
474   QString valStr = tr("GMSH_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
475   valStr += tr("GMSH_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
476 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
477   valStr += tr("GMSH_SIZE_FROM_CURVATURE") + " = " + QString::number( data.myMeshCurvatureSize ) + "; ";
478 #endif
479   if ( data.mySecondOrder )
480     valStr +=  tr("GMSH_SECOND_ORDER") + "; ";
481
482   return valStr;
483 }
484
485 bool GMSHPluginGUI_HypothesisCreator::readParamsFromHypo( GmshHypothesisData& h_data ) const
486 {
487   GMSHPlugin::GMSHPlugin_Hypothesis_var h =
488     GMSHPlugin::GMSHPlugin_Hypothesis::_narrow( initParamsHypothesis() );
489
490   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
491   h_data.myName = isCreation() && data ? data->Label : "";
492
493   h_data.my2DAlgo = (int) h->Get2DAlgo();
494   if ( !myIs2D )
495     h_data.my3DAlgo = (int) h->Get3DAlgo();
496   h_data.myRecomb2DAlgo = (int) h->GetRecomb2DAlgo();
497   h_data.myRecombineAll = h->GetRecombineAll();
498   h_data.mySubdivAlgo = (int) h->GetSubdivAlgo();
499   h_data.myRemeshAlgo = (int) h->GetRemeshAlgo();
500   h_data.myRemeshPara = (int) h->GetRemeshPara();
501   h_data.mySmouthSteps = h->GetSmouthSteps();
502   h_data.mySizeFactor = h->GetSizeFactor();
503 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
504   h_data.myMeshCurvatureSize = h->GetMeshCurvatureSize();
505   h_data.myMeshCurvatureSizeVar = getVariableName("SetMeshCurvatureSize");
506 #endif
507   h_data.myMinSize = h->GetMinSize();
508   h_data.myMaxSize = h->GetMaxSize();
509   h_data.mySmouthStepsVar = getVariableName("SmouthSteps");
510   h_data.mySizeFactorVar = getVariableName("SizeFactor");
511   h_data.myMinSizeVar = getVariableName("SetMinSize");
512   h_data.myMaxSizeVar = getVariableName("SetMaxSize");
513   h_data.mySecondOrder = h->GetSecondOrder();
514   h_data.myUseIncomplElem = h->GetUseIncomplElem();
515
516   GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this;
517   GMSHPlugin::string_array_var myEntries = h->GetCompoundOnEntries();
518   for ( CORBA::ULong i=0 ; i<myEntries->length() ; i++ )
519     {
520       QString entry = myEntries[i].in();
521       that->myCompoundSet.insert(entry);
522     }
523
524   return true;
525 }
526
527 bool GMSHPluginGUI_HypothesisCreator::storeParamsToHypo( const GmshHypothesisData& h_data ) const
528 {
529   GMSHPlugin::GMSHPlugin_Hypothesis_var h =
530     GMSHPlugin::GMSHPlugin_Hypothesis::_narrow( hypothesis() );
531
532   bool ok = true;
533   try
534   {
535     if( isCreation() )
536       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() );
537     if( !myIs3D )
538       h->Set2DAlgo( h_data.my2DAlgo );
539     if ( !myIs2D )
540       h->Set3DAlgo( h_data.my3DAlgo );
541     if (!myIs3D)
542       h->SetRecomb2DAlgo( h_data.myRecomb2DAlgo );
543     h->SetRecombineAll( h_data.myRecombineAll );
544     h->SetSubdivAlgo( h_data.mySubdivAlgo );
545     if (!myIs3D)
546     {
547       h->SetRemeshAlgo(h_data.myRemeshAlgo);
548       h->SetRemeshPara(h_data.myRemeshPara);
549     }
550     h->SetSmouthSteps( h_data.mySmouthSteps );
551     h->SetSizeFactor( h_data.mySizeFactor );
552 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
553     h->SetMeshCurvatureSize( h_data.myMeshCurvatureSize );
554 #endif
555     h->SetMinSize( h_data.myMinSize );
556     h->SetMaxSize( h_data.myMaxSize );
557     h->SetVarParameter( h_data.mySmouthStepsVar.toLatin1().constData(), "SmouthSteps");
558     h->SetVarParameter( h_data.mySizeFactorVar.toLatin1().constData(), "SizeFactor");
559 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
560     h->SetVarParameter( h_data.myMeshCurvatureSizeVar.toLatin1().constData(), "SetMeshCurvatureSize");
561 #endif
562     h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
563     h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize");
564     h->SetSecondOrder( h_data.mySecondOrder );
565     h->SetUseIncomplElem( h_data.myUseIncomplElem );
566     h->SetIs2d( myIs2D );
567
568     QString mainEntry = getMainShapeEntry();
569     for (QSet<QString>::const_iterator i = myCompoundSet.begin(); i != myCompoundSet.end(); ++i)
570     {
571       QString entry = *i;
572       if ( myCompoundToRemove.contains( entry ))
573         continue;
574       if ( !mainEntry.isEmpty() && !entry.startsWith( mainEntry ))
575       {
576         h_data.myErrorMsg = "Compound group is not defined on the main geometry";
577         ok = false;
578         break;
579       }
580       h->SetCompoundOnEntry(entry.toLatin1().constData());
581     }
582     for (QSet<QString>::const_iterator i = myCompoundToRemove.begin(); i != myCompoundToRemove.end(); ++i)
583     {
584       const QString entry = *i;
585       h->UnsetCompoundOnEntry(entry.toLatin1().constData());
586     }
587   }
588   catch(const SALOME::SALOME_Exception& ex)
589   {
590     SalomeApp_Tools::QtCatchCorbaException(ex);
591     ok = false;
592   }
593   return ok;
594 }
595
596 bool GMSHPluginGUI_HypothesisCreator::readParamsFromWidgets( GmshHypothesisData& h_data ) const
597 {
598   h_data.myName           = myName ? myName->text() : "";
599   if(my2DAlgo)
600     h_data.my2DAlgo       = my2DAlgo->currentIndex();
601   if (my3DAlgo)
602     h_data.my3DAlgo       = my3DAlgo->currentIndex();
603   if(myRecomb2DAlgo)
604     h_data.myRecomb2DAlgo   = myRecomb2DAlgo->currentIndex();
605   h_data.myRecombineAll   = myRecombineAll->isChecked();
606   h_data.mySubdivAlgo     = mySubdivAlgo->currentIndex();
607   if(myRemeshAlgo)
608     h_data.myRemeshAlgo   = myRemeshAlgo->currentIndex();
609   if(myRemeshPara)
610     h_data.myRemeshPara   = myRemeshPara->currentIndex();
611   h_data.mySmouthSteps    = mySmouthSteps->value();
612   h_data.mySizeFactor     = mySizeFactor->value();
613 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
614   h_data.myMeshCurvatureSize    = myMeshCurvatureSize->value();
615   h_data.myMeshCurvatureSizeVar = myMeshCurvatureSize->text();
616 #endif
617   h_data.myMinSize        = myMinSize->value();
618   h_data.myMaxSize        = myMaxSize->value();
619   h_data.mySmouthStepsVar = mySmouthSteps->text();
620   h_data.mySizeFactorVar  = mySizeFactor->text();
621   h_data.myMinSizeVar     = myMinSize->text();
622   h_data.myMaxSizeVar     = myMaxSize->text();
623   h_data.mySecondOrder    = mySecondOrder->isChecked();
624   h_data.myUseIncomplElem = myUseIncomplElem->isChecked();
625
626   // ne semble pas utile dans la mesure ou myCompoundSet n'a pas besoin d'etre modifier
627   /*
628   GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this;
629   int nbRows = myCompoundTable->rowCount();
630   for(int row=0 ; row < nbRows ; row++)
631   {
632     QString entry = myLocalSizeTable->item(row, 1)->text();
633     that->myCompoundSet.insert(entry);
634   }
635   */
636   return true;
637 }
638
639 // on ne modifie rien à partir de là
640
641 GeomSelectionTools* GMSHPluginGUI_HypothesisCreator::getGeomSelectionTools()
642 {
643   if (myGeomSelectionTools == NULL) {
644     myGeomSelectionTools = new GeomSelectionTools();
645   }
646   return myGeomSelectionTools;
647 }
648
649 QString GMSHPluginGUI_HypothesisCreator::caption() const
650 {
651   return tr( QString( "GMSH_%1_TITLE" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() );
652 }
653
654 QPixmap GMSHPluginGUI_HypothesisCreator::icon() const
655 {
656   QString hypIconName = tr( QString("ICON_DLG_GMSH_PARAMETERS%1").arg(myIs2D?QString("_2D"):QString("")).toLatin1().data() );
657   return SUIT_Session::session()->resourceMgr()->loadPixmap( "GMSHPlugin", hypIconName );
658 }
659
660 QString GMSHPluginGUI_HypothesisCreator::type() const
661 {
662   return tr( QString( "GMSH_%1_HYPOTHESIS" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() );
663 }
664
665 QString GMSHPluginGUI_HypothesisCreator::helpPage() const
666 {
667   return "gmsh_2d_3d_hypo_page.html";
668 }