SHAPER  9.12.0
XGUI_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 XGUI_Tools_H
21 #define XGUI_Tools_H
22 
23 #include "XGUI.h"
24 #include <QString>
25 #include <QRect>
26 
27 #include <ModelAPI_Feature.h>
28 #include <ModuleBase_ViewerPrs.h>
29 
30 #include <ModuleBase_Definitions.h>
31 
32 #include <memory>
33 
34 class QWidget;
35 class XGUI_Workshop;
37 
42 namespace XGUI_Tools {
43 
54 QString XGUI_EXPORT dir(const QString& path, bool isAbs = true);
55 
65 QString XGUI_EXPORT file(const QString& path, bool withExt = true);
66 
73 QString XGUI_EXPORT addSlash(const QString& path);
74 
75 // The model concerning tools
76 
81 QString unionOfObjectNames(const QObjectPtrList& theObjects, const QString& theSeparator);
82 
87 bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
88 
93 std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
94 
103 bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const std::set<FeaturePtr>& theFeatures);
104 
110 bool canRename(const ObjectPtr& theObject, const QString& theName);
111 
116 bool isAscii(const QString& theStr);
117 
123 XGUI_EXPORT XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
124 
125 
129 XGUI_EXPORT QString generateName(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
130 
133 std::string getTmpDirByEnv( const char* thePathEnv);
134 
136 void removeTemporaryFiles(const std::string& theDirectory,
137  const std::list<std::string>& theFiles);
138 };
139 
140 #endif
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:82
Commonly used methods in XGUI package and higher.
Definition: XGUI_Tools.cpp:67
std::string featureInfo(FeaturePtr theFeature)
Definition: XGUI_Tools.cpp:124
XGUI_Workshop * workshop(ModuleBase_IWorkshop *theWorkshop)
Definition: XGUI_Tools.cpp:244
bool isAscii(const QString &theStr)
Definition: XGUI_Tools.cpp:164
void removeTemporaryFiles(const std::string &theDirectory, const std::list< std::string > &theFiles)
Removes files and directory where they are located.
Definition: XGUI_Tools.cpp:377
bool canRemoveOrRename(QWidget *theParent, const std::set< FeaturePtr > &theFeatures)
Definition: XGUI_Tools.cpp:145
bool isModelObject(FeaturePtr theFeature)
Definition: XGUI_Tools.cpp:118
QString dir(const QString &path, bool isAbs)
Return directory part of the file path.
Definition: XGUI_Tools.cpp:69
bool canRename(const ObjectPtr &theObject, const QString &theName)
Definition: XGUI_Tools.cpp:200
std::string getTmpDirByEnv(const char *thePathEnv)
Creates and returns the temporary directory (with random name) using the environment variable path to...
Definition: XGUI_Tools.cpp:370
QString unionOfObjectNames(const QObjectPtrList &theObjects, const QString &theSeparator)
Definition: XGUI_Tools.cpp:103
QString addSlash(const QString &path)
Add a slash (platform-specific) to the end of path if it is not already there.
Definition: XGUI_Tools.cpp:93
QString file(const QString &path, bool withExt)
Return file name part of the file path.
Definition: XGUI_Tools.cpp:79
QString generateName(const ModuleBase_ViewerPrsPtr &thePrs)
Generates a presentation name in form: <object_name>/<face>_<face_index>
Definition: XGUI_Tools.cpp:252