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