1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
28 #include <ModelAPI_Feature.h>
29 #include <ModuleBase_ViewerPrs.h>
31 #include <ModuleBase_Definitions.h>
37 class ModuleBase_IWorkshop;
41 \brief Commonly used methods in XGUI package and higher.
43 namespace XGUI_Tools {
46 \brief Return directory part of the file path.
48 If the file path does not include directory part (the file is in the
49 current directory), null string is returned.
52 \param isAbs if true (default) \a path parameter is treated as absolute file path
53 \return directory part of the file path
55 QString XGUI_EXPORT dir(const QString& path, bool isAbs = true);
58 \brief Return file name part of the file path.
61 \param withExt if true (default) complete file name (with all
62 extension except the last) is returned, otherwise only base name
64 \return file name part of the file path
66 QString XGUI_EXPORT file(const QString& path, bool withExt = true);
69 \brief Add a slash (platform-specific) to the end of \a path
70 if it is not already there.
71 \param path directory path
72 \return modified path (with slash added to the end)
74 QString XGUI_EXPORT addSlash(const QString& path);
76 // The model concerning tools
78 /*! Unite object names in one string using the separator between values
79 \param theObjects a list of objects
80 \param theSeparator a separator
82 QString unionOfObjectNames(const QObjectPtrList& theObjects, const QString& theSeparator);
85 Returns true if the feature is a model object
86 \param theFeature a feature
88 bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
91 Returns the string presentation of the given feature
92 \param theFeature a feature
94 std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
97 Returns true if there are no parts in the document, which are not activated or
98 all objects in the list are not PartSet document.
99 It shows the warning control if the result is false.
100 \param theParent a parent for the warning control
101 \param theFeatures a list of checked features
102 \return a boolean value
104 bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const std::set<FeaturePtr>& theFeatures);
107 Check possibility to rename object
108 \param theObject an object to rename
109 \param theName a name
111 bool canRename(const ObjectPtr& theObject, const QString& theName);
114 Returns converted workshop
115 \param theWorkshop an interface workshop
116 \return XGUI workshop instance
118 XGUI_EXPORT XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
121 /// Generates a presentation name in form: <object_name>/<face>_<face_index>
122 /// \param thePrs a presentation
123 /// \return string value
124 XGUI_EXPORT QString generateName(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);