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