]> SALOME platform Git repositories - modules/geom.git/blob - src/EntityGUI/EntityGUI_SketcherDlg.h
Salome HOME
Merge from BR_new_bop4 (porting to new OCCT BOP) 13/09/2013
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : EntityGUI_SketcherDlg.h
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 //
27 #ifndef ENTITYGUI_SKETCHERDLG_H
28 #define ENTITYGUI_SKETCHERDLG_H
29
30 #include <GEOMBase_Helper.h>
31
32 #include <QGroupBox>
33 #include <QComboBox>
34 #include <QDialog>
35 #include <QLabel>
36
37 #include <gp_Ax3.hxx>
38
39 class QLineEdit;
40 class SalomeApp_DoubleSpinBox;
41 class EntityGUI_1Sel;
42 class EntityGUI_2Sel1Check;
43 class EntityGUI_1Sel1Spin1Check;
44 class EntityGUI_1Spin;
45 class EntityGUI_2Spin;
46 class EntityGUI_3Spin1Check;
47 class EntityGUI_4Spin1Check;
48 class EntityGUI_Point;
49 class EntityGUI_Dir1;
50 class EntityGUI_Dir2;
51 class EntityGUI_Skeleton;
52 class DlgRef_4Spin;
53 class GeometryGUI;
54
55 #ifndef COORD_MIN
56 #  define COORD_MIN -1e+15
57 #  define COORD_MAX +1e+15
58 #  define MAX_NUMBER 100000
59 #  define DBL_DIGITS_DISPLAY 16
60 #endif // COORD_MIN
61
62 //=================================================================================
63 // class    : EntityGUI_Dlg
64 // purpose  :
65 //=================================================================================
66 class EntityGUI_SketcherDlg : public QDialog, GEOMBase_Helper
67
68   Q_OBJECT
69
70 public:
71   EntityGUI_SketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0,
72                          const double = -1 );
73   ~EntityGUI_SketcherDlg();
74
75   bool eventFilter (QObject* object, QEvent* event);
76   
77   bool                               acceptMouseEvent() const;  // called by EntityGUI::OnMousePress()
78   void                               OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt&, bool isStart = true );             
79
80 protected:
81   void                               initSpinBox( SalomeApp_DoubleSpinBox*, 
82                                                   double, double, double = 0.1, 
83                                                   const char* quantity = "length_precision" );
84
85   // redefined from GEOMBase_Helper
86   virtual GEOM::GEOM_IOperations_ptr createOperation();
87   virtual bool                       isValid( QString& );
88   virtual bool                       execute( ObjectList& );
89   virtual void                       addSubshapesToStudy();
90   
91   void                               closeEvent( QCloseEvent* );
92   void                               keyPressEvent( QKeyEvent* );
93
94 private:
95   void                               Init();
96   void                               enterEvent( QEvent* );
97   void                               InitClick();
98   void                               setEnabledUndo( bool );
99   void                               setEnabledRedo( bool );
100     
101   QString                            GetNewCommand( QString& );
102
103   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
104                                                      const bool = false,
105                                                      const bool = false,
106                                                      const bool = true,
107                                                      const double = -1,
108                                                      const int  = -1,
109                                                      const int  = -1);
110   
111   void                               displayPntPreview( const double = 0.0,
112                                                         const double = 0.0,
113                                                         bool /*append*/ = true,
114                                                         bool /*update*/ = true
115                                                       );
116
117   bool                               createShapes( GEOM::GEOM_Object_ptr,
118                                                    TopoDS_Shape&,
119                                                    TopoDS_Shape& );
120   int                                getPnt1ConstructorId() const;
121   int                                getPnt2ConstructorId() const;
122   void                               OnFirstPoint();
123   void                               OnNextPoint(); 
124
125
126 private:
127   int                                myConstructorId;
128   int                                myConstructorDirId;
129   int                                myConstructorPntId;
130   int                                mySketchType;
131   int                                mySketchState;
132
133   bool                               myIsAllAdded;
134   bool                               myIsApply;
135   bool                               autoApply;
136
137   QLineEdit*                         myEditCurrentArgument;   /* Current LineEdit */
138
139   QStringList                        myCommand;
140   QStringList                        myUndoCommand;
141
142   QStringList                        myParameters;
143   QStringList                        myUndoParameters;
144
145   Standard_Real                      myX, myY, myDX, myDY;
146   Standard_Real                      myX1, myY1, myX2, myY2;
147   Standard_Real                      myXc, myYc, myDXc, myDYc;
148   Standard_Real                      myLength, myAngle, myRadius;
149   Standard_Real                      myLastX1, myLastY1;
150   Standard_Real                      myLastX2, myLastY2;
151
152   QString                            myXStr, myYStr, myDXStr, myDYStr;
153   QString                            myX1Str, myY1Str, myX2Str, myY2Str;
154   QString                            myXcStr, myYcStr, myDXcStr, myDYcStr;
155   QString                            myLengthStr, myAngleStr, myRadiusStr;
156   QString                            myLastX1Str, myLastY1Str;
157   QString                            myLastX2Str, myLastY2Str;                            
158
159   EntityGUI_Skeleton*                MainWidget;
160
161   EntityGUI_Point*                   GroupPt;
162   EntityGUI_Point*                   GroupPt2;
163   EntityGUI_Dir1*                    GroupD1;
164   EntityGUI_Dir2*                    GroupD2;
165
166   EntityGUI_1Sel*                    Group1Sel;
167   EntityGUI_2Sel1Check*              Group2Sel;
168   EntityGUI_1Sel1Spin1Check*         Group1Sel1Spin; 
169   EntityGUI_1Spin*                   Group1Spin;
170   EntityGUI_2Spin*                   Group2Spin;
171   EntityGUI_3Spin1Check*             Group3Spin;
172   EntityGUI_4Spin1Check*             Group4Spin;
173   DlgRef_4Spin*                      GroupRect;
174
175   QLabel*                            myErrLabel;
176
177   QGroupBox*                         GroupBox1;
178   QComboBox*                         ComboBox1;
179   QPushButton*                       planeButton;
180   QPushButton*                       selButton;
181   
182   QLineEdit*                         WPlaneLineEdit;
183
184   GeometryGUI*                       myGeometryGUI;
185
186   QString                            myHelpFileName;
187   
188   double                             myLineWidth;
189
190   QList<gp_Ax3>                      myLCSList;
191   GEOM::GEOM_Object_var              myGlobalCS;
192   GEOM::GEOM_Object_var              myWPlane;
193   QList< GEOM::GEOM_Object_var >     myWPlaneList;
194
195   int                                myCheckFlag;
196   
197   TopAbs_ShapeEnum                   myNeedType;
198
199 private:
200   enum SketchState { FIRST_POINT, NEXT_POINT };
201   
202   enum SketchType { PT_ABS, PT_RELATIVE, PT_SEL,
203                     PT_ABS_RADIUS,PT_REL_RADIUS,PT_SEL_RADIUS,
204                     PT_ABS_CENTER,PT_REL_CENTER,PT_SEL_CENTER,
205                     DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
206                     DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
207                     DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
208                     DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y };
209   
210 private slots:
211   void                               ClickOnEnd();
212   void                               ClickOnCancel();
213   bool                               ClickOnApply();
214   void                               ClickOnUndo();
215   void                               ClickOnRedo();
216   void                               ClickOnHelp();
217   void                               LineEditReturnPressed();
218   void                               SelectionIntoArgument();
219   void                               SetEditCurrentArgument();
220   void                               DeactivateActiveDialog();
221   void                               ActivateThisDialog();
222   void                               TypeClicked( int );
223   void                               RectClicked();
224   void                               DestClicked( int );
225   void                               PointClicked( int );
226   void                               Point2Clicked( int );
227   void                               Dir1Clicked( int );
228   void                               Dir2Clicked( int );
229   void                               CheckBoxClicked( int );
230   void                               ValueChangedInSpinBox( double );
231   void                               SetDoubleSpinBoxStep( double );
232   void                               AddLocalCS( GEOM::GEOM_Object_var );
233   void                               FindLocalCS();
234   gp_Ax3                             GetActiveLocalCS();
235   gp_Ax3                             WPlaneToLCS( GEOM::GEOM_Object_var );
236   void                               ActivateLocalCS();
237 };
238
239 #endif // ENTITYGUI_SKETCHERDLG_H