Salome HOME
Added a class to display text in the view in the 3D sketcher for display of coordinat...
[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 // For convenience
49 bool isSame (double d1, double d2);
50
51 //=================================================================================
52 // class    : EntityGUI_Dlg
53 // purpose  :
54 //=================================================================================
55 class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
56
57   Q_OBJECT
58
59   struct XYZ
60   {
61     XYZ() { x = y = z = 0.0; command = params = ""; L=A=0; }
62     double  x,  y,  z; // for preview only
63     int L, A;          // for preview only
64     QString command;
65     QString params;
66   };
67   
68   struct prsType
69   {
70     prsType(){L=A=0;}
71     int L;
72     int A;
73   };
74   
75   typedef QList<XYZ> XYZList;
76
77 public:
78   EntityGUI_3DSketcherDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2.);
79   ~EntityGUI_3DSketcherDlg();
80
81 protected:
82  
83   // redefined from GEOMBase_Helper
84   virtual GEOM::GEOM_IOperations_ptr createOperation();
85   virtual bool                       isValid( QString& );
86   virtual bool                       execute( ObjectList& );
87
88 private:
89   void                               Init();
90   void                               enterEvent( QEvent* );
91
92   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
93                                                      const bool = false,
94                                                      const bool = false,
95                                                      const bool = true,
96                                                      const double = -1,
97                                                      const int  = -1,
98                                                      const int  = -1);
99   
100   Handle(AIS_LengthDimension)        createAISLengthDimension(double theLength, 
101                                                               gp_Pnt P1, 
102                                                               gp_Pnt P2,
103                                                               gp_Dir theNormal);  
104   
105   Handle(AIS_AngleDimension)         createAISAngleDimension(double theAngle, 
106                                                              gp_Pnt P0, 
107                                                              gp_Pnt P1,
108                                                              gp_Pnt P2);
109   
110   void                               displayAngle(double theAngle, 
111                                                   gp_Pnt P0, 
112                                                   gp_Pnt P1,
113                                                   gp_Pnt P2, 
114                                                   bool store = false);
115   
116   void                               displayLength(gp_Pnt P1,
117                                                    gp_Pnt P2,
118                                                    gp_Dir theNormal,
119                                                    bool store = false);
120   
121   void                               displayText(std::string theText,
122                                                  gp_Pnt P,
123                                                  bool store = false);
124   
125   void                               displayTrihedron( int );
126   
127   void                               displayDimensions(bool store = false);
128
129   bool                               createShapes( GEOM::GEOM_Object_ptr,
130                                                    TopoDS_Shape&,
131                                                    TopoDS_Shape& );
132
133   XYZ                                getLastPoint() const;
134   XYZ                                getPenultimatePoint() const;
135   XYZ                                getCurrentPoint() const;
136   
137   gp_Dir                             getPresentationPlane() const;
138   
139   std::string                        doubleToString( double );
140   
141   gp_Trsf                            toReferenceSystem(gp_Pnt origin) const;
142   gp_Trsf                            toCurrentSystem(gp_Pnt origin) const;
143   
144   void                               removeLastIOFromPrs();
145   void                               restoreLastIOToPrs();
146   
147   double                             radius(gp_Pnt) const;
148   double                             height(gp_Pnt) const;
149   double                             longitude(gp_Pnt) const;
150   double                             latitude(gp_Pnt) const;
151
152 private:
153   XYZList                            myPointsList;
154   XYZList                            myRedoList;
155   AIS_ListOfInteractive              myLengthIORedoList;
156   AIS_ListOfInteractive              myAngleIORedoList;
157   prsType                            myPrsType;
158
159   EntityGUI_3Spin*                   Group3Spin;
160   EntityGUI_Angles*                  GroupAngles;
161   EntityGUI_Controls*                GroupControls;
162   EntityGUI_Type*                    GroupType;
163   QButtonGroup*                      myTypeGroup1;
164   QButtonGroup*                      myTypeGroup2;
165
166   int                                myMode;
167   int                                myCoordType;
168   int                                myOrientation;
169   bool                               myOK;
170   bool                               isLengthVisible;
171   bool                               isAngleVisible;
172   
173   double                             myLineWidth;
174   GeometryGUI*                       myGeometryGUI;
175   SOCC_Prs*                          myAnglePrs;
176   SOCC_Prs*                          myLengthPrs;
177   SOCC_Prs*                          myTextPrs;
178
179 private slots:
180   void                               ClickOnOk();
181   void                               ClickOnAddPoint();
182   bool                               ClickOnApply();
183   //  bool                               isSameAsPrevious();
184   void                               UpdateButtonsState();
185   void                               UpdatePointCoordinates();
186
187   void                               ClickOnUndo();
188   void                               ClickOnRedo();
189
190   void                               SelectionIntoArgument();
191   void                               DeactivateActiveDialog();
192   void                               ActivateThisDialog();
193   void                               TypeClicked( int );
194   void                               ValueChangedInSpinBox( double );
195   void                               ButtonClicked( bool );
196   void                               BoxChecked ( bool );
197   void                               SetDoubleSpinBoxStep( double );
198 };
199
200 #endif // ENTITYGUI_SKETCHERDLG_H