Salome HOME
tool box: display the item text if the icon is not defined;
authornds <nds@opencascade.com>
Thu, 9 Nov 2017 10:51:45 +0000 (13:51 +0300)
committernds <nds@opencascade.com>
Thu, 9 Nov 2017 10:51:45 +0000 (13:51 +0300)
shapetools: area for faces of the current shape .

src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h
src/ModuleBase/ModuleBase_ToolBox.cpp

index eeebf25b04ad6c48d2e47821e8ba646dfff87b69..fd854afb74009ba5ea90e2adfdfd31eeaece85ed 100644 (file)
@@ -93,6 +93,23 @@ double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theSh
   return aGProps.Mass();
 }
 
+//==================================================================================================
+double GeomAlgoAPI_ShapeTools::area (const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+  GProp_GProps aGProps;
+  if(!theShape.get()) {
+    return 0.0;
+  }
+  const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
+  if(aShape.IsNull()) {
+    return 0.0;
+  }
+  const Standard_Real anEps = 1.e-6;
+
+  BRepGProp::SurfaceProperties(aShape, aGProps, anEps);
+  return aGProps.Mass();
+}
+
 //==================================================================================================
 std::shared_ptr<GeomAPI_Pnt>
   GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape)
index a7f051a8dfc1f22b7c0166dc770f88dbf38df036..7745c4011f5640a6053f3b7635eda575dcbf3866 100644 (file)
@@ -48,6 +48,9 @@ public:
   /// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
   GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
 
+  /// \return the total area of the faces of the current shape or 0.0 if it can be computed.
+  GEOMALGOAPI_EXPORT static double area(const std::shared_ptr<GeomAPI_Shape> theShape);
+
   /// \return the centre of mass of the current face.
   /// The coordinates returned for the center of mass
   /// are expressed in the absolute Cartesian coordinate system.
index 55abd049722066ca4ce7d5f461121ced65a16f69..27197a7edeb54d3c5474c4a9d0fb1960d54eff74 100644 (file)
@@ -72,8 +72,12 @@ void ModuleBase_ToolBox::addItem(QWidget* thePage, const QString& theName, const
   QToolButton* aButton = new QToolButton(myButtonsFrame);
   aButton->setFocusPolicy(Qt::StrongFocus);
   aButton->setCheckable(true);
-  aButton->setIcon(theIcon);
-  aButton->setIconSize(theIcon.size());
+  if (theIcon.isNull())
+    aButton->setText(theName);
+  else {
+    aButton->setIcon(theIcon);
+    aButton->setIconSize(theIcon.size());
+  }
   aButton->setToolTip(theName);
   aButton->setObjectName(theName);
   myButtonsGroup->addButton(aButton, anOldCount);