1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "XGUI_InspectionPanel.h"
21 #include "XGUI_Workshop.h"
22 #include "XGUI_SelectionMgr.h"
23 #include "XGUI_Selection.h"
24 #include "XGUI_Tools.h"
25 #include "XGUI_ModuleConnector.h"
27 #include <ModuleBase_ViewerPrs.h>
28 #include <ModuleBase_Tools.h>
29 #include <ModuleBase_OperationDescription.h>
30 #include <ModuleBase_WidgetFactory.h>
31 #include <ModuleBase_IModule.h>
32 #include <ModuleBase_PageWidget.h>
34 #include <ModelAPI_ResultField.h>
36 #include <ModelAPI_Result.h>
38 #include <GeomAPI_Ax3.h>
39 #include <GeomAPI_Box.h>
40 #include <GeomAPI_Circ.h>
41 #include <GeomAPI_Cone.h>
42 #include <GeomAPI_Cylinder.h>
43 #include <GeomAPI_Edge.h>
44 #include <GeomAPI_Ellipse.h>
45 #include <GeomAPI_Face.h>
46 #include <GeomAPI_Pln.h>
47 #include <GeomAPI_Pnt.h>
48 #include <GeomAPI_Shell.h>
49 #include <GeomAPI_Solid.h>
50 #include <GeomAPI_Sphere.h>
51 #include <GeomAPI_Torus.h>
52 #include <GeomAPI_Vertex.h>
53 #include <GeomAPI_Wire.h>
56 #include <QScrollArea>
59 #include <QTableWidget>
60 #include <QHeaderView>
61 #include <QTextBrowser>
62 #include <QResizeEvent>
64 #include <QStackedWidget>
66 #include <BRepBndLib.hxx>
67 #include <TopoDS_Iterator.hxx>
68 #include <TopTools_MapOfShape.hxx>
69 #include <TopTools_ListOfShape.hxx>
70 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic
73 // ================ Auxiliary functions ================
74 #define TITLE(val) ("<b>" + (val) + "</b>")
76 static void appendPointToParameters(const QString& thePointTitle,
77 const GeomPointPtr& theCoord,
80 theParams += TITLE(thePointTitle) +
81 "<br> X: " + QString::number(theCoord->x()) +
82 "<br> Y: " + QString::number(theCoord->y()) +
83 "<br> Z: " + QString::number(theCoord->z()) +
87 static void appendDirToParameters(const QString& theDirTitle,
88 const GeomDirPtr& theDirection,
91 theParams += TITLE(theDirTitle) +
92 "<br> DX: " + QString::number(theDirection->x()) +
93 "<br> DY: " + QString::number(theDirection->y()) +
94 "<br> DZ: " + QString::number(theDirection->z()) +
98 static void appendGroupNameToParameters(const QString& theGroupTitle, QString& theParams)
100 theParams += TITLE(theGroupTitle) + "<br>";
103 static void appendNamedValueToParameters(const QString& theName,
104 const double theValue,
107 theParams += theName + ": " + QString::number(theValue) + "<br>";
110 static void appendNamedValueToParameters(const QString& theName,
114 theParams += theName + ": " + (theValue ? "True" : "False") + "<br>";
118 // ================ XGUI_InspectionPanel ================
120 XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_Workshop* theWorkshop)
121 : QDockWidget(theParent),
122 myWorkshop(theWorkshop)
124 setWindowTitle(tr("Inspection Panel"));
125 setObjectName(INSPECTION_PANEL);
126 setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
128 myStackWgt = new QStackedWidget(this);
130 // Create shape selection page
131 QSplitter* aSplitter = new QSplitter(Qt::Vertical, myStackWgt);
133 // Create an internal widget
134 QWidget* aNameWgt = new QWidget(aSplitter);
135 QHBoxLayout* aNameLayout = new QHBoxLayout(aNameWgt);
136 aNameLayout->setContentsMargins(3, 0, 3, 0);
137 aNameLayout->addWidget(new QLabel(tr("Object"), aNameWgt));
138 myNameEdt = new QLineEdit(aNameWgt);
139 myNameEdt->setReadOnly(true);
140 aNameLayout->addWidget(myNameEdt);
142 aSplitter->addWidget(aNameWgt);
144 // Table with sub-shapes
145 mySubShapesTab = new QTableWidget(9, 2, aSplitter);
146 mySubShapesTab->setFocusPolicy(Qt::NoFocus);
147 mySubShapesTab->verticalHeader()->hide();
149 aTitles << tr("Sub-shapes") << tr("Number");
150 mySubShapesTab->setHorizontalHeaderLabels(aTitles);
152 QStringList aSubShapes;
153 aSubShapes << tr("SHAPE") << tr("COMPOUND") << tr("COMPSOLID") <<
154 tr("SOLID") << tr("SHELL") << tr("FACE") << tr("WIRE") << tr("EDGE") << tr("VERTEX");
156 foreach(QString aType, aSubShapes) {
157 QTableWidgetItem* aItem = new QTableWidgetItem(aType);
158 aItem->setFlags(Qt::ItemIsEnabled);
159 mySubShapesTab->setItem(i++, 0, aItem);
161 for (i = 0; i < 9; i++) {
162 QTableWidgetItem* aItem = new QTableWidgetItem("");
163 aItem->setFlags(Qt::ItemIsEnabled);
164 aItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
165 mySubShapesTab->setItem(i, 1, aItem);
167 mySubShapesTab->setColumnWidth(0, 90);
168 mySubShapesTab->setColumnWidth(1, 70);
170 aSplitter->addWidget(mySubShapesTab);
173 QWidget* aTypeWgt = new QWidget(aSplitter);
174 QHBoxLayout* aTypeLayout = new QHBoxLayout(aTypeWgt);
175 aTypeLayout->setContentsMargins(3, 0, 3, 0);
177 aTypeLayout->addWidget(new QLabel(tr("Type:"), aTypeWgt));
178 myTypeLbl = new QLabel("", aTypeWgt);
179 aTypeLayout->addWidget(myTypeLbl);
181 aSplitter->addWidget(aTypeWgt);
183 myTypeParams = new QTextBrowser(aSplitter);
184 myTypeParams->setReadOnly(true);
185 myTypeParams->setFocusPolicy(Qt::NoFocus);
186 myTypeParams->viewport()->setBackgroundRole(QPalette::Window);
188 aSplitter->addWidget(myTypeParams);
190 aSplitter->setCollapsible(0, false);
191 aSplitter->setCollapsible(1, false);
192 aSplitter->setCollapsible(2, false);
193 aSplitter->setCollapsible(3, false);
196 aSizes << 10 << 140 << 10;
197 aSplitter->setSizes(aSizes);
199 myShapePanelId = myStackWgt->addWidget(aSplitter);
201 // Create feature selection page
202 QScrollArea* aScroll = new QScrollArea(myStackWgt);
203 aScroll->setWidgetResizable(true);
204 aScroll->setFrameStyle(QFrame::NoFrame);
206 myFeaturePane = new ModuleBase_PageWidget(aScroll);
207 myFeatureLayout = new QGridLayout(myFeaturePane);
208 myFeatureLayout->setContentsMargins(3, 3, 3, 3);
209 aScroll->setWidget(myFeaturePane);
210 //myFeaturePane->setEnabled(false);
212 myFeaturePanelId = myStackWgt->addWidget(aScroll);
214 setWidget(myStackWgt);
215 connect(myWorkshop->selector(), SIGNAL(selectionChanged()), SLOT(onSelectionChanged()));
218 //********************************************************************
219 XGUI_InspectionPanel::~XGUI_InspectionPanel()
223 //********************************************************************
224 void XGUI_InspectionPanel::setSubShapeValue(SudShape theId, int theVal)
226 mySubShapesTab->item(theId, 1)->setText(QString::number(theVal));
229 //********************************************************************
230 void XGUI_InspectionPanel::clearContent()
233 for (int i = 0; i <= VertexId; i++) {
234 mySubShapesTab->item((SudShape)i, 1)->setText("");
236 myTypeLbl->setText("");
239 myFeaturePane->clearPage();
242 //********************************************************************
243 void XGUI_InspectionPanel::onSelectionChanged()
250 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
251 QList<ModuleBase_ViewerPrsPtr> aSelectedList =
252 aSelection->getSelected(myWorkshop->selector()->placeOfSelection());
254 if (aSelectedList.count() > 0) {
255 ModuleBase_ViewerPrsPtr aPrs = aSelectedList.first();
257 std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aPrs->object());
260 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs->object());
261 if (aFeature.get()) {
262 myStackWgt->setCurrentIndex(myFeaturePanelId);
263 buildFeaturePane(aFeature);
266 myStackWgt->setCurrentIndex(myShapePanelId);
267 TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
268 if (aShape.IsNull()) {
269 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
271 GeomShapePtr aShpPtr = aRes->shape();
273 aShape = aShpPtr->impl<TopoDS_Shape>();
279 GeomShapePtr aShapePtr(new GeomAPI_Shape());
280 aShapePtr->setImpl(new TopoDS_Shape(aShape));
282 ModuleBase_ViewerPrsPtr aPrsCopy(new ModuleBase_ViewerPrs(aPrs->object(), aShapePtr));
283 setName(XGUI_Tools::generateName(aPrsCopy));
284 setShapeContent(aShape);
285 setShapeParams(aShape);
290 //********************************************************************
291 void XGUI_InspectionPanel::setName(const QString& theName)
293 myNameEdt->setText(theName);
296 //********************************************************************
297 void XGUI_InspectionPanel::setShapeContent(const TopoDS_Shape& theShape)
301 int iType, nbTypes[TopAbs_SHAPE];
302 for (iType = 0; iType < TopAbs_SHAPE; ++iType) {
305 nbTypes[theShape.ShapeType()]++;
307 TopTools_MapOfShape aMapOfShape;
308 aMapOfShape.Add(theShape);
309 TopTools_ListOfShape aListOfShape;
310 aListOfShape.Append(theShape);
312 TopTools_ListIteratorOfListOfShape itL(aListOfShape);
313 for (; itL.More(); itL.Next()) {
314 TopoDS_Shape sp = itL.Value();
315 TopoDS_Iterator it(sp);
316 for (; it.More(); it.Next()) {
317 TopoDS_Shape s = it.Value();
318 if (aMapOfShape.Add(s)) {
319 aListOfShape.Append(s);
320 nbTypes[s.ShapeType()]++;
324 setSubShapeValue(VertexId, nbTypes[TopAbs_VERTEX]);
325 setSubShapeValue(EdgeId, nbTypes[TopAbs_EDGE]);
326 setSubShapeValue(WireId, nbTypes[TopAbs_WIRE]);
327 setSubShapeValue(FaceId, nbTypes[TopAbs_FACE]);
328 setSubShapeValue(ShellId, nbTypes[TopAbs_SHELL]);
329 setSubShapeValue(SolidId, nbTypes[TopAbs_SOLID]);
330 setSubShapeValue(CompsolidId, nbTypes[TopAbs_COMPSOLID]);
331 setSubShapeValue(CompoundId, nbTypes[TopAbs_COMPOUND]);
332 setSubShapeValue(ShapeId, aMapOfShape.Extent());
334 catch (Standard_Failure) {
338 //********************************************************************
339 void XGUI_InspectionPanel::setShapeParams(const TopoDS_Shape& theShape)
341 GeomShapePtr aShape(new GeomAPI_Shape);
342 aShape->setImpl(new TopoDS_Shape(theShape));
344 switch (aShape->shapeType()) {
345 case GeomAPI_Shape::VERTEX:
346 fillVertex(aShape->vertex());
348 case GeomAPI_Shape::EDGE:
349 fillEdge(aShape->edge());
351 case GeomAPI_Shape::FACE:
352 fillFace(aShape->face());
354 case GeomAPI_Shape::SOLID:
355 fillSolid(aShape->solid());
357 case GeomAPI_Shape::WIRE:
358 fillWire(aShape->wire());
360 case GeomAPI_Shape::SHELL:
361 fillShell(aShape->shell());
363 case GeomAPI_Shape::COMPSOLID:
364 case GeomAPI_Shape::COMPOUND:
365 fillContainer(aShape);
370 //********************************************************************
371 void XGUI_InspectionPanel::fillVertex(const GeomVertexPtr& theVertex)
373 GeomPointPtr aPoint = theVertex->point();
375 myTypeLbl->setText(tr("Vertex"));
378 appendPointToParameters(tr("Coordinates"), aPoint, aParams);
379 setParamsText(aParams);
382 //********************************************************************
383 void XGUI_InspectionPanel::fillEdge(const GeomEdgePtr& theEdge)
386 if (theEdge->isDegenerated())
387 appendNamedValueToParameters(tr("Degenerated"), true, aParams);
389 GeomPointPtr aStartPnt = theEdge->firstPoint();
390 GeomPointPtr aEndPnt = theEdge->lastPoint();
391 bool addStartEndPoints = false;
393 if (theEdge->isLine()) {
394 myTypeLbl->setText(tr("Line segment"));
395 addStartEndPoints = true;
398 GeomCirclePtr aCircle = theEdge->circle();
400 addStartEndPoints = aStartPnt->distance(aEndPnt) >= Precision::Confusion();
401 if (addStartEndPoints)
402 myTypeLbl->setText("Arc of circle");
404 myTypeLbl->setText("Circle");
406 appendPointToParameters(tr("Center"), aCircle->center(), aParams);
407 appendDirToParameters(tr("Normal"), aCircle->normal(), aParams);
408 appendGroupNameToParameters(tr("Dimensions"), aParams);
409 appendNamedValueToParameters(tr("Radius"), aCircle->radius(), aParams);
412 GeomEllipsePtr anEllipse = theEdge->ellipse();
414 addStartEndPoints = aStartPnt->distance(aEndPnt) >= Precision::Confusion();
415 if (addStartEndPoints)
416 myTypeLbl->setText("Arc of ellipse");
418 myTypeLbl->setText("Ellipse");
420 appendPointToParameters(tr("Center"), anEllipse->center(), aParams);
421 appendDirToParameters(tr("Normal"), anEllipse->normal(), aParams);
422 appendGroupNameToParameters(tr("Dimensions"), aParams);
423 appendNamedValueToParameters(tr("Major radius"), anEllipse->majorRadius(), aParams);
424 appendNamedValueToParameters(tr("Minor radius"), anEllipse->minorRadius(), aParams);
428 myTypeLbl->setText(tr("Edge"));
432 if (addStartEndPoints) {
433 appendPointToParameters(tr("Start point"), aStartPnt, aParams);
434 appendPointToParameters(tr("End point"), aEndPnt, aParams);
436 setParamsText(aParams);
439 //********************************************************************
440 void XGUI_InspectionPanel::fillWire(const GeomWirePtr& theWire)
443 appendNamedValueToParameters(tr("Closed"), theWire->isClosed(), aParams);
445 // check the wire is a polygon
446 std::list<GeomPointPtr> aPolygonPoints;
447 if (theWire->isPolygon(aPolygonPoints)) {
448 myTypeLbl->setText(tr("Polygon"));
449 int aCornerIndex = 0;
450 for (std::list<GeomPointPtr>::const_iterator aPtIt = aPolygonPoints.begin();
451 aPtIt != aPolygonPoints.end(); ++aPtIt)
452 appendPointToParameters(tr("Point") + " " + QString::number(++aCornerIndex),
456 myTypeLbl->setText(tr("Wire"));
458 setParamsText(aParams);
461 //********************************************************************
462 void XGUI_InspectionPanel::fillFace(const GeomFacePtr& theFace)
465 // 1. Plane and planar faces
466 GeomPlanePtr aPlane = theFace->getPlane();
468 bool isCommonCase = true;
469 // Check face bounded by circle or ellipse
470 std::list<GeomShapePtr> aSubs = theFace->subShapes(GeomAPI_Shape::EDGE);
471 if (aSubs.size() == 1) {
472 GeomEdgePtr anEdge = aSubs.front()->edge();
473 if (anEdge->isCircle() || anEdge->isEllipse()) {
475 isCommonCase = false;
479 // Check face bounded by a single wire which is rectangle
480 aSubs = theFace->subShapes(GeomAPI_Shape::WIRE);
481 if (aSubs.size() == 1) {
482 GeomWirePtr aWire = aSubs.front()->wire();
483 std::list<GeomPointPtr> aCorners;
484 if (aWire->isRectangle(aCorners)) {
485 GeomPointPtr aBaseCorner = aCorners.front();
486 aCorners.pop_front();
488 double aWidth = aBaseCorner->distance(aCorners.front());
489 double aHeight = aBaseCorner->distance(aCorners.back());
491 myTypeLbl->setText(tr("Rectangle"));
492 appendPointToParameters(tr("Corner"), aBaseCorner, aParams);
493 appendDirToParameters(tr("Normal"), aPlane->direction(), aParams);
494 appendGroupNameToParameters(tr("Dimensions"), aParams);
495 appendNamedValueToParameters(tr("Width"), aWidth, aParams);
496 appendNamedValueToParameters(tr("Height"), aHeight, aParams);
497 setParamsText(aParams);
499 isCommonCase = false;
505 setPlaneType(tr("Plane"), aPlane);
509 GeomSpherePtr aSphere = theFace->getSphere();
511 setSphereType(tr("Sphere"), aSphere);
514 GeomCylinderPtr aCylinder = theFace->getCylinder();
516 setCylinderType(tr("Cylinder"), aCylinder);
519 GeomConePtr aCone = theFace->getCone();
521 setConeType(tr("Cone"), aCone);
524 GeomTorusPtr aTorus = theFace->getTorus();
526 setTorusType(tr("Torus"), aTorus);
529 myTypeLbl->setText(tr("Face"));
536 //********************************************************************
537 void XGUI_InspectionPanel::fillShell(const GeomShellPtr& theShell)
540 GeomSpherePtr aSphere = theShell->getSphere();
542 setSphereType(tr("Sphere"), aSphere);
545 GeomCylinderPtr aCylinder = theShell->getCylinder();
547 setCylinderType(tr("Cylinder"), aCylinder);
550 GeomConePtr aCone = theShell->getCone();
552 setConeType(tr("Cone"), aCone);
555 GeomTorusPtr aTorus = theShell->getTorus();
557 setTorusType(tr("Torus"), aTorus);
559 // 5. Axis-aligned/Rotated Box
560 GeomBoxPtr aBox = theShell->getParallelepiped();
562 if (aBox->isAxesAligned())
563 setBoxType(tr("Box"), aBox);
565 setRotatedBoxType(tr("Rotated Box"), aBox);
569 myTypeLbl->setText(tr("Shell"));
576 //********************************************************************
577 void XGUI_InspectionPanel::fillSolid(const GeomSolidPtr& theSolid)
580 GeomSpherePtr aSphere = theSolid->getSphere();
582 setSphereType(tr("Sphere"), aSphere);
585 GeomCylinderPtr aCylinder = theSolid->getCylinder();
587 setCylinderType(tr("Cylinder"), aCylinder);
590 GeomConePtr aCone = theSolid->getCone();
592 setConeType(tr("Cone"), aCone);
595 GeomTorusPtr aTorus = theSolid->getTorus();
597 setTorusType(tr("Torus"), aTorus);
599 // 5. Axis-aligned/Rotated Box
600 GeomBoxPtr aBox = theSolid->getParallelepiped();
602 if (aBox->isAxesAligned())
603 setBoxType(tr("Box"), aBox);
605 setRotatedBoxType(tr("Rotated Box"), aBox);
609 myTypeLbl->setText(tr("Solid"));
616 //********************************************************************
617 void XGUI_InspectionPanel::fillContainer(const GeomShapePtr& theShape)
619 if (theShape->shapeType() == GeomAPI_Shape::COMPSOLID)
620 myTypeLbl->setText("CompSolid");
621 else if (theShape->shapeType() == GeomAPI_Shape::COMPOUND)
622 myTypeLbl->setText("Compound");
625 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
627 BRepBndLib::Add(aShape, aBB);
632 gp_Pnt aMinPnt = aBB.CornerMin();
633 GeomPointPtr aMinPoint(new GeomAPI_Pnt(aMinPnt.X(), aMinPnt.Y(), aMinPnt.Z()));
635 gp_Pnt aMaxPnt = aBB.CornerMax();
636 GeomPointPtr aMaxPoint(new GeomAPI_Pnt(aMaxPnt.X(), aMaxPnt.Y(), aMaxPnt.Z()));
639 appendGroupNameToParameters(tr("Bounding box"), aParams);
640 appendPointToParameters(tr("Minimal corner"), aMinPoint, aParams);
641 appendPointToParameters(tr("Maximal corner"), aMaxPoint, aParams);
644 //********************************************************************
645 void XGUI_InspectionPanel::setPlaneType(const QString& theTitle,
646 const std::shared_ptr<GeomAPI_Pln>& thePlane)
648 myTypeLbl->setText(theTitle);
650 appendPointToParameters(tr("Origin"), thePlane->location(), aParams);
651 appendDirToParameters(tr("Normal"), thePlane->direction(), aParams);
652 setParamsText(aParams);
655 //********************************************************************
656 void XGUI_InspectionPanel::setSphereType(const QString& theTitle,
657 const std::shared_ptr<GeomAPI_Sphere>& theSphere)
659 myTypeLbl->setText(theTitle);
661 appendPointToParameters(tr("Center"), theSphere->center(), aParams);
662 appendGroupNameToParameters(tr("Dimensions"), aParams);
663 appendNamedValueToParameters(tr("Radius"), theSphere->radius(), aParams);
664 setParamsText(aParams);
667 //********************************************************************
668 void XGUI_InspectionPanel::setCylinderType(const QString& theTitle,
669 const std::shared_ptr<GeomAPI_Cylinder>& theCyl)
671 myTypeLbl->setText(theTitle);
673 appendPointToParameters(tr("Position"), theCyl->location(), aParams);
674 appendDirToParameters(tr("Axis"), theCyl->axis(), aParams);
675 appendGroupNameToParameters(tr("Dimensions"), aParams);
676 appendNamedValueToParameters(tr("Radius"), theCyl->radius(), aParams);
677 appendNamedValueToParameters(tr("Height"), theCyl->height(), aParams);
678 setParamsText(aParams);
681 //********************************************************************
682 void XGUI_InspectionPanel::setConeType(const QString& theTitle,
683 const std::shared_ptr<GeomAPI_Cone>& theCone)
685 myTypeLbl->setText(theTitle);
687 appendPointToParameters(tr("Position"), theCone->location(), aParams);
688 appendDirToParameters(tr("Axis"), theCone->axis(), aParams);
689 appendGroupNameToParameters(tr("Dimensions"), aParams);
690 appendNamedValueToParameters(tr("Radius 1"), theCone->radius1(), aParams);
691 appendNamedValueToParameters(tr("Radius 2"), theCone->radius2(), aParams);
692 appendNamedValueToParameters(tr("Height"), theCone->height(), aParams);
693 setParamsText(aParams);
696 //********************************************************************
697 void XGUI_InspectionPanel::setTorusType(const QString& theTitle,
698 const std::shared_ptr<GeomAPI_Torus>& theTorus)
700 myTypeLbl->setText(theTitle);
702 appendPointToParameters(tr("Center"), theTorus->center(), aParams);
703 appendDirToParameters(tr("Axis"), theTorus->direction(), aParams);
704 appendGroupNameToParameters(tr("Dimensions"), aParams);
705 appendNamedValueToParameters(tr("Major radius"), theTorus->majorRadius(), aParams);
706 appendNamedValueToParameters(tr("Minor radius"), theTorus->minorRadius(), aParams);
707 setParamsText(aParams);
710 //********************************************************************
711 void XGUI_InspectionPanel::setBoxType(const QString& theTitle,
712 const std::shared_ptr<GeomAPI_Box>& theBox)
714 myTypeLbl->setText(theTitle);
716 appendPointToParameters(tr("Position"), theBox->axes()->origin(), aParams);
717 appendGroupNameToParameters(tr("Dimensions"), aParams);
718 appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
719 appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
720 appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
721 setParamsText(aParams);
724 //********************************************************************
725 void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle,
726 const std::shared_ptr<GeomAPI_Box>& theBox)
728 myTypeLbl->setText(theTitle);
730 std::shared_ptr<GeomAPI_Ax3> anAxes = theBox->axes();
731 appendPointToParameters(tr("Position"), anAxes->origin(), aParams);
732 appendDirToParameters(tr("Z axis"), anAxes->normal(), aParams);
733 appendDirToParameters(tr("X axis"), anAxes->dirX(), aParams);
734 appendGroupNameToParameters(tr("Dimensions"), aParams);
735 appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
736 appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
737 appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
738 setParamsText(aParams);
742 //********************************************************************
743 void XGUI_InspectionPanel::setParamsText(const QString& theText)
745 myTypeParams->setText(theText);
748 //********************************************************************
749 void XGUI_InspectionPanel::buildFeaturePane(const FeaturePtr& theFeature)
751 std::string aXmlCfg, aDescription;
752 myWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
753 if (!aXmlCfg.empty()) {
754 QList<ModuleBase_ModelWidget*> aWidgets;
755 if (!myWorkshop->module()->createWidgets(theFeature, aXmlCfg.c_str(), aWidgets)) {
756 ModuleBase_WidgetFactory aFactory(aXmlCfg, myWorkshop->moduleConnector());
757 aFactory.createWidget(myFeaturePane);
758 aWidgets = aFactory.getModelWidgets();
760 foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
761 if (aWgt->isInformative()) {
762 aWgt->setFeature(theFeature, false, false);
763 aWgt->setReadOnly(true);
764 aWgt->setEditingMode(true);
765 aWgt->restoreValue();
766 aWgt->showInformativePage();
769 aWgt->setFeature(theFeature, false, false);
770 aWgt->setEditingMode(true);
777 void XGUI_InspectionPanel::showEvent(QShowEvent* theEvent)
779 QDockWidget::showEvent(theEvent);
780 onSelectionChanged();