]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_Tools.h
Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom.git into Dev_1.2.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_Tools.h
4 // Created:     11 July 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ModuleBase_Tools_H
8 #define ModuleBase_Tools_H
9
10 #include "ModuleBase.h"
11
12 #include <ModelAPI_Feature.h>
13 #include <TopAbs_ShapeEnum.hxx>
14
15 #include <QPixmap>
16
17 class QWidget;
18 class QLayout;
19 class QDoubleSpinBox;
20 class ModuleBase_ParamSpinBox;
21
22 namespace ModuleBase_Tools {
23
24 /*
25  * Methods to adjust margins and spacings.
26  */
27 MODULEBASE_EXPORT void adjustMargins(QWidget* theWidget);
28 MODULEBASE_EXPORT void adjustMargins(QLayout* theLayout);
29
30 MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
31 MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
32
33
34 /**
35  * \ingroup GUI
36  * Methods to modify a resource pixmap
37  */
38
39 //! Create composite pixmap. 
40 //! Pixmap \a theAdditionalIcon is drawn over pixmap \a dest with coordinates
41 //! specified relatively to the upper left corner of \a theIcon.
42
43 //! \param theAdditionalIcon resource text of the additional pixmap
44 //! \param theIcon resource text of the background pixmap
45 //! \return resulting pixmap
46 MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
47
48 //! Generates the pixmap lighter than the resources pixmap. 
49 //! Pixmap \a theIcon is lighted according to the given value.
50 //! If the lighter value is greater than 100, this functions returns a lighter pixmap.
51 //! Setting lighter value to 150 returns a color that is 50% brighter. If the factor is less than 100,
52 //! the return pixmap is darker. If the factor is 0 or negative, the return pixmap is unspecified.
53
54 //! \param resource text of the pixmap
55 //! \param theLighterValue a lighter factor
56 //! \return resulting pixmap
57 MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
58
59 /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
60 /// \param theSpin an X or Y coordinate widget
61 /// \param theValue a new value
62 MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
63
64 /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
65 /// \param theSpin an ModuleBase_ParamSpinBox that accepts text
66 /// \param theText a new value
67 MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText);
68
69 /// Converts the object to the feature or a result and generate information string
70 /// \param theObj an object
71 /// \param isUseAttributesInfo a flag whether the attribute values information is used
72 /// \return a string
73 MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false);
74
75 /// Converts string value (name of shape type) to shape enum value
76 /// \param theType - string with shape type name
77 /// \return TopAbs_ShapeEnum value
78 MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const QString& theType);
79
80 }
81
82 #endif