@@ -1,201 +1,201 | |||||
1 | cmake_minimum_required(VERSION 3.6) |
|
1 | cmake_minimum_required(VERSION 3.6) | |
2 | project(SciQLOPCore CXX) |
|
2 | project(SciQLOPCore CXX) | |
3 |
|
3 | |||
4 | OPTION (CPPCHECK "Analyzes the source code with cppcheck" OFF) |
|
4 | OPTION (CPPCHECK "Analyzes the source code with cppcheck" OFF) | |
5 | OPTION (CLANG_TIDY "Analyzes the source code with Clang Tidy" OFF) |
|
5 | OPTION (CLANG_TIDY "Analyzes the source code with Clang Tidy" OFF) | |
6 | OPTION (IWYU "Analyzes the source code with Include What You Use" OFF) |
|
6 | OPTION (IWYU "Analyzes the source code with Include What You Use" OFF) | |
7 |
|
7 | |||
8 | OPTION (Catalog "builds catalog API" ON) |
|
8 | OPTION (Catalog "builds catalog API" ON) | |
9 |
|
9 | |||
10 | set(CMAKE_CXX_STANDARD 17) |
|
10 | set(CMAKE_CXX_STANDARD 17) | |
11 |
|
11 | |||
12 | set(CMAKE_AUTOMOC ON) |
|
12 | set(CMAKE_AUTOMOC ON) | |
13 | #https://gitlab.kitware.com/cmake/cmake/issues/15227 |
|
13 | #https://gitlab.kitware.com/cmake/cmake/issues/15227 | |
14 | #set(CMAKE_AUTOUIC ON) |
|
14 | #set(CMAKE_AUTOUIC ON) | |
15 | if(POLICY CMP0071) |
|
15 | if(POLICY CMP0071) | |
16 | cmake_policy(SET CMP0071 OLD) |
|
16 | cmake_policy(SET CMP0071 OLD) | |
17 | endif() |
|
17 | endif() | |
18 | set(CMAKE_AUTORCC ON) |
|
18 | set(CMAKE_AUTORCC ON) | |
19 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
|
19 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | |
20 |
|
20 | |||
21 | find_package(Qt5 COMPONENTS Core Widgets Network PrintSupport Svg Test REQUIRED) |
|
21 | find_package(Qt5 COMPONENTS Core Widgets Network PrintSupport Svg Test REQUIRED) | |
22 |
|
22 | |||
23 | find_package(pybind11 CONFIG QUIET) |
|
23 | find_package(pybind11 CONFIG QUIET) | |
24 | if (NOT pybind11_FOUND) |
|
24 | if (NOT pybind11_FOUND) | |
25 | execute_process(COMMAND git submodule init external/pybind11 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
|
25 | execute_process(COMMAND git submodule init external/pybind11 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | |
26 | execute_process(COMMAND git submodule update external/pybind11 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
|
26 | execute_process(COMMAND git submodule update external/pybind11 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | |
27 | add_subdirectory(external/pybind11) |
|
27 | add_subdirectory(external/pybind11) | |
28 | endif() |
|
28 | endif() | |
29 |
|
29 | |||
30 | find_package(catalogs CONFIG QUIET) |
|
30 | find_package(libcatalogs CONFIG QUIET) | |
31 |
if (NOT |
|
31 | if (NOT libcatalogs_FOUND) | |
32 | execute_process(COMMAND git submodule init external/libcatalogs WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
|
32 | execute_process(COMMAND git submodule init external/libcatalogs WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | |
33 | execute_process(COMMAND git submodule update external/libcatalogs WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
|
33 | execute_process(COMMAND git submodule update external/libcatalogs WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | |
34 | add_subdirectory(external/libcatalogs) |
|
34 | add_subdirectory(external/libcatalogs) | |
35 | endif() |
|
35 | endif() | |
36 |
|
36 | |||
37 | macro(declare_test testname testexe sources libraries) |
|
37 | macro(declare_test testname testexe sources libraries) | |
38 | add_executable(${testexe} ${sources}) |
|
38 | add_executable(${testexe} ${sources}) | |
39 | target_link_libraries(${testexe} ${libraries}) |
|
39 | target_link_libraries(${testexe} ${libraries}) | |
40 | add_test(NAME ${testname} COMMAND ${testexe}) |
|
40 | add_test(NAME ${testname} COMMAND ${testexe}) | |
41 | endmacro(declare_test) |
|
41 | endmacro(declare_test) | |
42 |
|
42 | |||
43 | enable_testing() |
|
43 | enable_testing() | |
44 |
|
44 | |||
45 | FILE (GLOB_RECURSE core_SRCS |
|
45 | FILE (GLOB_RECURSE core_SRCS | |
46 | ./include/DataSource/DataSourceItemMergeHelper.h |
|
46 | ./include/DataSource/DataSourceItemMergeHelper.h | |
47 | ./include/DataSource/DataSourceItemAction.h |
|
47 | ./include/DataSource/DataSourceItemAction.h | |
48 | ./include/DataSource/DataSourceItem.h |
|
48 | ./include/DataSource/DataSourceItem.h | |
49 | ./include/DataSource/DataSourceController.h |
|
49 | ./include/DataSource/DataSourceController.h | |
50 | ./include/Common/SortUtils.h |
|
50 | ./include/Common/SortUtils.h | |
51 | ./include/Common/spimpl.h |
|
51 | ./include/Common/spimpl.h | |
52 | ./include/Common/MimeTypesDef.h |
|
52 | ./include/Common/MimeTypesDef.h | |
53 | ./include/Common/MetaTypes.h |
|
53 | ./include/Common/MetaTypes.h | |
54 | ./include/Common/StringUtils.h |
|
54 | ./include/Common/StringUtils.h | |
55 | ./include/Common/SignalWaiter.h |
|
55 | ./include/Common/SignalWaiter.h | |
56 | ./include/Common/DateUtils.h |
|
56 | ./include/Common/DateUtils.h | |
57 | ./include/Common/Numeric.h |
|
57 | ./include/Common/Numeric.h | |
58 | ./include/Common/deprecate.h |
|
58 | ./include/Common/deprecate.h | |
59 | ./include/Common/containers.h |
|
59 | ./include/Common/containers.h | |
60 | ./include/Common/debug.h |
|
60 | ./include/Common/debug.h | |
61 | ./include/Plugin/IPlugin.h |
|
61 | ./include/Plugin/IPlugin.h | |
62 | ./include/Data/ArrayDataIterator.h |
|
62 | ./include/Data/ArrayDataIterator.h | |
63 | ./include/Data/VariableRequest.h |
|
63 | ./include/Data/VariableRequest.h | |
64 | ./include/Data/VectorSeries.h |
|
64 | ./include/Data/VectorSeries.h | |
65 | ./include/Data/DateTimeRange.h |
|
65 | ./include/Data/DateTimeRange.h | |
66 | ./include/Data/DateTimeRangeHelper.h |
|
66 | ./include/Data/DateTimeRangeHelper.h | |
67 | ./include/Data/ScalarSeries.h |
|
67 | ./include/Data/ScalarSeries.h | |
68 | ./include/Data/DataSeriesMergeHelper.h |
|
68 | ./include/Data/DataSeriesMergeHelper.h | |
69 | ./include/Data/DataSeries.h |
|
69 | ./include/Data/DataSeries.h | |
70 | ./include/Data/AcquisitionDataPacket.h |
|
70 | ./include/Data/AcquisitionDataPacket.h | |
71 | ./include/Data/DataSeriesType.h |
|
71 | ./include/Data/DataSeriesType.h | |
72 | ./include/Data/AcquisitionRequest.h |
|
72 | ./include/Data/AcquisitionRequest.h | |
73 | ./include/Data/SqpIterator.h |
|
73 | ./include/Data/SqpIterator.h | |
74 | ./include/Data/ArrayData.h |
|
74 | ./include/Data/ArrayData.h | |
75 | ./include/Data/DataSeriesIterator.h |
|
75 | ./include/Data/DataSeriesIterator.h | |
76 | ./include/Data/DataSeriesUtils.h |
|
76 | ./include/Data/DataSeriesUtils.h | |
77 | ./include/Data/SpectrogramSeries.h |
|
77 | ./include/Data/SpectrogramSeries.h | |
78 | ./include/Data/Unit.h |
|
78 | ./include/Data/Unit.h | |
79 | ./include/Data/DataProviderParameters.h |
|
79 | ./include/Data/DataProviderParameters.h | |
80 | ./include/Data/OptionalAxis.h |
|
80 | ./include/Data/OptionalAxis.h | |
81 | ./include/Data/IDataProvider.h |
|
81 | ./include/Data/IDataProvider.h | |
82 | ./include/Data/IDataSeries.h |
|
82 | ./include/Data/IDataSeries.h | |
83 | ./include/Network/NetworkController.h |
|
83 | ./include/Network/NetworkController.h | |
84 | ./include/Network/Downloader.h |
|
84 | ./include/Network/Downloader.h | |
85 | ./include/Version.h |
|
85 | ./include/Version.h | |
86 | ./include/CoreGlobal.h |
|
86 | ./include/CoreGlobal.h | |
87 | ./include/Visualization/VisualizationController.h |
|
87 | ./include/Visualization/VisualizationController.h | |
88 | ./include/PluginManager/PluginManager.h |
|
88 | ./include/PluginManager/PluginManager.h | |
89 | ./include/Variable/VariableModel.h |
|
89 | ./include/Variable/VariableModel.h | |
90 | ./include/Variable/VariableModel2.h |
|
90 | ./include/Variable/VariableModel2.h | |
91 | ./include/Variable/VariableAcquisitionWorker.h |
|
91 | ./include/Variable/VariableAcquisitionWorker.h | |
92 | ./include/Variable/VariableCacheStrategy.h |
|
92 | ./include/Variable/VariableCacheStrategy.h | |
93 | ./include/Variable/VariableSynchronizationGroup.h |
|
93 | ./include/Variable/VariableSynchronizationGroup.h | |
94 | ./include/Variable/VariableSynchronizationGroup2.h |
|
94 | ./include/Variable/VariableSynchronizationGroup2.h | |
95 | ./include/Variable/ProportionalCacheStrategy.h |
|
95 | ./include/Variable/ProportionalCacheStrategy.h | |
96 | ./include/Variable/SingleThresholdCacheStrategy.h |
|
96 | ./include/Variable/SingleThresholdCacheStrategy.h | |
97 | ./include/Variable/VariableCacheStrategyFactory.h |
|
97 | ./include/Variable/VariableCacheStrategyFactory.h | |
98 | ./include/Variable/Variable.h |
|
98 | ./include/Variable/Variable.h | |
99 | ./include/Variable/VariableCacheController.h |
|
99 | ./include/Variable/VariableCacheController.h | |
100 | ./include/Variable/VariableController.h |
|
100 | ./include/Variable/VariableController.h | |
101 | ./include/Variable/VariableController2.h |
|
101 | ./include/Variable/VariableController2.h | |
102 | ./include/Variable/private/VCTransaction.h |
|
102 | ./include/Variable/private/VCTransaction.h | |
103 | ./include/Time/TimeController.h |
|
103 | ./include/Time/TimeController.h | |
104 | ./include/Settings/ISqpSettingsBindable.h |
|
104 | ./include/Settings/ISqpSettingsBindable.h | |
105 | ./include/Settings/SqpSettingsDefs.h |
|
105 | ./include/Settings/SqpSettingsDefs.h | |
106 |
|
106 | |||
107 | ./src/DataSource/DataSourceItem.cpp |
|
107 | ./src/DataSource/DataSourceItem.cpp | |
108 | ./src/DataSource/DataSourceItemAction.cpp |
|
108 | ./src/DataSource/DataSourceItemAction.cpp | |
109 | ./src/DataSource/DataSourceItemMergeHelper.cpp |
|
109 | ./src/DataSource/DataSourceItemMergeHelper.cpp | |
110 | ./src/DataSource/DataSourceController.cpp |
|
110 | ./src/DataSource/DataSourceController.cpp | |
111 | ./src/Common/DateUtils.cpp |
|
111 | ./src/Common/DateUtils.cpp | |
112 | ./src/Common/MimeTypesDef.cpp |
|
112 | ./src/Common/MimeTypesDef.cpp | |
113 | ./src/Common/StringUtils.cpp |
|
113 | ./src/Common/StringUtils.cpp | |
114 | ./src/Common/SignalWaiter.cpp |
|
114 | ./src/Common/SignalWaiter.cpp | |
115 | ./src/Data/ScalarSeries.cpp |
|
115 | ./src/Data/ScalarSeries.cpp | |
116 | ./src/Data/DataSeriesIterator.cpp |
|
116 | ./src/Data/DataSeriesIterator.cpp | |
117 | ./src/Data/OptionalAxis.cpp |
|
117 | ./src/Data/OptionalAxis.cpp | |
118 | ./src/Data/ArrayDataIterator.cpp |
|
118 | ./src/Data/ArrayDataIterator.cpp | |
119 | ./src/Data/SpectrogramSeries.cpp |
|
119 | ./src/Data/SpectrogramSeries.cpp | |
120 | ./src/Data/DataSeriesUtils.cpp |
|
120 | ./src/Data/DataSeriesUtils.cpp | |
121 | ./src/Data/VectorSeries.cpp |
|
121 | ./src/Data/VectorSeries.cpp | |
122 | ./src/Network/NetworkController.cpp |
|
122 | ./src/Network/NetworkController.cpp | |
123 | ./src/Network/Downloader.cpp |
|
123 | ./src/Network/Downloader.cpp | |
124 | ./src/Visualization/VisualizationController.cpp |
|
124 | ./src/Visualization/VisualizationController.cpp | |
125 | ./src/PluginManager/PluginManager.cpp |
|
125 | ./src/PluginManager/PluginManager.cpp | |
126 | ./src/Variable/VariableController.cpp |
|
126 | ./src/Variable/VariableController.cpp | |
127 | ./src/Variable/VariableController2.cpp |
|
127 | ./src/Variable/VariableController2.cpp | |
128 | ./src/Variable/VariableModel.cpp |
|
128 | ./src/Variable/VariableModel.cpp | |
129 | ./src/Variable/VariableModel2.cpp |
|
129 | ./src/Variable/VariableModel2.cpp | |
130 | ./src/Variable/VariableCacheController.cpp |
|
130 | ./src/Variable/VariableCacheController.cpp | |
131 | ./src/Variable/VariableSynchronizationGroup.cpp |
|
131 | ./src/Variable/VariableSynchronizationGroup.cpp | |
132 | ./src/Variable/VariableSynchronizationGroup2.cpp |
|
132 | ./src/Variable/VariableSynchronizationGroup2.cpp | |
133 | ./src/Variable/Variable.cpp |
|
133 | ./src/Variable/Variable.cpp | |
134 | ./src/Variable/VariableAcquisitionWorker.cpp |
|
134 | ./src/Variable/VariableAcquisitionWorker.cpp | |
135 | ./src/Version.cpp |
|
135 | ./src/Version.cpp | |
136 | ./src/Time/TimeController.cpp |
|
136 | ./src/Time/TimeController.cpp | |
137 | ./src/Settings/SqpSettingsDefs.cpp |
|
137 | ./src/Settings/SqpSettingsDefs.cpp | |
138 |
|
138 | |||
139 | ) |
|
139 | ) | |
140 |
|
140 | |||
141 |
|
141 | |||
142 | IF(Catalog) |
|
142 | IF(Catalog) | |
143 | FILE (GLOB_RECURSE core_catalog_SRCS |
|
143 | FILE (GLOB_RECURSE core_catalog_SRCS | |
144 | ./src/Catalogue/CatalogueController.cpp |
|
144 | ./src/Catalogue/CatalogueController.cpp | |
145 | ./include/Catalogue/CatalogueController.h |
|
145 | ./include/Catalogue/CatalogueController.h | |
146 | ) |
|
146 | ) | |
147 | ELSE() |
|
147 | ELSE() | |
148 | FILE (GLOB_RECURSE core_catalog_SRCS |
|
148 | FILE (GLOB_RECURSE core_catalog_SRCS | |
149 | ) |
|
149 | ) | |
150 | ENDIF(Catalog) |
|
150 | ENDIF(Catalog) | |
151 |
|
151 | |||
152 | add_definitions(-DCORE_STATIC) |
|
152 | add_definitions(-DCORE_STATIC) | |
153 | #add_definitions(-DHIDE_DEPRECATED) |
|
153 | #add_definitions(-DHIDE_DEPRECATED) | |
154 | add_definitions(-DSCIQLOP_CRASH_ON_ERROR) |
|
154 | add_definitions(-DSCIQLOP_CRASH_ON_ERROR) | |
155 |
|
155 | |||
156 | add_library(sciqlopcore ${core_SRCS} ${core_catalog_SRCS}) |
|
156 | add_library(sciqlopcore ${core_SRCS} ${core_catalog_SRCS}) | |
157 | SET_TARGET_PROPERTIES(sciqlopcore PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) |
|
157 | SET_TARGET_PROPERTIES(sciqlopcore PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | |
158 |
|
158 | |||
159 | target_include_directories(sciqlopcore PUBLIC |
|
159 | target_include_directories(sciqlopcore PUBLIC | |
160 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
|
160 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | |
161 | $<INSTALL_INTERFACE:include/SciQLOP> |
|
161 | $<INSTALL_INTERFACE:include/SciQLOP> | |
162 | ) |
|
162 | ) | |
163 |
|
163 | |||
164 | target_link_libraries(sciqlopcore PUBLIC |
|
164 | target_link_libraries(sciqlopcore PUBLIC | |
165 | Qt5::Core |
|
165 | Qt5::Core | |
166 | Qt5::Network |
|
166 | Qt5::Network | |
167 | ) |
|
167 | ) | |
168 |
|
168 | |||
169 | if(Catalog) |
|
169 | if(Catalog) | |
170 | target_link_libraries(sciqlopcore PUBLIC |
|
170 | target_link_libraries(sciqlopcore PUBLIC | |
171 | catalogs |
|
171 | catalogs | |
172 | ) |
|
172 | ) | |
173 | endif() |
|
173 | endif() | |
174 |
|
174 | |||
175 |
|
175 | |||
176 | pybind11_add_module(sciqlopqt src/pybind11_wrappers/QtWrappers.cpp) |
|
176 | pybind11_add_module(sciqlopqt src/pybind11_wrappers/QtWrappers.cpp) | |
177 | target_link_libraries(sciqlopqt PUBLIC Qt5::Core) |
|
177 | target_link_libraries(sciqlopqt PUBLIC Qt5::Core) | |
178 |
|
178 | |||
179 | pybind11_add_module(pysciqlopcore src/pybind11_wrappers/CoreWrappers.cpp) |
|
179 | pybind11_add_module(pysciqlopcore src/pybind11_wrappers/CoreWrappers.cpp) | |
180 | target_link_libraries(pysciqlopcore PUBLIC sciqlopcore) |
|
180 | target_link_libraries(pysciqlopcore PUBLIC sciqlopcore) | |
181 |
|
181 | |||
182 | add_library(pysciqlop src/pybind11_wrappers/pywrappers_common.h) |
|
182 | add_library(pysciqlop src/pybind11_wrappers/pywrappers_common.h) | |
183 | target_link_libraries(pysciqlop PUBLIC Qt5::Core) |
|
183 | target_link_libraries(pysciqlop PUBLIC Qt5::Core) | |
184 | target_include_directories(pysciqlop PUBLIC |
|
184 | target_include_directories(pysciqlop PUBLIC | |
185 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/pybind11_wrappers/> |
|
185 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/pybind11_wrappers/> | |
186 | $<INSTALL_INTERFACE:include/SciQLOP/py_wrappers> |
|
186 | $<INSTALL_INTERFACE:include/SciQLOP/py_wrappers> | |
187 | ) |
|
187 | ) | |
188 |
|
188 | |||
189 | SET_PROPERTY(GLOBAL PROPERTY CORE_PYTHON_PATH ${CMAKE_CURRENT_BINARY_DIR}) |
|
189 | SET_PROPERTY(GLOBAL PROPERTY CORE_PYTHON_PATH ${CMAKE_CURRENT_BINARY_DIR}) | |
190 |
|
190 | |||
191 |
|
191 | |||
192 | install(TARGETS sciqlopcore EXPORT SciQLOPCoreConfig |
|
192 | install(TARGETS sciqlopcore EXPORT SciQLOPCoreConfig | |
193 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
|
193 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | |
194 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
|
194 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | |
195 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
|
195 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | |
196 |
|
196 | |||
197 | install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SciQLOP) |
|
197 | install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SciQLOP) | |
198 | install(EXPORT SciQLOPCoreConfig DESTINATION share/SciQLOPCore/cmake) |
|
198 | install(EXPORT SciQLOPCoreConfig DESTINATION share/SciQLOPCore/cmake) | |
199 | export(TARGETS sciqlopcore FILE SciQLOPCoreConfig.cmake) |
|
199 | export(TARGETS sciqlopcore FILE SciQLOPCoreConfig.cmake) | |
200 |
|
200 | |||
201 | add_subdirectory(tests) |
|
201 | add_subdirectory(tests) |
@@ -1,63 +1,65 | |||||
1 | #ifndef SCIQLOP_DATETIMERANGEHELPER_H |
|
1 | #ifndef SCIQLOP_DATETIMERANGEHELPER_H | |
2 | #define SCIQLOP_DATETIMERANGEHELPER_H |
|
2 | #define SCIQLOP_DATETIMERANGEHELPER_H | |
3 |
|
3 | |||
|
4 | #include <optional> | |||
|
5 | ||||
4 | #include <cmath> |
|
6 | #include <cmath> | |
5 | #include <variant> |
|
7 | #include <variant> | |
6 | #include <QObject> |
|
8 | #include <QObject> | |
7 |
|
9 | |||
8 | #include <QDebug> |
|
10 | #include <QDebug> | |
9 |
|
11 | |||
10 | #include <opaque/numeric_typedef.hpp> |
|
12 | #include <opaque/numeric_typedef.hpp> | |
11 | #include <Common/DateUtils.h> |
|
13 | #include <Common/DateUtils.h> | |
12 | #include <Common/MetaTypes.h> |
|
14 | #include <Common/MetaTypes.h> | |
13 | #include <Common/Numeric.h> |
|
15 | #include <Common/Numeric.h> | |
14 | #include <Data/DateTimeRange.h> |
|
16 | #include <Data/DateTimeRange.h> | |
15 |
|
17 | |||
16 | namespace DateTimeRangeHelper { |
|
18 | namespace DateTimeRangeHelper { | |
17 |
|
19 | |||
18 |
|
20 | |||
19 | inline bool isnan(const DateTimeRange& range) |
|
21 | inline bool isnan(const DateTimeRange& range) | |
20 | { |
|
22 | { | |
21 | return std::isnan(range.m_TStart) && std::isnan(range.m_TEnd); |
|
23 | return std::isnan(range.m_TStart) && std::isnan(range.m_TEnd); | |
22 | } |
|
24 | } | |
23 |
|
25 | |||
24 | inline bool hasnan(const DateTimeRange& range) |
|
26 | inline bool hasnan(const DateTimeRange& range) | |
25 | { |
|
27 | { | |
26 | return std::isnan(range.m_TStart) || std::isnan(range.m_TEnd); |
|
28 | return std::isnan(range.m_TStart) || std::isnan(range.m_TEnd); | |
27 | } |
|
29 | } | |
28 |
|
30 | |||
29 | inline bool isPureShift(const DateTimeRange& range1, const DateTimeRange& range2) |
|
31 | inline bool isPureShift(const DateTimeRange& range1, const DateTimeRange& range2) | |
30 | { |
|
32 | { | |
31 | return SciQLop::numeric::almost_equal<double>(range1.delta(), range2.delta(), 1) |
|
33 | return SciQLop::numeric::almost_equal<double>(range1.delta(), range2.delta(), 1) | |
32 | && !SciQLop::numeric::almost_equal(range1.m_TStart, range2.m_TStart, 1); |
|
34 | && !SciQLop::numeric::almost_equal(range1.m_TStart, range2.m_TStart, 1); | |
33 | } |
|
35 | } | |
34 |
|
36 | |||
35 | inline bool isPureZoom(const DateTimeRange& range1, const DateTimeRange& range2) |
|
37 | inline bool isPureZoom(const DateTimeRange& range1, const DateTimeRange& range2) | |
36 | { |
|
38 | { | |
37 | return !SciQLop::numeric::almost_equal<double>(range1.delta(),range2.delta(),1)&& |
|
39 | return !SciQLop::numeric::almost_equal<double>(range1.delta(),range2.delta(),1)&& | |
38 | SciQLop::numeric::almost_equal<double>(range1.center(), range2.center(),1); |
|
40 | SciQLop::numeric::almost_equal<double>(range1.center(), range2.center(),1); | |
39 | } |
|
41 | } | |
40 |
|
42 | |||
41 | /** |
|
43 | /** | |
42 | * @brief computeTransformation such as range2 = zoom*range1 + shift |
|
44 | * @brief computeTransformation such as range2 = zoom*range1 + shift | |
43 | * @param range1 |
|
45 | * @param range1 | |
44 | * @param range2 |
|
46 | * @param range2 | |
45 | * @return trnaformation applied to range1 to get range2 or an object of type |
|
47 | * @return trnaformation applied to range1 to get range2 or an object of type | |
46 | * InvalidDateTimeRangeTransformation if the transformation has NaN or forbiden values |
|
48 | * InvalidDateTimeRangeTransformation if the transformation has NaN or forbiden values | |
47 | */ |
|
49 | */ | |
48 | inline std::optional<DateTimeRangeTransformation> |
|
50 | inline std::optional<DateTimeRangeTransformation> | |
49 | computeTransformation(const DateTimeRange& range1, const DateTimeRange& range2) |
|
51 | computeTransformation(const DateTimeRange& range1, const DateTimeRange& range2) | |
50 | { |
|
52 | { | |
51 | std::optional<DateTimeRangeTransformation> transformation; |
|
53 | std::optional<DateTimeRangeTransformation> transformation; | |
52 | double zoom = range2.delta()/range1.delta(); |
|
54 | double zoom = range2.delta()/range1.delta(); | |
53 | Seconds<double> shift = range2.center() - (range1*zoom).center(); |
|
55 | Seconds<double> shift = range2.center() - (range1*zoom).center(); | |
54 | bool zoomValid = zoom!=0. && !std::isnan(zoom) && !std::isinf(zoom); |
|
56 | bool zoomValid = zoom!=0. && !std::isnan(zoom) && !std::isinf(zoom); | |
55 | bool shiftValid = !std::isnan(shift.value) && !std::isinf(shift.value); |
|
57 | bool shiftValid = !std::isnan(shift.value) && !std::isinf(shift.value); | |
56 | if(zoomValid && shiftValid) |
|
58 | if(zoomValid && shiftValid) | |
57 | transformation = DateTimeRangeTransformation{zoom, shift}; |
|
59 | transformation = DateTimeRangeTransformation{zoom, shift}; | |
58 | return transformation; |
|
60 | return transformation; | |
59 | } |
|
61 | } | |
60 |
|
62 | |||
61 | } |
|
63 | } | |
62 |
|
64 | |||
63 | #endif // SCIQLOP_DATETIMERANGEHELPER_H |
|
65 | #endif // SCIQLOP_DATETIMERANGEHELPER_H |
@@ -1,108 +1,110 | |||||
1 | #ifndef SCIQLOP_VARIABLE_H |
|
1 | #ifndef SCIQLOP_VARIABLE_H | |
2 | #define SCIQLOP_VARIABLE_H |
|
2 | #define SCIQLOP_VARIABLE_H | |
3 |
|
3 | |||
|
4 | #include <optional> | |||
|
5 | ||||
4 | #include <QLoggingCategory> |
|
6 | #include <QLoggingCategory> | |
5 | #include <QObject> |
|
7 | #include <QObject> | |
6 | #include <QUuid> |
|
8 | #include <QUuid> | |
7 | #include <QReadWriteLock> |
|
9 | #include <QReadWriteLock> | |
8 |
|
10 | |||
9 | #include "CoreGlobal.h" |
|
11 | #include "CoreGlobal.h" | |
10 | #include <Data/DataSeriesIterator.h> |
|
12 | #include <Data/DataSeriesIterator.h> | |
11 | #include <Data/DataSeriesType.h> |
|
13 | #include <Data/DataSeriesType.h> | |
12 | #include <Data/DateTimeRange.h> |
|
14 | #include <Data/DateTimeRange.h> | |
13 |
|
15 | |||
14 |
|
16 | |||
15 | #include <Common/deprecate.h> |
|
17 | #include <Common/deprecate.h> | |
16 | #include <Common/MetaTypes.h> |
|
18 | #include <Common/MetaTypes.h> | |
17 | #include <Common/spimpl.h> |
|
19 | #include <Common/spimpl.h> | |
18 |
|
20 | |||
19 | Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) |
|
21 | Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) | |
20 |
|
22 | |||
21 | class IDataSeries; |
|
23 | class IDataSeries; | |
22 | class QString; |
|
24 | class QString; | |
23 |
|
25 | |||
24 | /** |
|
26 | /** | |
25 | * @brief The Variable class represents a variable in SciQlop. |
|
27 | * @brief The Variable class represents a variable in SciQlop. | |
26 | */ |
|
28 | */ | |
27 | class SCIQLOP_CORE_EXPORT Variable : public QObject { |
|
29 | class SCIQLOP_CORE_EXPORT Variable : public QObject { | |
28 |
|
30 | |||
29 | Q_OBJECT |
|
31 | Q_OBJECT | |
30 |
|
32 | |||
31 | public: |
|
33 | public: | |
32 | explicit Variable(const QString &name, const QVariantHash &metadata = {}); |
|
34 | explicit Variable(const QString &name, const QVariantHash &metadata = {}); | |
33 |
|
35 | |||
34 | /// Copy ctor |
|
36 | /// Copy ctor | |
35 | explicit Variable(const Variable &other); |
|
37 | explicit Variable(const Variable &other); | |
36 |
|
38 | |||
37 | std::shared_ptr<Variable> clone() const; |
|
39 | std::shared_ptr<Variable> clone() const; | |
38 |
|
40 | |||
39 | QString name() const noexcept; |
|
41 | QString name() const noexcept; | |
40 | void setName(const QString &name) noexcept; |
|
42 | void setName(const QString &name) noexcept; | |
41 | DateTimeRange range() const noexcept; |
|
43 | DateTimeRange range() const noexcept; | |
42 | void setRange(const DateTimeRange &range, bool notify=false) noexcept; |
|
44 | void setRange(const DateTimeRange &range, bool notify=false) noexcept; | |
43 | DateTimeRange cacheRange() const noexcept; |
|
45 | DateTimeRange cacheRange() const noexcept; | |
44 | void setCacheRange(const DateTimeRange &cacheRange) noexcept; |
|
46 | void setCacheRange(const DateTimeRange &cacheRange) noexcept; | |
45 |
|
47 | |||
46 | /// @return the number of points hold by the variable. The number of points is updated each time |
|
48 | /// @return the number of points hold by the variable. The number of points is updated each time | |
47 | /// the data series changes |
|
49 | /// the data series changes | |
48 | unsigned int nbPoints() const noexcept; |
|
50 | unsigned int nbPoints() const noexcept; | |
49 |
|
51 | |||
50 | /// Returns the real range of the variable, i.e. the min and max x-axis values of the data |
|
52 | /// Returns the real range of the variable, i.e. the min and max x-axis values of the data | |
51 | /// series between the range of the variable. The real range is updated each time the variable |
|
53 | /// series between the range of the variable. The real range is updated each time the variable | |
52 | /// range or the data series changed |
|
54 | /// range or the data series changed | |
53 | /// @return the real range, invalid range if the data series is null or empty |
|
55 | /// @return the real range, invalid range if the data series is null or empty | |
54 | /// @sa setDataSeries() |
|
56 | /// @sa setDataSeries() | |
55 | /// @sa setRange() |
|
57 | /// @sa setRange() | |
56 | std::optional<DateTimeRange> realRange() const noexcept; |
|
58 | std::optional<DateTimeRange> realRange() const noexcept; | |
57 |
|
59 | |||
58 | /// @return the data of the variable, nullptr if there is no data |
|
60 | /// @return the data of the variable, nullptr if there is no data | |
59 | std::shared_ptr<IDataSeries> dataSeries() const noexcept; |
|
61 | std::shared_ptr<IDataSeries> dataSeries() const noexcept; | |
60 |
|
62 | |||
61 | /// @return the type of data that the variable holds |
|
63 | /// @return the type of data that the variable holds | |
62 | DataSeriesType type() const noexcept; |
|
64 | DataSeriesType type() const noexcept; | |
63 |
|
65 | |||
64 | QVariantHash metadata() const noexcept; |
|
66 | QVariantHash metadata() const noexcept; | |
65 |
|
67 | |||
66 | void updateData(const std::vector<IDataSeries*>& dataSeries, |
|
68 | void updateData(const std::vector<IDataSeries*>& dataSeries, | |
67 | const DateTimeRange& newRange, const DateTimeRange& newCacheRange, |
|
69 | const DateTimeRange& newRange, const DateTimeRange& newCacheRange, | |
68 | bool notify=true); |
|
70 | bool notify=true); | |
69 |
|
71 | |||
70 | DEPRECATE( |
|
72 | DEPRECATE( | |
71 |
|
73 | |||
72 | bool contains(const DateTimeRange &range) const noexcept; |
|
74 | bool contains(const DateTimeRange &range) const noexcept; | |
73 | bool intersect(const DateTimeRange &range) const noexcept; |
|
75 | bool intersect(const DateTimeRange &range) const noexcept; | |
74 | bool isInside(const DateTimeRange &range) const noexcept; |
|
76 | bool isInside(const DateTimeRange &range) const noexcept; | |
75 |
|
77 | |||
76 | bool cacheContains(const DateTimeRange &range) const noexcept; |
|
78 | bool cacheContains(const DateTimeRange &range) const noexcept; | |
77 | bool cacheIntersect(const DateTimeRange &range) const noexcept; |
|
79 | bool cacheIntersect(const DateTimeRange &range) const noexcept; | |
78 | bool cacheIsInside(const DateTimeRange &range) const noexcept; |
|
80 | bool cacheIsInside(const DateTimeRange &range) const noexcept; | |
79 | QVector<DateTimeRange> provideNotInCacheRangeList(const DateTimeRange &range) const noexcept; |
|
81 | QVector<DateTimeRange> provideNotInCacheRangeList(const DateTimeRange &range) const noexcept; | |
80 | QVector<DateTimeRange> provideInCacheRangeList(const DateTimeRange &range) const noexcept; |
|
82 | QVector<DateTimeRange> provideInCacheRangeList(const DateTimeRange &range) const noexcept; | |
81 | void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; |
|
83 | void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; | |
82 | static QVector<DateTimeRange> provideNotInCacheRangeList(const DateTimeRange &oldRange, |
|
84 | static QVector<DateTimeRange> provideNotInCacheRangeList(const DateTimeRange &oldRange, | |
83 | const DateTimeRange &nextRange); |
|
85 | const DateTimeRange &nextRange); | |
84 |
|
86 | |||
85 | static QVector<DateTimeRange> provideInCacheRangeList(const DateTimeRange &oldRange, |
|
87 | static QVector<DateTimeRange> provideInCacheRangeList(const DateTimeRange &oldRange, | |
86 | const DateTimeRange &nextRange); |
|
88 | const DateTimeRange &nextRange); | |
87 | ) |
|
89 | ) | |
88 |
|
90 | |||
89 | operator QUuid() {return _uuid;} |
|
91 | operator QUuid() {return _uuid;} | |
90 | QUuid ID(){return _uuid;} |
|
92 | QUuid ID(){return _uuid;} | |
91 | signals: |
|
93 | signals: | |
92 | void updated(); |
|
94 | void updated(); | |
93 | DEPRECATE( |
|
95 | DEPRECATE( | |
94 | /// Signal emitted when when the data series of the variable is loaded for the first time |
|
96 | /// Signal emitted when when the data series of the variable is loaded for the first time | |
95 | void dataInitialized(); |
|
97 | void dataInitialized(); | |
96 | ) |
|
98 | ) | |
97 | private: |
|
99 | private: | |
98 | class VariablePrivate; |
|
100 | class VariablePrivate; | |
99 | spimpl::unique_impl_ptr<VariablePrivate> impl; |
|
101 | spimpl::unique_impl_ptr<VariablePrivate> impl; | |
100 | QUuid _uuid; |
|
102 | QUuid _uuid; | |
101 | QReadWriteLock m_lock; |
|
103 | QReadWriteLock m_lock; | |
102 | }; |
|
104 | }; | |
103 |
|
105 | |||
104 | // Required for using shared_ptr in signals/slots |
|
106 | // Required for using shared_ptr in signals/slots | |
105 | SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr<Variable>) |
|
107 | SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr<Variable>) | |
106 | SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_VECTOR_REGISTRY, QVector<std::shared_ptr<Variable> >) |
|
108 | SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_VECTOR_REGISTRY, QVector<std::shared_ptr<Variable> >) | |
107 |
|
109 | |||
108 | #endif // SCIQLOP_VARIABLE_H |
|
110 | #endif // SCIQLOP_VARIABLE_H |
General Comments 0
You need to be logged in to leave comments.
Login now