itom  4.1.0
pythonUi.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef PYTHONUI_H
24 #define PYTHONUI_H
25 
26 #include "pythonCommon.h"
27 #include "pythonQtConversion.h"
28 #include "pythonQtSignalMapper.h"
29 #include "pythonItomMetaObject.h"
30 
31 #include <qstring.h>
32 #include <qvariant.h>
33 #include <qobject.h>
34 #include <qhash.h>
35 
36 namespace ito
37 {
38 
39 class PythonUi
40 {
41 public:
42 
43  //#################################################################################################
44  // UiItem
45  //#################################################################################################
46 
47  //-------------------------------------------------------------------------------------------------
48  // typedefs
49  //-------------------------------------------------------------------------------------------------
50  typedef struct
51  {
52  PyObject_HEAD
53  PyObject *baseItem; //parent UiItem (e.g. the whole dialog), NULL if no parent.
54  char* objName; //object name of corresponding widget in UI
55  char* widgetClassName; //class name of corresponding widget in UI
56  unsigned int objectID; //itom internal ID of hashed meta object of this widget (for communication with uiOrganizer)
57  const MethodDescriptionList* methodList; //borrowed pointer to an item in methodDescriptionListStorage.
58  PyObject *weakreflist;
59  }
60  PyUiItem;
61 
62  typedef struct
63  {
64  PyUiItem uiItem;
65  int uiHandle;
66  int winType;
67  int buttonBarType;
68  bool childOfMainWindow;
69  bool deleteOnClose;
70  PyObject *dialogButtons;
71  char* filename;
72  PythonQtSignalMapper *signalMapper;
73  }
74  PyUi;
75 
76 
77  //-------------------------------------------------------------------------------------------------
78  // constructor, deconstructor, alloc, dellaoc
79  //-------------------------------------------------------------------------------------------------
80  static void PyUiItem_dealloc(PyUiItem *self);
81  static PyObject *PyUiItem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
82  static int PyUiItem_init(PyUiItem *self, PyObject *args, PyObject *kwds);
83 
84  //-------------------------------------------------------------------------------------------------
85  // mapping members
86  //-------------------------------------------------------------------------------------------------
87  static int PyUiItem_mappingLength(PyUiItem* self);
88  static PyObject* PyUiItem_mappingGetElem(PyUiItem* self, PyObject* key);
89  static int PyUiItem_mappingSetElem(PyUiItem* self, PyObject* key, PyObject* value);
90 
91  //-------------------------------------------------------------------------------------------------
92  // general members
93  //-------------------------------------------------------------------------------------------------
94  static PyObject* PyUiItem_repr(PyUiItem *self);
95  static PyObject* PyUiItem_getClassName(PyUiItem *self);
96  static PyObject* PyUiItem_call(PyUiItem *self, PyObject* args);
97  static PyObject* PyUiItem_connect(PyUiItem *self, PyObject* args, PyObject *kwds);
98  static PyObject* PyUiItem_connectKeyboardInterrupt(PyUiItem *self, PyObject* args, PyObject *kwds);
99  static PyObject* PyUiItem_connectProgressObserverInterrupt(PyUiItem *self, PyObject* args, PyObject *kwds);
100  static PyObject* PyUiItem_disconnect(PyUiItem *self, PyObject* args, PyObject *kwds);
101  static PyObject* PyUiItem_getProperties(PyUiItem *self, PyObject *args);
102  static PyObject* PyUiItem_setProperties(PyUiItem *self, PyObject *args);
103  static PyObject *PyUiItem_getPropertyInfo(PyUiItem *self, PyObject *args);
104  static PyObject* PyUiItem_getattro(PyUiItem *self, PyObject *name);
105  static int PyUiItem_setattro(PyUiItem *self, PyObject *name, PyObject *value);
106 
107  static PyObject* PyUiItem_setAttribute(PyUiItem *self, PyObject *args);
108  static PyObject* PyUiItem_getAttribute(PyUiItem *self, PyObject *args);
109 
110  static PyObject* PyUiItem_setWindowFlags(PyUiItem *self, PyObject *args);
111  static PyObject* PyUiItem_getWindowFlags(PyUiItem *self);
112 
113  static PyObject* PyUiItem_info(PyUiItem *self, PyObject *args);
114  static PyObject* PyUiItem_exists(PyUiItem *self);
115  static PyObject* PyUiItem_children(PyUiItem *self, PyObject *args, PyObject *kwds);
116  static PyObject* PyUiItem_getChild(PyUiItem *self, PyObject *args, PyObject *kwds);
117  static PyObject* PyUiItem_getLayout(PyUiItem *self);
118 
119  //-------------------------------------------------------------------------------------------------
120  // helpers
121  //-------------------------------------------------------------------------------------------------
122  static bool loadMethodDescriptionList(PyUiItem *self);
123  static PythonQtSignalMapper* PyUiItem_getTopLevelSignalMapper(PyUiItem *self);
124 
125  //-------------------------------------------------------------------------------------------------
126  // type structures
127  //-------------------------------------------------------------------------------------------------
128  static PyMemberDef PyUiItem_members[];
129  static PyGetSetDef PyUiItem_getseters[];
130  static PyMethodDef PyUiItem_methods[];
131  static PyTypeObject PyUiItemType;
132  static PyModuleDef PyUiItemModule;
133  static PyMappingMethods PyUiItem_mappingProtocol;
134  static void PyUiItem_addTpDict(PyObject *tp_dict);
135 
136 
137 
138  //#################################################################################################
139  // Ui
140  //#################################################################################################
141 
142 
143  //-------------------------------------------------------------------------------------------------
144  // constructor, deconstructor, alloc, dellaoc
145  //-------------------------------------------------------------------------------------------------
146  static void PyUi_dealloc(PyUi *self);
147  static PyObject *PyUi_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
148  static int PyUi_init(PyUi *self, PyObject *args, PyObject *kwds);
149 
150  //-------------------------------------------------------------------------------------------------
151  // general members
152  //-------------------------------------------------------------------------------------------------
153  static PyObject* PyUi_repr(PyUi *self);
154 
155  static PyObject *PyUi_show(PyUi *self, PyObject *args);
156  static PyObject *PyUi_hide(PyUi *self);
157  static PyObject *PyUi_isVisible(PyUi *self);
158 
159  static PyObject *PyUi_getPropertyInfo(PyUi *self, PyObject *args);
160  static PyObject *PyUi_getProperties(PyUi *self, PyObject *args);
161  static PyObject *PyUi_setProperties(PyUi *self, PyObject *args);
162 
163  //-------------------------------------------------------------------------------------------------
164  // static members
165  //-------------------------------------------------------------------------------------------------
166  static PyObject* PyUi_getDouble(PyUi *self, PyObject *args, PyObject *kwds);
167  static PyObject* PyUi_getInt(PyUi *self, PyObject *args, PyObject *kwds);
168  static PyObject* PyUi_getItem(PyUi *self, PyObject *args, PyObject *kwds);
169  static PyObject* PyUi_getText(PyUi *self, PyObject *args, PyObject *kwds);
170 
171  static PyObject* PyUi_msgInformation(PyUi *self, PyObject *args, PyObject *kwds);
172  static PyObject* PyUi_msgQuestion(PyUi *self, PyObject *args, PyObject *kwds);
173  static PyObject* PyUi_msgWarning(PyUi *self, PyObject *args, PyObject *kwds);
174  static PyObject* PyUi_msgCritical(PyUi *self, PyObject *args, PyObject *kwds);
175  static PyObject* PyUi_msgGeneral(PyUi *self, PyObject *args, PyObject *kwds, int type);
176 
177  static PyObject* PyUi_getExistingDirectory(PyUi *self, PyObject *args, PyObject *kwds);
178  static PyObject* PyUi_getOpenFileNames(PyUi *self, PyObject *args, PyObject *kwds);
179  static PyObject* PyUi_getOpenFileName(PyUi *self, PyObject *args, PyObject *kwds);
180  static PyObject* PyUi_getSaveFileName(PyUi *self, PyObject *args, PyObject *kwds);
181 
182  static PyObject* PyUi_createNewAlgoWidget(PyUi *self, PyObject *args, PyObject *kwds);
183  static PyObject* PyUi_createNewAlgoWidget2(PyUi *self, PyObject *args, PyObject *kwds);
184  static PyObject *PyUi_availableWidgets(PyUi *self);
185 
186  //-------------------------------------------------------------------------------------------------
187  // type structures
188  //-------------------------------------------------------------------------------------------------
189  static PyGetSetDef PyUi_getseters[];
190  static PyMemberDef PyUi_members[];
191  static PyMethodDef PyUi_methods[];
192  static PyTypeObject PyUiType;
193  static PyModuleDef PyUiModule;
194  static void PyUi_addTpDict(PyObject *tp_dict);
195 
196  //-------------------------------------------------------------------------------------------------
197  // macros
198  //-------------------------------------------------------------------------------------------------
199  #define PyUiItem_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiItemType)
200  #define PyUi_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiType)
201 
202 private:
203  static QHash<QByteArray, QSharedPointer<ito::MethodDescriptionList> > methodDescriptionListStorage; //key is a widget-className, every PyUiItem which needs a methodDescriptionList gets it from this storage or if not available from UiOrganizer and puts it then to this storage
204 };
205 
206 }; //end namespace ito
207 
208 
209 #endif
static PyObject * PyUiItem_info(PyUiItem *self, PyObject *args)
Definition: pythonUi.cpp:1819
static PyObject * PyUiItem_getLayout(PyUiItem *self)
Definition: pythonUi.cpp:2086
Definition: apiFunctionsGraph.cpp:39
static PyObject * PyUiItem_children(PyUiItem *self, PyObject *args, PyObject *kwds)
Definition: pythonUi.cpp:1969
static PyObject * PyUiItem_exists(PyUiItem *self)
Definition: pythonUi.cpp:1897
Definition: pythonUi.h:62
This class provides the possibility to redirect any signal emitted in an user-defined GUI to differen...
Definition: pythonQtSignalMapper.h:169
Definition: pythonUi.h:50
Definition: pythonUi.h:39