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