Salome HOME
untabify
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.h
1 //  Copyright (C) 2007-2008  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 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : EntityGUI_SketcherDlg.h
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
25 //
26 #ifndef ENTITYGUI_SKETCHERDLG_H
27 #define ENTITYGUI_SKETCHERDLG_H
28
29 #include <GEOMBase_Helper.h>
30
31 #include <QGroupBox>
32 #include <QComboBox>
33 #include <QDialog>
34
35 #include <gp_Ax3.hxx>
36
37 class QLineEdit;
38 class SalomeApp_DoubleSpinBox;
39 class EntityGUI_1Sel;
40 class EntityGUI_1Spin;
41 class EntityGUI_2Spin;
42 class EntityGUI_3Spin;
43 class EntityGUI_4Spin;
44 class EntityGUI_Point;
45 class EntityGUI_Dir1;
46 class EntityGUI_Dir2;
47 class EntityGUI_Skeleton;
48 class GeometryGUI;
49
50 #ifndef COORD_MIN
51 #  define COORD_MIN -1e+15
52 #  define COORD_MAX +1e+15
53 #  define MAX_NUMBER 100000
54 #  define DBL_DIGITS_DISPLAY 16
55 #endif // COORD_MIN
56
57 //=================================================================================
58 // class    : EntityGUI_Dlg
59 // purpose  :
60 //=================================================================================
61 class EntityGUI_SketcherDlg : public QDialog, GEOMBase_Helper
62
63   Q_OBJECT
64
65 public:
66   EntityGUI_SketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0,
67                          const double = 2. );
68   ~EntityGUI_SketcherDlg();
69
70   bool eventFilter (QObject* object, QEvent* event);
71
72 protected:
73   void                               initSpinBox( SalomeApp_DoubleSpinBox*, 
74                                                   double, double, double = 0.1, 
75                                                   int = 3 );
76
77   // redefined from GEOMBase_Helper
78   virtual GEOM::GEOM_IOperations_ptr createOperation();
79   virtual bool                       isValid( QString& );
80   virtual bool                       execute( ObjectList& );
81
82   void                               closeEvent( QCloseEvent* );
83   void                               keyPressEvent( QKeyEvent* );
84
85 private:
86   void                               Init();
87   void                               enterEvent( QEvent* );
88   void                               InitClick();
89   void                               setEnabledUndo( bool );
90   void                               setEnabledRedo( bool );
91     
92   QString                            GetNewCommand( QString& );
93
94   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
95                                                      const bool = false,
96                                                      const bool = false,
97                                                      const bool = true,
98                                                      const double = -1,
99                                                      const int  = -1,
100                                                      const int  = -1);
101
102   bool                               createShapes( GEOM::GEOM_Object_ptr,
103                                                    TopoDS_Shape&,
104                                                    TopoDS_Shape& );
105
106 private:
107   int                                myConstructorId;
108   int                                myConstructorDirId;
109   int                                mySketchType;
110   int                                mySketchState;
111
112   bool                               myIsAllAdded;
113   bool                               myIsApply;
114
115   QLineEdit*                         myEditCurrentArgument;   /* Current LineEdit */
116
117   QStringList                        myCommand;
118   QStringList                        myUndoCommand;
119
120   QStringList                        myParameters;
121   QStringList                        myUndoParameters;
122
123   Standard_Real                      myX, myY, myDX, myDY;
124   Standard_Real                      myLength, myAngle, myRadius;
125   Standard_Real                      myLastX1, myLastY1;
126   Standard_Real                      myLastX2, myLastY2;
127
128   QString                            myXStr, myYStr, myDXStr, myDYStr;
129   QString                            myLengthStr, myAngleStr, myRadiusStr;
130   QString                            myLastX1Str, myLastY1Str;
131   QString                            myLastX2Str, myLastY2Str;                            
132
133   EntityGUI_Skeleton*                MainWidget;
134
135   EntityGUI_Point*                   GroupPt;
136   EntityGUI_Dir1*                    GroupD1;
137   EntityGUI_Dir2*                    GroupD2;
138
139   EntityGUI_1Sel*                    Group1Sel;
140   EntityGUI_1Spin*                   Group1Spin;
141   EntityGUI_2Spin*                   Group2Spin;
142   EntityGUI_3Spin*                   Group3Spin;
143   EntityGUI_4Spin*                   Group4Spin;
144
145   QGroupBox*                         GroupBox1;
146   QComboBox*                         ComboBox1;
147
148   GeometryGUI*                       myGeometryGUI;
149
150   QString                            myHelpFileName;
151   
152   double                             myLineWidth;
153
154   QList<gp_Ax3>                      myLCSList;
155
156 private:
157   enum SketchState { FIRST_POINT, NEXT_POINT };
158   
159   enum SketchType { PT_ABS, PT_RELATIVE, PT_SEL,
160                     DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
161                     DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
162                     DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
163                     DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y };
164   
165 private slots:
166   void                               ClickOnEnd();
167   void                               ClickOnCancel();
168   bool                               ClickOnApply();
169   void                               ClickOnUndo();
170   void                               ClickOnRedo();
171   void                               ClickOnHelp();
172   void                               LineEditReturnPressed();
173   void                               SelectionIntoArgument();
174   void                               SetEditCurrentArgument();
175   void                               DeactivateActiveDialog();
176   void                               ActivateThisDialog();
177   void                               TypeClicked( int );
178   void                               DestClicked( int );
179   void                               PointClicked( int );
180   void                               Dir1Clicked( int );
181   void                               Dir2Clicked( int );
182   void                               ValueChangedInSpinBox( double );
183   void                               SetDoubleSpinBoxStep( double );
184   void                               FindLocalCS();
185   gp_Ax3                             GetActiveLocalCS();
186 };
187
188 #endif // ENTITYGUI_SKETCHERDLG_H