Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / XGUI / XGUI_Tools.h
1 #ifndef XGUI_Tools_H
2 #define XGUI_Tools_H
3
4 #include "XGUI.h"
5 #include <QString>
6 #include <QRect>
7
8 #include <boost/shared_ptr.hpp>
9
10 class TopoDS_Shape;
11 class ModelAPI_Feature;
12 /*!
13  \brief Return directory part of the file path.
14
15  If the file path does not include directory part (the file is in the
16  current directory), null string is returned.
17
18  \param path file path
19  \param abs if true (default) \a path parameter is treated as absolute file path
20  \return directory part of the file path
21  */
22 QString XGUI_EXPORT dir(const QString& path, bool isAbs = true);
23
24 /*!
25  \brief Return file name part of the file path.
26
27  \param path file path
28  \param withExt if true (default) complete file name (with all
29  extension except the last) is returned, otherwise only base name
30  is returned
31  \return file name part of the file path
32  */
33 QString XGUI_EXPORT file(const QString& path, bool withExt = true);
34
35 /*!
36  \brief Return extension part of the file path.
37
38  \param path file path
39  \param full if true complete extension (all extensions, dot separated)
40  is returned, otherwise (default) only last extension is returned
41  \return extension part of the file path 
42  */
43 QString XGUI_EXPORT extension(const QString& path, bool full = false);
44
45 /*!
46  \brief Add a slash (platform-specific) to the end of \a path
47  if it is not already there.
48  \param path directory path
49  \return modified path (with slash added to the end)
50  */
51 QString XGUI_EXPORT addSlash(const QString& path);
52
53 /*! 
54  Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) )
55  and BottomRight = ( TopLeft + (x2-x1)(y2-y1) )    
56  */
57 QRect XGUI_EXPORT makeRect(const int x1, const int y1, const int x2, const int y2);
58
59 /*!
60  Returns the string presentation of the given feature
61  \param theFeature a feature
62 */
63 std::string XGUI_EXPORT featureInfo(boost::shared_ptr<ModelAPI_Feature> theFeature);
64 #endif