From: nds Date: Thu, 9 Nov 2017 10:51:45 +0000 (+0300) Subject: tool box: display the item text if the icon is not defined; X-Git-Tag: V_2.10.0RC~169 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=62227c4d1f7cbec7341618fe732c0d0285d272c5;p=modules%2Fshaper.git tool box: display the item text if the icon is not defined; shapetools: area for faces of the current shape . --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index eeebf25b0..fd854afb7 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -93,6 +93,23 @@ double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr theSh return aGProps.Mass(); } +//================================================================================================== +double GeomAlgoAPI_ShapeTools::area (const std::shared_ptr theShape) +{ + GProp_GProps aGProps; + if(!theShape.get()) { + return 0.0; + } + const TopoDS_Shape& aShape = theShape->impl(); + if(aShape.IsNull()) { + return 0.0; + } + const Standard_Real anEps = 1.e-6; + + BRepGProp::SurfaceProperties(aShape, aGProps, anEps); + return aGProps.Mass(); +} + //================================================================================================== std::shared_ptr GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr theShape) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h index a7f051a8d..7745c4011 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h @@ -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 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 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. diff --git a/src/ModuleBase/ModuleBase_ToolBox.cpp b/src/ModuleBase/ModuleBase_ToolBox.cpp index 55abd0497..27197a7ed 100644 --- a/src/ModuleBase/ModuleBase_ToolBox.cpp +++ b/src/ModuleBase/ModuleBase_ToolBox.cpp @@ -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);