1 // Copyright (C) 2004-2016 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, or (at your option) any later version.
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 // GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin
21 // File : GHS3DPluginGUI_HypothesisCreator.h
22 // Author : Michael Zorin
23 // Module : GHS3DPlugin
25 #ifndef GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
26 #define GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
29 #if defined GHS3DPluginGUI_EXPORTS
30 #define GHS3DPLUGINGUI_EXPORT __declspec( dllexport )
32 #define GHS3DPLUGINGUI_EXPORT __declspec( dllimport )
35 #define GHS3DPLUGINGUI_EXPORT
38 #include <SMESHGUI_Hypotheses.h>
39 #include <GeomSelectionTools.h>
40 #include <TopAbs_ShapeEnum.hxx>
42 #include <QItemDelegate>
46 #include <GEOM_Client.hxx>
47 #include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
48 #include CORBA_SERVER_HEADER(SMESH_Gen)
49 #include CORBA_SERVER_HEADER(SMESH_Mesh)
57 class QTableWidgetItem;
60 class SMESHGUI_SpinBox;
61 class StdMeshersGUI_ObjectReferenceParamWdg;
62 class LightApp_SelectionMgr;
63 class SUIT_SelectionFilter;
64 class GHS3DPluginGUI_AdvWidget;
70 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
73 bool operator == (const QTEnfVertex* other) const {
75 if (this->coords.size() && other->coords.size())
76 return (this->coords == other->coords);
78 return (this->geomEntry == other->geomEntry);
87 std::vector<double> coords;
90 typedef QList< QTEnfVertex* > QEnfVertexList;
95 std::string geomEntry;
97 std::vector<double> coords;
98 std::string groupName;
102 struct CompareEnfVertices
104 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
106 if (e1->coords.size() && e2->coords.size())
107 return (e1->coords < e2->coords);
109 return (e1->geomEntry < e2->geomEntry);
115 // List of enforced vertices
116 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
123 std::string groupName;
126 struct CompareEnfMeshes
128 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
130 if (e1->entry == e2->entry)
131 return (e1->elementType < e2->elementType);
133 return (e1->entry < e2->entry);
139 // List of enforced meshes
140 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
144 bool myToMeshHoles,myToMakeGroupsOfDomains,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint,
145 myLogInStandardOutput, myRemoveLogOnSuccess;
146 long myMaximumMemory;
147 long myInitialMemory;
148 int myOptimizationLevel;
149 QString myName,myWorkingDir,myTextOption;
151 short myVerboseLevel;
152 TEnfVertexList myEnforcedVertices;
153 TEnfMeshList myEnforcedMeshes;
154 } GHS3DHypothesisData;
157 \brief Class for creation of GHS3D2D and GHS3D3D hypotheses
159 class GHS3DPLUGINGUI_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
164 GHS3DPluginGUI_HypothesisCreator( const QString& );
165 virtual ~GHS3DPluginGUI_HypothesisCreator();
167 virtual bool checkParams(QString& msg) const;
168 virtual QString helpPage() const;
171 virtual QFrame* buildFrame ();
172 virtual void retrieveParams() const;
173 virtual QString storeParams () const;
175 virtual QString caption() const;
176 virtual QPixmap icon() const;
177 virtual QString type() const;
180 void onToMeshHoles(bool);
181 void onDirBtnClicked();
182 void updateWidgets();
184 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
185 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
186 bool isCompound = false);
187 void onAddEnforcedVertex();
188 void onRemoveEnforcedVertex();
189 void synchronizeCoords();
190 void updateEnforcedVertexValues(QTableWidgetItem* );
191 void onSelectEnforcedVertex();
192 void clearEnforcedVertexWidgets();
193 void checkVertexIsDefined();
194 void clearEnfVertexSelection();
196 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
197 void onAddEnforcedMesh();
198 void onRemoveEnforcedMesh();
199 //void synchronizeEnforcedMesh();
200 void checkEnfMeshIsDefined();
203 void vertexDefined(bool);
204 void enfMeshDefined(bool);
207 bool readParamsFromHypo( GHS3DHypothesisData& ) const;
208 bool readParamsFromWidgets( GHS3DHypothesisData& ) const;
209 bool storeParamsToHypo( const GHS3DHypothesisData& ) const;
210 GeomSelectionTools* getGeomSelectionTool();
211 GEOM::GEOM_Gen_var getGeomEngine();
216 QCheckBox* myToMeshHolesCheck;
217 QCheckBox* myToMakeGroupsOfDomains;
218 QComboBox* myOptimizationLevelCombo;
221 GHS3DPluginGUI_AdvWidget* myAdvWidget;
224 QPixmap iconVertex, iconCompound;
225 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
226 GEOM::GEOM_Object_var myEnfVertex;
227 QTableWidget* myEnforcedTableWidget;
228 SMESHGUI_SpinBox* myXCoord;
229 SMESHGUI_SpinBox* myYCoord;
230 SMESHGUI_SpinBox* myZCoord;
231 SMESHGUI_SpinBox* mySizeValue;
232 QLineEdit* myGroupName;
233 // QGroupBox* makeGroupsCheck;
234 // QCheckBox* myGlobalGroupName;
235 QPushButton* addVertexButton;
236 QPushButton* removeVertexButton;
238 QWidget* myEnfMeshGroup;
239 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
240 // SMESH::SMESH_IDSource_var myEnfMesh;
241 QComboBox* myEnfMeshConstraint;
242 QStringList myEnfMeshConstraintLabels;
243 // SMESH::mesh_array_var myEnfMeshArray;
244 QTableWidget* myEnforcedMeshTableWidget;
245 QLineEdit* myMeshGroupName;
246 QPushButton* addEnfMeshButton;
247 QPushButton* removeEnfMeshButton;
249 GeomSelectionTools* GeomToolSelected;
250 // SVTK_Selector* mySelector;
251 // LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
254 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
259 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
261 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
262 const QModelIndex &index) const;
264 void setEditorData(QWidget *editor, const QModelIndex &index) const;
265 void setModelData(QWidget *editor, QAbstractItemModel *model,
266 const QModelIndex &index) const;
268 void updateEditorGeometry(QWidget *editor,
269 const QStyleOptionViewItem &option, const QModelIndex &index) const;
271 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
274 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
279 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
281 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
282 const QModelIndex &index) const;
284 void setEditorData(QWidget *editor, const QModelIndex &index) const;
285 void setModelData(QWidget *editor, QAbstractItemModel *model,
286 const QModelIndex &index) const;
288 void updateEditorGeometry(QWidget *editor,
289 const QStyleOptionViewItem &option, const QModelIndex &index) const;