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