From: vsv Date: Mon, 9 Jul 2018 16:56:04 +0000 (+0300) Subject: Issue #2556: "What is" window X-Git-Tag: SHAPER_V9_1_0RC1~140 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e3f085c91aeb28d45269c769d17f88e13d6a360;p=modules%2Fshaper.git Issue #2556: "What is" window --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 1352b9049..73d877e8d 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -1270,6 +1270,31 @@ FeaturePtr findParameter(const QString& theName) } +//******************************************************************** +std::string generateName(const AttributePtr& theAttribute, + ModuleBase_IWorkshop* theWorkshop) +{ + std::string aName; + if (theAttribute.get() != NULL) { + ModuleBase_Operation* anOperation = theWorkshop->currentOperation(); + + FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); + if (aFeature.get()) { + std::string aXmlCfg, aDescription; + theWorkshop->module()->getXMLRepresentation(aFeature->getKind(), aXmlCfg, aDescription); + + ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop); + std::string anAttributeTitle; + aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle); + + std::stringstream aStreamName; + aStreamName << theAttribute->owner()->data()->name() << "/" << anAttributeTitle.c_str(); + aName = aStreamName.str(); + } + } + return aName; +} + } // namespace ModuleBase_Tools diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 4570f3fe6..6dd1e0985 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -380,6 +380,16 @@ bool MODULEBASE_EXPORT isNameExist(const QString& theName, FeaturePtr theIgnoreP /// Find parameter by its name /// \theName a name of parameter FeaturePtr MODULEBASE_EXPORT findParameter(const QString& theName); + + +//----------- Class members ------------- +/// Returns a name in the next form: attribute_feature_name/attribute_id +/// \param theAttribute a model attribute +/// \param theWorkshop a workshop class instance +/// \return string value +std::string MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute, + ModuleBase_IWorkshop* theWorkshop); + } #endif diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 44b11938f..d2e98f068 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -697,7 +697,7 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList() AttributePtr anAttribute = aRefAttrListAttr->attribute(i); QString aName; if (anAttribute.get()) { - std::string anAttrName = generateName(anAttribute, myWorkshop); + std::string anAttrName = ModuleBase_Tools::generateName(anAttribute, myWorkshop); aName = QString::fromStdString(anAttrName); } else { diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 665c9e56b..3d4afc9a1 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -247,28 +247,3 @@ void ModuleBase_WidgetSelector::deactivate() aSelectAttr->removeTemporaryValues(); } } - -//******************************************************************** -std::string ModuleBase_WidgetSelector::generateName(const AttributePtr& theAttribute, - ModuleBase_IWorkshop* theWorkshop) -{ - std::string aName; - if (theAttribute.get() != NULL) { - ModuleBase_Operation* anOperation = theWorkshop->currentOperation(); - - FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); - if (aFeature.get()) { - std::string aXmlCfg, aDescription; - theWorkshop->module()->getXMLRepresentation(aFeature->getKind(), aXmlCfg, aDescription); - - ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop); - std::string anAttributeTitle; - aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle); - - std::stringstream aStreamName; - aStreamName << theAttribute->owner()->data()->name() << "/"<< anAttributeTitle.c_str(); - aName = aStreamName.str(); - } - } - return aName; -} diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 6e798f80e..ffc9ff1f5 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -126,14 +126,6 @@ protected: ObjectPtr& theObject, GeomShapePtr& theShape); - //----------- Class members ------------- - /// Returns a name in the next form: attribute_feature_name/attribute_id - /// \param theAttribute a model attribute - /// \param theWorkshop a workshop class instance - /// \return string value - static std::string generateName(const AttributePtr& theAttribute, - ModuleBase_IWorkshop* theWorkshop); - protected: bool myIsPointsFiltering; }; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index c0f8bd0dc..f3a2fb50c 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -229,7 +229,7 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); if (aRefAttr && aRefAttr->attr().get() != NULL) { //myIsObject = aRefAttr->isObject(); - std::string anAttrName = generateName(aRefAttr->attr(), myWorkshop); + std::string anAttrName = ModuleBase_Tools::generateName(aRefAttr->attr(), myWorkshop); myTextLine->setText(QString::fromStdString(anAttrName)); } else { diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index 729c96761..2a1624da8 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -232,7 +232,7 @@ void XGUI_FacesPanel::processSelection() aPrs->interactive()); if (aResultPrs.IsNull()) continue; - QString aItemName = generateName(aPrs); + QString aItemName = XGUI_Tools::generateName(aPrs); if (myListView->hasItem(aItemName)) return; @@ -425,31 +425,6 @@ void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent) emit closed(); } -//******************************************************************** -QString XGUI_FacesPanel::generateName(const ModuleBase_ViewerPrsPtr& thePrs) -{ - if (!thePrs.get() || !thePrs->object().get()) - return "Undefined"; - - GeomShapePtr aContext; - ObjectPtr anObject = thePrs->object(); - ResultPtr aResult = std::dynamic_pointer_cast(anObject); - if (aResult.get()) - aContext = aResult->shape(); - else { - // TODO if there is this case - } - - QString aName = anObject->data()->name().c_str(); - if (aContext.get()) { - GeomShapePtr aSubShape(new GeomAPI_Shape()); - aSubShape->setImpl(new TopoDS_Shape(ModuleBase_Tools::getSelectedShape(thePrs))); - if (!aSubShape->isEqual(aContext)) - aName += QString("_%1").arg(GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape)); - } - return aName; -} - //******************************************************************** bool XGUI_FacesPanel::customizeObject(const ObjectPtr& theObject, const AISObjectPtr& thePresentation) diff --git a/src/XGUI/XGUI_FacesPanel.h b/src/XGUI/XGUI_FacesPanel.h index 567fa8e13..be9b5ab02 100644 --- a/src/XGUI/XGUI_FacesPanel.h +++ b/src/XGUI/XGUI_FacesPanel.h @@ -171,11 +171,6 @@ private: static void updateProcessedObjects(QMap > theItems, std::set >& theObjects); - /// Generates a presentation name in form: /_ - /// \param thePrs a presentation - /// \return string value - static QString generateName(const std::shared_ptr& thePrs); - protected slots: /// Deletes element in list of items void onDeleteItem(); diff --git a/src/XGUI/XGUI_InspectionPanel.cpp b/src/XGUI/XGUI_InspectionPanel.cpp index b89334e9b..a74e2b8b0 100644 --- a/src/XGUI/XGUI_InspectionPanel.cpp +++ b/src/XGUI/XGUI_InspectionPanel.cpp @@ -21,6 +21,12 @@ #include "XGUI_InspectionPanel.h" #include "XGUI_SelectionMgr.h" #include "XGUI_Selection.h" +#include "XGUI_Tools.h" + +#include +#include + +#include #include #include @@ -30,6 +36,20 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // CAREFUL ! position of this file is critic + XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr) : QDockWidget(theParent), mySelectionMgr(theMgr) @@ -75,7 +95,7 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr mySubShapesTab->setItem(i++, 0, aItem); } for (i = 0; i < 9; i++) { - QTableWidgetItem* aItem = new QTableWidgetItem("0"); + QTableWidgetItem* aItem = new QTableWidgetItem(""); aItem->setFlags(Qt::ItemIsEnabled); aItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); mySubShapesTab->setItem(i, 1, aItem); @@ -94,7 +114,7 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr aTypeLayout->setContentsMargins(0, 0, 0, 0); aTypeLayout->addWidget(new QLabel(tr("Type:"), aTypeWgt)); - myTypeLbl = new QLabel("No-type", aTypeWgt); + myTypeLbl = new QLabel("", aTypeWgt); aTypeLayout->addWidget(myTypeLbl); aMainLayout->addWidget(aTypeWgt); @@ -112,34 +132,200 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr aScrollArea->setWidget(aMainWidget); connect(mySelectionMgr, SIGNAL(selectionChanged()), SLOT(onSelectionChanged())); - - // Test - setVertexType(0, 0, 0); } +//******************************************************************** XGUI_InspectionPanel::~XGUI_InspectionPanel() { } +//******************************************************************** void XGUI_InspectionPanel::setSubShapeValue(SudShape theId, int theVal) { mySubShapesTab->item(theId, 1)->setText(QString::number(theVal)); } +//******************************************************************** +void XGUI_InspectionPanel::clearContent() +{ + setName(""); + for (int i = 0; i <= VertexId; i++) { + mySubShapesTab->item((SudShape)i, 1)->setText(""); + } + myTypeLbl->setText(""); + myTypeParams->setText(""); +} + +//******************************************************************** void XGUI_InspectionPanel::onSelectionChanged() { - QObjectPtrList aObjects = mySelectionMgr->selection()->selectedObjects(); - if (aObjects.count() > 0) { - ObjectPtr aObj = aObjects.first(); - setName(aObj->data()->name().c_str()); + clearContent(); + XGUI_Selection* aSelection = mySelectionMgr->selection(); + QList aSelectedList = aSelection->getSelected(ModuleBase_ISelection::Viewer); + if (aSelectedList.count() > 0) { + ModuleBase_ViewerPrsPtr aPrs = aSelectedList.first(); + setName(XGUI_Tools::generateName(aPrs)); + + TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs); + setShapeContent(aShape); + setShapeParams(aShape); } } +//******************************************************************** void XGUI_InspectionPanel::setName(const QString& theName) { myNameEdt->setText(theName); } +//******************************************************************** +void XGUI_InspectionPanel::setShapeContent(const TopoDS_Shape& theShape) +{ + try { + OCC_CATCH_SIGNALS; + int iType, nbTypes[TopAbs_SHAPE]; + for (iType = 0; iType < TopAbs_SHAPE; ++iType) { + nbTypes[iType] = 0; + } + nbTypes[theShape.ShapeType()]++; + + TopTools_MapOfShape aMapOfShape; + aMapOfShape.Add(theShape); + TopTools_ListOfShape aListOfShape; + aListOfShape.Append(theShape); + + TopTools_ListIteratorOfListOfShape itL(aListOfShape); + for (; itL.More(); itL.Next()) { + TopoDS_Shape sp = itL.Value(); + TopoDS_Iterator it(sp); + for (; it.More(); it.Next()) { + TopoDS_Shape s = it.Value(); + if (aMapOfShape.Add(s)) { + aListOfShape.Append(s); + nbTypes[s.ShapeType()]++; + } + } + } + setSubShapeValue(VertexId, nbTypes[TopAbs_VERTEX]); + setSubShapeValue(EdgeId, nbTypes[TopAbs_EDGE]); + setSubShapeValue(WireId, nbTypes[TopAbs_WIRE]); + setSubShapeValue(FaceId, nbTypes[TopAbs_FACE]); + setSubShapeValue(ShellId, nbTypes[TopAbs_SHELL]); + setSubShapeValue(SolidId, nbTypes[TopAbs_SOLID]); + setSubShapeValue(CompsolidId, nbTypes[TopAbs_COMPSOLID]); + setSubShapeValue(CompoundId, nbTypes[TopAbs_COMPOUND]); + setSubShapeValue(ShapeId, aMapOfShape.Extent()); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + //SetErrorCode(aFail->GetMessageString()); + } +} + +//******************************************************************** +void XGUI_InspectionPanel::setShapeParams(const TopoDS_Shape& theShape) +{ + switch (theShape.ShapeType()) { + case TopAbs_VERTEX: + fillVertex(theShape); + break; + case TopAbs_EDGE: + fillEdge(theShape); + break; + case TopAbs_FACE: + fillFace(theShape); + break; + case TopAbs_SOLID: + fillSolid(theShape); + break; + case TopAbs_WIRE: + case TopAbs_SHELL: + case TopAbs_COMPSOLID: + case TopAbs_COMPOUND: + fillContainer(theShape); + break; + } +} + +//******************************************************************** +void XGUI_InspectionPanel::fillVertex(const TopoDS_Shape& theShape) +{ + TopoDS_Vertex aV = TopoDS::Vertex(theShape); + gp_Pnt aP = BRep_Tool::Pnt(aV); + setVertexType(aP.XYZ()); +} + +//******************************************************************** +void XGUI_InspectionPanel::fillEdge(const TopoDS_Shape& theShape) +{ + TopoDS_Edge aE = TopoDS::Edge(theShape); + + bool bDegenerated = BRep_Tool::Degenerated(aE); + + double aT1, aT2; + Handle(Geom_Curve) aC3D = BRep_Tool::Curve(aE, aT1, aT2); + GeomAdaptor_Curve aGAC(aC3D); + GeomAbs_CurveType aCT = aGAC.GetType(); + + if (aCT == GeomAbs_Line) { // Line + gp_Pnt aP1, aP2; + aGAC.D0(aT1, aP1); + aGAC.D0(aT2, aP2); + setLineType(aP1.XYZ(), aP2.XYZ()); + + } else if (aCT == GeomAbs_Circle) { + gp_Circ aCirc = aGAC.Circle(); + gp_Pnt aP = aCirc.Location(); + gp_Ax2 aAx2 = aCirc.Position(); + double aR1 = aCirc.Radius(); + gp_Dir aDir = aAx2.Axis().Direction(); + + bool isArc = (Abs(aT2 - aT1 - aC3D->Period()) >= Precision::PConfusion()); + if (isArc) { + gp_Pnt aP1, aP2; + aGAC.D0(aT1, aP1); + aGAC.D0(aT2, aP2); + setArcType(aP.XYZ(), aDir.XYZ(), aR1, aP1.XYZ(), aP2.XYZ()); + } else + setCircleType(aP.XYZ(), aDir.XYZ(), aR1); + + } else if (aCT == GeomAbs_Ellipse) { + gp_Elips aElips = aGAC.Ellipse(); + gp_Pnt aP = aElips.Location(); + gp_Ax2 aAx2 = aElips.Position(); + double aR1 = aElips.MajorRadius(); + double aR2 = aElips.MinorRadius(); + gp_Dir aDir = aAx2.Axis().Direction(); + gp_Pnt aP1, aP2; + aGAC.D0(aT1, aP1); + aGAC.D0(aT2, aP2); + bool isArc = aP1.Distance(aP2) > Precision::Confusion(); + if (isArc) + setEllipseArcType(aP.XYZ(), aDir.XYZ(), aR1, aR2, aP1.XYZ(), aP2.XYZ()); + else + setEllipseType(aP.XYZ(), aDir.XYZ(), aR1, aR2); + } +} + +//******************************************************************** +void XGUI_InspectionPanel::fillFace(const TopoDS_Shape& theShape) +{ + +} + +//******************************************************************** +void XGUI_InspectionPanel::fillSolid(const TopoDS_Shape& theShape) +{ + +} + +//******************************************************************** +void XGUI_InspectionPanel::fillContainer(const TopoDS_Shape& theShape) +{ + +} + +//******************************************************************** #define TITLE(val) ("" + val + "") void XGUI_InspectionPanel::setCylinderType(double theX, double theY, double theZ, @@ -161,6 +347,7 @@ void XGUI_InspectionPanel::setCylinderType(double theX, double theY, double theZ myTypeParams->setText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setSphereType(double theX, double theY, double theZ, double theRadius) { myTypeLbl->setText(tr("Sphere")); @@ -173,6 +360,7 @@ void XGUI_InspectionPanel::setSphereType(double theX, double theY, double theZ, myTypeParams->setText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setBoxType(double theX, double theY, double theZ, double theXsize, double theYsize, double theZsize) { @@ -188,7 +376,7 @@ void XGUI_InspectionPanel::setBoxType(double theX, double theY, double theZ, myTypeParams->setText(aParams); } - +//******************************************************************** void XGUI_InspectionPanel::setRotatedBoxType(double theX, double theY, double theZ, double theZaxisX, double theZaxisY, double theZaxisZ, double theXaxisX, double theXaxisY, double theXaxisZ, @@ -214,6 +402,7 @@ void XGUI_InspectionPanel::setRotatedBoxType(double theX, double theY, double th myTypeParams->setText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setPlaneType(double theX, double theY, double theZ, double theDX, double theDY, double theDZ) { @@ -229,12 +418,117 @@ void XGUI_InspectionPanel::setPlaneType(double theX, double theY, double theZ, myTypeParams->setText(aParams); } -void XGUI_InspectionPanel::setVertexType(double theX, double theY, double theZ) +//******************************************************************** +void XGUI_InspectionPanel::setVertexType(const gp_XYZ& theLoc) { myTypeLbl->setText(tr("Vertex")); QString aParams = TITLE(tr("Coordinates")) + - "
X: " + QString::number(theX) + - "
Y: " + QString::number(theY) + - "
Z: " + QString::number(theZ); + "
X: " + QString::number(theLoc.X()) + + "
Y: " + QString::number(theLoc.Y()) + + "
Z: " + QString::number(theLoc.Z()); + myTypeParams->setText(aParams); +} + +//******************************************************************** +void XGUI_InspectionPanel::setCircleType(const gp_XYZ& theLoc, const gp_XYZ& theDir, + double theRadius) +{ + myTypeLbl->setText(tr("Circle")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theLoc.X()) + + "
Y: " + QString::number(theLoc.Y()) + + "
Z: " + QString::number(theLoc.Z()) + + "
" + TITLE(tr("Normal")) + + "
DX: " + QString::number(theDir.X()) + + "
DY: " + QString::number(theDir.Y()) + + "
DZ: " + QString::number(theDir.Z()) + + "
" + TITLE(tr("Dimensions")) + + "
" + tr("Radius:") + QString::number(theRadius); myTypeParams->setText(aParams); -} \ No newline at end of file +} + +//******************************************************************** +void XGUI_InspectionPanel::setArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir, + double theRadius, const gp_XYZ& theP1, const gp_XYZ& theP2) +{ + myTypeLbl->setText(tr("Arc")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theLoc.X()) + + "
Y: " + QString::number(theLoc.Y()) + + "
Z: " + QString::number(theLoc.Z()) + + "
" + TITLE(tr("Normal")) + + "
DX: " + QString::number(theDir.X()) + + "
DY: " + QString::number(theDir.Y()) + + "
DZ: " + QString::number(theDir.Z()) + + "
" + TITLE(tr("Dimensions")) + + "
" + tr("Radius:") + QString::number(theRadius) + + "
" + TITLE(tr("Point 1")) + + "
X: " + QString::number(theP1.X()) + + "
Y: " + QString::number(theP1.Y()) + + "
Z: " + QString::number(theP1.Z()) + + "
" + TITLE(tr("Point 2")) + + "
X: " + QString::number(theP2.X()) + + "
Y: " + QString::number(theP2.Y()) + + "
Z: " + QString::number(theP2.Z()); + myTypeParams->setText(aParams); +} + +//******************************************************************** +void XGUI_InspectionPanel::setEllipseType(const gp_XYZ& theLoc, const gp_XYZ& theDir, + double theMajorRad, double theMinorRad) +{ + myTypeLbl->setText(tr("Ellipse")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theLoc.X()) + + "
Y: " + QString::number(theLoc.Y()) + + "
Z: " + QString::number(theLoc.Z()) + + "
" + TITLE(tr("Normal")) + + "
DX: " + QString::number(theDir.X()) + + "
DY: " + QString::number(theDir.Y()) + + "
DZ: " + QString::number(theDir.Z()) + + "
" + TITLE(tr("Dimensions")) + + "
" + tr("Major radius:") + QString::number(theMajorRad) + + "
" + tr("Minor radius:") + QString::number(theMinorRad); + myTypeParams->setText(aParams); +} + +//******************************************************************** +void XGUI_InspectionPanel::setEllipseArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir, + double theMajorRad, double theMinorRad, const gp_XYZ& theP1, const gp_XYZ& theP2) +{ + myTypeLbl->setText(tr("Elliptical arc")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theLoc.X()) + + "
Y: " + QString::number(theLoc.Y()) + + "
Z: " + QString::number(theLoc.Z()) + + "
" + TITLE(tr("Normal")) + + "
DX: " + QString::number(theDir.X()) + + "
DY: " + QString::number(theDir.Y()) + + "
DZ: " + QString::number(theDir.Z()) + + "
" + TITLE(tr("Dimensions")) + + "
" + tr("Major radius:") + QString::number(theMajorRad) + + "
" + tr("Minor radius:") + QString::number(theMinorRad) + + "
" + TITLE(tr("Point 1")) + + "
X: " + QString::number(theP1.X()) + + "
Y: " + QString::number(theP1.Y()) + + "
Z: " + QString::number(theP1.Z()) + + "
" + TITLE(tr("Point 2")) + + "
X: " + QString::number(theP2.X()) + + "
Y: " + QString::number(theP2.Y()) + + "
Z: " + QString::number(theP2.Z()); + myTypeParams->setText(aParams); +} + +void XGUI_InspectionPanel::setLineType(const gp_XYZ& theP1, const gp_XYZ& theP2) +{ + myTypeLbl->setText(tr("Line")); + QString aParams = TITLE(tr("Point 1")) + + "
X: " + QString::number(theP1.X()) + + "
Y: " + QString::number(theP1.Y()) + + "
Z: " + QString::number(theP1.Z()) + + "
" + TITLE(tr("Point 2")) + + "
X: " + QString::number(theP2.X()) + + "
Y: " + QString::number(theP2.Y()) + + "
Z: " + QString::number(theP2.Z()); + myTypeParams->setText(aParams); +} diff --git a/src/XGUI/XGUI_InspectionPanel.h b/src/XGUI/XGUI_InspectionPanel.h index 27ea2a8b2..014581a17 100644 --- a/src/XGUI/XGUI_InspectionPanel.h +++ b/src/XGUI/XGUI_InspectionPanel.h @@ -23,6 +23,8 @@ #include "XGUI.h" +#include + #include class XGUI_SelectionMgr; @@ -57,6 +59,10 @@ public: virtual ~XGUI_InspectionPanel(); +private slots: + void onSelectionChanged(); + +private: void setSubShapeValue(SudShape theId, int theVal); void setName(const QString& theName); @@ -78,10 +84,36 @@ public: void setPlaneType(double theX, double theY, double theZ, double theDX, double theDY, double theDZ); - void setVertexType(double theX, double theY, double theZ); + void setVertexType(const gp_XYZ& theLoc); -private slots: - void onSelectionChanged(); + void setCircleType(const gp_XYZ& theLoc, const gp_XYZ& theDir, double theRadius); + + void setArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir, double theRadius, + const gp_XYZ& theP1, const gp_XYZ& theP2); + + void setEllipseType(const gp_XYZ& theLoc, const gp_XYZ& theDir, + double theMajorRad, double theMinorRad); + + void setEllipseArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir, + double theMajorRad, double theMinorRad, const gp_XYZ& theP1, const gp_XYZ& theP2); + + void setLineType(const gp_XYZ& theP1, const gp_XYZ& theP2); + + void setShapeContent(const TopoDS_Shape& theShape); + + void setShapeParams(const TopoDS_Shape& theShape); + + void clearContent(); + + void fillVertex(const TopoDS_Shape& theShape); + + void fillEdge(const TopoDS_Shape& theShape); + + void fillFace(const TopoDS_Shape& theShape); + + void fillSolid(const TopoDS_Shape& theShape); + + void fillContainer(const TopoDS_Shape& theShape); private: XGUI_SelectionMgr* mySelectionMgr; diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index b52be827e..e5bc7a308 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -39,6 +39,9 @@ #include #include +#include + +#include #include #include @@ -172,4 +175,63 @@ XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop) return aConnector ? aConnector->workshop() : 0; } + +//******************************************************************** +QString generateName(const ModuleBase_ViewerPrsPtr& thePrs) +{ + if (!thePrs.get() || !thePrs->object().get()) + return "Undefined"; + + GeomShapePtr aContext; + ObjectPtr anObject = thePrs->object(); + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + if (aResult.get()) + aContext = aResult->shape(); + else { + // TODO if there is this case + } + + QString aName = anObject->data()->name().c_str(); + if (aContext.get()) { + GeomShapePtr aSubShape(new GeomAPI_Shape()); + TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(thePrs); + aSubShape->setImpl(new TopoDS_Shape(aShape)); + if (!aSubShape->isEqual(aContext)) { + QString aTypeName; + switch (aShape.ShapeType()) { + case TopAbs_COMPOUND: + aTypeName = "compound"; + break; + case TopAbs_COMPSOLID: + aTypeName = "compsolid"; + break; + case TopAbs_SOLID: + aTypeName = "solid"; + break; + case TopAbs_SHELL: + aTypeName = "shell"; + break; + case TopAbs_FACE: + aTypeName = "face"; + break; + case TopAbs_WIRE: + aTypeName = "wire"; + break; + case TopAbs_EDGE: + aTypeName = "edge"; + break; + case TopAbs_VERTEX: + aTypeName = "vertex"; + break; + case TopAbs_SHAPE: + aTypeName = "shape"; + break; + } + int aId = GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape); + aName += QString("/%1_%2").arg(aTypeName).arg(aId); + } + } + return aName; +} + } diff --git a/src/XGUI/XGUI_Tools.h b/src/XGUI/XGUI_Tools.h index 4a16a357c..b6ede361b 100644 --- a/src/XGUI/XGUI_Tools.h +++ b/src/XGUI/XGUI_Tools.h @@ -26,6 +26,7 @@ #include #include +#include #include @@ -116,6 +117,11 @@ bool canRename(const ObjectPtr& theObject, const QString& theName); */ XGUI_EXPORT XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop); + +/// Generates a presentation name in form: /_ +/// \param thePrs a presentation +/// \return string value +XGUI_EXPORT QString generateName(const std::shared_ptr& thePrs); }; #endif