SHAPER 9.16.0
ModuleBase_Tools.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef ModuleBase_Tools_H
21#define ModuleBase_Tools_H
22
23#include "ModuleBase.h"
24#include "ModuleBase_Definitions.h"
25
26#include <ModelAPI_Attribute.h>
27#include <ModelAPI_Feature.h>
28#include <ModelAPI_Folder.h>
29
30#include <TopAbs_ShapeEnum.hxx>
31#include <TopoDS_Shape.hxx>
32#include <Prs3d_Drawer.hxx>
33#include <AIS_Shape.hxx>
34
35#include <Quantity_Color.hxx>
36
37#include <QIcon>
38#include <QPixmap>
39#include <QLocale>
40
41#include <map>
42
43class QWidget;
44class QLayout;
45class QDoubleSpinBox;
46class QAction;
51
52class GeomAPI_Shape;
53
55
56namespace ModuleBase_Tools {
57
59MODULEBASE_EXPORT void adjustMargins(QWidget* theWidget);
60MODULEBASE_EXPORT void adjustMargins(QLayout* theLayout);
61
62MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
63MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
64
70MODULEBASE_EXPORT void activateWindow(QWidget* theWidget, const QString& theInfo = QString());
71
77MODULEBASE_EXPORT void setFocus(QWidget* theWidget, const QString& theInfo = QString());
78
79
84MODULEBASE_EXPORT void setShadowEffect(QWidget* theWidget, const bool isSetEffect);
85
88
92
96MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
97
101
105MODULEBASE_EXPORT QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon);
106
113
117MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
118
122MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
123
127MODULEBASE_EXPORT void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue);
128
132MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText);
133
137MODULEBASE_EXPORT void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue);
138
142MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText);
143
152MODULEBASE_EXPORT QAction* createAction(const QIcon& theIcon, const QString& theText,
153 QObject* theParent, const QObject* theReceiver = 0,
154 const char* theMember = "",
155 const QString& theToolTip = QString(),
156 const QString& theStatusTip = QString());
157
158#ifdef _DEBUG
162MODULEBASE_EXPORT QString objectName(const ObjectPtr& theObj);
163
168MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj,
169 const bool isUseAttributesInfo = false);
170#endif
171
175MODULEBASE_EXPORT int shapeType(const QString& theType);
176
180MODULEBASE_EXPORT bool isSubResult(ObjectPtr theObject);
181
190MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult,
191 bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner,
192 bool& hasResultInHistory, bool& hasFolder, bool &hasGroupsOnly);
193
198//MODULEBASE_EXPORT void setDefaultDeviationCoefficient(
199// const std::shared_ptr<ModelAPI_Result>& theResult,
200// const Handle(Prs3d_Drawer)& theDrawer);
201
206MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
207 const Handle(Prs3d_Drawer)& theDrawer);
208
213MODULEBASE_EXPORT Quantity_Color color(const std::string& theSection,
214 const std::string& theName);
215
218MODULEBASE_EXPORT ObjectPtr getObject(const AttributePtr& theAttribute);
219
222MODULEBASE_EXPORT TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape);
223
227MODULEBASE_EXPORT TopoDS_Shape getSelectedShape(
228 const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
229
232MODULEBASE_EXPORT void getParameters(QStringList& theParameters);
233
236MODULEBASE_EXPORT std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop,
237 const FeaturePtr& theFeature);
238
247MODULEBASE_EXPORT bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
248 const std::shared_ptr<GeomAPI_Shape>& theShape,
249 ModuleBase_IWorkshop* theWorkshop,
250 const bool theTemporarily);
251
262MODULEBASE_EXPORT bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
263 const std::shared_ptr<GeomAPI_Shape>& theShape,
264 ModuleBase_IWorkshop* theWorkshop,
265 const bool theTemporarily,
266 const bool theCheckIfAttributeHasObject);
267
272MODULEBASE_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(const AttributePtr& theAttribute,
273 ModuleBase_IWorkshop* theWorkshop);
274
277MODULEBASE_EXPORT void flushUpdated(ObjectPtr theObject);
278
281MODULEBASE_EXPORT void blockUpdateViewer(const bool theValue);
282
287MODULEBASE_EXPORT QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
288 int theMaxLineInPixels = 150);
289
293MODULEBASE_EXPORT QLocale doubleLocale();
294
298void MODULEBASE_EXPORT refsToFeatureInFeatureDocument(const ObjectPtr& theObject,
299 std::set<FeaturePtr>& theRefFeatures);
300
301
308//bool MODULEBASE_EXPORT isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature);
309
310
314//bool MODULEBASE_EXPORT isSubOfComposite(const ObjectPtr& theObject);
315
316
321std::shared_ptr<ModelAPI_Result> MODULEBASE_EXPORT firstResult(const ObjectPtr& theObject);
322
327bool MODULEBASE_EXPORT hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures);
328
335bool MODULEBASE_EXPORT askToDelete(const std::set<FeaturePtr> aFeatures,
336 const std::map<FeaturePtr,
337 std::set<FeaturePtr> >& theReferences,
338 QWidget* theParent,
339 std::set<FeaturePtr>& theReferencesToDelete,
340 const std::string& thePrefixInfo = "");
341
345bool MODULEBASE_EXPORT warningAboutConflict(QWidget* theParent, const std::string& theWarningText);
346
352void MODULEBASE_EXPORT convertToFeatures(const QObjectPtrList& theObjects,
353 std::set<FeaturePtr>& theFeatures);
354
355
359void MODULEBASE_EXPORT convertToFolders(const QObjectPtrList& theObjects,
360 std::set<FolderPtr>& theFolders);
361
362
367QString MODULEBASE_EXPORT translate(const Events_InfoMessage& theMessage);
368
374QString MODULEBASE_EXPORT translate(const std::string& theContext, const std::string& theMessage);
375
378void MODULEBASE_EXPORT setPointBallHighlighting(AIS_InteractiveObject* theAIS);
379
382FeaturePtr MODULEBASE_EXPORT createParameter(const QString& theText);
383
387void MODULEBASE_EXPORT editParameter(FeaturePtr theParam, const QString& theText);
388
391bool MODULEBASE_EXPORT isNameExist(const QString& theName, FeaturePtr theIgnoreParameter);
392
395FeaturePtr MODULEBASE_EXPORT findParameter(const QString& theName);
396
402bool MODULEBASE_EXPORT isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2);
403
404//----------- Class members -------------
409std::wstring MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute,
410 ModuleBase_IWorkshop* theWorkshop);
411
413qreal MODULEBASE_EXPORT currentPixelRatio();
414
417void MODULEBASE_EXPORT setDisplaying(std::shared_ptr<ModelAPI_ResultPart> thePart,
418 bool theDisplayFromScript = false);
419}
420
421#endif
An event message for sending a string message which has to be translated.
Definition: Events_InfoMessage.h:35
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An extension of a double spin box which let to use parameters and expressions for value definition.
Definition: ModuleBase_ParamIntSpinBox.h:34
An extension of a double spin box which let to use parameters and expressions for value definition.
Definition: ModuleBase_ParamSpinBox.h:37
Presentation.
Definition: ModuleBase_ViewerPrs.h:37
QPixmap composite(const QString &theAdditionalIcon, const QString &theIcon)
Methods to modify a resource pixmap.
Definition: ModuleBase_Tools.cpp:244