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 <ModelAPI_Result.h>
8 #include <ModelAPI_ResultParameter.h>
9 #include <ModelAPI_Feature.h>
10 #include <GeomAPI_Shape.h>
17 namespace XGUI_Tools {
18 //******************************************************************
19 QString dir(const QString& path, bool isAbs)
21 QDir aDir = QFileInfo(path).dir();
22 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
23 if (dirPath == QString("."))
28 //******************************************************************
29 QString file(const QString& path, bool withExt)
32 while (!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
33 fPath.remove(fPath.length() - 1, 1);
36 return QFileInfo(fPath).fileName();
38 return QFileInfo(fPath).completeBaseName();
41 //******************************************************************
42 QString addSlash(const QString& path)
45 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
46 && res.at(res.length() - 1) != QChar('\\'))
47 res += QDir::separator();
51 //******************************************************************
52 bool isModelObject(FeaturePtr theFeature)
54 return theFeature && !theFeature->data();
57 //******************************************************************
58 std::string featureInfo(FeaturePtr theFeature)
60 std::ostringstream aStream;
62 aStream << theFeature.get() << " " << theFeature->getKind();
63 return QString(aStream.str().c_str()).toStdString();
66 //******************************************************************
67 /*FeaturePtr realFeature(const FeaturePtr theFeature)
69 if (theFeature->data()) {
72 ObjectPtr aObject = std::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
73 return aObject->featureRef();