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