Salome HOME
552ce7774e399a2a934aa9e55477afe6307f9644
[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 protected:
89   /// Vitrual method is redefined in order to adjust size of internal wirdet to size of
90   /// the whole whindow
91   /// \param theEvent an event with resize parameters
92   virtual void resizeEvent(QResizeEvent* theEvent);
93
94 private slots:
95   /// A slot to react on selection changed
96   void onSelectionChanged();
97
98 private:
99   /// Set counts of a sub-shapes
100   /// \param theId an id of sub-shape type
101   /// \param theVal a number of sub-shapes of corresponded type
102   void setSubShapeValue(SudShape theId, int theVal);
103
104   /// Set name of current selection
105   /// \param theName the name
106   void setName(const QString& theName);
107
108   /// Set content of selected shape into table
109   /// \param theShape the shape
110   void setShapeContent(const TopoDS_Shape& theShape);
111
112   /// Set parameters of the selected shape
113   /// \param theShape the shape
114   void setShapeParams(const TopoDS_Shape& theShape);
115
116   /// Clear content of the window
117   void clearContent();
118
119   /// Show parameters of a vertex
120   /// \param theVertex the vertex
121   void fillVertex(const std::shared_ptr<GeomAPI_Vertex>& theVertex);
122
123   /// Show parameters of a edge
124   /// \param theEdge the edge
125   void fillEdge(const std::shared_ptr<GeomAPI_Edge>& theEdge);
126
127   /// Show parameters of a wire
128   /// \param theWire the wire
129   void fillWire(const std::shared_ptr<GeomAPI_Wire>& theWire);
130
131   /// Show parameters of a face
132   /// \param theFace the face
133   void fillFace(const std::shared_ptr<GeomAPI_Face>& theFace);
134
135   /// Show parameters of a shell
136   /// \param theShell the shell
137   void fillShell(const std::shared_ptr<GeomAPI_Shell>& theShell);
138
139   /// Show parameters of a solid
140   /// \param theSolid the solid
141   void fillSolid(const std::shared_ptr<GeomAPI_Solid>& theSolid);
142
143   /// Show parameters of a compound
144   /// \param theShape the compound
145   void fillContainer(const std::shared_ptr<GeomAPI_Shape>& theShape);
146
147   /// Show parameters of a plane
148   /// \param theTitle a title of the object
149   /// \param thePlane the plane
150   void setPlaneType(const QString& theTitle, const std::shared_ptr<GeomAPI_Pln>& thePlane);
151
152   /// Show parameters of a sphere
153   /// \param theTitle a title of the object
154   /// \param theSphere the sphere
155   void setSphereType(const QString& theTitle, const std::shared_ptr<GeomAPI_Sphere>& theSphere);
156
157   /// Show parameters of a cylinder
158   /// \param theTitle a title of the object
159   /// \param theCyl the cylinder
160   void setCylinderType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cylinder>& theCyl);
161
162   /// Show parameters of a cone
163   /// \param theTitle a title of the object
164   /// \param theCone the cone
165   void setConeType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cone>& theCone);
166
167   /// Show parameters of a torus
168   /// \param theTitle a title of the object
169   /// \param theTorus the torus
170   void setTorusType(const QString& theTitle, const std::shared_ptr<GeomAPI_Torus>& theTorus);
171
172   /// Show parameters of a box
173   /// \param theTitle a title of the object
174   /// \param theBox the box
175   void setBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
176
177   /// Show parameters of a rotated box
178   /// \param theTitle a title of the object
179   /// \param theBox the box
180   void setRotatedBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
181
182
183   /// Set text into parameters area
184   /// \param theText the text
185   void setParamsText(const QString& theText);
186
187 private:
188   XGUI_SelectionMgr* mySelectionMgr; //> selection manager
189
190   QLineEdit* myNameEdt; //> Name field
191   QTableWidget* mySubShapesTab; //> table of sub-shapes
192   QLabel* myTypeLbl; //> label of a type
193   QTextBrowser* myTypeParams; //> parameters area
194   QVBoxLayout* myMainLayout; //> main layout
195   QWidget* myMainWidget;  //> main widget
196 };
197
198 #endif