Salome HOME
63cf7d5dbbb07fd4d32d3e379c81ada5173179e7
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.h
1 //  Copyright (C) 2007-2010  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 GeometryGUI;
53
54 #ifndef COORD_MIN
55 #  define COORD_MIN -1e+15
56 #  define COORD_MAX +1e+15
57 #  define MAX_NUMBER 100000
58 #  define DBL_DIGITS_DISPLAY 16
59 #endif // COORD_MIN
60
61 //=================================================================================
62 // class    : EntityGUI_Dlg
63 // purpose  :
64 //=================================================================================
65 class EntityGUI_SketcherDlg : public QDialog, GEOMBase_Helper
66
67   Q_OBJECT
68
69 public:
70   EntityGUI_SketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0,
71                          const double = 2. );
72   ~EntityGUI_SketcherDlg();
73
74   bool eventFilter (QObject* object, QEvent* event);
75
76 protected:
77   void                               initSpinBox( SalomeApp_DoubleSpinBox*, 
78                                                   double, double, double = 0.1, 
79                                                   const char* quantity = "length_precision" );
80
81   // redefined from GEOMBase_Helper
82   virtual GEOM::GEOM_IOperations_ptr createOperation();
83   virtual bool                       isValid( QString& );
84   virtual bool                       execute( ObjectList& );
85
86   void                               closeEvent( QCloseEvent* );
87   void                               keyPressEvent( QKeyEvent* );
88
89 private:
90   void                               Init();
91   void                               enterEvent( QEvent* );
92   void                               InitClick();
93   void                               setEnabledUndo( bool );
94   void                               setEnabledRedo( bool );
95     
96   QString                            GetNewCommand( QString& );
97
98   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
99                                                      const bool = false,
100                                                      const bool = false,
101                                                      const bool = true,
102                                                      const double = -1,
103                                                      const int  = -1,
104                                                      const int  = -1);
105
106   bool                               createShapes( GEOM::GEOM_Object_ptr,
107                                                    TopoDS_Shape&,
108                                                    TopoDS_Shape& );
109
110 private:
111   int                                myConstructorId;
112   int                                myConstructorDirId;
113   int                                myConstructorPntId;
114   int                                mySketchType;
115   int                                mySketchState;
116
117   bool                               myIsAllAdded;
118   bool                               myIsApply;
119
120   QLineEdit*                         myEditCurrentArgument;   /* Current LineEdit */
121
122   QStringList                        myCommand;
123   QStringList                        myUndoCommand;
124
125   QStringList                        myParameters;
126   QStringList                        myUndoParameters;
127
128   Standard_Real                      myX, myY, myDX, myDY;
129   Standard_Real                      myXc, myYc, myDXc, myDYc;
130   Standard_Real                      myLength, myAngle, myRadius;
131   Standard_Real                      myLastX1, myLastY1;
132   Standard_Real                      myLastX2, myLastY2;
133
134   QString                            myXStr, myYStr, myDXStr, myDYStr;
135   QString                            myXcStr, myYcStr, myDXcStr, myDYcStr;
136   QString                            myLengthStr, myAngleStr, myRadiusStr;
137   QString                            myLastX1Str, myLastY1Str;
138   QString                            myLastX2Str, myLastY2Str;                            
139
140   EntityGUI_Skeleton*                MainWidget;
141
142   EntityGUI_Point*                   GroupPt;
143   EntityGUI_Point*                   GroupPt2;
144   EntityGUI_Dir1*                    GroupD1;
145   EntityGUI_Dir2*                    GroupD2;
146
147   EntityGUI_1Sel*                    Group1Sel;
148   EntityGUI_2Sel1Check*              Group2Sel;
149   EntityGUI_1Sel1Spin1Check*         Group1Sel1Spin; 
150   EntityGUI_1Spin*                   Group1Spin;
151   EntityGUI_2Spin*                   Group2Spin;
152   EntityGUI_3Spin1Check*             Group3Spin;
153   EntityGUI_4Spin1Check*             Group4Spin;
154
155   QLabel*                            myErrLabel;
156
157   QGroupBox*                         GroupBox1;
158   QComboBox*                         ComboBox1;
159   QPushButton*                       planeButton;
160
161   GeometryGUI*                       myGeometryGUI;
162
163   QString                            myHelpFileName;
164   
165   double                             myLineWidth;
166
167   QList<gp_Ax3>                      myLCSList;
168
169   int                                myCheckFlag;
170
171 private:
172   enum SketchState { FIRST_POINT, NEXT_POINT };
173   
174   enum SketchType { PT_ABS, PT_RELATIVE, PT_SEL,
175                     PT_ABS_RADIUS,PT_REL_RADIUS,PT_SEL_RADIUS,
176                     PT_ABS_CENTER,PT_REL_CENTER,PT_SEL_CENTER,
177                     DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
178                     DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
179                     DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
180                     DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y };
181   
182 private slots:
183   void                               ClickOnEnd();
184   void                               ClickOnCancel();
185   bool                               ClickOnApply();
186   void                               ClickOnUndo();
187   void                               ClickOnRedo();
188   void                               ClickOnHelp();
189   void                               LineEditReturnPressed();
190   void                               SelectionIntoArgument();
191   void                               SetEditCurrentArgument();
192   void                               DeactivateActiveDialog();
193   void                               ActivateThisDialog();
194   void                               TypeClicked( int );
195   void                               DestClicked( int );
196   void                               PointClicked( int );
197   void                               Point2Clicked( int );
198   void                               Dir1Clicked( int );
199   void                               Dir2Clicked( int );
200   void                               CheckBoxClicked( int );
201   void                               ValueChangedInSpinBox( double );
202   void                               SetDoubleSpinBoxStep( double );
203   void                               FindLocalCS();
204   gp_Ax3                             GetActiveLocalCS();
205   void                               ActivateLocalCS();
206 };
207
208 #endif // ENTITYGUI_SKETCHERDLG_H