1 // Copyright (C) 2007-2012 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
21 // File : BLSURFPluginGUI_HypothesisCreator.h
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #ifndef BLSURFPLUGINGUI_HypothesisCreator_H
28 #define BLSURFPLUGINGUI_HypothesisCreator_H
31 #if defined BLSURFPLUGIN_GUI_EXPORTS || defined BLSURFPluginGUI_EXPORTS
32 #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllexport )
34 #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllimport )
37 #define BLSURFPLUGIN_GUI_EXPORT
41 // E.A. : On windows with python 2.6, there is a conflict
42 // E.A. : between pymath.h and Standard_math.h which define
43 // E.A. : some same symbols : acosh, asinh, ...
44 #include <Standard_math.hxx>
50 #include <QItemDelegate>
52 #include <SMESHGUI_Hypotheses.h>
53 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
54 #include <SALOMEconfig.h>
59 #include <TopAbs_ShapeEnum.hxx>
60 #include <GeomSelectionTools.h>
61 #include <GEOM_Client.hxx>
62 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
75 class QTreeWidgetItem;
76 class QTableWidgetItem;
79 class SMESHGUI_SpinBox;
80 class LightApp_SelectionMgr;
81 // class DlgBlSurfHyp_Enforced;
84 typedef std::string TEnfName;
86 typedef std::string TEntry;
88 typedef std::set<TEntry> TEntryList;
89 // Enforced vertex = 3 coordinates
90 typedef std::vector<double> TEnfVertexCoords;
91 // List of enforced vertices
92 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
97 TEnfVertexCoords coords;
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;
118 // Map Face Entry / List of enforced vertices
119 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
121 // Map Face Entry / InternalEnforcedVertices
122 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
126 int myTopology, myVerbosity;
127 int myPhysicalMesh, myGeometricMesh;
128 double myAngleMeshS, myAngleMeshC, myGradation;
129 double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax;
130 bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
131 bool myPreCADMergeEdges, myPreCADRemoveNanoEdges, myPreCADDiscardInput;
132 double myPreCADEpsNano;
133 // bool myGMFFileMode;
134 std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
135 TEnfVertexList enfVertexList;
136 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
138 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
141 } BlsurfHypothesisData;
145 // class BLSURFPluginGUI_ObjectReferenceParamWdg: public StdMeshersGUI_ObjectReferenceParamWdg
149 // BLSURFPluginGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter,
151 // bool multiSelection=false);
152 // BLSURFPluginGUI_ObjectReferenceParamWdg( SMESH::MeshObjectType objType,
154 // bool multiSelection=false);
155 // ~BLSURFPluginGUI_ObjectReferenceParamWdg();
161 // void activateSelectionOnly();
162 // void deactivateSelectionOnly();
163 // void setActivationStatus(bool status);
167 * \brief Class for creation of BLSURF hypotheses
169 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
174 BLSURFPluginGUI_HypothesisCreator( const QString& );
175 virtual ~BLSURFPluginGUI_HypothesisCreator();
177 virtual bool checkParams(QString& msg) const;
178 virtual QString helpPage() const;
181 virtual QFrame* buildFrame ();
182 virtual void retrieveParams() const;
183 virtual QString storeParams () const;
185 virtual QString caption() const;
186 virtual QPixmap icon() const;
187 virtual QString type() const;
190 void onPhysicalMeshChanged();
191 void onGeometricMeshChanged();
193 void onDeleteOption();
194 void onChooseGMFFile();
195 void onOptionChosenInPopup( QAction* );
196 void onTopologyChanged( int );
197 void onMapGeomContentModified();
198 void onSmpItemClicked( QTreeWidgetItem *, int );
199 void onSmpTabChanged(int);
200 void onAttractorClicked(int);
201 void onConstSizeClicked(int);
205 void onSetSizeMap(QTreeWidgetItem *, int);
207 QTreeWidgetItem* addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
209 void addEnforcedVertex(QTreeWidgetItem * theFaceItem, double x=0, double y=0, double z=0,
210 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
212 void onAddEnforcedVertices();
213 void onRemoveEnforcedVertex();
214 void synchronizeCoords();
215 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
216 void onSelectEnforcedVertex();
217 // void deactivateSelection(QWidget*, QWidget*);
218 void clearEnforcedVertexWidgets();
219 void onInternalVerticesClicked(int);
222 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
223 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
224 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
225 bool sizeMapsValidation();
226 bool sizeMapValidationFromRow(int,bool displayError = true);
227 bool sizeMapValidationFromEntry(QString,bool displayError = true);
228 GeomSelectionTools* getGeomSelectionTool();
229 GEOM::GEOM_Gen_var getGeomEngine();
230 //void insertElementType( TopAbs_ShapeEnum );
231 void insertElement( GEOM::GEOM_Object_var, bool modify = false );
232 void insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
233 int findRowFromEntry(QString entry);
234 CORBA::Object_var entryToObject(QString entry);
235 static LightApp_SelectionMgr* selectionMgr();
240 QComboBox* myPhysicalMesh;
241 SMESHGUI_SpinBox* myPhySize;
242 SMESHGUI_SpinBox* myPhyMin;
243 SMESHGUI_SpinBox* myPhyMax;
244 QComboBox* myGeometricMesh;
245 SMESHGUI_SpinBox* myAngleMeshS;
246 SMESHGUI_SpinBox* myAngleMeshC;
247 SMESHGUI_SpinBox* myGeoMin;
248 SMESHGUI_SpinBox* myGeoMax;
249 SMESHGUI_SpinBox* myGradation;
250 QCheckBox* myAllowQuadrangles;
251 QCheckBox* myDecimesh;
254 QComboBox* myTopology;
255 QGroupBox* myPreCADGroupBox;
256 QCheckBox* myPreCADMergeEdges;
257 QCheckBox* myPreCADRemoveNanoEdges;
258 QCheckBox* myPreCADDiscardInput;
259 SMESHGUI_SpinBox* myPreCADEpsNano;
260 QSpinBox* myVerbosity;
261 QTableWidget* myOptionTable;
262 QLineEdit* myGMFFileName;
263 // QCheckBox* myGMFFileMode;
267 QTreeWidget *mySizeMapTable;
268 QPushButton *addMapButton;
269 QPushButton *removeMapButton;
270 QPushButton *modifyMapButton;
272 QWidget *myAttractorGroup;
273 QWidget *mySmpStdGroup;
274 QCheckBox *myAttractorCheck;
275 QCheckBox *myConstSizeCheck;
276 QGroupBox *myDistanceGroup;
277 // QGroupBox *myParamsGroup;
278 // QWidget *myParamsGroup;
279 SMESHGUI_SpinBox *myAttSizeSpin;
280 SMESHGUI_SpinBox *myAttDistSpin;
281 SMESHGUI_SpinBox *myAttDistSpin2;
282 SMESHGUI_SpinBox *mySmpSizeSpin;
283 QLabel *myAttDistLabel;
284 QLabel *myAttDistLabel2;
285 QLabel *myAttSizeLabel;
286 // Selection widgets for size maps
287 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
288 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
289 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
290 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
291 GEOM::GEOM_Object_var mySMapObject;
292 GEOM::GEOM_Object_var myAttObject;
293 GEOM::GEOM_Object_var myDistObject;
299 // TODO FACE AND VERTEX SELECTION
300 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
301 GEOM::GEOM_Object_var myEnfFace;
302 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
303 GEOM::GEOM_Object_var myEnfVertex;
305 // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget;
306 QTreeWidget* myEnforcedTreeWidget;
307 SMESHGUI_SpinBox* myXCoord;
308 SMESHGUI_SpinBox* myYCoord;
309 SMESHGUI_SpinBox* myZCoord;
311 QLineEdit* myGroupName;
312 // QGroupBox* makeGroupsCheck;
313 // QCheckBox* myGlobalGroupName;
315 QPushButton* addVertexButton;
316 QPushButton* removeVertexButton;
318 QCheckBox *myInternalEnforcedVerticesAllFaces;
319 QLineEdit *myInternalEnforcedVerticesAllFacesGroup;
321 // map = entry , size map
322 QMap<QString, QString> mySMPMap; // Map <face entry, size>
323 QMap<QString, QString> myATTMap; // Map <face entry, att. entry>
324 QMap<QString, double> myDistMap; // Map <entry,distance with constant size>
325 QMap<QString, double> myAttDistMap; // Map <entry, influence distance>
326 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
327 GeomSelectionTools* GeomToolSelected;
328 LightApp_SelectionMgr* aSel;
330 BLSURFPlugin::string_array_var myOptions, myPreCADOptions;
333 PyObject * main_dict;
337 class EnforcedTreeWidgetDelegate : public QItemDelegate
342 EnforcedTreeWidgetDelegate(QObject *parent = 0);
344 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
345 const QModelIndex &index) const;
347 void setEditorData(QWidget *editor, const QModelIndex &index) const;
348 void setModelData(QWidget *editor, QAbstractItemModel *model,
349 const QModelIndex &index) const;
351 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
352 const QModelIndex &index) const;
354 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
357 #endif // BLSURFPLUGINGUI_HypothesisCreator_H