Salome HOME
64260b2ae166c2bd28a3a6fc4cd3506ca24effb9
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.h
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : EntityGUI_SketcherDlg.h
25 //  Author : Damine COQUERET
26 //  Module : GEOM
27
28 #ifndef ENTITYGUI_SKETCHERDLG_H
29 #define ENTITYGUI_SKETCHERDLG_H
30
31 #include "GEOM_EntityGUI.hxx"
32
33 #include "GEOMBase_Helper.h"
34
35 #include "EntityGUI_Skeleton_QTD.h"
36 #include "EntityGUI_Point_QTD.h"
37 #include "EntityGUI_Dir1_QTD.h"
38 #include "EntityGUI_Dir2_QTD.h"
39
40 #include "EntityGUI_1Sel_QTD.h"
41 #include "EntityGUI_1Spin.h"
42 #include "EntityGUI_2Spin.h"
43 #include "EntityGUI_3Spin.h"
44 #include "EntityGUI_4Spin.h"
45
46 #include "EntityGUI.h"
47 #include "GeometryGUI.h"
48
49 #include <gp_Dir.hxx>
50
51 #include <qwidget.h>
52 #include <qgroupbox.h>
53 #include <qlineedit.h>
54 #include <qlayout.h>
55 #include <qradiobutton.h>
56 #include <qbuttongroup.h>
57
58 //=================================================================================
59 // class    : EntityGUI_Dlg
60 // purpose  :
61 //=================================================================================
62 class GEOM_ENTITYGUI_EXPORT EntityGUI_SketcherDlg : public EntityGUI_Skeleton_QTD, public GEOMBase_Helper
63
64     Q_OBJECT
65
66 public:
67     EntityGUI_SketcherDlg(GeometryGUI* GUI, QWidget* parent = 0,
68                           const char* name = 0, bool modal = FALSE, WFlags fl = 0,
69                           const double lineWidth = 2.);
70     ~EntityGUI_SketcherDlg();
71
72     bool eventFilter (QObject* object, QEvent* event);
73
74 protected:
75     // redefined from GEOMBase_Helper
76     virtual GEOM::GEOM_IOperations_ptr createOperation();
77     virtual bool isValid( QString& );
78     virtual bool execute( ObjectList& objects );
79
80     void closeEvent( QCloseEvent* e );
81     void keyPressEvent( QKeyEvent* e );
82
83 private :
84     void Init();
85     void enterEvent(QEvent* e);
86     void InitClick();
87     void setEnabledUndo(bool value);
88     void setEnabledRedo(bool value);
89
90     QString GetNewCommand();
91
92     int myConstructorId;
93     int myConstructorDirId;
94     int mySketchType;
95     int mySketchState;
96
97     bool myIsAllAdded;
98
99     QLineEdit* myEditCurrentArgument;   /* Current LineEdit */
100
101     QStringList myCommand;
102     QStringList myUndoCommand;
103
104     Standard_Real myX, myY, myDX, myDY;
105     Standard_Real myLength, myAngle, myRadius;
106     Standard_Real myLastX1, myLastY1;
107     Standard_Real myLastX2, myLastY2;
108
109     EntityGUI_Point_QTD* GroupPt;
110     EntityGUI_Dir1_QTD* GroupD1;
111     EntityGUI_Dir2_QTD* GroupD2;
112
113     EntityGUI_1Sel_QTD* Group1Sel;
114     EntityGUI_1Spin* Group1Spin;
115     EntityGUI_2Spin* Group2Spin;
116     EntityGUI_3Spin* Group3Spin;
117     EntityGUI_4Spin* Group4Spin;
118
119     GeometryGUI*  myGeometryGUI;
120
121     QString myHelpFileName;
122
123     enum SketchState {FIRST_POINT, NEXT_POINT};
124
125     enum SketchType {PT_ABS, PT_RELATIVE, PT_SEL,
126                      DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
127                      DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
128                      DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
129                      DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y};
130
131   double myLineWidth;
132   virtual void displayPreview  ( GEOM::GEOM_Object_ptr obj,
133                                  const bool            append = false,
134                                  const bool            activate = false,
135                                  const bool            update = true,
136                                  const double          lineWidth = -1 );
137
138   bool createShapes( GEOM::GEOM_Object_ptr theObject,
139                      TopoDS_Shape&         theApplyedWire,
140                      TopoDS_Shape&         theLastSegment );
141
142 private slots:
143     void ClickOnEnd();
144     void ClickOnCancel();
145     bool ClickOnApply();
146     void ClickOnUndo();
147     void ClickOnRedo();
148     void ClickOnHelp();
149     void LineEditReturnPressed();
150     void SelectionIntoArgument();
151     void SetEditCurrentArgument();
152     void DeactivateActiveDialog();
153     void ActivateThisDialog();
154     void TypeClicked(int constructorId);
155     void DestClicked(int constructorId);
156     void PointClicked(int constructorId);
157     void Dir1Clicked(int constructorId);
158     void Dir2Clicked(int constructorId);
159     void ValueChangedInSpinBox(double newValue);
160 };
161
162 #endif // ENTITYGUI_SKETCHERDLG_H