1 // Copyright (C) 2007-2011 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;
123 int myTopology, myVerbosity;
124 int myPhysicalMesh, myGeometricMesh;
125 double myAngleMeshS, myAngleMeshC, myGradation;
126 double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax;
127 bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex;
128 TEnfVertexList enfVertexList;
129 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
131 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
134 } BlsurfHypothesisData;
138 // class BLSURFPluginGUI_ObjectReferenceParamWdg: public StdMeshersGUI_ObjectReferenceParamWdg
142 // BLSURFPluginGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter,
144 // bool multiSelection=false);
145 // BLSURFPluginGUI_ObjectReferenceParamWdg( MeshObjectType objType,
147 // bool multiSelection=false);
148 // ~BLSURFPluginGUI_ObjectReferenceParamWdg();
154 // void activateSelectionOnly();
155 // void deactivateSelectionOnly();
156 // void setActivationStatus(bool status);
160 * \brief Class for creation of BLSURF hypotheses
162 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
167 BLSURFPluginGUI_HypothesisCreator( const QString& );
168 virtual ~BLSURFPluginGUI_HypothesisCreator();
170 virtual bool checkParams() const;
171 virtual QString helpPage() const;
172 //void insertElementType( TopAbs_ShapeEnum );
173 void insertElement( GEOM::GEOM_Object_var, bool modify = false );
174 void insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
175 int findRowFromEntry(QString entry);
176 CORBA::Object_var entryToObject(QString entry);
177 static LightApp_SelectionMgr* selectionMgr();
180 virtual QFrame* buildFrame ();
181 virtual void retrieveParams() const;
182 virtual QString storeParams () const;
184 virtual QString caption() const;
185 virtual QPixmap icon() const;
186 virtual QString type() const;
189 void onPhysicalMeshChanged();
190 void onGeometricMeshChanged();
192 void onDeleteOption();
193 void onOptionChosenInPopup( QAction* );
194 void onMapGeomContentModified();
195 void onSmpItemClicked( QTreeWidgetItem *, int );
196 void onSmpTabChanged(int);
197 void onAttractorClicked(int);
198 void onConstSizeClicked(int);
202 void onSetSizeMap(QTreeWidgetItem *, int);
204 void addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x=0, double y=0, double z=0,
205 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
206 void onAddEnforcedVertices();
207 void onRemoveEnforcedVertex();
208 void synchronizeCoords();
209 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
210 void onSelectEnforcedVertex();
211 void deactivateSelection(QWidget*, QWidget*);
212 void clearEnforcedVertexWidgets();
215 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
216 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
217 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
218 bool sizeMapsValidation();
219 bool sizeMapValidationFromRow(int,bool displayError = true);
220 bool sizeMapValidationFromEntry(QString,bool displayError = true);
221 GeomSelectionTools* getGeomSelectionTool();
222 GEOM::GEOM_Gen_var getGeomEngine();
227 QComboBox* myPhysicalMesh;
228 SMESHGUI_SpinBox* myPhySize;
229 SMESHGUI_SpinBox* myPhyMin;
230 SMESHGUI_SpinBox* myPhyMax;
231 QComboBox* myGeometricMesh;
232 SMESHGUI_SpinBox* myAngleMeshS;
233 SMESHGUI_SpinBox* myAngleMeshC;
234 SMESHGUI_SpinBox* myGeoMin;
235 SMESHGUI_SpinBox* myGeoMax;
236 SMESHGUI_SpinBox* myGradation;
237 QCheckBox* myAllowQuadrangles;
238 QCheckBox* myDecimesh;
241 QComboBox* myTopology;
242 QSpinBox* myVerbosity;
243 QTableWidget* myOptionTable;
247 QTreeWidget *mySizeMapTable;
248 QPushButton *addMapButton;
249 QPushButton *removeMapButton;
250 QPushButton *modifyMapButton;
252 QWidget *myAttractorGroup;
253 QWidget *mySmpStdGroup;
254 QCheckBox *myAttractorCheck;
255 QCheckBox *myConstSizeCheck;
256 QGroupBox *myDistanceGroup;
257 // QGroupBox *myParamsGroup;
258 // QWidget *myParamsGroup;
259 SMESHGUI_SpinBox *myAttSizeSpin;
260 SMESHGUI_SpinBox *myAttDistSpin;
261 SMESHGUI_SpinBox *myAttDistSpin2;
262 SMESHGUI_SpinBox *mySmpSizeSpin;
263 QLabel *myAttDistLabel;
264 QLabel *myAttDistLabel2;
265 QLabel *myAttSizeLabel;
266 // Selection widgets for size maps
267 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
268 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
269 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
270 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
271 GEOM::GEOM_Object_var mySMapObject;
272 GEOM::GEOM_Object_var myAttObject;
273 GEOM::GEOM_Object_var myDistObject;
279 // TODO FACE AND VERTEX SELECTION
280 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
281 GEOM::GEOM_Object_var myEnfFace;
282 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
283 GEOM::GEOM_Object_var myEnfVertex;
285 // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget;
286 QTreeWidget* myEnforcedTreeWidget;
287 SMESHGUI_SpinBox* myXCoord;
288 SMESHGUI_SpinBox* myYCoord;
289 SMESHGUI_SpinBox* myZCoord;
291 QLineEdit* myGroupName;
292 QGroupBox* makeGroupsCheck;
293 QLineEdit* myGlobalGroupName;
295 QPushButton* addVertexButton;
296 QPushButton* removeVertexButton;
298 // map = entry , size map
299 QMap<QString, QString> mySMPMap; // Map <face entry, size>
300 QMap<QString, QString> myATTMap; // Map <face entry, att. entry>
301 QMap<QString, double> myDistMap; // Map <entry,distance with constant size>
302 QMap<QString, double> myAttDistMap; // Map <entry, influence distance>
303 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
304 GeomSelectionTools* GeomToolSelected;
305 LightApp_SelectionMgr* aSel;
307 BLSURFPlugin::string_array_var myOptions;
310 PyObject * main_dict;
314 class EnforcedTreeWidgetDelegate : public QItemDelegate
319 EnforcedTreeWidgetDelegate(QObject *parent = 0);
321 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
322 const QModelIndex &index) const;
324 void setEditorData(QWidget *editor, const QModelIndex &index) const;
325 void setModelData(QWidget *editor, QAbstractItemModel *model,
326 const QModelIndex &index) const;
328 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
329 const QModelIndex &index) const;
331 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
334 #endif // BLSURFPLUGINGUI_HypothesisCreator_H