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