Salome HOME
Open transaction before setCurrentFeatuire if it is not opened
[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 ModuleBase_ParamSpinBox that accepts text
67 /// \param theText a new value
68 MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText);
69
70 /// Converts the object to the feature or a result and generate information string
71 /// \param theObj an object
72 /// \param isUseAttributesInfo a flag whether the attribute values information is used
73 /// \return a string
74 MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false);
75
76 /// Converts string value (name of shape type) to shape enum value
77 /// \param theType - string with shape type name
78 /// \return TopAbs_ShapeEnum value
79 MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const QString& theType);
80
81 /*!
82 Check types of objects which are in the given list
83 \param theObjects the list of objects
84 \param hasResult will be set to true if list contains Result objects
85 \param hasFeature will be set to true if list contains Feature objects
86 \param hasParameter will be set to true if list contains Parameter objects
87 */
88 MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter);
89 }
90
91 #endif