Salome HOME
Issue 0020580: improved validation in integer and double spin boxes, possibility...
[modules/geom.git] / src / EntityGUI / EntityGUI_3DSketcherDlg.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_3DSketcherDlg.h
23 // Author : DMV, OCN
24 //
25
26 #ifndef ENTITYGUI_3DSKETCHERDLG_H
27 #define ENTITYGUI_3DSKETCHERDLG_H
28
29 #include <GEOMBase_Skeleton.h>
30
31 class QButtonGroup;
32 class QDoubleSpinBox;
33 class EntityGUI_3Spin;
34 class DlgRef_3Radio;
35
36 #ifndef COORD_MIN
37 #  define COORD_MIN -1e+15
38 #  define COORD_MAX +1e+15
39 #  define MAX_NUMBER 100000
40 #  define DBL_DIGITS_DISPLAY 16
41 #endif // COORD_MIN
42
43 //=================================================================================
44 // class    : EntityGUI_Dlg
45 // purpose  :
46 //=================================================================================
47 class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
48
49   Q_OBJECT
50
51   struct XYZ
52   {
53     XYZ() { x = y = z = 0.0; xt = yt = zt = "0.0"; }
54     double  x,  y,  z;
55     QString xt, yt, zt;
56   };
57   typedef QList<XYZ> XYZList;
58
59 public:
60   EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. );
61   ~EntityGUI_3DSketcherDlg();
62
63 protected:
64  
65   // redefined from GEOMBase_Helper
66   virtual GEOM::GEOM_IOperations_ptr createOperation();
67   virtual bool                       isValid( QString& );
68   virtual bool                       execute( ObjectList& );
69
70 private:
71   void                               Init();
72   void                               enterEvent( QEvent* );
73
74   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
75                                                      const bool = false,
76                                                      const bool = false,
77                                                      const bool = true,
78                                                      const double = -1,
79                                                      const int  = -1,
80                                                      const int  = -1);
81
82   bool                               createShapes( GEOM::GEOM_Object_ptr,
83                                                    TopoDS_Shape&,
84                                                    TopoDS_Shape& );
85
86   XYZ                                getLastPoint() const;
87   XYZ                                getCurrentPoint() const;
88
89 private:
90   XYZList                            myPointsList;
91   XYZList                            myRedoList;
92
93   EntityGUI_3Spin*                   Group3Spin;
94   DlgRef_3Radio*                     GroupType;
95   QButtonGroup*                      myTypeGroup;
96
97   int                                myMode;
98   bool                               myOK;
99   double                             myLineWidth;
100   GeometryGUI*                       myGeometryGUI;
101
102 private slots:
103   void                               ClickOnOk();
104   void                               ClickOnAddPoint();
105   bool                               ClickOnApply();
106   //  bool                               isSameAsPrevious();
107   void                               UpdateButtonsState();
108
109   void                               ClickOnUndo();
110   void                               ClickOnRedo();
111
112   void                               SelectionIntoArgument();
113   void                               DeactivateActiveDialog();
114   void                               ActivateThisDialog();
115   void                               TypeClicked( int );
116   void                               ValueChangedInSpinBox( double );
117   void                               SetDoubleSpinBoxStep( double );
118 };
119
120 #endif // ENTITYGUI_SKETCHERDLG_H