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