Salome HOME
Merge branch 'master' of newgeom:newgeom
[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 <ModelAPI_Feature.h>
9
10 #include <boost/shared_ptr.hpp>
11
12 class TopoDS_Shape;
13 /*!
14  \brief Return directory part of the file path.
15
16  If the file path does not include directory part (the file is in the
17  current directory), null string is returned.
18
19  \param path file path
20  \param abs if true (default) \a path parameter is treated as absolute file path
21  \return directory part of the file path
22  */
23 namespace XGUI_Tools
24 {
25   QString XGUI_EXPORT dir(const QString& path, bool isAbs = true);
26
27   /*!
28    \brief Return file name part of the file path.
29
30    \param path file path
31    \param withExt if true (default) complete file name (with all
32    extension except the last) is returned, otherwise only base name
33    is returned
34    \return file name part of the file path
35    */
36   QString XGUI_EXPORT file(const QString& path, bool withExt = true);
37
38   /*!
39    \brief Return extension part of the file path.
40
41    \param path file path
42    \param full if true complete extension (all extensions, dot separated)
43    is returned, otherwise (default) only last extension is returned
44    \return extension part of the file path 
45    */
46   QString XGUI_EXPORT extension(const QString& path, bool full = false);
47
48   /*!
49    \brief Add a slash (platform-specific) to the end of \a path
50    if it is not already there.
51    \param path directory path
52    \return modified path (with slash added to the end)
53    */
54   QString XGUI_EXPORT addSlash(const QString& path);
55
56   /*! 
57    Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) )
58    and BottomRight = ( TopLeft + (x2-x1)(y2-y1) )    
59    */
60   QRect XGUI_EXPORT makeRect(const int x1, const int y1, const int x2, const int y2);
61
62   /// The model concerning tools
63
64   /*!
65    Returns true if the feature is a model object
66    \param theFeature a feature
67   */
68   bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
69
70   /*!
71    Returns the string presentation of the given feature
72    \param theFeature a feature
73   */
74   std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
75
76   /**
77   * Returns pointer on real feature
78   */
79   FeaturePtr realFeature(const FeaturePtr theFeature);
80 }
81
82 #endif