Salome HOME
Fix for the issue #1818: checking angle for fillet on Linux.
[modules/shaper.git] / src / XGUI / XGUI_Tools.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_Tools_H
4 #define XGUI_Tools_H
5
6 #include "XGUI.h"
7 #include <QString>
8 #include <QRect>
9
10 #include <ModelAPI_Feature.h>
11
12 #include <ModuleBase_Definitions.h>
13
14 #include <memory>
15
16 class QWidget;
17 class XGUI_Workshop;
18 class ModuleBase_IWorkshop;
19
20 /*!
21  \ingroup GUI
22  \brief Commonly used methods in XGUI package and higher.
23  */
24 namespace XGUI_Tools {
25
26 /**
27  \brief Return directory part of the file path.
28
29  If the file path does not include directory part (the file is in the
30  current directory), null string is returned.
31
32  \param path file path
33  \param isAbs if true (default) \a path parameter is treated as absolute file path
34  \return directory part of the file path
35 */
36 QString XGUI_EXPORT dir(const QString& path, bool isAbs = true);
37
38 /*!
39  \brief Return file name part of the file path.
40
41  \param path file path
42  \param withExt if true (default) complete file name (with all
43  extension except the last) is returned, otherwise only base name
44  is returned
45  \return file name part of the file path
46  */
47 QString XGUI_EXPORT file(const QString& path, bool withExt = true);
48
49 /*!
50  \brief Add a slash (platform-specific) to the end of \a path
51  if it is not already there.
52  \param path directory path
53  \return modified path (with slash added to the end)
54  */
55 QString XGUI_EXPORT addSlash(const QString& path);
56
57 // The model concerning tools
58
59 /*! Unite object names in one string using the separator between values
60  \param theObjects a list of objects
61  \param theSeparator a separator
62  */
63 QString unionOfObjectNames(const QObjectPtrList& theObjects, const QString& theSeparator);
64
65 /*!
66  Returns true if the feature is a model object
67  \param theFeature a feature
68  */
69 bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
70
71 /*!
72  Returns the string presentation of the given feature
73  \param theFeature a feature
74  */
75 std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
76
77 /*!
78  Returns true if there are no parts in the document, which are not activated or
79  all objects in the list are not PartSet document.
80  It shows the warning control if the result is false.
81  \param theParent a parent for the warning control
82  \param theFeatures a list of checked features
83  \return a boolean value
84  */
85 bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const std::set<FeaturePtr>& theFeatures);
86
87 /*! 
88  Check possibility to rename object
89  \param theObject an object to rename
90  \param theName a name
91  */
92 bool canRename(const ObjectPtr& theObject, const QString& theName);
93
94 /*!
95  Returns converted workshop
96  \param theWorkshop an interface workshop
97  \return XGUI workshop instance
98 */
99 XGUI_EXPORT XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
100
101 };
102
103 #endif