Salome HOME
a048c1656920e7ab4650863175af2e665306ef35
[plugins/gmshplugin.git] / src / GUI / GMSHPluginGUI_HypothesisCreator.cxx
1 // Copyright (C) 2012-2015  ALNEOS
2 // Copyright (C) 2016-2022  EDF R&D
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 }
118
119 GMSHPluginGUI_HypothesisCreator::~GMSHPluginGUI_HypothesisCreator()
120 {
121 }
122
123 bool GMSHPluginGUI_HypothesisCreator::checkParams(QString& msg) const
124 {
125   GmshHypothesisData data_old, data_new;
126   readParamsFromHypo( data_old );
127   readParamsFromWidgets( data_new );
128   bool res = storeParamsToHypo( data_new );
129   msg = data_new.myErrorMsg;
130   storeParamsToHypo( data_old );
131   return res;
132 }
133
134 QFrame* GMSHPluginGUI_HypothesisCreator::buildFrame()
135 {
136   QFrame* fr = new QFrame( 0 );
137   fr->setObjectName( "myframe" );
138   QVBoxLayout* lay = new QVBoxLayout( fr );
139   lay->setMargin( 5 );
140   lay->setSpacing( 0 );
141
142   QTabWidget* tab = new QTabWidget( fr );
143   tab->setTabShape( QTabWidget::Rounded );
144   tab->setTabPosition( QTabWidget::North );
145   lay->addWidget( tab );
146   QWidget* GroupC1 = new QWidget();
147   tab->insertTab( 0, GroupC1, tr( "SMESH_ARGUMENTS" ) );
148
149   QGridLayout* aGroupLayout = new QGridLayout( GroupC1 );
150   aGroupLayout->setSpacing( 6 );
151   aGroupLayout->setMargin( 11 );
152
153   int row = 0;
154   myName = 0;
155   if( isCreation() )
156   {
157     aGroupLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), GroupC1 ), row, 0 );
158     myName = new QLineEdit( GroupC1 );
159     myName->setMinimumWidth(160);
160     aGroupLayout->addWidget( myName, row, 1 );
161     row++;
162   }
163
164   aGroupLayout->addWidget( new QLabel( tr( "GMSH_2D_ALGO" ), GroupC1 ), row, 0 );
165   my2DAlgo = new QComboBox( GroupC1 );
166   QStringList types2DAlgo;
167   types2DAlgo << tr( "GMSH_AUTOMATIC" )
168               << tr( "GMSH_MESH_ADAPT" )
169               << tr( "GMSH_DELAUNAY" )
170               << tr( "GMSH_FRONTAL" )
171               << tr( "GMSH_DELAUNAY_FOR_QUAD" )
172 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
173               << tr( "GMSH_PACKING_OF_PARALLELOGRAMS" )
174               << tr( "GMSH_QUASI_STRUCTURED_QUAD" );
175 #else
176               << tr( "GMSH_PACKING_OF_PARALLELOGRAMS" );
177 #endif
178   my2DAlgo->addItems( types2DAlgo );
179   aGroupLayout->addWidget( my2DAlgo, row, 1 );
180   row++;
181
182   my3DAlgo = 0;
183   if ( !myIs2D )
184   {
185     aGroupLayout->addWidget( new QLabel( tr( "GMSH_3D_ALGO" ), GroupC1 ), row, 0 );
186     my3DAlgo = new QComboBox( GroupC1 );
187     QStringList types3DAlgo;
188     types3DAlgo << tr( "GMSH_DELAUNAY3" ) << tr( "GMSH_FRONTAL_DELAUNAY" ) << tr( "GMSH_MMG3D" ) <<
189                    tr( "GMSH_R_TREE" ) << tr( "GMSH_HXT" );
190     my3DAlgo->addItems( types3DAlgo );
191     aGroupLayout->addWidget( my3DAlgo, row, 1 );
192     row++;
193   }
194
195   aGroupLayout->addWidget( new QLabel( tr( "GMSH_2D_RECOMB_ALGO" ), GroupC1 ), row, 0 );
196   myRecomb2DAlgo = new QComboBox( GroupC1 );
197   QStringList typesRecomb2DAlgo;
198 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
199   typesRecomb2DAlgo << tr( "GMSH_SIMPLE" ) << tr( "GMSH_BLOSSOM" ) << tr( "GMSH_SIMPLE_FULL_QUADS" ) << tr( "GMSH_BLOSSOM_FULL_QUADS" );
200 #else
201   typesRecomb2DAlgo << tr( "GMSH_STANDARD" ) << tr( "GMSH_BLOSSOM" );
202 #endif
203   myRecomb2DAlgo->addItems( typesRecomb2DAlgo );
204   aGroupLayout->addWidget( myRecomb2DAlgo, row, 1 );
205   row++;
206
207   myRecombineAll = new QCheckBox( tr( "GMSH_RECOMBINE_ALL" ), GroupC1 );
208   aGroupLayout->addWidget( myRecombineAll, row, 0 );
209   row++;
210
211   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SUBDIV_ALGO" ), GroupC1 ), row, 0 );
212   mySubdivAlgo = new QComboBox( GroupC1 );
213   QStringList typesSubdivAlgo;
214   typesSubdivAlgo << tr( "GMSH_NONE" ) << tr( "GMSH_ALL_QUADS" )   << tr( "GMSH_ALL_HEXAS" );
215   mySubdivAlgo->addItems( typesSubdivAlgo );
216   aGroupLayout->addWidget( mySubdivAlgo, row, 1 );
217   row++;
218
219   aGroupLayout->addWidget( new QLabel( tr( "GMSH_REMESH_ALGO" ), GroupC1 ), row, 0 );
220   myRemeshAlgo = new QComboBox( GroupC1 );
221   QStringList typesRemeshAlgo;
222   typesRemeshAlgo << tr( "GMSH_NO_SPLIT" ) << tr( "GMSH_AUTO" )   << tr( "GMSH_AUTO_ONLY_WITH_METIS" );
223   myRemeshAlgo->addItems( typesRemeshAlgo );
224   aGroupLayout->addWidget( myRemeshAlgo, row, 1 );
225   row++;
226
227   aGroupLayout->addWidget( new QLabel( tr( "GMSH_REMESH_PARA" ), GroupC1 ), row, 0 );
228   myRemeshPara = new QComboBox( GroupC1 );
229   QStringList typesRemeshPara;
230   typesRemeshPara << tr( "GMSH_HARMONIC" ) << tr( "GMSH_CONFORMAL" )   << tr( "GMSH_RBF_HARMONIC" );
231   myRemeshPara->addItems( typesRemeshPara );
232   aGroupLayout->addWidget( myRemeshPara, row, 1 );
233   row++;
234
235   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SMOOTHING_STEPS" ), GroupC1 ), row, 0 );
236   mySmouthSteps = new SMESHGUI_SpinBox( GroupC1 );
237   mySmouthSteps->RangeStepAndValidator( 1, 1000, 1, "length_precision" );
238   aGroupLayout->addWidget( mySmouthSteps, row, 1 );
239   row++;
240
241   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SIZE_FACTOR" ), GroupC1 ), row, 0 );
242   mySizeFactor = new SMESHGUI_SpinBox( GroupC1 );
243   mySizeFactor->RangeStepAndValidator( 1e-06, 1e+06, 0.1, "length_precision" );
244   aGroupLayout->addWidget( mySizeFactor, row, 1 );
245   row++;
246
247 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
248   aGroupLayout->addWidget( new QLabel( tr( "GMSH_SIZE_FROM_CURVATURE" ), GroupC1 ), row, 0 );
249   myMeshCurvatureSize = new SMESHGUI_SpinBox( GroupC1 );
250   myMeshCurvatureSize->RangeStepAndValidator( 0.0, 1e+22, 1.0, "length_precision" );
251   aGroupLayout->addWidget( myMeshCurvatureSize, row, 1 );
252   row++;
253 #endif
254
255   aGroupLayout->addWidget( new QLabel( tr( "GMSH_MIN_SIZE" ), GroupC1 ), row, 0 );
256   myMinSize = new SMESHGUI_SpinBox( GroupC1 );
257   myMinSize->RangeStepAndValidator( 0.0, 1e+22, 1., "length_precision" );
258   aGroupLayout->addWidget( myMinSize, row, 1 );
259   row++;
260
261   aGroupLayout->addWidget( new QLabel( tr( "GMSH_MAX_SIZE" ), GroupC1 ), row, 0 );
262   myMaxSize = new SMESHGUI_SpinBox( GroupC1 );
263   myMaxSize->RangeStepAndValidator( 0.0, 1e+22, 1e+21, "length_precision" );
264   aGroupLayout->addWidget( myMaxSize, row, 1 );
265   row++;
266
267   mySecondOrder = new QCheckBox( tr( "GMSH_SECOND_ORDER" ), GroupC1 );
268   aGroupLayout->addWidget( mySecondOrder, row, 0 );
269
270   myUseIncomplElem = new QCheckBox( tr( "GMSH_USE_INCOMPLETE_ELEMENT" ), GroupC1 );
271   aGroupLayout->addWidget( myUseIncomplElem, row, 1 );
272   row++;
273
274   connect( mySecondOrder, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
275
276   // Compounds
277   QWidget* compoundGroup = new QWidget();
278   tab->insertTab(1, compoundGroup, tr("GMSH_COMPOUND"));
279
280   myCompoundTable = new QTableWidget(0, 2, compoundGroup);
281   QGridLayout* compoundLayout = new QGridLayout(compoundGroup);
282   compoundLayout->addWidget(myCompoundTable, 1, 0, 8, 1);
283
284   QStringList compoundHeaders;
285   compoundHeaders << tr( "GMSH_COMPOUND_ENTRY_COLUMN" ) << tr( "GMSH_COMPOUND_NAME_COLUMN" );
286   myCompoundTable->setHorizontalHeaderLabels(compoundHeaders);
287   myCompoundTable->horizontalHeader()->hideSection(0);
288   myCompoundTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
289   myCompoundTable->resizeColumnToContents(1);
290   myCompoundTable->setAlternatingRowColors(true);
291   myCompoundTable->verticalHeader()->hide();
292
293   QPushButton* addCompoundButton = new QPushButton(tr("GMSH_COMPOUND_ADD"), compoundGroup);
294   compoundLayout->addWidget(addCompoundButton, 1, 1, 1, 1);
295   QFrame *line2 = new QFrame(compoundGroup);
296
297   line2->setFrameShape(QFrame::HLine);
298   line2->setFrameShadow(QFrame::Sunken);
299   compoundLayout->addWidget(line2, 2, 1, 1, 1);
300
301   QPushButton* removeButton = new QPushButton(tr("GMSH_COMPOUND_REMOVE"), compoundGroup);
302   compoundLayout->addWidget(removeButton, 3, 1, 1, 1);
303
304   connect( addCompoundButton, SIGNAL(clicked()), this, SLOT(onAddCompound()));
305   connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveCompound()));
306
307   return fr;
308 }
309
310 void GMSHPluginGUI_HypothesisCreator::updateWidgets()
311 {
312   myUseIncomplElem->setEnabled(mySecondOrder->isChecked());
313 }
314
315 void GMSHPluginGUI_HypothesisCreator::onAddCompound()
316 {
317   GMSHPlugin::GMSHPlugin_Hypothesis_var h = GMSHPlugin::GMSHPlugin_Hypothesis::_narrow(initParamsHypothesis());
318   GeomSelectionTools* geomSelectionTools = getGeomSelectionTools();
319   LightApp_SelectionMgr* mySel = geomSelectionTools->selectionMgr();
320   SALOME_ListIO ListSelectedObjects;
321   mySel->selectedObjects(ListSelectedObjects, NULL, false );
322   SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
323   for ( ; Object_It.More() ; Object_It.Next())
324   {
325     Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
326     std::string entry, shapeName;
327     entry = geomSelectionTools->getEntryOfObject(anObject);
328     shapeName = anObject->getName();
329     TopAbs_ShapeEnum shapeType;
330     shapeType = geomSelectionTools->entryToShapeType(entry);
331     if ((shapeType == TopAbs_SHAPE) || (shapeType != TopAbs_EDGE && shapeType != TopAbs_FACE))
332       continue;
333     myCompoundTable->setFocus();
334     QString shapeEntry;
335     shapeEntry = QString::fromStdString(entry);
336     if (myCompoundSet.contains(shapeEntry))
337       continue;
338     int row = myCompoundTable->rowCount() ;
339     myCompoundTable->setRowCount(row+1);
340     myCompoundTable->setItem(row, 0, new QTableWidgetItem(shapeEntry));
341     myCompoundTable->item(row, 0 )->setFlags(0);
342     myCompoundTable->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(shapeName)));
343     myCompoundTable->item(row, 1 )->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
344     myCompoundTable->resizeColumnToContents(1);
345     myCompoundTable->clearSelection();
346     myCompoundTable->scrollToItem( myCompoundTable->item( row, 1 ) );
347     myCompoundSet.insert(shapeEntry);
348     myCompoundToRemove.remove(shapeEntry);
349   }
350 }
351
352 void GMSHPluginGUI_HypothesisCreator::onRemoveCompound()
353 {
354   QList<int> selectedRows;
355   QList<QTableWidgetItem*> selected = myCompoundTable->selectedItems();
356   QTableWidgetItem* item;
357   int row;
358   foreach(item, selected)
359   {
360     row = item->row();
361     if (!selectedRows.contains(row))
362       selectedRows.append( row );
363   }
364   qSort( selectedRows );
365   QListIterator<int> it( selectedRows );
366   it.toBack();
367   while (it.hasPrevious())
368   {
369     row = it.previous();
370     QString entry = myCompoundTable->item(row,0)->text();
371     if (myCompoundSet.contains(entry))
372     {
373       myCompoundSet.remove(entry);
374       myCompoundToRemove.insert(entry);
375     }
376     myCompoundTable->removeRow(row );
377   }
378   myCompoundTable->resizeColumnToContents(1);
379 }
380
381 void GMSHPluginGUI_HypothesisCreator::retrieveParams() const
382 {
383   GmshHypothesisData data;
384   readParamsFromHypo( data );
385
386   if( myName )
387     myName->setText( data.myName );
388   my2DAlgo->setCurrentIndex( data.my2DAlgo );
389   if ( !myIs2D )
390     my3DAlgo->setCurrentIndex( data.my3DAlgo );
391   myRecomb2DAlgo->setCurrentIndex( data.myRecomb2DAlgo );
392   if ( myRecombineAll )
393     myRecombineAll->setChecked( data.myRecombineAll );
394   if ( mySubdivAlgo )
395   mySubdivAlgo->setCurrentIndex( data.mySubdivAlgo );
396   myRemeshAlgo->setCurrentIndex( data.myRemeshAlgo);
397   myRemeshPara->setCurrentIndex( data.myRemeshPara);
398   if(data.mySmouthStepsVar.isEmpty())
399     mySmouthSteps->setValue( data.mySmouthSteps );
400   else
401     mySmouthSteps->setText( data.mySmouthStepsVar );
402   if(data.mySizeFactorVar.isEmpty())
403     mySizeFactor->setValue( data.mySizeFactor );
404   else
405     mySizeFactor->setText( data.mySizeFactorVar );
406 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
407   if(data.myMeshCurvatureSizeVar.isEmpty())
408     myMeshCurvatureSize->setValue( data.myMeshCurvatureSize );
409   else
410     myMeshCurvatureSize->setText( data.myMeshCurvatureSizeVar );
411 #endif
412   if(data.myMaxSizeVar.isEmpty())
413     myMaxSize->setValue( data.myMaxSize );
414   else
415     myMaxSize->setText( data.myMaxSizeVar );
416   if(data.myMinSizeVar.isEmpty())
417     myMinSize->setValue( data.myMinSize );
418   else
419     myMinSize->setText( data.myMinSizeVar );
420   if ( mySecondOrder )
421     mySecondOrder->setChecked( data.mySecondOrder );
422   if ( myUseIncomplElem )
423     myUseIncomplElem->setChecked( data.myUseIncomplElem );
424
425   GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this;
426   that->updateWidgets();
427
428   GeomSelectionTools* geomSelectionTools = that->getGeomSelectionTools();
429   for (QSet<QString>::const_iterator i = myCompoundSet.begin(); i != myCompoundSet.end(); ++i)
430   {
431     const QString entry = *i;
432     std::string shapeName = geomSelectionTools->getNameFromEntry(entry.toStdString());
433     int row = myCompoundTable->rowCount();
434     myCompoundTable->setRowCount(row+1);
435     myCompoundTable->setItem(row, 0, new QTableWidgetItem(entry));
436     myCompoundTable->item(row, 0)->setFlags(0);
437     myCompoundTable->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(shapeName)));
438     myCompoundTable->item(row, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
439   }
440   myCompoundTable->resizeColumnToContents(1);
441 }
442
443 QString GMSHPluginGUI_HypothesisCreator::storeParams() const
444 {
445   GmshHypothesisData data;
446   readParamsFromWidgets( data );
447   storeParamsToHypo( data );
448
449   QString valStr = tr("GMSH_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
450   valStr += tr("GMSH_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
451 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
452   valStr += tr("GMSH_SIZE_FROM_CURVATURE") + " = " + QString::number( data.myMeshCurvatureSize ) + "; ";
453 #endif
454   if ( data.mySecondOrder )
455     valStr +=  tr("GMSH_SECOND_ORDER") + "; ";
456
457   return valStr;
458 }
459
460 bool GMSHPluginGUI_HypothesisCreator::readParamsFromHypo( GmshHypothesisData& h_data ) const
461 {
462   GMSHPlugin::GMSHPlugin_Hypothesis_var h =
463     GMSHPlugin::GMSHPlugin_Hypothesis::_narrow( initParamsHypothesis() );
464
465   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
466   h_data.myName = isCreation() && data ? data->Label : "";
467
468   h_data.my2DAlgo = (int) h->Get2DAlgo();
469   if ( !myIs2D )
470     h_data.my3DAlgo = (int) h->Get3DAlgo();
471   h_data.myRecomb2DAlgo = (int) h->GetRecomb2DAlgo();
472   h_data.myRecombineAll = h->GetRecombineAll();
473   h_data.mySubdivAlgo = (int) h->GetSubdivAlgo();
474   h_data.myRemeshAlgo = (int) h->GetRemeshAlgo();
475   h_data.myRemeshPara = (int) h->GetRemeshPara();
476   h_data.mySmouthSteps = h->GetSmouthSteps();
477   h_data.mySizeFactor = h->GetSizeFactor();
478 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
479   h_data.myMeshCurvatureSize = h->GetMeshCurvatureSize();
480   h_data.myMeshCurvatureSizeVar = getVariableName("SetMeshCurvatureSize");
481 #endif
482   h_data.myMinSize = h->GetMinSize();
483   h_data.myMaxSize = h->GetMaxSize();
484   h_data.mySmouthStepsVar = getVariableName("SmouthSteps");
485   h_data.mySizeFactorVar = getVariableName("SizeFactor");
486   h_data.myMinSizeVar = getVariableName("SetMinSize");
487   h_data.myMaxSizeVar = getVariableName("SetMaxSize");
488   h_data.mySecondOrder = h->GetSecondOrder();
489   h_data.myUseIncomplElem = h->GetUseIncomplElem();
490
491   GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this;
492   GMSHPlugin::string_array_var myEntries = h->GetCompoundOnEntries();
493   for ( CORBA::ULong i=0 ; i<myEntries->length() ; i++ )
494     {
495       QString entry = myEntries[i].in();
496       that->myCompoundSet.insert(entry);
497     }
498
499   return true;
500 }
501
502 bool GMSHPluginGUI_HypothesisCreator::storeParamsToHypo( const GmshHypothesisData& h_data ) const
503 {
504   GMSHPlugin::GMSHPlugin_Hypothesis_var h =
505     GMSHPlugin::GMSHPlugin_Hypothesis::_narrow( hypothesis() );
506
507   bool ok = true;
508   try
509   {
510     if( isCreation() )
511       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() );
512
513     h->Set2DAlgo( h_data.my2DAlgo );
514     if ( !myIs2D )
515       h->Set3DAlgo( h_data.my3DAlgo );
516     h->SetRecomb2DAlgo( h_data.myRecomb2DAlgo );
517     h->SetRecombineAll( h_data.myRecombineAll );
518     h->SetSubdivAlgo( h_data.mySubdivAlgo );
519     h->SetRemeshAlgo( h_data.myRemeshAlgo );
520     h->SetRemeshPara( h_data.myRemeshPara );
521     h->SetSmouthSteps( h_data.mySmouthSteps );
522     h->SetSizeFactor( h_data.mySizeFactor );
523 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
524     h->SetMeshCurvatureSize( h_data.myMeshCurvatureSize );
525 #endif
526     h->SetMinSize( h_data.myMinSize );
527     h->SetMaxSize( h_data.myMaxSize );
528     h->SetVarParameter( h_data.mySmouthStepsVar.toLatin1().constData(), "SmouthSteps");
529     h->SetVarParameter( h_data.mySizeFactorVar.toLatin1().constData(), "SizeFactor");
530 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
531     h->SetVarParameter( h_data.myMeshCurvatureSizeVar.toLatin1().constData(), "SetMeshCurvatureSize");
532 #endif
533     h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
534     h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize");
535     h->SetSecondOrder( h_data.mySecondOrder );
536     h->SetUseIncomplElem( h_data.myUseIncomplElem );
537     h->SetIs2d( myIs2D );
538
539     QString mainEntry = getMainShapeEntry();
540     for (QSet<QString>::const_iterator i = myCompoundSet.begin(); i != myCompoundSet.end(); ++i)
541     {
542       QString entry = *i;
543       if ( myCompoundToRemove.contains( entry ))
544         continue;
545       if ( !mainEntry.isEmpty() && !entry.startsWith( mainEntry ))
546       {
547         h_data.myErrorMsg = "Compound group is not defined on the main geometry";
548         ok = false;
549         break;
550       }
551       h->SetCompoundOnEntry(entry.toLatin1().constData());
552     }
553     for (QSet<QString>::const_iterator i = myCompoundToRemove.begin(); i != myCompoundToRemove.end(); ++i)
554     {
555       const QString entry = *i;
556       h->UnsetCompoundOnEntry(entry.toLatin1().constData());
557     }
558   }
559   catch(const SALOME::SALOME_Exception& ex)
560   {
561     SalomeApp_Tools::QtCatchCorbaException(ex);
562     ok = false;
563   }
564   return ok;
565 }
566
567 bool GMSHPluginGUI_HypothesisCreator::readParamsFromWidgets( GmshHypothesisData& h_data ) const
568 {
569   h_data.myName           = myName ? myName->text() : "";
570   h_data.my2DAlgo         = my2DAlgo->currentIndex();
571   if (my3DAlgo)
572     h_data.my3DAlgo       = my3DAlgo->currentIndex();
573   h_data.myRecomb2DAlgo   = myRecomb2DAlgo->currentIndex();
574   h_data.myRecombineAll   = myRecombineAll->isChecked();
575   h_data.mySubdivAlgo     = mySubdivAlgo->currentIndex();
576   h_data.myRemeshAlgo     = myRemeshAlgo->currentIndex();
577   h_data.myRemeshPara     = myRemeshPara->currentIndex();
578   h_data.mySmouthSteps    = mySmouthSteps->value();
579   h_data.mySizeFactor     = mySizeFactor->value();
580 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
581   h_data.myMeshCurvatureSize    = myMeshCurvatureSize->value();
582   h_data.myMeshCurvatureSizeVar = myMeshCurvatureSize->text();
583 #endif
584   h_data.myMinSize        = myMinSize->value();
585   h_data.myMaxSize        = myMaxSize->value();
586   h_data.mySmouthStepsVar = mySmouthSteps->text();
587   h_data.mySizeFactorVar  = mySizeFactor->text();
588   h_data.myMinSizeVar     = myMinSize->text();
589   h_data.myMaxSizeVar     = myMaxSize->text();
590   h_data.mySecondOrder    = mySecondOrder->isChecked();
591   h_data.myUseIncomplElem = myUseIncomplElem->isChecked();
592
593   // ne semble pas utile dans la mesure ou myCompoundSet n'a pas besoin d'etre modifier
594   /*
595   GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this;
596   int nbRows = myCompoundTable->rowCount();
597   for(int row=0 ; row < nbRows ; row++)
598   {
599     QString entry = myLocalSizeTable->item(row, 1)->text();
600     that->myCompoundSet.insert(entry);
601   }
602   */
603   return true;
604 }
605
606 // on ne modifie rien à partir de là
607
608 GeomSelectionTools* GMSHPluginGUI_HypothesisCreator::getGeomSelectionTools()
609 {
610   if (myGeomSelectionTools == NULL) {
611     myGeomSelectionTools = new GeomSelectionTools();
612   }
613   return myGeomSelectionTools;
614 }
615
616 QString GMSHPluginGUI_HypothesisCreator::caption() const
617 {
618   return tr( QString( "GMSH_%1_TITLE" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() );
619 }
620
621 QPixmap GMSHPluginGUI_HypothesisCreator::icon() const
622 {
623   QString hypIconName = tr( QString("ICON_DLG_GMSH_PARAMETERS%1").arg(myIs2D?QString("_2D"):QString("")).toLatin1().data() );
624   return SUIT_Session::session()->resourceMgr()->loadPixmap( "GMSHPlugin", hypIconName );
625 }
626
627 QString GMSHPluginGUI_HypothesisCreator::type() const
628 {
629   return tr( QString( "GMSH_%1_HYPOTHESIS" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() );
630 }
631
632 QString GMSHPluginGUI_HypothesisCreator::helpPage() const
633 {
634   return "gmsh_2d_3d_hypo_page.html";
635 }