Salome HOME
3d959cd82878d536b1a3ea4e57ffb41ca88f5977
[modules/geom.git] / src / EntityGUI / EntityGUI_PolylineDlg.h
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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 #ifndef ENTITYGUI_POLYLINEDLG_H
24 #define ENTITYGUI_POLYLINEDLG_H
25
26 #include <GEOMBase_Skeleton.h>
27
28 class CurveCreator_Curve;
29 class CurveCreator_Widget;
30 class OCCViewer_ViewManager;
31 class QGroupBox;
32 class QComboBox;
33
34 //=================================================================================
35 // class    : EntityGUI_PolylineDlg
36 // purpose  :
37 //=================================================================================
38 class EntityGUI_PolylineDlg : public GEOMBase_Skeleton
39 {
40   Q_OBJECT
41
42 public:
43
44   EntityGUI_PolylineDlg (GeometryGUI*, QWidget* = 0,
45                          bool = false, Qt::WindowFlags = 0);
46
47   virtual ~EntityGUI_PolylineDlg();
48
49   void  deleteSelected();
50   bool  deleteEnabled();
51
52   void  setPreviewZLayer( int theLayer );
53   int   getPreviewZLayer() const;
54
55 protected:
56
57   // redefined from GEOMBase_Helper
58   virtual GEOM::GEOM_IOperations_ptr createOperation();
59   virtual bool                       isValid( QString& );
60   virtual bool                       execute( ObjectList& );
61   virtual QList<GEOM::GeomObjPtr>    getSourceObjects();
62
63   /**
64    * This method sets/gets the view manager to control the temporary
65    * displayed objects on Z layer. 
66    * \param theManager the view manager.
67    */
68   void                   setPreviewManager( OCCViewer_ViewManager* theManager );
69   OCCViewer_ViewManager* getPreviewManager();
70
71   /**
72    * This method defines a state of selection button.
73    * \return true if selection button is checked, otherwise false.
74    */
75   bool isCheckToSelect();
76
77 private:
78
79   void Init();
80   void Clear();
81   void enterEvent(QEvent *);
82
83   /**
84    * This method converts the curve into curve parameters required to
85    * construct an object using the interface
86    * GEOM_ICurvesOperations::MakePolyline2DOnPlane.
87    *
88    * \param theCurve a curve object, that contains data.
89    *  \param theCoordsList the list of coordinates list. theCoordsList[0]
90    *         is the coordinates list of the first section. theCoordsList[1]
91    *         is for the second section etc. Output parameter.
92    *  \param theNamesList the list of names. The order corresponds to
93    *         theCoordsList. Output parameter.
94    *  \param theTypesList the list of curve types. The order corresponds to
95    *         theCoordsList. Output parameter.
96    *  \param theClosedList the list of Closed flags. The order corresponds to
97    *         theCoordsList. Output parameter.
98    */
99   void GetCurveParams(GEOM::ListOfListOfDouble &theCoords,
100                       GEOM::string_array       &theNames,
101                       GEOM::short_array        &theTypes,
102                       GEOM::ListOfBool         &theCloseds);
103
104   /**
105    * This method returns the current local coordinate system.
106    *
107    * \return local coordinate system.
108    */
109   gp_Ax3 GetActiveLocalCS();
110
111   /**
112    * This method returns the current working plane. Can be null.
113    *
114    * \return the current working plane.
115    */
116   GEOM::GeomObjPtr GetActiveWPlane();
117
118   /**
119    * This method add a local coordinate system of the selected object.
120    *
121    * \param theSelectedObject the selected object. It can be a planar face
122    *        or an imported polyline.
123    * \param IsPlane true for planar face; false for imported polyline.
124    * \param theLCS the local coordinate system.
125    */
126   void AddLocalCS(GEOM::GeomObjPtr  theSelectedObject,
127                   const bool        IsPlane,
128                   const gp_Ax3      &theLCS);
129
130   /**
131    * This method converts the working plane object into
132    * the local coordinate system of the polyline.
133    *
134    * \param theGeomObj the working plane
135    * \return the local coordinate system
136    */
137   gp_Ax3 WPlaneToLCS(GEOM::GeomObjPtr theGeomObj);
138
139   /**
140    * This method displays the AIS_InteractiveObject(s) to preview
141    * on the Z layer and sets VIOLET color.
142    */
143   void displayPreview();
144
145   /**
146    * This method erases AIS_InteractiveObject(s) from
147    * AIS_InteractiveContext and release memory.
148    */
149   void erasePreview();
150
151 protected slots:
152
153   void ClickOnOk();
154   bool ClickOnApply();
155   void processStartedSubOperation( QWidget*, bool );
156   void processFinishedSubOperation( QWidget* );
157   void SetEditCurrentArgument( bool );
158   void SelectionIntoArgument( bool isForced = false );
159   void ActivateThisDialog();
160   void ActivateLocalCS();
161
162 private:
163
164   CurveCreator_Curve           *myCurve;
165   CurveCreator_Widget          *myEditorWidget;
166   QGroupBox                    *myAddElementBox;
167   QComboBox                    *myPlnComboBox;
168   QPushButton                  *myPlnButton;
169   QPushButton                  *myPlnSelButton;
170   QPushButton                  *myPolylineSelButton;
171   QLineEdit                    *myWPlaneLineEdit;
172   QLineEdit                    *myPolylineEdit;
173   QLineEdit                    *myEditCurrentArgument;   /* Current LineEdit */
174   QList<gp_Ax3>                 myLCSList;
175   QList<GEOM::GeomObjPtr>       myWPlaneList;
176   OCCViewer_ViewManager*        myPreviewManager;
177   int                           myPreviewZLayer;
178
179 };
180
181 #endif // ENTITYGUI_POLYLINEDLG_H