]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2556: "What is" window
authorvsv <vsv@opencascade.com>
Mon, 9 Jul 2018 16:56:04 +0000 (19:56 +0300)
committervsv <vsv@opencascade.com>
Mon, 9 Jul 2018 16:56:22 +0000 (19:56 +0300)
12 files changed:
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_FacesPanel.h
src/XGUI/XGUI_InspectionPanel.cpp
src/XGUI/XGUI_InspectionPanel.h
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Tools.h

index 1352b904909337034a452669277cd8815aa005a8..73d877e8d914c6171e983f7fbeef0616412374aa 100755 (executable)
@@ -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
 
 
index 4570f3fe64f4aa12ee07d85d70a537919c854295..6dd1e0985d96d4508da53cdcca7182d592d38eb9 100755 (executable)
@@ -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
index 44b11938f331a0a4a3e4d4cf2bbab89c1ae8cc94..d2e98f0683088ad3d016b1bec3ab4dfab6509e87 100755 (executable)
@@ -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 {
index 665c9e56befda9c91613a5d48d0b6d6811126be6..3d4afc9a18ac56b24f7d825b896b20a18fa20606 100755 (executable)
@@ -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;
-}
index 6e798f80ec4b11059ffe310e17a7c9603ced9b54..ffc9ff1f5872b7e2d0995a6a378b255227c138c1 100755 (executable)
@@ -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;
 };
index c0f8bd0dceca75e7fa63a8c58134eea69c21eae9..f3a2fb50ca9e90d73f60b41cc37179c353934641 100644 (file)
@@ -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 {
index 729c967616e2513632f1ce408f9f5635e1ecb097..2a1624da88adccfa72d99557287b703a348729a4 100644 (file)
@@ -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<ModelAPI_Result>(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)
index 567fa8e1390742c3c0e00f3a659b398f4572333c..be9b5ab02ccd70aff6d5239ffd69c00fbf3df92e 100644 (file)
@@ -171,11 +171,6 @@ private:
   static void updateProcessedObjects(QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> > theItems,
                                      std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
 
-  /// Generates a presentation name in form: <object_name>/<face>_<face_index>
-  /// \param thePrs a presentation
-  /// \return string value
-  static QString generateName(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
-
 protected slots:
   /// Deletes element in list of items
   void onDeleteItem();
index b89334e9bf7b7815a37904d7cc2c5e16b5be6ae0..a74e2b8b0dd39724e78c68136e57b13d9b742375 100644 (file)
 #include "XGUI_InspectionPanel.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Selection.h"
+#include "XGUI_Tools.h"
+
+#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
+
+#include <ModelAPI_Result.h>
 
 #include <QLayout>
 #include <QScrollArea>
 #include <QHeaderView>
 #include <QTextBrowser>
 
+#include <BRep_Tool.hxx>
+#include <GeomAbs_CurveType.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Elips.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <Standard_ErrorHandler.hxx> // 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<ModuleBase_ViewerPrsPtr> 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) ("<b>" + val + "</b>")
 
 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")) +
-    "<br> X: " + QString::number(theX) +
-    "<br> Y: " + QString::number(theY) +
-    "<br> Z: " + QString::number(theZ);
+    "<br> X: " + QString::number(theLoc.X()) +
+    "<br> Y: " + QString::number(theLoc.Y()) +
+    "<br> 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")) +
+    "<br> X: " + QString::number(theLoc.X()) +
+    "<br> Y: " + QString::number(theLoc.Y()) +
+    "<br> Z: " + QString::number(theLoc.Z()) +
+    "<br>" + TITLE(tr("Normal")) +
+    "<br> DX: " + QString::number(theDir.X()) +
+    "<br> DY: " + QString::number(theDir.Y()) +
+    "<br> DZ: " + QString::number(theDir.Z()) +
+    "<br>" + TITLE(tr("Dimensions")) +
+    "<br>" + 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")) +
+    "<br> X: " + QString::number(theLoc.X()) +
+    "<br> Y: " + QString::number(theLoc.Y()) +
+    "<br> Z: " + QString::number(theLoc.Z()) +
+    "<br>" + TITLE(tr("Normal")) +
+    "<br> DX: " + QString::number(theDir.X()) +
+    "<br> DY: " + QString::number(theDir.Y()) +
+    "<br> DZ: " + QString::number(theDir.Z()) +
+    "<br>" + TITLE(tr("Dimensions")) +
+    "<br>" + tr("Radius:") + QString::number(theRadius) +
+    "<br>" + TITLE(tr("Point 1")) +
+    "<br> X: " + QString::number(theP1.X()) +
+    "<br> Y: " + QString::number(theP1.Y()) +
+    "<br> Z: " + QString::number(theP1.Z()) +
+    "<br>" + TITLE(tr("Point 2")) +
+    "<br> X: " + QString::number(theP2.X()) +
+    "<br> Y: " + QString::number(theP2.Y()) +
+    "<br> 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")) +
+    "<br> X: " + QString::number(theLoc.X()) +
+    "<br> Y: " + QString::number(theLoc.Y()) +
+    "<br> Z: " + QString::number(theLoc.Z()) +
+    "<br>" + TITLE(tr("Normal")) +
+    "<br> DX: " + QString::number(theDir.X()) +
+    "<br> DY: " + QString::number(theDir.Y()) +
+    "<br> DZ: " + QString::number(theDir.Z()) +
+    "<br>" + TITLE(tr("Dimensions")) +
+    "<br>" + tr("Major radius:") + QString::number(theMajorRad) +
+    "<br>" + 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")) +
+    "<br> X: " + QString::number(theLoc.X()) +
+    "<br> Y: " + QString::number(theLoc.Y()) +
+    "<br> Z: " + QString::number(theLoc.Z()) +
+    "<br>" + TITLE(tr("Normal")) +
+    "<br> DX: " + QString::number(theDir.X()) +
+    "<br> DY: " + QString::number(theDir.Y()) +
+    "<br> DZ: " + QString::number(theDir.Z()) +
+    "<br>" + TITLE(tr("Dimensions")) +
+    "<br>" + tr("Major radius:") + QString::number(theMajorRad) +
+    "<br>" + tr("Minor radius:") + QString::number(theMinorRad) +
+    "<br>" + TITLE(tr("Point 1")) +
+    "<br> X: " + QString::number(theP1.X()) +
+    "<br> Y: " + QString::number(theP1.Y()) +
+    "<br> Z: " + QString::number(theP1.Z()) +
+    "<br>" + TITLE(tr("Point 2")) +
+    "<br> X: " + QString::number(theP2.X()) +
+    "<br> Y: " + QString::number(theP2.Y()) +
+    "<br> 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")) +
+    "<br> X: " + QString::number(theP1.X()) +
+    "<br> Y: " + QString::number(theP1.Y()) +
+    "<br> Z: " + QString::number(theP1.Z()) +
+    "<br>" + TITLE(tr("Point 2")) +
+    "<br> X: " + QString::number(theP2.X()) +
+    "<br> Y: " + QString::number(theP2.Y()) +
+    "<br> Z: " + QString::number(theP2.Z());
+  myTypeParams->setText(aParams);
+}
index 27ea2a8b2910db0364639c571fedc110dee3dfbc..014581a173cc3221e5f2690cc7f86bae83279bcc 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "XGUI.h"
 
+#include <TopoDS_Shape.hxx>
+
 #include <QDockWidget>
 
 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;
index b52be827ea67d9ce23d0112942fb36c1b75eeab2..e5bc7a30829b394cd07d8a7159c7a814285b77b0 100644 (file)
@@ -39,6 +39,9 @@
 #include <Events_InfoMessage.h>
 
 #include <GeomAPI_Shape.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
+
+#include <TopoDS_Shape.hxx>
 
 #include <QDir>
 #include <QMessageBox>
@@ -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<ModelAPI_Result>(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;
+}
+
 }
index 4a16a357ce4737458313cab7f9f00ce98c96d7dd..b6ede361b89ca0367311e3d1921c93ce4a99ecb5 100644 (file)
@@ -26,6 +26,7 @@
 #include <QRect>
 
 #include <ModelAPI_Feature.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <ModuleBase_Definitions.h>
 
@@ -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: <object_name>/<face>_<face_index>
+/// \param thePrs a presentation
+/// \return string value
+XGUI_EXPORT QString generateName(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
 };
 
 #endif