itom 1.0.14
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef PYTHONWORKSPACE_H 00024 #define PYTHONWORKSPACE_H 00025 00026 #ifndef Q_MOC_RUN 00027 #define PY_ARRAY_UNIQUE_SYMBOL itom_ARRAY_API //see numpy help ::array api :: Miscellaneous :: Importing the api (this line must bebefore include global.h) 00028 #define NO_IMPORT_ARRAY 00029 00030 //#define NPY_NO_DEPRECATED_API 0x00000007 //see comment in pythonNpDataObject.cpp 00031 //python 00032 // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3 00033 #ifdef _DEBUG 00034 #undef _DEBUG 00035 #if (defined linux) | (defined CMAKE) 00036 #include "Python.h" 00037 #include "numpy/arrayobject.h" 00038 #else 00039 #include "Python.h" 00040 #include "../Lib/site-packages/numpy/core/include/numpy/arrayobject.h" //for numpy arrays 00041 #endif 00042 #define _DEBUG 00043 #else 00044 #ifdef linux 00045 #include "Python.h" 00046 #include "numpy/arrayobject.h" 00047 #else 00048 #include "Python.h" 00049 #include "../Lib/site-packages/numpy/core/include/numpy/arrayobject.h" //for numpy arrays 00050 #endif 00051 #endif 00052 #endif 00053 00054 #include "../global.h" 00055 00056 #include <qstring.h> 00057 #include <qhash.h> 00058 #include <qmutex.h> 00059 #include <qset.h> 00060 #include <qstringlist.h> 00061 00062 namespace ito 00063 { 00064 00065 class PyWorkspaceItem; 00066 00067 class PyWorkspaceItem 00068 { 00069 public: 00070 PyWorkspaceItem() : m_exist(false), m_isarrayelement(false), m_childState(stateNoChilds) 00071 { 00072 } 00073 ~PyWorkspaceItem(); 00074 PyWorkspaceItem(const PyWorkspaceItem &other); 00075 00076 enum childState { stateNoChilds = 0x00, stateChilds = 0x01}; 00077 00078 QString m_name; 00079 QString m_type; 00080 QString m_value; 00081 QString m_extendedValue; 00082 int m_compatibleParamBaseType; 00083 bool m_exist; 00084 bool m_isarrayelement; 00085 int m_childState; 00086 QHash<QString, PyWorkspaceItem*> m_childs; 00087 }; 00088 00089 00090 class PyWorkspaceContainer : public QObject //each container has one view 00091 { 00092 Q_OBJECT 00093 public: 00094 00095 PyWorkspaceContainer(bool globalNotLocal); 00096 ~PyWorkspaceContainer(); 00097 00098 void clear(); 00099 void loadDictionary(PyObject *obj, QString fullNameParentItem = ""); 00100 00101 inline bool isGlobalWorkspace() const { return m_globalNotLocal; } 00102 inline bool isRoot(PyWorkspaceItem *item) const { return item == &m_rootItem; } 00103 inline void emitGetChildNodes(ito::PyWorkspaceContainer *container, QString fullNameParentItem) { emit getChildNodes(container,fullNameParentItem); } 00104 00105 inline QString getDelimiter() const { return m_delimiter; }; 00106 00107 ito::PyWorkspaceItem* getItemByFullName(const QString &fullname); 00108 00109 QMutex m_accessMutex; 00110 QSet<QString> m_expandedFullNames; //this full names are recently expanded in the corresponding view (full name is "." + name + "." + subname + "." + subsubname ...) 00111 PyWorkspaceItem m_rootItem; 00112 00113 private: 00114 void loadDictionaryRec(PyObject *obj, QString fullNameParentItem, PyWorkspaceItem *parentItem, QStringList &deletedKeys); 00115 void parseSinglePyObject(PyWorkspaceItem *item, PyObject *value, QString &fullName, QStringList &deletedKeys, int &m_compatibleParamBaseType); 00116 00117 QSet<QString> m_blackListType; 00118 bool m_globalNotLocal; 00119 00120 QString m_delimiter; 00121 00122 PyObject *dictUnicode; 00123 00124 signals: 00125 void updateAvailable(ito::PyWorkspaceItem *rootItem, QString fullNameRoot, QStringList recentlyDeletedFullNames); //TODO 00126 void getChildNodes(ito::PyWorkspaceContainer *container, QString fullNameParentItem); //signal catched by python //TODO 00127 }; 00128 00129 } //end namespace ito 00130 00131 00132 #endif