1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #include "XGUI_Tools.h"
5 #include <TopoDS_Shape.hxx>
6 #include <ModelAPI_Object.h>
7 #include <GeomAPI_Shape.h>
14 namespace XGUI_Tools {
15 //******************************************************************
16 QString dir(const QString& path, bool isAbs)
18 QDir aDir = QFileInfo(path).dir();
19 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
20 if (dirPath == QString("."))
25 //******************************************************************
26 QString file(const QString& path, bool withExt)
29 while (!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
30 fPath.remove(fPath.length() - 1, 1);
33 return QFileInfo(fPath).fileName();
35 return QFileInfo(fPath).completeBaseName();
38 //******************************************************************
39 QString addSlash(const QString& path)
42 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
43 && res.at(res.length() - 1) != QChar('\\'))
44 res += QDir::separator();
48 //******************************************************************
49 bool isModelObject(FeaturePtr theFeature)
51 return theFeature && !theFeature->data();
54 //******************************************************************
55 std::string featureInfo(FeaturePtr theFeature)
57 std::ostringstream aStream;
59 aStream << theFeature.get() << " " << theFeature->getKind();
60 return QString(aStream.str().c_str()).toStdString();
63 //******************************************************************
64 /*FeaturePtr realFeature(const FeaturePtr theFeature)
66 if (theFeature->data()) {
69 ObjectPtr aObject = std::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
70 return aObject->featureRef();