Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / XGUI / XGUI_InspectionPanel.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef XGUI_INSPECTIONPANEL_H_
22 #define XGUI_INSPECTIONPANEL_H_
23
24 #include "XGUI.h"
25
26 #include <QDockWidget>
27
28 #include <memory>
29
30 class XGUI_SelectionMgr;
31 class QLineEdit;
32 class QTableWidget;
33 class QLabel;
34 class QTextBrowser;
35 class QVBoxLayout;
36 class QResizeEvent;
37
38 class TopoDS_Shape;
39
40 class GeomAPI_Vertex;
41 class GeomAPI_Edge;
42 class GeomAPI_Wire;
43 class GeomAPI_Face;
44 class GeomAPI_Shell;
45 class GeomAPI_Solid;
46 class GeomAPI_Shape;
47
48 class GeomAPI_Pln;
49 class GeomAPI_Sphere;
50 class GeomAPI_Cylinder;
51 class GeomAPI_Cone;
52 class GeomAPI_Torus;
53 class GeomAPI_Box;
54
55 /// Internal name of property panel widget
56 const static char* INSPECTION_PANEL = "inspection_panel_dock";
57
58 /**
59 * \ingroup GUI
60 * A class which represents an inspection panel: to show content of currently selected objects
61 */
62 class XGUI_EXPORT XGUI_InspectionPanel : public QDockWidget
63 {
64   Q_OBJECT
65 public:
66   /// Type of selected objects
67   enum SudShape {
68     ShapeId,
69     CompoundId,
70     CompsolidId,
71     SolidId,
72     ShellId,
73     FaceId,
74     WireId,
75     EdgeId,
76     VertexId
77   };
78
79   /// Constructor
80   /// \param theParent is a parent of the property panel
81   /// \param theMgr operation manager
82   XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr);
83
84   // Destructor
85   virtual ~XGUI_InspectionPanel();
86
87
88 private slots:
89   /// A slot to react on selection changed
90   void onSelectionChanged();
91
92 private:
93   /// Set counts of a sub-shapes
94   /// \param theId an id of sub-shape type
95   /// \param theVal a number of sub-shapes of corresponded type
96   void setSubShapeValue(SudShape theId, int theVal);
97
98   /// Set name of current selection
99   /// \param theName the name
100   void setName(const QString& theName);
101
102   /// Set content of selected shape into table
103   /// \param theShape the shape
104   void setShapeContent(const TopoDS_Shape& theShape);
105
106   /// Set parameters of the selected shape
107   /// \param theShape the shape
108   void setShapeParams(const TopoDS_Shape& theShape);
109
110   /// Clear content of the window
111   void clearContent();
112
113   /// Show parameters of a vertex
114   /// \param theVertex the vertex
115   void fillVertex(const std::shared_ptr<GeomAPI_Vertex>& theVertex);
116
117   /// Show parameters of a edge
118   /// \param theEdge the edge
119   void fillEdge(const std::shared_ptr<GeomAPI_Edge>& theEdge);
120
121   /// Show parameters of a wire
122   /// \param theWire the wire
123   void fillWire(const std::shared_ptr<GeomAPI_Wire>& theWire);
124
125   /// Show parameters of a face
126   /// \param theFace the face
127   void fillFace(const std::shared_ptr<GeomAPI_Face>& theFace);
128
129   /// Show parameters of a shell
130   /// \param theShell the shell
131   void fillShell(const std::shared_ptr<GeomAPI_Shell>& theShell);
132
133   /// Show parameters of a solid
134   /// \param theSolid the solid
135   void fillSolid(const std::shared_ptr<GeomAPI_Solid>& theSolid);
136
137   /// Show parameters of a compound
138   /// \param theShape the compound
139   void fillContainer(const std::shared_ptr<GeomAPI_Shape>& theShape);
140
141   /// Show parameters of a plane
142   /// \param theTitle a title of the object
143   /// \param thePlane the plane
144   void setPlaneType(const QString& theTitle, const std::shared_ptr<GeomAPI_Pln>& thePlane);
145
146   /// Show parameters of a sphere
147   /// \param theTitle a title of the object
148   /// \param theSphere the sphere
149   void setSphereType(const QString& theTitle, const std::shared_ptr<GeomAPI_Sphere>& theSphere);
150
151   /// Show parameters of a cylinder
152   /// \param theTitle a title of the object
153   /// \param theCyl the cylinder
154   void setCylinderType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cylinder>& theCyl);
155
156   /// Show parameters of a cone
157   /// \param theTitle a title of the object
158   /// \param theCone the cone
159   void setConeType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cone>& theCone);
160
161   /// Show parameters of a torus
162   /// \param theTitle a title of the object
163   /// \param theTorus the torus
164   void setTorusType(const QString& theTitle, const std::shared_ptr<GeomAPI_Torus>& theTorus);
165
166   /// Show parameters of a box
167   /// \param theTitle a title of the object
168   /// \param theBox the box
169   void setBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
170
171   /// Show parameters of a rotated box
172   /// \param theTitle a title of the object
173   /// \param theBox the box
174   void setRotatedBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
175
176
177   /// Set text into parameters area
178   /// \param theText the text
179   void setParamsText(const QString& theText);
180
181 private:
182   XGUI_SelectionMgr* mySelectionMgr; //> selection manager
183
184   QLineEdit* myNameEdt; //> Name field
185   QTableWidget* mySubShapesTab; //> table of sub-shapes
186   QLabel* myTypeLbl; //> label of a type
187   QTextBrowser* myTypeParams; //> parameters area
188   QVBoxLayout* myMainLayout; //> main layout
189   //QWidget* myMainWidget;  //> main widget
190 };
191
192 #endif