1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_Tools.h
4 // Created: 11 July 2014
5 // Author: Vitaly Smetannikov
7 #ifndef ModuleBase_Tools_H
8 #define ModuleBase_Tools_H
10 #include "ModuleBase.h"
12 #include <ModelAPI_Feature.h>
13 #include <TopAbs_ShapeEnum.hxx>
21 namespace ModuleBase_Tools {
24 * Methods to adjust margins and spacings.
26 MODULEBASE_EXPORT void adjustMargins(QWidget* theWidget);
27 MODULEBASE_EXPORT void adjustMargins(QLayout* theLayout);
29 MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
30 MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
35 * Methods to modify a resource pixmap
38 //! Create composite pixmap.
39 //! Pixmap \a theAdditionalIcon is drawn over pixmap \a dest with coordinates
40 //! specified relatively to the upper left corner of \a theIcon.
42 //! \param theAdditionalIcon resource text of the additional pixmap
43 //! \param theIcon resource text of the background pixmap
44 //! \return resulting pixmap
45 MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
47 //! Generates the pixmap lighter than the resources pixmap.
48 //! Pixmap \a theIcon is lighted according to the given value.
49 //! If the lighter value is greater than 100, this functions returns a lighter pixmap.
50 //! Setting lighter value to 150 returns a color that is 50% brighter. If the factor is less than 100,
51 //! the return pixmap is darker. If the factor is 0 or negative, the return pixmap is unspecified.
53 //! \param resource text of the pixmap
54 //! \param theLighterValue a lighter factor
55 //! \return resulting pixmap
56 MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
58 /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
59 /// \param theSpin an X or Y coordinate widget
60 /// \param theValue a new value
61 MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
63 /// Converts the object to the feature or a result and generate information string
64 /// \param theObj an object
65 /// \param isUseAttributesInfo a flag whether the attribute values information is used
67 MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false);
69 /// Converts string value (name of shape type) to shape enum value
70 /// \param theType - string with shape type name
71 /// \return TopAbs_ShapeEnum value
72 MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const QString& theType);