]> SALOME platform Git repositories - modules/geom.git/blob - src/EntityGUI/EntityGUI_SketcherDlg.h
Salome HOME
Hide GroupBoxName
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.h
1 // GEOM GEOMGUI : GUI for Geometry component
2 //
3 // Copyright (C) 2003  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 // File   : EntityGUI_SketcherDlg.h
23 // Author : Damien COQUERET, Open CASCADE S.A.S.
24 //
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 QDoubleSpinBox;
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 protected:
67   void                               initSpinBox( QDoubleSpinBox*, 
68                                                   double, double, double = 0.1, 
69                                                   int = 3 );
70
71   // redefined from GEOMBase_Helper
72   virtual GEOM::GEOM_IOperations_ptr createOperation();
73   virtual bool                       isValid( QString& );
74   virtual bool                       execute( ObjectList& );
75
76   void                               closeEvent( QCloseEvent* );
77   void                               keyPressEvent( QKeyEvent* );
78
79 private:
80   void                               Init();
81   void                               enterEvent( QEvent* );
82   void                               InitClick();
83   void                               setEnabledUndo( bool );
84   void                               setEnabledRedo( bool );
85     
86   QString                            GetNewCommand();
87
88   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
89                                                      const bool = false,
90                                                      const bool = false,
91                                                      const bool = true,
92                                                      const double  = -1 );
93
94   bool                               createShapes( GEOM::GEOM_Object_ptr,
95                                                    TopoDS_Shape&,
96                                                    TopoDS_Shape& );
97
98 private:
99   int                                myConstructorId;
100   int                                myConstructorDirId;
101   int                                mySketchType;
102   int                                mySketchState;
103
104   bool                               myIsAllAdded;
105
106   QLineEdit*                         myEditCurrentArgument;   /* Current LineEdit */
107
108   QStringList                        myCommand;
109   QStringList                        myUndoCommand;
110
111   Standard_Real                      myX, myY, myDX, myDY;
112   Standard_Real                      myLength, myAngle, myRadius;
113   Standard_Real                      myLastX1, myLastY1;
114   Standard_Real                      myLastX2, myLastY2;
115
116   EntityGUI_Skeleton*                MainWidget;
117
118   EntityGUI_Point*                   GroupPt;
119   EntityGUI_Dir1*                    GroupD1;
120   EntityGUI_Dir2*                    GroupD2;
121
122   EntityGUI_1Sel*                    Group1Sel;
123   EntityGUI_1Spin*                   Group1Spin;
124   EntityGUI_2Spin*                   Group2Spin;
125   EntityGUI_3Spin*                   Group3Spin;
126   EntityGUI_4Spin*                   Group4Spin;
127
128   GeometryGUI*                       myGeometryGUI;
129
130   QString                            myHelpFileName;
131   
132   double                             myLineWidth;
133
134 private:
135   enum SketchState { FIRST_POINT, NEXT_POINT };
136   
137   enum SketchType { PT_ABS, PT_RELATIVE, PT_SEL,
138                     DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
139                     DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
140                     DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
141                     DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y };
142   
143 private slots:
144   void                               ClickOnEnd();
145   void                               ClickOnCancel();
146   bool                               ClickOnApply();
147   void                               ClickOnUndo();
148   void                               ClickOnRedo();
149   void                               ClickOnHelp();
150   void                               LineEditReturnPressed();
151   void                               SelectionIntoArgument();
152   void                               SetEditCurrentArgument();
153   void                               DeactivateActiveDialog();
154   void                               ActivateThisDialog();
155   void                               TypeClicked( int );
156   void                               DestClicked( int );
157   void                               PointClicked( int );
158   void                               Dir1Clicked( int );
159   void                               Dir2Clicked( int );
160   void                               ValueChangedInSpinBox( double );
161   void                               SetDoubleSpinBoxStep( double );
162 };
163
164 #endif // ENTITYGUI_SKETCHERDLG_H