1 #include "XGUI_Tools.h"
3 #include <TopoDS_Shape.hxx>
4 #include <ModelAPI_Feature.h>
11 //******************************************************************
12 QString dir(const QString& path, bool isAbs)
14 QDir aDir = QFileInfo(path).dir();
15 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
16 if (dirPath == QString("."))
21 //******************************************************************
22 QString file(const QString& path, bool withExt)
25 while(!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
26 fPath.remove(fPath.length() - 1, 1);
29 return QFileInfo(fPath).fileName();
31 return QFileInfo(fPath).completeBaseName();
34 //******************************************************************
35 QString extension(const QString& path, bool full)
37 return full ? QFileInfo(path).completeSuffix() : QFileInfo(path).suffix();
40 //******************************************************************
41 QString addSlash(const QString& path)
44 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
45 && res.at(res.length() - 1) != QChar('\\'))
46 res += QDir::separator();
50 //******************************************************************
51 QRect makeRect(const int x1, const int y1, const int x2, const int y2)
53 return QRect(qMin(x1, x2), qMin(y1, y2), qAbs(x2 - x1), qAbs(y2 - y1));
56 //******************************************************************
57 std::string featureInfo(boost::shared_ptr<ModelAPI_Feature> theFeature)
59 std::ostringstream aStream;
61 aStream << theFeature.get();
62 return QString(aStream.str().c_str()).toStdString();