1 #include "XGUI_Tools.h"
3 #include <TopoDS_Shape.hxx>
4 #include <ModelAPI_Object.h>
5 #include <GeomAPI_Shape.h>
14 //******************************************************************
15 QString dir(const QString& path, bool isAbs)
17 QDir aDir = QFileInfo(path).dir();
18 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
19 if (dirPath == QString("."))
24 //******************************************************************
25 QString file(const QString& path, bool withExt)
28 while(!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
29 fPath.remove(fPath.length() - 1, 1);
32 return QFileInfo(fPath).fileName();
34 return QFileInfo(fPath).completeBaseName();
37 //******************************************************************
38 QString extension(const QString& path, bool full)
40 return full ? QFileInfo(path).completeSuffix() : QFileInfo(path).suffix();
43 //******************************************************************
44 QString addSlash(const QString& path)
47 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
48 && res.at(res.length() - 1) != QChar('\\'))
49 res += QDir::separator();
53 //******************************************************************
54 QRect makeRect(const int x1, const int y1, const int x2, const int y2)
56 return QRect(qMin(x1, x2), qMin(y1, y2), qAbs(x2 - x1), qAbs(y2 - y1));
59 //******************************************************************
60 bool isModelObject(FeaturePtr theFeature)
62 return theFeature && !theFeature->data();
65 //******************************************************************
66 std::string featureInfo(FeaturePtr theFeature)
68 std::ostringstream aStream;
70 aStream << theFeature.get() << " " << theFeature->getKind();
71 return QString(aStream.str().c_str()).toStdString();
74 //******************************************************************
75 /*FeaturePtr realFeature(const FeaturePtr theFeature)
77 if (theFeature->data()) {
80 ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
81 return aObject->featureRef();