]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Tools.cpp
Salome HOME
42ddf7318fdcc02e4f6521763f192386bd5dc4b9
[modules/shaper.git] / src / XGUI / XGUI_Tools.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #include "XGUI_Tools.h"
4
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>
11
12 #include <QDir>
13
14 #include <iostream>
15 #include <sstream>
16
17 namespace XGUI_Tools {
18 //******************************************************************
19 QString dir(const QString& path, bool isAbs)
20 {
21   QDir aDir = QFileInfo(path).dir();
22   QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
23   if (dirPath == QString("."))
24     dirPath = QString();
25   return dirPath;
26 }
27
28 //******************************************************************
29 QString file(const QString& path, bool withExt)
30 {
31   QString fPath = path;
32   while (!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
33     fPath.remove(fPath.length() - 1, 1);
34
35   if (withExt)
36     return QFileInfo(fPath).fileName();
37   else
38     return QFileInfo(fPath).completeBaseName();
39 }
40
41 //******************************************************************
42 QString addSlash(const QString& path)
43 {
44   QString res = path;
45   if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
46       && res.at(res.length() - 1) != QChar('\\'))
47     res += QDir::separator();
48   return res;
49 }
50
51 //******************************************************************
52 bool isModelObject(FeaturePtr theFeature)
53 {
54   return theFeature && !theFeature->data();
55 }
56
57 //******************************************************************
58 std::string featureInfo(FeaturePtr theFeature)
59 {
60   std::ostringstream aStream;
61   if (theFeature)
62     aStream << theFeature.get() << " " << theFeature->getKind();
63   return QString(aStream.str().c_str()).toStdString();
64 }
65
66 //******************************************************************
67 /*FeaturePtr realFeature(const FeaturePtr theFeature)
68  {
69  if (theFeature->data()) {
70  return theFeature;
71  } else {
72  ObjectPtr aObject = std::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
73  return aObject->featureRef();
74  }
75  }*/
76
77
78
79 }