Salome HOME
3c23a480aa7cad5e499b39cf7f15265371f53ace
[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
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_Angles;
33 class EntityGUI_Controls;
34 class DlgRef_3Radio;
35 class SOCC_Prs;
36
37 #include <AIS_ListOfInteractive.hxx>
38
39 #ifndef COORD_MIN
40 #  define COORD_MIN -1e+15
41 #  define COORD_MAX +1e+15
42 #  define MAX_NUMBER 100000
43 #  define DBL_DIGITS_DISPLAY 16
44 #endif // COORD_MIN
45
46 //=================================================================================
47 // class    : EntityGUI_Dlg
48 // purpose  :
49 //=================================================================================
50 class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
51
52   Q_OBJECT
53
54   struct XYZ
55   {
56     XYZ() { x = y = z = 0.0; xt = yt = zt = "0.0"; }
57     double  x,  y,  z;
58     QString xt, yt, zt;
59   };
60   typedef QList<XYZ> XYZList;
61
62 public:
63   EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. );
64   ~EntityGUI_3DSketcherDlg();
65
66 protected:
67  
68   // redefined from GEOMBase_Helper
69   virtual GEOM::GEOM_IOperations_ptr createOperation();
70   virtual bool                       isValid( QString& );
71   virtual bool                       execute( ObjectList& );
72
73 private:
74   void                               Init();
75   void                               enterEvent( QEvent* );
76
77   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
78                                                      const bool = false,
79                                                      const bool = false,
80                                                      const bool = true,
81                                                      const double = -1,
82                                                      const int  = -1,
83                                                      const int  = -1);
84   
85   void                               displayTrihedron( int );
86   
87   void                               displayAngle( double, double, double, int, bool store = false );
88   void                               displayLength( double theLength = -1.0, bool store = false );
89
90   bool                               createShapes( GEOM::GEOM_Object_ptr,
91                                                    TopoDS_Shape&,
92                                                    TopoDS_Shape& );
93
94   XYZ                                getLastPoint() const;
95   XYZ                                getPenultimatePoint() const;
96   XYZ                                getCurrentPoint() const;
97   
98   std::string                        doubleToString( double );
99
100 private:
101   XYZList                            myPointsList;
102   XYZList                            myRedoList;
103   AIS_ListOfInteractive              myLengthIORedoList;
104   AIS_ListOfInteractive              myAngleIORedoList;
105   int                                myPrsType;
106   std::list<int>                     myPrsTypeList;
107   std::list<int>                     myPrsTypeRedoList;
108
109   EntityGUI_3Spin*                   Group3Spin;
110   EntityGUI_Angles*                  GroupAngles;
111   EntityGUI_Controls*                GroupControls;
112   DlgRef_3Radio*                     GroupType;
113   QButtonGroup*                      myTypeGroup;
114
115   int                                myMode;
116   int                                myOrientation;
117   bool                               myOK;
118   bool                               isLengthVisible;
119   bool                               isAngleVisible;
120   
121   double                             myLineWidth;
122   GeometryGUI*                       myGeometryGUI;
123   SOCC_Prs*                          myAnglePrs;
124   SOCC_Prs*                          myLengthPrs;
125
126 private slots:
127   void                               ClickOnOk();
128   void                               ClickOnAddPoint();
129   bool                               ClickOnApply();
130   //  bool                               isSameAsPrevious();
131   void                               UpdateButtonsState();
132
133   void                               ClickOnUndo();
134   void                               ClickOnRedo();
135
136   void                               SelectionIntoArgument();
137   void                               DeactivateActiveDialog();
138   void                               ActivateThisDialog();
139   void                               TypeClicked( int );
140   void                               ValueChangedInSpinBox( double );
141   void                               ButtonClicked( bool );
142   void                               BoxChecked ( bool );
143   void                               SetDoubleSpinBoxStep( double );
144 };
145
146 #endif // ENTITYGUI_SKETCHERDLG_H