]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_InspectionPanel.cpp
Salome HOME
Issue #3120: Show Empty panel if selection doesn't contain a shape
[modules/shaper.git] / src / XGUI / XGUI_InspectionPanel.cpp
1 // Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 //
19
20 #include "XGUI_InspectionPanel.h"
21 #include "XGUI_Workshop.h"
22 #include "XGUI_SelectionMgr.h"
23 #include "XGUI_Selection.h"
24 #include "XGUI_Tools.h"
25 #include "XGUI_ModuleConnector.h"
26
27 #include <ModuleBase_ViewerPrs.h>
28 #include <ModuleBase_Tools.h>
29 #include <ModuleBase_OperationDescription.h>
30 #include <ModuleBase_WidgetFactory.h>
31 #include <ModuleBase_IModule.h>
32 #include <ModuleBase_PageWidget.h>
33
34 #include <ModelAPI_ResultField.h>
35
36 #include <ModelAPI_Result.h>
37
38 #include <GeomAPI_Ax3.h>
39 #include <GeomAPI_Box.h>
40 #include <GeomAPI_Circ.h>
41 #include <GeomAPI_Cone.h>
42 #include <GeomAPI_Cylinder.h>
43 #include <GeomAPI_Edge.h>
44 #include <GeomAPI_Ellipse.h>
45 #include <GeomAPI_Face.h>
46 #include <GeomAPI_Pln.h>
47 #include <GeomAPI_Pnt.h>
48 #include <GeomAPI_Shell.h>
49 #include <GeomAPI_Solid.h>
50 #include <GeomAPI_Sphere.h>
51 #include <GeomAPI_Torus.h>
52 #include <GeomAPI_Vertex.h>
53 #include <GeomAPI_Wire.h>
54
55 #include <QLayout>
56 #include <QScrollArea>
57 #include <QLabel>
58 #include <QLineEdit>
59 #include <QTableWidget>
60 #include <QHeaderView>
61 #include <QTextBrowser>
62 #include <QResizeEvent>
63 #include <QSplitter>
64 #include <QStackedWidget>
65
66 #include <BRepBndLib.hxx>
67 #include <TopoDS_Iterator.hxx>
68 #include <TopTools_MapOfShape.hxx>
69 #include <TopTools_ListOfShape.hxx>
70 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic
71
72
73 // ================     Auxiliary functions     ================
74 #define TITLE(val) ("<b>" + (val) + "</b>")
75
76 static void appendPointToParameters(const QString& thePointTitle,
77                                     const GeomPointPtr& theCoord,
78                                           QString& theParams)
79 {
80   theParams += TITLE(thePointTitle) +
81     "<br> X: " + QString::number(theCoord->x()) +
82     "<br> Y: " + QString::number(theCoord->y()) +
83     "<br> Z: " + QString::number(theCoord->z()) +
84     "<br>";
85 }
86
87 static void appendDirToParameters(const QString& theDirTitle,
88                                   const GeomDirPtr& theDirection,
89                                         QString& theParams)
90 {
91   theParams += TITLE(theDirTitle) +
92     "<br> DX: " + QString::number(theDirection->x()) +
93     "<br> DY: " + QString::number(theDirection->y()) +
94     "<br> DZ: " + QString::number(theDirection->z()) +
95     "<br>";
96 }
97
98 static void appendGroupNameToParameters(const QString& theGroupTitle, QString& theParams)
99 {
100   theParams += TITLE(theGroupTitle) + "<br>";
101 }
102
103 static void appendNamedValueToParameters(const QString& theName,
104                                          const double   theValue,
105                                                QString& theParams)
106 {
107   theParams += theName + ": " + QString::number(theValue) + "<br>";
108 }
109
110 static void appendNamedValueToParameters(const QString& theName,
111                                          const bool     theValue,
112                                                QString& theParams)
113 {
114   theParams += theName + ": " + (theValue ? "True" : "False") + "<br>";
115 }
116
117
118 // ================     XGUI_InspectionPanel    ================
119
120 XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_Workshop* theWorkshop)
121   : QDockWidget(theParent),
122   myWorkshop(theWorkshop)
123 {
124   setWindowTitle(tr("Inspection Panel"));
125   setObjectName(INSPECTION_PANEL);
126   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
127
128   myStackWgt = new QStackedWidget(this);
129
130   // Create shape selection page
131   QSplitter* aSplitter = new QSplitter(Qt::Vertical, myStackWgt);
132
133   // Create an internal widget
134   QWidget* aNameWgt = new QWidget(aSplitter);
135   QHBoxLayout* aNameLayout = new QHBoxLayout(aNameWgt);
136   aNameLayout->setContentsMargins(3, 0, 3, 0);
137   aNameLayout->addWidget(new QLabel(tr("Object"), aNameWgt));
138   myNameEdt = new QLineEdit(aNameWgt);
139   myNameEdt->setReadOnly(true);
140   aNameLayout->addWidget(myNameEdt);
141
142   aSplitter->addWidget(aNameWgt);
143
144   // Table with sub-shapes
145   mySubShapesTab = new QTableWidget(9, 2, aSplitter);
146   mySubShapesTab->setFocusPolicy(Qt::NoFocus);
147   mySubShapesTab->verticalHeader()->hide();
148   QStringList aTitles;
149   aTitles << tr("Sub-shapes") << tr("Number");
150   mySubShapesTab->setHorizontalHeaderLabels(aTitles);
151
152   QStringList aSubShapes;
153   aSubShapes << tr("SHAPE") << tr("COMPOUND") << tr("COMPSOLID") <<
154     tr("SOLID") << tr("SHELL") << tr("FACE") << tr("WIRE") << tr("EDGE") << tr("VERTEX");
155   int i = 0;
156   foreach(QString aType, aSubShapes) {
157     QTableWidgetItem* aItem = new QTableWidgetItem(aType);
158     aItem->setFlags(Qt::ItemIsEnabled);
159     mySubShapesTab->setItem(i++, 0, aItem);
160   }
161   for (i = 0; i < 9; i++) {
162     QTableWidgetItem* aItem = new QTableWidgetItem("");
163     aItem->setFlags(Qt::ItemIsEnabled);
164     aItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
165     mySubShapesTab->setItem(i, 1, aItem);
166   }
167   mySubShapesTab->setColumnWidth(0, 90);
168   mySubShapesTab->setColumnWidth(1, 70);
169
170   aSplitter->addWidget(mySubShapesTab);
171
172   // Type of object
173   QWidget* aTypeWgt = new QWidget(aSplitter);
174   QHBoxLayout* aTypeLayout = new QHBoxLayout(aTypeWgt);
175   aTypeLayout->setContentsMargins(3, 0, 3, 0);
176
177   aTypeLayout->addWidget(new QLabel(tr("Type:"), aTypeWgt));
178   myTypeLbl = new QLabel("", aTypeWgt);
179   aTypeLayout->addWidget(myTypeLbl);
180
181   aSplitter->addWidget(aTypeWgt);
182
183   myTypeParams = new QTextBrowser(aSplitter);
184   myTypeParams->setReadOnly(true);
185   myTypeParams->setFocusPolicy(Qt::NoFocus);
186   myTypeParams->viewport()->setBackgroundRole(QPalette::Window);
187
188   aSplitter->addWidget(myTypeParams);
189
190   aSplitter->setCollapsible(0, false);
191   aSplitter->setCollapsible(1, false);
192   aSplitter->setCollapsible(2, false);
193   aSplitter->setCollapsible(3, false);
194
195   QList<int> aSizes;
196   aSizes << 10 << 140 << 10;
197   aSplitter->setSizes(aSizes);
198
199   myShapePanelId = myStackWgt->addWidget(aSplitter);
200
201   // Create feature selection page
202   QScrollArea* aScroll = new QScrollArea(myStackWgt);
203   aScroll->setWidgetResizable(true);
204   aScroll->setFrameStyle(QFrame::NoFrame);
205
206   myFeaturePane = new ModuleBase_PageWidget(aScroll);
207   myFeatureLayout = new QGridLayout(myFeaturePane);
208   myFeatureLayout->setContentsMargins(3, 3, 3, 3);
209   aScroll->setWidget(myFeaturePane);
210   //myFeaturePane->setEnabled(false);
211
212   myFeaturePanelId = myStackWgt->addWidget(aScroll);
213
214   setWidget(myStackWgt);
215   connect(myWorkshop->selector(), SIGNAL(selectionChanged()), SLOT(onSelectionChanged()));
216 }
217
218 //********************************************************************
219 XGUI_InspectionPanel::~XGUI_InspectionPanel()
220 {
221 }
222
223 //********************************************************************
224 void XGUI_InspectionPanel::setSubShapeValue(SudShape theId, int theVal)
225 {
226   mySubShapesTab->item(theId, 1)->setText(QString::number(theVal));
227 }
228
229 //********************************************************************
230 void XGUI_InspectionPanel::clearContent()
231 {
232   setName("");
233   for (int i = 0; i <= VertexId; i++) {
234     mySubShapesTab->item((SudShape)i, 1)->setText("");
235   }
236   myTypeLbl->setText("");
237   setParamsText("");
238
239   myFeaturePane->clearPage();
240 }
241
242 //********************************************************************
243 void XGUI_InspectionPanel::onSelectionChanged()
244 {
245   if (!isVisible())
246     return;
247
248   clearContent();
249
250   XGUI_Selection* aSelection = myWorkshop->selector()->selection();
251   QList<ModuleBase_ViewerPrsPtr> aSelectedList =
252     aSelection->getSelected(myWorkshop->selector()->placeOfSelection());
253
254   if (aSelectedList.count() > 0) {
255     ModuleBase_ViewerPrsPtr aPrs = aSelectedList.first();
256     FieldStepPtr aStep =
257       std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aPrs->object());
258     if (aStep)
259       return;
260     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs->object());
261     if (aFeature.get()) {
262       myStackWgt->setCurrentIndex(myFeaturePanelId);
263       buildFeaturePane(aFeature);
264     }
265     else {
266       TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
267       if (aShape.IsNull()) {
268         ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
269         if (aRes.get()) {
270           GeomShapePtr aShpPtr = aRes->shape();
271           if (aShpPtr.get()) {
272             aShape = aShpPtr->impl<TopoDS_Shape>();
273           }
274         }
275       }
276       if (aShape.IsNull()) {
277         myStackWgt->setCurrentIndex(myFeaturePanelId);
278         return;
279       }
280       myStackWgt->setCurrentIndex(myShapePanelId);
281       GeomShapePtr aShapePtr(new GeomAPI_Shape());
282       aShapePtr->setImpl(new TopoDS_Shape(aShape));
283
284       ModuleBase_ViewerPrsPtr aPrsCopy(new ModuleBase_ViewerPrs(aPrs->object(), aShapePtr));
285       setName(XGUI_Tools::generateName(aPrsCopy));
286       setShapeContent(aShape);
287       setShapeParams(aShape);
288     }
289   }
290 }
291
292 //********************************************************************
293 void XGUI_InspectionPanel::setName(const QString& theName)
294 {
295   myNameEdt->setText(theName);
296 }
297
298 //********************************************************************
299 void XGUI_InspectionPanel::setShapeContent(const TopoDS_Shape& theShape)
300 {
301   try {
302     OCC_CATCH_SIGNALS;
303     int iType, nbTypes[TopAbs_SHAPE];
304     for (iType = 0; iType < TopAbs_SHAPE; ++iType) {
305       nbTypes[iType] = 0;
306     }
307     nbTypes[theShape.ShapeType()]++;
308
309     TopTools_MapOfShape aMapOfShape;
310     aMapOfShape.Add(theShape);
311     TopTools_ListOfShape aListOfShape;
312     aListOfShape.Append(theShape);
313
314     TopTools_ListIteratorOfListOfShape itL(aListOfShape);
315     for (; itL.More(); itL.Next()) {
316       TopoDS_Shape sp = itL.Value();
317       TopoDS_Iterator it(sp);
318       for (; it.More(); it.Next()) {
319         TopoDS_Shape s = it.Value();
320         if (aMapOfShape.Add(s)) {
321           aListOfShape.Append(s);
322           nbTypes[s.ShapeType()]++;
323         }
324       }
325     }
326     setSubShapeValue(VertexId, nbTypes[TopAbs_VERTEX]);
327     setSubShapeValue(EdgeId, nbTypes[TopAbs_EDGE]);
328     setSubShapeValue(WireId, nbTypes[TopAbs_WIRE]);
329     setSubShapeValue(FaceId, nbTypes[TopAbs_FACE]);
330     setSubShapeValue(ShellId, nbTypes[TopAbs_SHELL]);
331     setSubShapeValue(SolidId, nbTypes[TopAbs_SOLID]);
332     setSubShapeValue(CompsolidId, nbTypes[TopAbs_COMPSOLID]);
333     setSubShapeValue(CompoundId, nbTypes[TopAbs_COMPOUND]);
334     setSubShapeValue(ShapeId, aMapOfShape.Extent());
335   }
336   catch (Standard_Failure) {
337   }
338 }
339
340 //********************************************************************
341 void XGUI_InspectionPanel::setShapeParams(const TopoDS_Shape& theShape)
342 {
343   GeomShapePtr aShape(new GeomAPI_Shape);
344   aShape->setImpl(new TopoDS_Shape(theShape));
345
346   switch (aShape->shapeType()) {
347   case GeomAPI_Shape::VERTEX:
348     fillVertex(aShape->vertex());
349     break;
350   case GeomAPI_Shape::EDGE:
351     fillEdge(aShape->edge());
352     break;
353   case GeomAPI_Shape::FACE:
354     fillFace(aShape->face());
355     break;
356   case GeomAPI_Shape::SOLID:
357     fillSolid(aShape->solid());
358     break;
359   case GeomAPI_Shape::WIRE:
360     fillWire(aShape->wire());
361     break;
362   case GeomAPI_Shape::SHELL:
363     fillShell(aShape->shell());
364     break;
365   case GeomAPI_Shape::COMPSOLID:
366   case GeomAPI_Shape::COMPOUND:
367     fillContainer(aShape);
368     break;
369   }
370 }
371
372 //********************************************************************
373 void XGUI_InspectionPanel::fillVertex(const GeomVertexPtr& theVertex)
374 {
375   GeomPointPtr aPoint = theVertex->point();
376
377   myTypeLbl->setText(tr("Vertex"));
378
379   QString aParams;
380   appendPointToParameters(tr("Coordinates"), aPoint, aParams);
381   setParamsText(aParams);
382 }
383
384 //********************************************************************
385 void XGUI_InspectionPanel::fillEdge(const GeomEdgePtr& theEdge)
386 {
387   QString aParams;
388   if (theEdge->isDegenerated())
389     appendNamedValueToParameters(tr("Degenerated"), true, aParams);
390
391   GeomPointPtr aStartPnt = theEdge->firstPoint();
392   GeomPointPtr aEndPnt = theEdge->lastPoint();
393   bool addStartEndPoints = false;
394
395   if (theEdge->isLine()) {
396     myTypeLbl->setText(tr("Line segment"));
397     addStartEndPoints = true;
398   }
399   else {
400     GeomCirclePtr aCircle = theEdge->circle();
401     if (aCircle) {
402       addStartEndPoints = aStartPnt->distance(aEndPnt) >= Precision::Confusion();
403       if (addStartEndPoints)
404         myTypeLbl->setText("Arc of circle");
405       else
406         myTypeLbl->setText("Circle");
407
408       appendPointToParameters(tr("Center"), aCircle->center(), aParams);
409       appendDirToParameters(tr("Normal"), aCircle->normal(), aParams);
410       appendGroupNameToParameters(tr("Dimensions"), aParams);
411       appendNamedValueToParameters(tr("Radius"), aCircle->radius(), aParams);
412     }
413     else {
414       GeomEllipsePtr anEllipse = theEdge->ellipse();
415       if (anEllipse) {
416         addStartEndPoints = aStartPnt->distance(aEndPnt) >= Precision::Confusion();
417         if (addStartEndPoints)
418           myTypeLbl->setText("Arc of ellipse");
419         else
420           myTypeLbl->setText("Ellipse");
421
422         appendPointToParameters(tr("Center"), anEllipse->center(), aParams);
423         appendDirToParameters(tr("Normal"), anEllipse->normal(), aParams);
424         appendGroupNameToParameters(tr("Dimensions"), aParams);
425         appendNamedValueToParameters(tr("Major radius"), anEllipse->majorRadius(), aParams);
426         appendNamedValueToParameters(tr("Minor radius"), anEllipse->minorRadius(), aParams);
427       }
428       else
429         // Common case
430         myTypeLbl->setText(tr("Edge"));
431     }
432   }
433
434   if (addStartEndPoints) {
435     appendPointToParameters(tr("Start point"), aStartPnt, aParams);
436     appendPointToParameters(tr("End point"), aEndPnt, aParams);
437   }
438   setParamsText(aParams);
439 }
440
441 //********************************************************************
442 void XGUI_InspectionPanel::fillWire(const GeomWirePtr& theWire)
443 {
444   QString aParams;
445   appendNamedValueToParameters(tr("Closed"), theWire->isClosed(), aParams);
446
447   // check the wire is a polygon
448   std::list<GeomPointPtr> aPolygonPoints;
449   if (theWire->isPolygon(aPolygonPoints)) {
450     myTypeLbl->setText(tr("Polygon"));
451     int aCornerIndex = 0;
452     for (std::list<GeomPointPtr>::const_iterator aPtIt = aPolygonPoints.begin();
453          aPtIt != aPolygonPoints.end(); ++aPtIt)
454        appendPointToParameters(tr("Point") + " " + QString::number(++aCornerIndex),
455                                *aPtIt, aParams);
456   }
457   else
458     myTypeLbl->setText(tr("Wire"));
459
460   setParamsText(aParams);
461 }
462
463 //********************************************************************
464 void XGUI_InspectionPanel::fillFace(const GeomFacePtr& theFace)
465 {
466   QString aParams;
467   // 1. Plane and planar faces
468   GeomPlanePtr aPlane = theFace->getPlane();
469   if (aPlane) {
470     bool isCommonCase = true;
471     // Check face bounded by circle or ellipse
472     std::list<GeomShapePtr> aSubs = theFace->subShapes(GeomAPI_Shape::EDGE);
473     if (aSubs.size() == 1) {
474       GeomEdgePtr anEdge = aSubs.front()->edge();
475       if (anEdge->isCircle() || anEdge->isEllipse()) {
476         fillEdge(anEdge);
477         isCommonCase = false;
478       }
479     }
480     else {
481       // Check face bounded by a single wire which is rectangle
482       aSubs = theFace->subShapes(GeomAPI_Shape::WIRE);
483       if (aSubs.size() == 1) {
484         GeomWirePtr aWire = aSubs.front()->wire();
485         std::list<GeomPointPtr> aCorners;
486         if (aWire->isRectangle(aCorners)) {
487           GeomPointPtr aBaseCorner = aCorners.front();
488           aCorners.pop_front();
489
490           double aWidth = aBaseCorner->distance(aCorners.front());
491           double aHeight = aBaseCorner->distance(aCorners.back());
492
493           myTypeLbl->setText(tr("Rectangle"));
494           appendPointToParameters(tr("Corner"), aBaseCorner, aParams);
495           appendDirToParameters(tr("Normal"), aPlane->direction(), aParams);
496           appendGroupNameToParameters(tr("Dimensions"), aParams);
497           appendNamedValueToParameters(tr("Width"), aWidth, aParams);
498           appendNamedValueToParameters(tr("Height"), aHeight, aParams);
499           setParamsText(aParams);
500
501           isCommonCase = false;
502         }
503       }
504     }
505
506     if (isCommonCase)
507       setPlaneType(tr("Plane"), aPlane);
508   }
509   else {
510     // 2. Sphere
511     GeomSpherePtr aSphere = theFace->getSphere();
512     if (aSphere)
513       setSphereType(tr("Sphere"), aSphere);
514     else {
515       // 3. Cylinder
516       GeomCylinderPtr aCylinder = theFace->getCylinder();
517       if (aCylinder)
518         setCylinderType(tr("Cylinder"), aCylinder);
519       else {
520         // 4. Cone
521         GeomConePtr aCone = theFace->getCone();
522         if (aCone)
523           setConeType(tr("Cone"), aCone);
524         else {
525           // 5. Torus
526           GeomTorusPtr aTorus = theFace->getTorus();
527           if (aTorus)
528             setTorusType(tr("Torus"), aTorus);
529           else
530             // 6. Common case
531             myTypeLbl->setText(tr("Face"));
532         }
533       }
534     }
535   }
536 }
537
538 //********************************************************************
539 void XGUI_InspectionPanel::fillShell(const GeomShellPtr& theShell)
540 {
541   // 1. Sphere
542   GeomSpherePtr aSphere = theShell->getSphere();
543   if (aSphere)
544     setSphereType(tr("Sphere"), aSphere);
545   else {
546     // 2. Cylinder
547     GeomCylinderPtr aCylinder = theShell->getCylinder();
548     if (aCylinder)
549       setCylinderType(tr("Cylinder"), aCylinder);
550     else {
551       // 3. Cone
552       GeomConePtr aCone = theShell->getCone();
553       if (aCone)
554         setConeType(tr("Cone"), aCone);
555       else {
556         // 4. Torus
557         GeomTorusPtr aTorus = theShell->getTorus();
558         if (aTorus)
559           setTorusType(tr("Torus"), aTorus);
560         else {
561           // 5. Axis-aligned/Rotated Box
562           GeomBoxPtr aBox = theShell->getParallelepiped();
563           if (aBox) {
564             if (aBox->isAxesAligned())
565               setBoxType(tr("Box"), aBox);
566             else
567               setRotatedBoxType(tr("Rotated Box"), aBox);
568           }
569           else
570             // 6. Common case
571             myTypeLbl->setText(tr("Shell"));
572         }
573       }
574     }
575   }
576 }
577
578 //********************************************************************
579 void XGUI_InspectionPanel::fillSolid(const GeomSolidPtr& theSolid)
580 {
581   // 1. Sphere
582   GeomSpherePtr aSphere = theSolid->getSphere();
583   if (aSphere)
584     setSphereType(tr("Sphere"), aSphere);
585   else {
586     // 2. Cylinder
587     GeomCylinderPtr aCylinder = theSolid->getCylinder();
588     if (aCylinder)
589       setCylinderType(tr("Cylinder"), aCylinder);
590     else {
591       // 3. Cone
592       GeomConePtr aCone = theSolid->getCone();
593       if (aCone)
594         setConeType(tr("Cone"), aCone);
595       else {
596         // 4. Torus
597         GeomTorusPtr aTorus = theSolid->getTorus();
598         if (aTorus)
599           setTorusType(tr("Torus"), aTorus);
600         else {
601           // 5. Axis-aligned/Rotated Box
602           GeomBoxPtr aBox = theSolid->getParallelepiped();
603           if (aBox) {
604             if (aBox->isAxesAligned())
605               setBoxType(tr("Box"), aBox);
606             else
607               setRotatedBoxType(tr("Rotated Box"), aBox);
608           }
609           else
610             // 6. Common case
611             myTypeLbl->setText(tr("Solid"));
612         }
613       }
614     }
615   }
616 }
617
618 //********************************************************************
619 void XGUI_InspectionPanel::fillContainer(const GeomShapePtr& theShape)
620 {
621   if (theShape->shapeType() == GeomAPI_Shape::COMPSOLID)
622     myTypeLbl->setText("CompSolid");
623   else if (theShape->shapeType() == GeomAPI_Shape::COMPOUND)
624     myTypeLbl->setText("Compound");
625
626   // fill bounding box
627   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
628   Bnd_Box aBB;
629   BRepBndLib::Add(aShape, aBB);
630
631   if (aBB.IsVoid())
632     return;
633
634   gp_Pnt aMinPnt = aBB.CornerMin();
635   GeomPointPtr aMinPoint(new GeomAPI_Pnt(aMinPnt.X(), aMinPnt.Y(), aMinPnt.Z()));
636
637   gp_Pnt aMaxPnt = aBB.CornerMax();
638   GeomPointPtr aMaxPoint(new GeomAPI_Pnt(aMaxPnt.X(), aMaxPnt.Y(), aMaxPnt.Z()));
639
640   QString aParams;
641   appendGroupNameToParameters(tr("Bounding box"), aParams);
642   appendPointToParameters(tr("Minimal corner"), aMinPoint, aParams);
643   appendPointToParameters(tr("Maximal corner"), aMaxPoint, aParams);
644 }
645
646 //********************************************************************
647 void XGUI_InspectionPanel::setPlaneType(const QString& theTitle,
648                                         const std::shared_ptr<GeomAPI_Pln>& thePlane)
649 {
650   myTypeLbl->setText(theTitle);
651   QString aParams;
652   appendPointToParameters(tr("Origin"), thePlane->location(), aParams);
653   appendDirToParameters(tr("Normal"), thePlane->direction(), aParams);
654   setParamsText(aParams);
655 }
656
657 //********************************************************************
658 void XGUI_InspectionPanel::setSphereType(const QString& theTitle,
659                                          const std::shared_ptr<GeomAPI_Sphere>& theSphere)
660 {
661   myTypeLbl->setText(theTitle);
662   QString aParams;
663   appendPointToParameters(tr("Center"), theSphere->center(), aParams);
664   appendGroupNameToParameters(tr("Dimensions"), aParams);
665   appendNamedValueToParameters(tr("Radius"), theSphere->radius(), aParams);
666   setParamsText(aParams);
667 }
668
669 //********************************************************************
670 void XGUI_InspectionPanel::setCylinderType(const QString& theTitle,
671                                            const std::shared_ptr<GeomAPI_Cylinder>& theCyl)
672 {
673   myTypeLbl->setText(theTitle);
674   QString aParams;
675   appendPointToParameters(tr("Position"), theCyl->location(), aParams);
676   appendDirToParameters(tr("Axis"), theCyl->axis(), aParams);
677   appendGroupNameToParameters(tr("Dimensions"), aParams);
678   appendNamedValueToParameters(tr("Radius"), theCyl->radius(), aParams);
679   appendNamedValueToParameters(tr("Height"), theCyl->height(), aParams);
680   setParamsText(aParams);
681 }
682
683 //********************************************************************
684 void XGUI_InspectionPanel::setConeType(const QString& theTitle,
685                                        const std::shared_ptr<GeomAPI_Cone>& theCone)
686 {
687   myTypeLbl->setText(theTitle);
688   QString aParams;
689   appendPointToParameters(tr("Position"), theCone->location(), aParams);
690   appendDirToParameters(tr("Axis"), theCone->axis(), aParams);
691   appendGroupNameToParameters(tr("Dimensions"), aParams);
692   appendNamedValueToParameters(tr("Radius 1"), theCone->radius1(), aParams);
693   appendNamedValueToParameters(tr("Radius 2"), theCone->radius2(), aParams);
694   appendNamedValueToParameters(tr("Height"), theCone->height(), aParams);
695   setParamsText(aParams);
696 }
697
698 //********************************************************************
699 void XGUI_InspectionPanel::setTorusType(const QString& theTitle,
700                                         const std::shared_ptr<GeomAPI_Torus>& theTorus)
701 {
702   myTypeLbl->setText(theTitle);
703   QString aParams;
704   appendPointToParameters(tr("Center"), theTorus->center(), aParams);
705   appendDirToParameters(tr("Axis"), theTorus->direction(), aParams);
706   appendGroupNameToParameters(tr("Dimensions"), aParams);
707   appendNamedValueToParameters(tr("Major radius"), theTorus->majorRadius(), aParams);
708   appendNamedValueToParameters(tr("Minor radius"), theTorus->minorRadius(), aParams);
709   setParamsText(aParams);
710 }
711
712 //********************************************************************
713 void XGUI_InspectionPanel::setBoxType(const QString& theTitle,
714                                       const std::shared_ptr<GeomAPI_Box>& theBox)
715 {
716   myTypeLbl->setText(theTitle);
717   QString aParams;
718   appendPointToParameters(tr("Position"), theBox->axes()->origin(), aParams);
719   appendGroupNameToParameters(tr("Dimensions"), aParams);
720   appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
721   appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
722   appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
723   setParamsText(aParams);
724 }
725
726 //********************************************************************
727 void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle,
728                                              const std::shared_ptr<GeomAPI_Box>& theBox)
729 {
730   myTypeLbl->setText(theTitle);
731   QString aParams;
732   std::shared_ptr<GeomAPI_Ax3> anAxes = theBox->axes();
733   appendPointToParameters(tr("Position"), anAxes->origin(), aParams);
734   appendDirToParameters(tr("Z axis"), anAxes->normal(), aParams);
735   appendDirToParameters(tr("X axis"), anAxes->dirX(), aParams);
736   appendGroupNameToParameters(tr("Dimensions"), aParams);
737   appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
738   appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
739   appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
740   setParamsText(aParams);
741 }
742
743
744 //********************************************************************
745 void XGUI_InspectionPanel::setParamsText(const QString& theText)
746 {
747   myTypeParams->setText(theText);
748 }
749
750 //********************************************************************
751 void XGUI_InspectionPanel::buildFeaturePane(const FeaturePtr& theFeature)
752 {
753   std::string aXmlCfg, aDescription;
754   myWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
755   if (!aXmlCfg.empty()) {
756     QList<ModuleBase_ModelWidget*> aWidgets;
757     if (!myWorkshop->module()->createWidgets(theFeature, aXmlCfg.c_str(), aWidgets)) {
758       ModuleBase_WidgetFactory aFactory(aXmlCfg, myWorkshop->moduleConnector());
759       aFactory.createWidget(myFeaturePane);
760       aWidgets = aFactory.getModelWidgets();
761     }
762     foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
763       if (aWgt->isInformative()) {
764         aWgt->setFeature(theFeature, false, false);
765         aWgt->setReadOnly(true);
766         aWgt->setEditingMode(true);
767         aWgt->restoreValue();
768         aWgt->showInformativePage();
769       }
770       else {
771         aWgt->setFeature(theFeature, false, false);
772         aWgt->setEditingMode(true);
773         aWgt->hide();
774       }
775     }
776   }
777 }
778
779 void XGUI_InspectionPanel::showEvent(QShowEvent* theEvent)
780 {
781   QDockWidget::showEvent(theEvent);
782   onSelectionChanged();
783 }