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