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