Salome HOME
c842dbbf31032c18feca7980a57b1a1a1ee6d163
[modules/geom.git] / src / EntityGUI / EntityGUI_3DSketcherDlg.h
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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
20 // GEOM GEOMGUI : GUI for Geometry component
21 // File   : EntityGUI_3DSketcherDlg.h
22 // Author : DMV, OCN
23
24 #ifndef ENTITYGUI_3DSKETCHERDLG_H
25 #define ENTITYGUI_3DSKETCHERDLG_H
26
27 #include <GEOMBase_Skeleton.h>
28
29 class QButtonGroup;
30 class QDoubleSpinBox;
31 class EntityGUI_3Spin;
32 class EntityGUI_Type;
33 class EntityGUI_Angles;
34 class EntityGUI_Controls;
35 class SOCC_Prs;
36 class gp_Dir;
37
38 #include <AIS_ListOfInteractive.hxx>
39 #include <AIS_AngleDimension.hxx>
40 #include <AIS_LengthDimension.hxx>
41
42 #ifndef COORD_MIN
43 #  define COORD_MIN -1e+15
44 #  define COORD_MAX +1e+15
45 #  define MAX_NUMBER 100000
46 #  define DBL_DIGITS_DISPLAY 16
47 #endif // COORD_MIN
48
49 // For convenience
50 bool isSame (double d1, double d2);
51
52 //=================================================================================
53 // class    : EntityGUI_Dlg
54 // purpose  :
55 //=================================================================================
56 class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
57
58   Q_OBJECT
59
60   struct XYZ
61   {
62     XYZ() { x = y = z = 0.0; command = params = ""; L=A=T=0; }
63     double  x,  y,  z; // for preview only
64     int L, A, T;       // for preview only
65     QString command;
66     QString params;
67   };
68   
69   struct prsType
70   {
71     prsType(){L=A=T=0;}
72     int L;
73     int A;
74     int T;
75   };
76   
77   typedef QList<XYZ> XYZList;
78
79 public:
80   EntityGUI_3DSketcherDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2.);
81   ~EntityGUI_3DSketcherDlg();
82
83 protected:
84  
85   // redefined from GEOMBase_Helper
86   virtual GEOM::GEOM_IOperations_ptr createOperation();
87   virtual bool                       isValid( QString& );
88   virtual bool                       execute( ObjectList& );
89
90 private:
91   void                               Init();
92   void                               enterEvent( QEvent* );
93
94   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
95                                                      const bool = false,
96                                                      const bool = false,
97                                                      const bool = true,
98                                                      const double = -1,
99                                                      const int  = -1,
100                                                      const int  = -1);
101   
102   Handle(AIS_LengthDimension)        createAISLengthDimension(double theLength, 
103                                                               gp_Pnt P1, 
104                                                               gp_Pnt P2,
105                                                               gp_Dir theNormal);  
106   
107   Handle(AIS_AngleDimension)         createAISAngleDimension(double theAngle, 
108                                                              gp_Pnt P0, 
109                                                              gp_Pnt P1,
110                                                              gp_Pnt P2);
111   
112   void                               displayAngle(double theAngle, 
113                                                   gp_Pnt P0, 
114                                                   gp_Pnt P1,
115                                                   gp_Pnt P2, 
116                                                   bool store = false);
117   
118   void                               displayLength(gp_Pnt P1,
119                                                    gp_Pnt P2,
120                                                    gp_Dir theNormal,
121                                                    bool store = false);
122   
123   void                               displayText(std::string theText,
124                                                  gp_Pnt P,
125                                                  bool store = false);
126   
127   void                               displayTrihedron( int );
128   
129   void                               displayDimensions(bool store = false);
130
131   bool                               createShapes( GEOM::GEOM_Object_ptr,
132                                                    TopoDS_Shape&,
133                                                    TopoDS_Shape& );
134
135   XYZ                                getLastPoint() const;
136   XYZ                                getPenultimatePoint() const;
137   XYZ                                getCurrentPoint() const;
138   
139   gp_Dir                             getPresentationPlane() const;
140   
141   std::string                        doubleToString( double );
142   
143   gp_Trsf                            toReferenceSystem(gp_Pnt origin) const;
144   gp_Trsf                            toCurrentSystem(gp_Pnt origin) const;
145   
146   void                               removeLastIOFromPrs();
147   void                               restoreLastIOToPrs();
148   
149   double                             radius(gp_Pnt) const;
150   double                             height(gp_Pnt) const;
151   double                             longitude(gp_Pnt) const;
152   double                             latitude(gp_Pnt) const;
153
154 private:
155   XYZList                            myPointsList;
156   XYZList                            myRedoList;
157   AIS_ListOfInteractive              myLengthIORedoList;
158   AIS_ListOfInteractive              myAngleIORedoList;
159   AIS_ListOfInteractive              myTextIORedoList;
160   prsType                            myPrsType;
161
162   EntityGUI_3Spin*                   Group3Spin;
163   EntityGUI_Angles*                  GroupAngles;
164   EntityGUI_Controls*                GroupControls;
165   EntityGUI_Type*                    GroupType;
166   QButtonGroup*                      myTypeGroup1;
167   QButtonGroup*                      myTypeGroup2;
168
169   int                                myMode;
170   int                                myCoordType;
171   int                                myOrientation;
172   bool                               myOK;
173   bool                               isLengthVisible;
174   bool                               isAngleVisible;
175   
176   double                             myLineWidth;
177   GeometryGUI*                       myGeometryGUI;
178   SOCC_Prs*                          myAnglePrs;
179   SOCC_Prs*                          myLengthPrs;
180   SOCC_Prs*                          myTextPrs;
181   bool                               myIsUndoRedo;
182   XYZ                                myWorkPoint;
183
184 private slots:
185   void                               ClickOnOk();
186   void                               ClickOnAddPoint();
187   bool                               ClickOnApply();
188   //  bool                               isSameAsPrevious();
189   void                               UpdateButtonsState();
190   void                               UpdatePointCoordinates();
191
192   void                               ClickOnUndo();
193   void                               ClickOnRedo();
194
195   void                               SelectionIntoArgument();
196   void                               DeactivateActiveDialog();
197   void                               ActivateThisDialog();
198   void                               TypeClicked( int );
199   void                               ValueChangedInSpinBox( double );
200   void                               ButtonClicked( bool );
201   void                               BoxChecked ( bool );
202   void                               SetDoubleSpinBoxStep( double );
203 };
204
205 #endif // ENTITYGUI_SKETCHERDLG_H