SHAPER  9.12.0
ModuleBase_Tools.h
1 // Copyright (C) 2014-2023 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 
43 class QWidget;
44 class QLayout;
45 class QDoubleSpinBox;
46 class QAction;
51 
52 class GeomAPI_Shape;
53 
54 class Events_InfoMessage;
55 
56 namespace ModuleBase_Tools {
57 
59 MODULEBASE_EXPORT void adjustMargins(QWidget* theWidget);
60 MODULEBASE_EXPORT void adjustMargins(QLayout* theLayout);
61 
62 MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
63 MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
64 
70 MODULEBASE_EXPORT void activateWindow(QWidget* theWidget, const QString& theInfo = QString());
71 
77 MODULEBASE_EXPORT void setFocus(QWidget* theWidget, const QString& theInfo = QString());
78 
79 
84 MODULEBASE_EXPORT void setShadowEffect(QWidget* theWidget, const bool isSetEffect);
85 
88 
92 
96 MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
97 
101 
105 MODULEBASE_EXPORT QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon);
106 
113 
117 MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
118 
122 MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
123 
127 MODULEBASE_EXPORT void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue);
128 
132 MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText);
133 
137 MODULEBASE_EXPORT void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue);
138 
142 MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText);
143 
152 MODULEBASE_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
162 MODULEBASE_EXPORT QString objectName(const ObjectPtr& theObj);
163 
168 MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj,
169  const bool isUseAttributesInfo = false);
170 #endif
171 
175 MODULEBASE_EXPORT int shapeType(const QString& theType);
176 
180 MODULEBASE_EXPORT bool isSubResult(ObjectPtr theObject);
181 
190 MODULEBASE_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 
206 MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
207  const Handle(Prs3d_Drawer)& theDrawer);
208 
213 MODULEBASE_EXPORT Quantity_Color color(const std::string& theSection,
214  const std::string& theName);
215 
218 MODULEBASE_EXPORT ObjectPtr getObject(const AttributePtr& theAttribute);
219 
222 MODULEBASE_EXPORT TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape);
223 
227 MODULEBASE_EXPORT TopoDS_Shape getSelectedShape(
228  const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
229 
232 MODULEBASE_EXPORT void getParameters(QStringList& theParameters);
233 
236 MODULEBASE_EXPORT std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop,
237  const FeaturePtr& theFeature);
238 
247 MODULEBASE_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 
262 MODULEBASE_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 
272 MODULEBASE_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(const AttributePtr& theAttribute,
273  ModuleBase_IWorkshop* theWorkshop);
274 
277 MODULEBASE_EXPORT void flushUpdated(ObjectPtr theObject);
278 
281 MODULEBASE_EXPORT void blockUpdateViewer(const bool theValue);
282 
287 MODULEBASE_EXPORT QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
288  int theMaxLineInPixels = 150);
289 
293 MODULEBASE_EXPORT QLocale doubleLocale();
294 
298 void 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 
321 std::shared_ptr<ModelAPI_Result> MODULEBASE_EXPORT firstResult(const ObjectPtr& theObject);
322 
327 bool MODULEBASE_EXPORT hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures);
328 
335 bool 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 
345 bool MODULEBASE_EXPORT warningAboutConflict(QWidget* theParent, const std::string& theWarningText);
346 
352 void MODULEBASE_EXPORT convertToFeatures(const QObjectPtrList& theObjects,
353  std::set<FeaturePtr>& theFeatures);
354 
355 
359 void MODULEBASE_EXPORT convertToFolders(const QObjectPtrList& theObjects,
360  std::set<FolderPtr>& theFolders);
361 
362 
367 QString MODULEBASE_EXPORT translate(const Events_InfoMessage& theMessage);
368 
374 QString MODULEBASE_EXPORT translate(const std::string& theContext, const std::string& theMessage);
375 
378 void MODULEBASE_EXPORT setPointBallHighlighting(AIS_InteractiveObject* theAIS);
379 
382 FeaturePtr MODULEBASE_EXPORT createParameter(const QString& theText);
383 
387 void MODULEBASE_EXPORT editParameter(FeaturePtr theParam, const QString& theText);
388 
391 bool MODULEBASE_EXPORT isNameExist(const QString& theName, FeaturePtr theIgnoreParameter);
392 
395 FeaturePtr MODULEBASE_EXPORT findParameter(const QString& theName);
396 
402 bool MODULEBASE_EXPORT isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2);
403 
404 //----------- Class members -------------
409 std::wstring MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute,
410  ModuleBase_IWorkshop* theWorkshop);
411 
413 qreal MODULEBASE_EXPORT currentPixelRatio();
414 
417 void 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