##// END OF EJS Templates
Added cpp_utils as subproject and removed few warnings...
jeandet -
r1485:4f6ae2f1ca26
parent child
Show More
@@ -1,45 +1,46
1 shiboken2 = find_program('shiboken2')
1 shiboken2 = find_program('shiboken2')
2 qmake = find_program('qmake-qt5','qmake')
2 qmake = find_program('qmake-qt5','qmake')
3
3
4 pymod = import('python')
4 pymod = import('python')
5 python3 = pymod.find_installation('python3', modules:['PySide2','shiboken2', 'shiboken2_generator'])
5 python3 = pymod.find_installation('python3', modules:['PySide2','shiboken2', 'shiboken2_generator'])
6
6
7 qt5_modules = ['QtCore','QtGui','QtWidgets']
7 qt5_modules = ['QtCore','QtGui','QtWidgets']
8
8
9 qt_headers_path = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip('\n')
9 qt_headers_path = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip('\n')
10 generated_srcs = run_command(python3, 'src_list.py', 'meson').stdout().split(';')
10 generated_srcs = run_command(python3, 'src_list.py', 'meson').stdout().split(';')
11
11
12 modules_arg = '--modules=@0@'.format(','.join(qt5_modules))
12 modules_arg = '--modules=@0@'.format(','.join(qt5_modules))
13
13
14 shiboken2_build_flags = run_command(python3, 'shiboken-helper.py', '--includes', modules_arg).stdout().strip('\n').split(' ')
14 shiboken2_build_flags = run_command(python3, 'shiboken-helper.py', '--includes', modules_arg).stdout().strip('\n').split(' ')
15 shiboken2_link_flags = run_command(python3, 'shiboken-helper.py', '--libs', modules_arg).stdout().strip('\n').split(' ')
15 shiboken2_link_flags = run_command(python3, 'shiboken-helper.py', '--libs', modules_arg).stdout().strip('\n').split(' ')
16 shiboken2_typesystem = run_command(python3, 'shiboken-helper.py', '--typesystem').stdout().strip('\n')
16 shiboken2_typesystem = run_command(python3, 'shiboken-helper.py', '--typesystem').stdout().strip('\n')
17
17
18 sciqlop_bindings_incs = shiboken2_build_flags + [
18 sciqlop_bindings_incs = shiboken2_build_flags + [
19 '-I'+meson.current_source_dir()+'/../../gui/include',
19 '-I'+meson.current_source_dir()+'/../../gui/include',
20 '-I'+meson.current_source_dir()+'/../../core/include',
20 '-I'+meson.current_source_dir()+'/../../core/include',
21 '-I'+meson.current_source_dir()+'/../../subprojects/TimeSeries/include',
21 '-I'+meson.current_source_dir()+'/../../subprojects/TimeSeries/include',
22 '-I'+meson.current_source_dir()+'/../../subprojects/cpp_utils/include',
22 '-I'+python3.get_path('include'),
23 '-I'+python3.get_path('include'),
23 '-I'+qt_headers_path
24 '-I'+qt_headers_path
24 ]
25 ]
25
26
26 foreach mod:qt5_modules
27 foreach mod:qt5_modules
27 sciqlop_bindings_incs += ['-I'+qt_headers_path+'/'+mod]
28 sciqlop_bindings_incs += ['-I'+qt_headers_path+'/'+mod]
28 endforeach
29 endforeach
29
30
30
31
31 sciqlop_bindings_src = files('bindings.h', 'PyDataProvider.h', 'numpy_wrappers.h', 'numpy_wrappers.cpp')
32 sciqlop_bindings_src = files('bindings.h', 'PyDataProvider.h', 'numpy_wrappers.h', 'numpy_wrappers.cpp')
32
33
33 subdir('SciQLopBindings')
34 subdir('SciQLopBindings')
34
35
35 shiboken_dep = declare_dependency(compile_args: shiboken2_build_flags, link_args: shiboken2_link_flags)
36 shiboken_dep = declare_dependency(compile_args: shiboken2_build_flags, link_args: shiboken2_link_flags)
36
37
37 sciqlop_bindings = python3.extension_module('SciQLopBindings',sciqlop_bindings_src,shiboken2_generator_out,
38 sciqlop_bindings = python3.extension_module('SciQLopBindings',sciqlop_bindings_src,shiboken2_generator_out,
38 dependencies : [sciqlop_app_dep, python3.dependency(), shiboken_dep],
39 dependencies : [sciqlop_app_dep, python3.dependency(), shiboken_dep, cpp_utils_dep],
39 )
40 )
40
41
41
42
42 configure_file(input:'main.py', output:'main.py', copy:true)
43 configure_file(input:'main.py', output:'main.py', copy:true)
43 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
44 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
44
45
45 executable('sciqlop', 'main.cpp', dependencies :python3.dependency())
46 executable('sciqlop', 'main.cpp', dependencies :python3.dependency())
@@ -1,261 +1,265
1 #ifndef NUMPY_WRAPPERS_H
1 #ifndef NUMPY_WRAPPERS_H
2 #define NUMPY_WRAPPERS_H
2 #define NUMPY_WRAPPERS_H
3 #include <Data/ScalarTimeSerie.h>
3 #include <Data/ScalarTimeSerie.h>
4 #include <Data/VectorTimeSerie.h>
4 #include <Data/VectorTimeSerie.h>
5 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
5 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
6 #if defined(slots) && (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__))
6 #if defined(slots) && (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__))
7 #pragma push_macro("slots")
7 #pragma push_macro("slots")
8 #undef slots
8 #undef slots
9 extern "C"
9 extern "C"
10 {
10 {
11 /*
11 /*
12 * Python 2 uses the "register" keyword, which is deprecated in C++ 11
12 * Python 2 uses the "register" keyword, which is deprecated in C++ 11
13 * and forbidden in C++17.
13 * and forbidden in C++17.
14 */
14 */
15 #if defined(__clang__)
15 #if defined(__clang__)
16 #pragma clang diagnostic push
16 #pragma clang diagnostic push
17 #pragma clang diagnostic ignored "-Wdeprecated-register"
17 #pragma clang diagnostic ignored "-Wdeprecated-register"
18 #endif
18 #endif
19
19
20 #include <Python.h>
20 #include <Python.h>
21 #include <numpy/arrayobject.h>
21 #include <numpy/arrayobject.h>
22
22
23 #if defined(__clang__)
23 #if defined(__clang__)
24 #pragma clang diagnostic pop
24 #pragma clang diagnostic pop
25 #endif
25 #endif
26 }
26 }
27 #else
27 #else
28 #include <Python.h>
28 #include <Python.h>
29 #include <numpy/arrayobject.h>
29 #include <numpy/arrayobject.h>
30 #endif
30 #endif
31 #include <assert.h>
31 #include <assert.h>
32
32
33 #include <map>
33 #include <map>
34 #include <warnings.h>
34
35
35 inline int init_numpy()
36 inline int init_numpy()
36 {
37 {
38 DISABLE_WARNING_PUSH
39 DISABLE_WARNING_CONVERSION_NULL
37 import_array(); // PyError if not successful
40 import_array(); // PyError if not successful
41 DISABLE_WARNING_POP
38 return 0;
42 return 0;
39 }
43 }
40 const static int numpy_initialized = init_numpy();
44 const static int numpy_initialized = init_numpy();
41 template <typename dest_type = PyObject>
45 template <typename dest_type = PyObject>
42 struct PyObjectWrapper
46 struct PyObjectWrapper
43 {
47 {
44 private:
48 private:
45 PyObject* _py_obj = nullptr;
49 PyObject* _py_obj = nullptr;
46 void inc_refcount() { Py_XINCREF(_py_obj); }
50 void inc_refcount() { Py_XINCREF(_py_obj); }
47 void dec_refcount()
51 void dec_refcount()
48 {
52 {
49 Py_XDECREF(_py_obj);
53 Py_XDECREF(_py_obj);
50 _py_obj = nullptr;
54 _py_obj = nullptr;
51 }
55 }
52
56
53 public:
57 public:
54 PyObjectWrapper() : _py_obj { nullptr } {}
58 PyObjectWrapper() : _py_obj { nullptr } {}
55 PyObjectWrapper(const PyObjectWrapper& other) : _py_obj { other._py_obj } { inc_refcount(); }
59 PyObjectWrapper(const PyObjectWrapper& other) : _py_obj { other._py_obj } { inc_refcount(); }
56 PyObjectWrapper(PyObjectWrapper&& other) : _py_obj { other._py_obj } { inc_refcount(); }
60 PyObjectWrapper(PyObjectWrapper&& other) : _py_obj { other._py_obj } { inc_refcount(); }
57 explicit PyObjectWrapper(PyObject* obj) : _py_obj { obj } { inc_refcount(); }
61 explicit PyObjectWrapper(PyObject* obj) : _py_obj { obj } { inc_refcount(); }
58 ~PyObjectWrapper() { dec_refcount(); }
62 ~PyObjectWrapper() { dec_refcount(); }
59 PyObjectWrapper& operator=(PyObjectWrapper&& other)
63 PyObjectWrapper& operator=(PyObjectWrapper&& other)
60 {
64 {
61 dec_refcount();
65 dec_refcount();
62 this->_py_obj = other._py_obj;
66 this->_py_obj = other._py_obj;
63 inc_refcount();
67 inc_refcount();
64 return *this;
68 return *this;
65 }
69 }
66 PyObjectWrapper& operator=(const PyObjectWrapper& other)
70 PyObjectWrapper& operator=(const PyObjectWrapper& other)
67 {
71 {
68 dec_refcount();
72 dec_refcount();
69 this->_py_obj = other._py_obj;
73 this->_py_obj = other._py_obj;
70 inc_refcount();
74 inc_refcount();
71 return *this;
75 return *this;
72 }
76 }
73
77
74 PyObject* py_object() { return _py_obj; }
78 PyObject* py_object() { return _py_obj; }
75 inline dest_type* get() { return reinterpret_cast<dest_type*>(_py_obj); }
79 inline dest_type* get() { return reinterpret_cast<dest_type*>(_py_obj); }
76 inline bool is_null() { return _py_obj == nullptr; }
80 inline bool is_null() { return _py_obj == nullptr; }
77 };
81 };
78
82
79 struct NpArray_view
83 struct NpArray_view
80 {
84 {
81 private:
85 private:
82 PyObjectWrapper<PyArrayObject> _py_obj;
86 PyObjectWrapper<PyArrayObject> _py_obj;
83 NpArray_view(const NpArray_view&& other) = delete;
87 NpArray_view(const NpArray_view&& other) = delete;
84
88
85 public:
89 public:
86 static bool isNpArray(PyObject* obj)
90 static bool isNpArray(PyObject* obj)
87 {
91 {
88 auto arr = reinterpret_cast<PyArrayObject*>(obj);
92 auto arr = reinterpret_cast<PyArrayObject*>(obj);
89 auto is_c_aray = obj && PyArray_Check(arr) && PyArray_ISCARRAY(arr);
93 auto is_c_aray = obj && PyArray_Check(arr) && PyArray_ISCARRAY(arr);
90 return is_c_aray;
94 return is_c_aray;
91 }
95 }
92 NpArray_view() : _py_obj { nullptr } {}
96 NpArray_view() : _py_obj { nullptr } {}
93 NpArray_view(const NpArray_view& other) : _py_obj { other._py_obj } {}
97 NpArray_view(const NpArray_view& other) : _py_obj { other._py_obj } {}
94 NpArray_view(NpArray_view&& other) : _py_obj { other._py_obj } {}
98 NpArray_view(NpArray_view&& other) : _py_obj { other._py_obj } {}
95 explicit NpArray_view(PyObject* obj) : _py_obj { obj }
99 explicit NpArray_view(PyObject* obj) : _py_obj { obj }
96 {
100 {
97 assert(isNpArray(obj));
101 assert(isNpArray(obj));
98 assert(PyArray_ISFLOAT(_py_obj.get()));
102 assert(PyArray_ISFLOAT(_py_obj.get()));
99 }
103 }
100
104
101 NpArray_view& operator=(const NpArray_view& other)
105 NpArray_view& operator=(const NpArray_view& other)
102 {
106 {
103 this->_py_obj = other._py_obj;
107 this->_py_obj = other._py_obj;
104 return *this;
108 return *this;
105 }
109 }
106
110
107 NpArray_view& operator=(NpArray_view&& other)
111 NpArray_view& operator=(NpArray_view&& other)
108 {
112 {
109 this->_py_obj = other._py_obj;
113 this->_py_obj = other._py_obj;
110 return *this;
114 return *this;
111 }
115 }
112
116
113 std::vector<std::size_t> shape()
117 std::vector<std::size_t> shape()
114 {
118 {
115 std::vector<std::size_t> shape;
119 std::vector<std::size_t> shape;
116 if (!_py_obj.is_null())
120 if (!_py_obj.is_null())
117 {
121 {
118 if (int ndim = PyArray_NDIM(_py_obj.get()); ndim > 0)
122 if (int ndim = PyArray_NDIM(_py_obj.get()); ndim > 0)
119 {
123 {
120 if (ndim < 10)
124 if (ndim < 10)
121 {
125 {
122 shape.resize(ndim);
126 shape.resize(ndim);
123 std::copy_n(PyArray_SHAPE(_py_obj.get()), ndim, std::begin(shape));
127 std::copy_n(PyArray_SHAPE(_py_obj.get()), ndim, std::begin(shape));
124 }
128 }
125 }
129 }
126 }
130 }
127 return shape;
131 return shape;
128 }
132 }
129
133
130 std::size_t ndim()
134 std::size_t ndim()
131 {
135 {
132 if (!_py_obj.is_null())
136 if (!_py_obj.is_null())
133 {
137 {
134 return static_cast<std::size_t>(PyArray_NDIM(_py_obj.get()));
138 return static_cast<std::size_t>(PyArray_NDIM(_py_obj.get()));
135 }
139 }
136 return 0;
140 return 0;
137 }
141 }
138
142
139 std::size_t size(std::size_t index = 0)
143 std::size_t size(std::size_t index = 0)
140 {
144 {
141 if (!_py_obj.is_null())
145 if (!_py_obj.is_null())
142 {
146 {
143 if (index < static_cast<std::size_t>(PyArray_NDIM(_py_obj.get())))
147 if (index < static_cast<std::size_t>(PyArray_NDIM(_py_obj.get())))
144 {
148 {
145 return PyArray_SHAPE(_py_obj.get())[index];
149 return PyArray_SHAPE(_py_obj.get())[index];
146 }
150 }
147 }
151 }
148 return 0;
152 return 0;
149 }
153 }
150
154
151 std::size_t flat_size()
155 std::size_t flat_size()
152 {
156 {
153 auto s = this->shape();
157 auto s = this->shape();
154 return std::accumulate(
158 return std::accumulate(
155 std::cbegin(s), std::cend(s), 1, [](const auto& a, const auto& b) { return a * b; });
159 std::cbegin(s), std::cend(s), 1, [](const auto& a, const auto& b) { return a * b; });
156 }
160 }
157
161
158 double data(std::size_t pos)
162 double data(std::size_t pos)
159 {
163 {
160 if (!_py_obj.is_null())
164 if (!_py_obj.is_null())
161 {
165 {
162 return reinterpret_cast<double*>(PyArray_DATA(_py_obj.get()))[pos];
166 return reinterpret_cast<double*>(PyArray_DATA(_py_obj.get()))[pos];
163 }
167 }
164 return nan("NAN");
168 return nan("NAN");
165 }
169 }
166
170
167 std::vector<double> to_std_vect()
171 std::vector<double> to_std_vect()
168 {
172 {
169 assert(!this->_py_obj.is_null());
173 assert(!this->_py_obj.is_null());
170 auto sz = flat_size();
174 auto sz = flat_size();
171 std::vector<double> v(sz);
175 std::vector<double> v(sz);
172 auto d_ptr = reinterpret_cast<double*>(PyArray_DATA(_py_obj.get()));
176 auto d_ptr = reinterpret_cast<double*>(PyArray_DATA(_py_obj.get()));
173 std::copy(d_ptr, d_ptr + sz, std::begin(v));
177 std::copy(d_ptr, d_ptr + sz, std::begin(v));
174 return v;
178 return v;
175 }
179 }
176
180
177 std::vector<VectorTimeSerie::raw_value_type> to_std_vect_vect()
181 std::vector<VectorTimeSerie::raw_value_type> to_std_vect_vect()
178 {
182 {
179 auto sz = size(0);
183 auto sz = size(0);
180 std::vector<VectorTimeSerie::raw_value_type> v(sz);
184 std::vector<VectorTimeSerie::raw_value_type> v(sz);
181 if (sz)
185 if (sz)
182 {
186 {
183 assert(ndim() == 2);
187 assert(ndim() == 2);
184 assert(size(1) == 3);
188 assert(size(1) == 3);
185 auto d_ptr
189 auto d_ptr
186 = reinterpret_cast<VectorTimeSerie::raw_value_type*>(PyArray_DATA(_py_obj.get()));
190 = reinterpret_cast<VectorTimeSerie::raw_value_type*>(PyArray_DATA(_py_obj.get()));
187 std::copy(d_ptr, d_ptr + sz, std::begin(v));
191 std::copy(d_ptr, d_ptr + sz, std::begin(v));
188 }
192 }
189 return v;
193 return v;
190 }
194 }
191
195
192 PyObject* py_object() { return _py_obj.py_object(); }
196 PyObject* py_object() { return _py_obj.py_object(); }
193 };
197 };
194
198
195 struct NpArray
199 struct NpArray
196 {
200 {
197 std::vector<std::size_t> shape;
201 std::vector<std::size_t> shape;
198 std::vector<double> data;
202 std::vector<double> data;
199 static bool isNpArray(PyObject* obj) { return NpArray_view::isNpArray(obj); }
203 static bool isNpArray(PyObject* obj) { return NpArray_view::isNpArray(obj); }
200 NpArray() = default;
204 NpArray() = default;
201 explicit NpArray(PyObject* obj)
205 explicit NpArray(PyObject* obj)
202 {
206 {
203 if (obj)
207 if (obj)
204 {
208 {
205 NpArray_view view { obj };
209 NpArray_view view { obj };
206 shape = view.shape();
210 shape = view.shape();
207 data = view.to_std_vect();
211 data = view.to_std_vect();
208 }
212 }
209 }
213 }
210
214
211 inline std::size_t ndim() { return shape.size(); }
215 inline std::size_t ndim() { return shape.size(); }
212
216
213 std::size_t size(std::size_t index = 0)
217 std::size_t size(std::size_t index = 0)
214 {
218 {
215 if (index < shape.size())
219 if (index < shape.size())
216 return shape[index];
220 return shape[index];
217 return 0;
221 return 0;
218 }
222 }
219
223
220 std::size_t flat_size()
224 std::size_t flat_size()
221 {
225 {
222 return std::accumulate(std::cbegin(shape), std::cend(shape), 1,
226 return std::accumulate(std::cbegin(shape), std::cend(shape), 1,
223 [](const auto& a, const auto& b) { return a * b; });
227 [](const auto& a, const auto& b) { return a * b; });
224 }
228 }
225
229
226 // TODO temporary hack should find a way to avoid this copy
230 // TODO temporary hack should find a way to avoid this copy
227 std::vector<VectorTimeSerie::raw_value_type> to_std_vect_vect()
231 std::vector<VectorTimeSerie::raw_value_type> to_std_vect_vect()
228 {
232 {
229 auto sz = size(0);
233 auto sz = size(0);
230 std::vector<VectorTimeSerie::raw_value_type> v(sz);
234 std::vector<VectorTimeSerie::raw_value_type> v(sz);
231 if (sz)
235 if (sz)
232 {
236 {
233 assert(ndim() == 2);
237 assert(ndim() == 2);
234 assert(size(1) == 3);
238 assert(size(1) == 3);
235 auto d_ptr = reinterpret_cast<VectorTimeSerie::raw_value_type*>(data.data());
239 auto d_ptr = reinterpret_cast<VectorTimeSerie::raw_value_type*>(data.data());
236 std::copy(d_ptr, d_ptr + sz, std::begin(v));
240 std::copy(d_ptr, d_ptr + sz, std::begin(v));
237 }
241 }
238 return v;
242 return v;
239 }
243 }
240
244
241 // TODO maybe ;)
245 // TODO maybe ;)
242 PyObject* py_object() { return nullptr; }
246 PyObject* py_object() { return nullptr; }
243 };
247 };
244
248
245 inline int test_np_array(NpArray& arr)
249 inline int test_np_array(NpArray& arr)
246 {
250 {
247 auto shape = arr.shape;
251 auto shape = arr.shape;
248 std::cout << "len(shape)=" << shape.size() << std::endl;
252 std::cout << "len(shape)=" << shape.size() << std::endl;
249 std::for_each(std::cbegin(shape), std::cend(shape), [](auto sz) {
253 std::for_each(std::cbegin(shape), std::cend(shape), [](auto sz) {
250 static int i = 0;
254 static int i = 0;
251 std::cout << "shape[" << i++ << "]=" << sz << std::endl;
255 std::cout << "shape[" << i++ << "]=" << sz << std::endl;
252 });
256 });
253 auto flatsize = std::accumulate(std::cbegin(shape), std::cend(shape), 0);
257 auto flatsize = std::accumulate(std::cbegin(shape), std::cend(shape), 0);
254 for (auto i = 0; i < flatsize; i++)
258 for (auto i = 0; i < flatsize; i++)
255 {
259 {
256 std::cout << "data[" << i << "]=" << arr.data[i] << std::endl;
260 std::cout << "data[" << i << "]=" << arr.data[i] << std::endl;
257 }
261 }
258 return 1;
262 return 1;
259 }
263 }
260
264
261 #endif //#ifndef NUMPY_WRAPPERS_H
265 #endif //#ifndef NUMPY_WRAPPERS_H
@@ -1,120 +1,118
1 #ifndef SCIQLOP_SQPAPPLICATION_H
1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
3
3
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 #include <QAction>
6 #include <QAction>
7 #include <QApplication>
7 #include <QApplication>
8 #include <QLoggingCategory>
8 #include <QLoggingCategory>
9 #include <QMenuBar>
9 #include <QMenuBar>
10 #include <QProxyStyle>
10 #include <QProxyStyle>
11 #include <QStyleOption>
11 #include <QStyleOption>
12 #include <QWidget>
12 #include <QWidget>
13 #include <QWidgetAction>
13 #include <QWidgetAction>
14
14
15 #include <Common/spimpl.h>
15 #include <Common/spimpl.h>
16
16
17 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
17 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
18
18
19 #if defined(sqpApp)
19 #if defined(sqpApp)
20 #undef sqpApp
20 #undef sqpApp
21 #endif
21 #endif
22 #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance()))
22 #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance()))
23
23
24 class DataSourceController;
24 class DataSourceController;
25 class NetworkController;
25 class NetworkController;
26 class TimeController;
26 class TimeController;
27 class VariableController;
27 class VariableController;
28 class VariableController2;
28 class VariableController2;
29 class VariableModel2;
29 class VariableModel2;
30 class DragDropGuiController;
30 class DragDropGuiController;
31 class ActionsGuiController;
31 class ActionsGuiController;
32 class CatalogueController;
32 class CatalogueController;
33
33
34 /* stolen from here https://forum.qt.io/topic/90403/show-tooltip-immediatly/6 */
34 /* stolen from here https://forum.qt.io/topic/90403/show-tooltip-immediatly/6 */
35 class MyProxyStyle : public QProxyStyle
35 class MyProxyStyle : public QProxyStyle
36 {
36 {
37 public:
37 public:
38 using QProxyStyle::QProxyStyle;
38 using QProxyStyle::QProxyStyle;
39
39
40 int styleHint(StyleHint hint, const QStyleOption* option = nullptr,
40 int styleHint(StyleHint hint, const QStyleOption* option = nullptr,
41 const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const override
41 const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const override
42 {
42 {
43 if (widget)
44 auto cname = widget->metaObject()->className();
45 if (hint == QStyle::SH_ToolButton_PopupDelay && widget
43 if (hint == QStyle::SH_ToolButton_PopupDelay && widget
46 /*&& widget->inherits(QWidgetAction::staticMetaObject.className())*/)
44 /*&& widget->inherits(QWidgetAction::staticMetaObject.className())*/)
47 {
45 {
48 return 0;
46 return 0;
49 }
47 }
50
48
51 return QProxyStyle::styleHint(hint, option, widget, returnData);
49 return QProxyStyle::styleHint(hint, option, widget, returnData);
52 }
50 }
53 };
51 };
54
52
55 /**
53 /**
56 * @brief The SqpApplication class aims to make the link between SciQlop
54 * @brief The SqpApplication class aims to make the link between SciQlop
57 * and its plugins. This is the intermediate class that SciQlop has to use
55 * and its plugins. This is the intermediate class that SciQlop has to use
58 * in the way to connect a data source. Please first use load method to initialize
56 * in the way to connect a data source. Please first use load method to initialize
59 * a plugin specified by its metadata name (JSON plugin source) then others specifics
57 * a plugin specified by its metadata name (JSON plugin source) then others specifics
60 * method will be able to access it.
58 * method will be able to access it.
61 * You can load a data source driver plugin then create a data source.
59 * You can load a data source driver plugin then create a data source.
62 */
60 */
63
61
64 class SqpApplication : public QApplication
62 class SqpApplication : public QApplication
65 {
63 {
66 Q_OBJECT
64 Q_OBJECT
67 public:
65 public:
68 explicit SqpApplication(int& argc, char** argv);
66 explicit SqpApplication(int& argc, char** argv);
69 ~SqpApplication() override;
67 ~SqpApplication() override;
70 void initialize();
68 void initialize();
71
69
72 /// Accessors for the differents sciqlop controllers
70 /// Accessors for the differents sciqlop controllers
73 DataSourceController& dataSourceController() noexcept;
71 DataSourceController& dataSourceController() noexcept;
74 NetworkController& networkController() noexcept;
72 NetworkController& networkController() noexcept;
75 TimeController& timeController() noexcept;
73 TimeController& timeController() noexcept;
76 VariableController2& variableController() noexcept;
74 VariableController2& variableController() noexcept;
77 std::shared_ptr<VariableController2> variableControllerOwner() noexcept;
75 std::shared_ptr<VariableController2> variableControllerOwner() noexcept;
78 CatalogueController& catalogueController() noexcept;
76 CatalogueController& catalogueController() noexcept;
79
77
80 /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but
78 /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but
81 /// doesn't live in a thread and access gui
79 /// doesn't live in a thread and access gui
82 DragDropGuiController& dragDropGuiController() noexcept;
80 DragDropGuiController& dragDropGuiController() noexcept;
83 ActionsGuiController& actionsGuiController() noexcept;
81 ActionsGuiController& actionsGuiController() noexcept;
84
82
85 enum class PlotsInteractionMode
83 enum class PlotsInteractionMode
86 {
84 {
87 None,
85 None,
88 ZoomBox,
86 ZoomBox,
89 DragAndDrop,
87 DragAndDrop,
90 SelectionZones
88 SelectionZones
91 };
89 };
92
90
93 enum class PlotsCursorMode
91 enum class PlotsCursorMode
94 {
92 {
95 NoCursor,
93 NoCursor,
96 Vertical,
94 Vertical,
97 Temporal,
95 Temporal,
98 Horizontal,
96 Horizontal,
99 Cross
97 Cross
100 };
98 };
101
99
102 PlotsInteractionMode plotsInteractionMode() const;
100 PlotsInteractionMode plotsInteractionMode() const;
103 void setPlotsInteractionMode(PlotsInteractionMode mode);
101 void setPlotsInteractionMode(PlotsInteractionMode mode);
104
102
105 PlotsCursorMode plotsCursorMode() const;
103 PlotsCursorMode plotsCursorMode() const;
106 void setPlotsCursorMode(PlotsCursorMode mode);
104 void setPlotsCursorMode(PlotsCursorMode mode);
107
105
108 private:
106 private:
109 class SqpApplicationPrivate;
107 class SqpApplicationPrivate;
110 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
108 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
111 };
109 };
112
110
113 inline SqpApplication* SqpApplication_ctor()
111 inline SqpApplication* SqpApplication_ctor()
114 {
112 {
115 static int argc;
113 static int argc;
116 static char** argv;
114 static char** argv;
117 return new SqpApplication(argc, argv);
115 return new SqpApplication(argc, argv);
118 }
116 }
119
117
120 #endif // SCIQLOP_SQPAPPLICATION_H
118 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,85 +1,86
1 #include <QMainWindow>
1 #include <QMainWindow>
2 #include <QObject>
2 #include <QObject>
3 #include <QScreen>
3 #include <QScreen>
4 #include <QString>
4 #include <QString>
5 #include <QWheelEvent>
5 #include <QWheelEvent>
6 #include <QtTest>
6 #include <QtTest>
7 #include <cstdlib>
7 #include <cstdlib>
8
8
9
9
10 #include <Common/cpp_utils.h>
10 #include <Common/cpp_utils.h>
11 #include <SqpApplication.h>
11 #include <SqpApplication.h>
12
12
13 #include <GUITestUtils.h>
13 #include <GUITestUtils.h>
14
14
15 #include <Catalogue/CatalogueController.h>
15 #include <Catalogue/CatalogueController.h>
16 #include <Catalogue2/browser.h>
16 #include <Catalogue2/browser.h>
17
17
18 template <int EventsCount = 1000>
18 template <int EventsCount = 1000>
19 auto build_CatalogueBrowser_test()
19 auto build_CatalogueBrowser_test()
20 {
20 {
21 sqpApp->catalogueController().add("test");
21 sqpApp->catalogueController().add("test");
22 sqpApp->catalogueController().add("stuff");
22 sqpApp->catalogueController().add("stuff");
23 sqpApp->catalogueController().add("default");
23 sqpApp->catalogueController().add("default");
24 sqpApp->catalogueController().add("new catalogue", "default");
24 sqpApp->catalogueController().add("new catalogue", "default");
25 auto catalogue = sqpApp->catalogueController().add("new catalogue2", "default");
25 auto catalogue = sqpApp->catalogueController().add("new catalogue2", "default");
26 for (auto _ : std::array<char, EventsCount>())
26 for (auto _ : std::array<char, EventsCount>())
27 {
27 {
28 (void)_;
28 static int i = 0;
29 static int i = 0;
29 auto event = CatalogueController::make_event_ptr();
30 auto event = CatalogueController::make_event_ptr();
30 event->name = std::string("Event ") + std::to_string(i++);
31 event->name = std::string("Event ") + std::to_string(i++);
31 event->tags = { "tag1", "tag2" };
32 event->tags = { "tag1", "tag2" };
32 event->products = { CatalogueController::Event_t::Product_t {
33 event->products = { CatalogueController::Event_t::Product_t {
33 std::string("Product2") + std::to_string(rand() % 30),
34 std::string("Product2") + std::to_string(rand() % 30),
34 static_cast<double>(1532357932 + rand() % 100),
35 static_cast<double>(1532357932 + rand() % 100),
35 static_cast<double>(1532358932 + rand() % 100) },
36 static_cast<double>(1532358932 + rand() % 100) },
36 CatalogueController::Event_t::Product_t {
37 CatalogueController::Event_t::Product_t {
37 std::string("Product2") + std::to_string(rand() % 30),
38 std::string("Product2") + std::to_string(rand() % 30),
38 static_cast<double>(1532357932 + rand() % 200),
39 static_cast<double>(1532357932 + rand() % 200),
39 static_cast<double>(1532358932 + rand() % 200) },
40 static_cast<double>(1532358932 + rand() % 200) },
40 CatalogueController::Event_t::Product_t {
41 CatalogueController::Event_t::Product_t {
41 std::string("Product2") + std::to_string(rand() % 30),
42 std::string("Product2") + std::to_string(rand() % 30),
42 static_cast<double>(1532357932 + rand() % 70),
43 static_cast<double>(1532357932 + rand() % 70),
43 static_cast<double>(1532358932 + rand() % 70) } };
44 static_cast<double>(1532358932 + rand() % 70) } };
44 catalogue->add(event);
45 catalogue->add(event);
45 }
46 }
46 return std::make_unique<CataloguesBrowser>();
47 return std::make_unique<CataloguesBrowser>();
47 }
48 }
48
49
49 class A_CatalogueBrowser : public QObject
50 class A_CatalogueBrowser : public QObject
50 {
51 {
51 Q_OBJECT
52 Q_OBJECT
52 public:
53 public:
53 explicit A_CatalogueBrowser(QObject* parent = Q_NULLPTR) : QObject(parent) {}
54 explicit A_CatalogueBrowser(QObject* parent = Q_NULLPTR) : QObject(parent) {}
54
55
55 private slots:
56 private slots:
56 void can_sort_events()
57 void can_sort_events()
57 {
58 {
58 auto w = build_CatalogueBrowser_test();
59 auto w = build_CatalogueBrowser_test();
59 QVERIFY(prepare_gui_test(w.get()));
60 QVERIFY(prepare_gui_test(w.get()));
60 // GET_CHILD_WIDGET_FOR_GUI_TESTS((*w.get()),,,)
61 // GET_CHILD_WIDGET_FOR_GUI_TESTS((*w.get()),,,)
61 for (int i = 0; i < 1000000; i++)
62 for (int i = 0; i < 1000000; i++)
62 {
63 {
63 QThread::usleep(100);
64 QThread::usleep(100);
64 QCoreApplication::processEvents();
65 QCoreApplication::processEvents();
65 }
66 }
66 }
67 }
67 };
68 };
68
69
69 QT_BEGIN_NAMESPACE
70 QT_BEGIN_NAMESPACE
70 QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
71 QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
71 QT_END_NAMESPACE
72 QT_END_NAMESPACE
72 int main(int argc, char* argv[])
73 int main(int argc, char* argv[])
73 {
74 {
74 Q_INIT_RESOURCE(sqpguiresources);
75 Q_INIT_RESOURCE(sqpguiresources);
75
76
76 SqpApplication app { argc, argv };
77 SqpApplication app { argc, argv };
77 app.setAttribute(Qt::AA_Use96Dpi, true);
78 app.setAttribute(Qt::AA_Use96Dpi, true);
78 QTEST_DISABLE_KEYPAD_NAVIGATION;
79 QTEST_DISABLE_KEYPAD_NAVIGATION;
79 QTEST_ADD_GPU_BLACKLIST_SUPPORT;
80 QTEST_ADD_GPU_BLACKLIST_SUPPORT;
80 A_CatalogueBrowser tc;
81 A_CatalogueBrowser tc;
81 QTEST_SET_MAIN_SOURCE_PATH;
82 QTEST_SET_MAIN_SOURCE_PATH;
82 return QTest::qExec(&tc, argc, argv);
83 return QTest::qExec(&tc, argc, argv);
83 }
84 }
84
85
85 #include "main.moc"
86 #include "main.moc"
@@ -1,52 +1,54
1 project('SciQLOP', 'cpp',default_options : ['cpp_std=c++17'], meson_version:'>=0.51.0')
1 project('SciQLOP', 'cpp',default_options : ['cpp_std=c++17'], meson_version:'>=0.51.0')
2 add_global_arguments('-DSCIQLOP_VERSION="1.1.0"', language : 'cpp')
2 add_global_arguments('-DSCIQLOP_VERSION="1.1.0"', language : 'cpp')
3
3
4 qt5 = import('qt5')
4 qt5 = import('qt5')
5 qt5core = dependency('qt5', modules : 'Core')
5 qt5core = dependency('qt5', modules : 'Core')
6 qt5widgets = dependency('qt5', modules : 'Widgets')
6 qt5widgets = dependency('qt5', modules : 'Widgets')
7 qt5gui = dependency('qt5', modules : 'Gui')
7 qt5gui = dependency('qt5', modules : 'Gui')
8 qt5svg = dependency('qt5', modules : 'Svg')
8 qt5svg = dependency('qt5', modules : 'Svg')
9 qt5xml = dependency('qt5', modules : 'Xml')
9 qt5xml = dependency('qt5', modules : 'Xml')
10 qt5network = dependency('qt5', modules : 'Network')
10 qt5network = dependency('qt5', modules : 'Network')
11 qt5printsupport = dependency('qt5', modules : 'PrintSupport')
11 qt5printsupport = dependency('qt5', modules : 'PrintSupport')
12 qt5Concurrent = dependency('qt5', modules : 'Concurrent')
12 qt5Concurrent = dependency('qt5', modules : 'Concurrent')
13 qt5test = dependency('qt5', modules : 'Test')
13 qt5test = dependency('qt5', modules : 'Test')
14
14
15 cpp_utils_dep = dependency('cpp_utils', fallback:['cpp_utils','cpp_utils_dep'])
16
15 moc = find_program('moc-qt5','moc')
17 moc = find_program('moc-qt5','moc')
16 rcc = find_program('rcc-qt5','rcc')
18 rcc = find_program('rcc-qt5','rcc')
17
19
18 if build_machine.system()=='darwin'
20 if build_machine.system()=='darwin'
19 add_global_link_arguments('-headerpad_max_install_names', language : 'cpp')
21 add_global_link_arguments('-headerpad_max_install_names', language : 'cpp')
20 install_data('build_cfg/mac/sciqlopLOGO.icns', install_dir : 'Contents/Resources')
22 install_data('build_cfg/mac/sciqlopLOGO.icns', install_dir : 'Contents/Resources')
21 install_data('build_cfg/mac/Info.plist', install_dir : 'Contents')
23 install_data('build_cfg/mac/Info.plist', install_dir : 'Contents')
22 meson.add_install_script('build_cfg/mac/install_script.sh')
24 meson.add_install_script('build_cfg/mac/install_script.sh')
23 elif host_machine.system()=='windows'
25 elif host_machine.system()=='windows'
24 meson.add_install_script('build_cfg/windows/install_script.sh')
26 meson.add_install_script('build_cfg/windows/install_script.sh')
25 elif host_machine.system()=='linux'
27 elif host_machine.system()=='linux'
26 install_data('app/resources/sciqlopLOGO.svg', install_dir : 'share/icons/hicolor/scalable/')
28 install_data('app/resources/sciqlopLOGO.svg', install_dir : 'share/icons/hicolor/scalable/')
27 install_data('app/resources/SciQLOP.desktop', install_dir : 'share/applications')
29 install_data('app/resources/SciQLOP.desktop', install_dir : 'share/applications')
28 install_data('app/resources/SciQLOP.appdata.xml', install_dir : 'share/metainfo')
30 install_data('app/resources/SciQLOP.appdata.xml', install_dir : 'share/metainfo')
29 endif
31 endif
30
32
31 # Sets AMDA server that will be used during execution.
33 # Sets AMDA server that will be used during execution.
32 # Available values are:
34 # Available values are:
33 # - "default": default AMDA server
35 # - "default": default AMDA server
34 # - "amdatest": AMDA test server
36 # - "amdatest": AMDA test server
35 # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file)
37 # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file)
36 # - "localhost": use local AMDA server
38 # - "localhost": use local AMDA server
37 # Any other value will lead to the use of the default server
39 # Any other value will lead to the use of the default server
38 add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp')
40 add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp')
39
41
40 subdir('core')
42 subdir('core')
41 subdir('gui')
43 subdir('gui')
42 subdir('plugins')
44 subdir('plugins')
43 subdir('app')
45 subdir('app')
44
46
45 cppcheck = find_program('cppcheck', required : false)
47 cppcheck = find_program('cppcheck', required : false)
46
48
47 if cppcheck.found()
49 if cppcheck.found()
48 run_target('cppcheck',
50 run_target('cppcheck',
49 command : [cppcheck, '--enable=all',
51 command : [cppcheck, '--enable=all',
50 '--project=' + join_paths(meson.build_root(), 'compile_commands.json')]
52 '--project=' + join_paths(meson.build_root(), 'compile_commands.json')]
51 )
53 )
52 endif
54 endif
General Comments 0
You need to be logged in to leave comments. Login now