1 #include "XGUI_Tools.h"
3 #include <TopoDS_Shape.hxx>
4 #include <ModelAPI_Object.h>
5 #include <GeomAPI_Shape.h>
12 namespace XGUI_Tools {
13 //******************************************************************
14 QString dir(const QString& path, bool isAbs)
16 QDir aDir = QFileInfo(path).dir();
17 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
18 if (dirPath == QString("."))
23 //******************************************************************
24 QString file(const QString& path, bool withExt)
27 while (!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
28 fPath.remove(fPath.length() - 1, 1);
31 return QFileInfo(fPath).fileName();
33 return QFileInfo(fPath).completeBaseName();
36 //******************************************************************
37 QString extension(const QString& path, bool full)
39 return full ? QFileInfo(path).completeSuffix() : QFileInfo(path).suffix();
42 //******************************************************************
43 QString addSlash(const QString& path)
46 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
47 && res.at(res.length() - 1) != QChar('\\'))
48 res += QDir::separator();
52 //******************************************************************
53 QRect makeRect(const int x1, const int y1, const int x2, const int y2)
55 return QRect(qMin(x1, x2), qMin(y1, y2), qAbs(x2 - x1), qAbs(y2 - y1));
58 //******************************************************************
59 bool isModelObject(FeaturePtr theFeature)
61 return theFeature && !theFeature->data();
64 //******************************************************************
65 std::string featureInfo(FeaturePtr theFeature)
67 std::ostringstream aStream;
69 aStream << theFeature.get() << " " << theFeature->getKind();
70 return QString(aStream.str().c_str()).toStdString();
73 //******************************************************************
74 /*FeaturePtr realFeature(const FeaturePtr theFeature)
76 if (theFeature->data()) {
79 ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
80 return aObject->featureRef();