Salome HOME
EDF 1337 : Sketch 3D, allow definition of a point by angle
[modules/geom.git] / src / EntityGUI / EntityGUI_3DSketcherDlg.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
19 // GEOM GEOMGUI : GUI for Geometry component
20 // File   : EntityGUI_3DSketcherDlg.h
21 // Author : DMV, OCN
22
23 #ifndef ENTITYGUI_3DSKETCHERDLG_H
24 #define ENTITYGUI_3DSKETCHERDLG_H
25
26 #include <GEOMBase_Skeleton.h>
27
28 class QButtonGroup;
29 class QDoubleSpinBox;
30 class EntityGUI_3Spin;
31 class EntityGUI_Type;
32 class EntityGUI_Angles;
33 class EntityGUI_Controls;
34 class SOCC_Prs;
35 class gp_Dir;
36
37 #include <AIS_ListOfInteractive.hxx>
38 #include <AIS_AngleDimension.hxx>
39 #include <AIS_LengthDimension.hxx>
40
41 #ifndef COORD_MIN
42 #  define COORD_MIN -1e+15
43 #  define COORD_MAX +1e+15
44 #  define MAX_NUMBER 100000
45 #  define DBL_DIGITS_DISPLAY 16
46 #endif // COORD_MIN
47
48 //=================================================================================
49 // class    : EntityGUI_Dlg
50 // purpose  :
51 //=================================================================================
52 class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
53
54   Q_OBJECT
55
56   struct XYZ
57   {
58     XYZ() { x = y = z = 0.0; command = params = ""; L=A=0; }
59     double  x,  y,  z; // for preview only
60     int L, A;          // for preview only
61     QString command;
62     QString params;
63   };
64   
65   struct prsType
66   {
67     prsType(){L=A=0;}
68     int L;
69     int A;
70   };
71   
72   typedef QList<XYZ> XYZList;
73
74 public:
75   EntityGUI_3DSketcherDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2.);
76   ~EntityGUI_3DSketcherDlg();
77
78 protected:
79  
80   // redefined from GEOMBase_Helper
81   virtual GEOM::GEOM_IOperations_ptr createOperation();
82   virtual bool                       isValid( QString& );
83   virtual bool                       execute( ObjectList& );
84
85 private:
86   void                               Init();
87   void                               enterEvent( QEvent* );
88
89   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
90                                                      const bool = false,
91                                                      const bool = false,
92                                                      const bool = true,
93                                                      const double = -1,
94                                                      const int  = -1,
95                                                      const int  = -1);
96   
97   Handle(AIS_LengthDimension)        createAISLengthDimension(double theLength, 
98                                                               gp_Pnt P1, 
99                                                               gp_Pnt P2,
100                                                               gp_Dir theNormal);  
101   
102   Handle(AIS_AngleDimension)         createAISAngleDimension(double theAngle, 
103                                                              gp_Pnt P0, 
104                                                              gp_Pnt P1,
105                                                              gp_Pnt P2);
106   
107   void                               displayAngle(double theAngle, 
108                                                   gp_Pnt P0, 
109                                                   gp_Pnt P1,
110                                                   gp_Pnt P2, 
111                                                   bool store = false);
112   
113   void                               displayLength(gp_Pnt P1,
114                                                    gp_Pnt P2,
115                                                    gp_Dir theNormal,
116                                                    bool store = false);
117   
118   void                               displayTrihedron( int );
119   
120   void                               displayDimensions(bool store = false);
121
122   bool                               createShapes( GEOM::GEOM_Object_ptr,
123                                                    TopoDS_Shape&,
124                                                    TopoDS_Shape& );
125
126   XYZ                                getLastPoint() const;
127   XYZ                                getPenultimatePoint() const;
128   XYZ                                getCurrentPoint() const;
129   
130   gp_Dir                             getPresentationPlane() const;
131   
132   std::string                        doubleToString( double );
133   
134   void                               removeLastIOFromPrs();
135   void                               restoreLastIOToPrs();
136
137 private:
138   XYZList                            myPointsList;
139   XYZList                            myRedoList;
140   AIS_ListOfInteractive              myLengthIORedoList;
141   AIS_ListOfInteractive              myAngleIORedoList;
142   prsType                            myPrsType;
143
144   EntityGUI_3Spin*                   Group3Spin;
145   EntityGUI_Angles*                  GroupAngles;
146   EntityGUI_Controls*                GroupControls;
147   EntityGUI_Type*                    GroupType;
148   QButtonGroup*                      myTypeGroup1;
149   QButtonGroup*                      myTypeGroup2;
150
151   int                                myMode;
152   int                                myCoordType;
153   int                                myOrientation;
154   bool                               myOK;
155   bool                               isLengthVisible;
156   bool                               isAngleVisible;
157   
158   double                             myLineWidth;
159   GeometryGUI*                       myGeometryGUI;
160   SOCC_Prs*                          myAnglePrs;
161   SOCC_Prs*                          myLengthPrs;
162
163 private slots:
164   void                               ClickOnOk();
165   void                               ClickOnAddPoint();
166   bool                               ClickOnApply();
167   //  bool                               isSameAsPrevious();
168   void                               UpdateButtonsState();
169   void                               UpdatePointCoordinates();
170
171   void                               ClickOnUndo();
172   void                               ClickOnRedo();
173
174   void                               SelectionIntoArgument();
175   void                               DeactivateActiveDialog();
176   void                               ActivateThisDialog();
177   void                               TypeClicked( int );
178   void                               ValueChangedInSpinBox( double );
179   void                               ButtonClicked( bool );
180   void                               BoxChecked ( bool );
181   void                               SetDoubleSpinBoxStep( double );
182 };
183
184 #endif // ENTITYGUI_SKETCHERDLG_H