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