Salome HOME
Defined a suitable plane for right relative positioning of dimension presentations
[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_Angles;
32 class EntityGUI_Controls;
33 class DlgRef_3Radio;
34 class SOCC_Prs;
35
36 #include <AIS_ListOfInteractive.hxx>
37
38 #ifndef COORD_MIN
39 #  define COORD_MIN -1e+15
40 #  define COORD_MAX +1e+15
41 #  define MAX_NUMBER 100000
42 #  define DBL_DIGITS_DISPLAY 16
43 #endif // COORD_MIN
44
45 //=================================================================================
46 // class    : EntityGUI_Dlg
47 // purpose  :
48 //=================================================================================
49 class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
50
51   Q_OBJECT
52
53   struct XYZ
54   {
55     XYZ() { x = y = z = 0.0; command = params = ""; }
56     double  x,  y,  z; // for preview only
57     QString command;
58     QString params;
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, int type = 1);
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   void                               removeLastIOFromPrs( int );
101   void                               restoreLastIOToPrs( int );
102
103 private:
104   XYZList                            myPointsList;
105   XYZList                            myRedoList;
106   AIS_ListOfInteractive              myLengthIORedoList;
107   AIS_ListOfInteractive              myAngleIORedoList;
108   int                                myPrsType;
109   std::list<int>                     myPrsTypeList;
110   std::list<int>                     myPrsTypeRedoList;
111
112   EntityGUI_3Spin*                   Group3Spin;
113   EntityGUI_Angles*                  GroupAngles;
114   EntityGUI_Controls*                GroupControls;
115   DlgRef_3Radio*                     GroupType;
116   QButtonGroup*                      myTypeGroup;
117
118   int                                myMode;
119   int                                myOrientation;
120   bool                               myOK;
121   bool                               isLengthVisible;
122   bool                               isAngleVisible;
123   
124   double                             myLineWidth;
125   GeometryGUI*                       myGeometryGUI;
126   SOCC_Prs*                          myAnglePrs;
127   SOCC_Prs*                          myLengthPrs;
128
129 private slots:
130   void                               ClickOnOk();
131   void                               ClickOnAddPoint();
132   bool                               ClickOnApply();
133   //  bool                               isSameAsPrevious();
134   void                               UpdateButtonsState();
135   void                               UpdatePointCoordinates();
136
137   void                               ClickOnUndo();
138   void                               ClickOnRedo();
139
140   void                               SelectionIntoArgument();
141   void                               DeactivateActiveDialog();
142   void                               ActivateThisDialog();
143   void                               TypeClicked( int );
144   void                               ValueChangedInSpinBox( double );
145   void                               ButtonClicked( bool );
146   void                               BoxChecked ( bool );
147   void                               SetDoubleSpinBoxStep( double );
148 };
149
150 #endif // ENTITYGUI_SKETCHERDLG_H