Salome HOME
Merge tag 'V_1.3.1' into HEAD
[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 #include "ModuleBase_Definitions.h"
12
13 #include <ModelAPI_Feature.h>
14 #include <TopAbs_ShapeEnum.hxx>
15
16 #include <QPixmap>
17
18 class QWidget;
19 class QLayout;
20 class QDoubleSpinBox;
21 class ModuleBase_ParamSpinBox;
22
23 namespace ModuleBase_Tools {
24
25 /*
26  * Methods to adjust margins and spacings.
27  */
28 MODULEBASE_EXPORT void adjustMargins(QWidget* theWidget);
29 MODULEBASE_EXPORT void adjustMargins(QLayout* theLayout);
30
31 MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
32 MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
33
34
35 /**
36  * \ingroup GUI
37  * Methods to modify a resource pixmap
38  */
39
40 //! Create composite pixmap. 
41 //! Pixmap \a theAdditionalIcon is drawn over pixmap \a dest with coordinates
42 //! specified relatively to the upper left corner of \a theIcon.
43
44 //! \param theAdditionalIcon resource text of the additional pixmap
45 //! \param theIcon resource text of the background pixmap
46 //! \return resulting pixmap
47 MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
48
49 //! Generates the pixmap lighter than the resources pixmap. 
50 //! Pixmap \a theIcon is lighted according to the given value.
51 //! If the lighter value is greater than 100, this functions returns a lighter pixmap.
52 //! Setting lighter value to 150 returns a color that is 50% brighter. If the factor is less than 100,
53 //! the return pixmap is darker. If the factor is 0 or negative, the return pixmap is unspecified.
54
55 //! \param resource text of the pixmap
56 //! \param theLighterValue a lighter factor
57 //! \return resulting pixmap
58 MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
59
60 /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
61 /// \param theSpin an X or Y coordinate widget
62 /// \param theValue a new value
63 MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
64
65 /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
66 /// \param theSpin an X or Y coordinate widget
67 /// \param theValue a new value
68 MODULEBASE_EXPORT void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue);
69
70 /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
71 /// \param theSpin an ModuleBase_ParamSpinBox that accepts text
72 /// \param theText a new value
73 MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText);
74
75 /// Converts the object to the feature or a result and generate information string
76 /// \param theObj an object
77 /// \param isUseAttributesInfo a flag whether the attribute values information is used
78 /// \return a string
79 MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false);
80
81 /// Converts string value (name of shape type) to shape enum value
82 /// \param theType - string with shape type name
83 /// \return TopAbs_ShapeEnum value
84 MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const QString& theType);
85
86 /// Checks whether the object is a sub result. It gets the feature of the object,
87 /// obtains all results of the feature and check if the object is a sub result
88 /// \return boolean result
89 MODULEBASE_EXPORT bool isSubResult(ObjectPtr theObject);
90
91 /*!
92 Check types of objects which are in the given list
93 \param theObjects the list of objects
94 \param hasResult will be set to true if list contains Result objects
95 \param hasFeature will be set to true if list contains Feature objects
96 \param hasParameter will be set to true if list contains Parameter objects
97 \param hasSubFeature will be set to true if list contains Sub-Feature objects
98 */
99 MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature);
100
101 /*! Returns the default deviation coefficient value
102 \return double value
103 */
104 MODULEBASE_EXPORT double defaultDeviationCoefficient();
105 }
106
107 #endif