]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Tools.h
Salome HOME
7cf55846e5bbd9762979d2f340cb33dca47191f4
[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
18 /*!
19  \ingroup GUI
20  \brief Return directory part of the file path.
21
22  If the file path does not include directory part (the file is in the
23  current directory), null string is returned.
24
25  \param path file path
26  \param abs if true (default) \a path parameter is treated as absolute file path
27  \return directory part of the file path
28  */
29 namespace XGUI_Tools {
30
31 /**
32 * Returns directory name from name of file
33 * \param path a path to a file
34 * \param isAbs is absolute or relative 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 /*!
60  Returns true if the feature is a model object
61  \param theFeature a feature
62  */
63 bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
64
65 /*!
66  Returns the string presentation of the given feature
67  \param theFeature a feature
68  */
69 std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
70
71 /*!
72  Returns true if there are no parts in the document, which are not activated or
73  all objects in the list are not PartSet document.
74  It shows the warning control if the result is false.
75  \param theParent a parent for the warning control
76  \param aList a list of object
77  \return a boolean value
78  */
79 bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const QObjectPtrList& aList);
80
81 /*! 
82  Check possibility to rename object
83  \param theParent a parent widget
84  \param theObject an object to rename
85  \param theName a name
86  */
87 bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName);
88
89 /*!
90  Returns true if there are no parts in the document, which are not activated
91  \param theNotActivatedNames out string which contains not activated names
92  \return a boolean value
93  */
94 bool XGUI_EXPORT allDocumentsActivated(QString& theNotActivatedNames);
95
96 /*!
97   Returns a container of referenced feature to the current object in the object document.
98   \param theObject an object, which will be casted to a feature type
99   \param theRefFeatures an output container
100  */
101 void XGUI_EXPORT refsToFeatureInFeatureDocument(const ObjectPtr& theObject,
102                                                 std::set<FeaturePtr>& theRefFeatures);
103
104 /*!
105  Returns true if the object if a sub child of the feature. The feature is casted to the
106  composite one. If it is possible, the sub object check happens. The method is applyed
107  recursively to the feature subs.
108  \param theObject a candidate to be a sub object
109  \param theFeature a candidate to be a composite feature
110  \return a boolean value
111  */
112 bool XGUI_EXPORT isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature);
113
114 /*!
115  Returns a container of references feature to the source object. The search happens in the object
116  document and in other Part documents if the object belongs to the PartSet. The search is recursive,
117  in other words it is applyed to set of the found objects until it is possible.
118  It do not returns the referenced features to the object if this references is a composite feature
119  which has the object as a sub object.
120  \param theSourceObject an object, which references are searched
121  \param theObject an intermediate recursive object, should be set in the source object
122  \param theDirectRefFeatures direct references
123  \param theIndirectRefFeatures indirect references
124  \param theAlreadyProcessed set of processed elements, used for optimization (do not reanalyse processed)
125  \return a boolean value
126  */
127 void XGUI_EXPORT refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject,
128                                              const ObjectPtr& theObject,
129                                              std::set<FeaturePtr>& theDirectRefFeatures,
130                                              std::set<FeaturePtr>& theIndirectRefFeatures,
131                                              std::set<FeaturePtr>& theAlreadyProcessed);
132 };
133
134 #endif