##// END OF EJS Templates
Creates iterator for QCPColorMap...
Alexandre Leroux -
r1058:d684e1205d9a
parent child
Show More
@@ -0,0 +1,40
1 #ifndef SCIQLOP_QCPCOLORMAPITERATOR_H
2 #define SCIQLOP_QCPCOLORMAPITERATOR_H
3
4 #include <iterator>
5
6 class QCPColorMapData;
7
8 /**
9 * Forward iterator for @sa QCPColorMap
10 */
11 class QCPColorMapIterator {
12 public:
13 using iterator_category = std::forward_iterator_tag;
14 using value_type = double;
15 using difference_type = std::ptrdiff_t;
16 using pointer = const value_type *;
17 using reference = value_type;
18
19 explicit QCPColorMapIterator(QCPColorMapData *data, bool begin);
20 virtual ~QCPColorMapIterator() noexcept = default;
21
22 QCPColorMapIterator &operator++();
23 QCPColorMapIterator operator++(int);
24
25 pointer operator->() const;
26 reference operator*() const;
27
28 bool operator==(const QCPColorMapIterator &other);
29 bool operator!=(const QCPColorMapIterator &other);
30
31 private:
32 void updateValue();
33
34 QCPColorMapData *m_Data; ///< Data iterated
35 int m_KeyIndex; ///< Current iteration key index
36 int m_ValueIndex; ///< Current iteration value index
37 double m_Value; ///< Current iteration value
38 };
39
40 #endif // SCIQLOP_QCPCOLORMAPITERATOR_H
@@ -0,0 +1,58
1 #include "Visualization/QCPColorMapIterator.h"
2
3 #include <Visualization/qcustomplot.h>
4
5 QCPColorMapIterator::QCPColorMapIterator(QCPColorMapData *data, bool begin)
6 : m_Data{data}, m_KeyIndex{begin ? 0 : data->keySize()}, m_ValueIndex{0}
7 {
8 updateValue();
9 }
10
11 QCPColorMapIterator &QCPColorMapIterator::operator++()
12 {
13 // Increments indexes
14 ++m_ValueIndex;
15 if (m_ValueIndex == m_Data->valueSize()) {
16 ++m_KeyIndex;
17 m_ValueIndex = 0;
18 }
19
20 // Updates value
21 updateValue();
22
23 return *this;
24 }
25
26 QCPColorMapIterator QCPColorMapIterator::operator++(int)
27 {
28 auto result = *this;
29 this->operator++();
30 return result;
31 }
32
33 QCPColorMapIterator::pointer QCPColorMapIterator::operator->() const
34 {
35 return &m_Value;
36 }
37
38 QCPColorMapIterator::reference QCPColorMapIterator::operator*() const
39 {
40 return m_Value;
41 }
42
43 bool QCPColorMapIterator::operator==(const QCPColorMapIterator &other)
44 {
45 return std::tie(m_Data, m_KeyIndex, m_ValueIndex)
46 == std::tie(other.m_Data, other.m_KeyIndex, other.m_ValueIndex);
47 }
48
49 bool QCPColorMapIterator::operator!=(const QCPColorMapIterator &other)
50 {
51 return !(*this == other);
52 }
53
54 void QCPColorMapIterator::updateValue()
55 {
56 m_Value = m_KeyIndex != m_Data->keySize() ? m_Data->cell(m_KeyIndex, m_ValueIndex)
57 : std::numeric_limits<double>::quiet_NaN();
58 }
@@ -1,100 +1,101
1 1
2 2 gui_moc_headers = [
3 3 'include/DataSource/DataSourceWidget.h',
4 4 'include/Settings/SqpSettingsDialog.h',
5 5 'include/Settings/SqpSettingsGeneralWidget.h',
6 6 'include/SidePane/SqpSidePane.h',
7 7 'include/SqpApplication.h',
8 8 'include/DragAndDrop/DragDropScroller.h',
9 9 'include/DragAndDrop/DragDropTabSwitcher.h',
10 10 'include/TimeWidget/TimeWidget.h',
11 11 'include/Variable/VariableInspectorWidget.h',
12 12 'include/Variable/RenameVariableDialog.h',
13 13 'include/Visualization/qcustomplot.h',
14 14 'include/Visualization/VisualizationGraphWidget.h',
15 15 'include/Visualization/VisualizationTabWidget.h',
16 16 'include/Visualization/VisualizationWidget.h',
17 17 'include/Visualization/VisualizationZoneWidget.h',
18 18 'include/Visualization/VisualizationDragDropContainer.h',
19 19 'include/Visualization/VisualizationDragWidget.h',
20 20 'include/Visualization/ColorScaleEditor.h'
21 21 ]
22 22
23 23 gui_ui_files = [
24 24 'ui/DataSource/DataSourceWidget.ui',
25 25 'ui/Settings/SqpSettingsDialog.ui',
26 26 'ui/Settings/SqpSettingsGeneralWidget.ui',
27 27 'ui/SidePane/SqpSidePane.ui',
28 28 'ui/TimeWidget/TimeWidget.ui',
29 29 'ui/Variable/VariableInspectorWidget.ui',
30 30 'ui/Variable/RenameVariableDialog.ui',
31 31 'ui/Variable/VariableMenuHeaderWidget.ui',
32 32 'ui/Visualization/VisualizationGraphWidget.ui',
33 33 'ui/Visualization/VisualizationTabWidget.ui',
34 34 'ui/Visualization/VisualizationWidget.ui',
35 35 'ui/Visualization/VisualizationZoneWidget.ui',
36 36 'ui/Visualization/ColorScaleEditor.ui'
37 37 ]
38 38
39 39 gui_qresources = ['resources/sqpguiresources.qrc']
40 40
41 41 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
42 42 ui_files : gui_ui_files,
43 43 qresources : gui_qresources)
44 44
45 45 gui_sources = [
46 46 'src/SqpApplication.cpp',
47 47 'src/DragAndDrop/DragDropHelper.cpp',
48 48 'src/DragAndDrop/DragDropScroller.cpp',
49 49 'src/DragAndDrop/DragDropTabSwitcher.cpp',
50 50 'src/Common/ColorUtils.cpp',
51 51 'src/Common/VisualizationDef.cpp',
52 52 'src/DataSource/DataSourceTreeWidgetItem.cpp',
53 53 'src/DataSource/DataSourceTreeWidgetHelper.cpp',
54 54 'src/DataSource/DataSourceWidget.cpp',
55 55 'src/DataSource/DataSourceTreeWidget.cpp',
56 56 'src/Settings/SqpSettingsDialog.cpp',
57 57 'src/Settings/SqpSettingsGeneralWidget.cpp',
58 58 'src/SidePane/SqpSidePane.cpp',
59 59 'src/TimeWidget/TimeWidget.cpp',
60 60 'src/Variable/VariableInspectorWidget.cpp',
61 61 'src/Variable/VariableInspectorTableView.cpp',
62 62 'src/Variable/VariableMenuHeaderWidget.cpp',
63 63 'src/Variable/RenameVariableDialog.cpp',
64 64 'src/Visualization/VisualizationGraphHelper.cpp',
65 65 'src/Visualization/VisualizationGraphRenderingDelegate.cpp',
66 66 'src/Visualization/VisualizationGraphWidget.cpp',
67 67 'src/Visualization/VisualizationTabWidget.cpp',
68 68 'src/Visualization/VisualizationWidget.cpp',
69 69 'src/Visualization/VisualizationZoneWidget.cpp',
70 70 'src/Visualization/qcustomplot.cpp',
71 71 'src/Visualization/QCustomPlotSynchronizer.cpp',
72 72 'src/Visualization/operations/FindVariableOperation.cpp',
73 73 'src/Visualization/operations/GenerateVariableMenuOperation.cpp',
74 74 'src/Visualization/operations/MenuBuilder.cpp',
75 75 'src/Visualization/operations/RemoveVariableOperation.cpp',
76 76 'src/Visualization/operations/RescaleAxeOperation.cpp',
77 77 'src/Visualization/VisualizationDragDropContainer.cpp',
78 78 'src/Visualization/VisualizationDragWidget.cpp',
79 79 'src/Visualization/AxisRenderingUtils.cpp',
80 80 'src/Visualization/PlottablesRenderingUtils.cpp',
81 81 'src/Visualization/MacScrollBarStyle.cpp',
82 82 'src/Visualization/VisualizationCursorItem.cpp',
83 83 'src/Visualization/ColorScaleEditor.cpp',
84 'src/Visualization/SqpColorScale.cpp'
84 'src/Visualization/SqpColorScale.cpp',
85 'src/Visualization/QCPColorMapIterator.cpp'
85 86 ]
86 87
87 88 gui_inc = include_directories(['include'])
88 89
89 90 sciqlop_gui_lib = library('sciqlopgui',
90 91 gui_sources,
91 92 gui_moc_files,
92 93 include_directories : [gui_inc],
93 94 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core],
94 95 install : true
95 96 )
96 97
97 98 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
98 99 include_directories : gui_inc,
99 100 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core])
100 101
@@ -1,9 +1,22
1 1 \.h:\d+:.IPSIS_S04.*found: ui
2 2 qcustomplot\.h:\d+:.IPSIS
3 3 qcustomplot\.cpp:\d+:.IPSIS
4 4
5 5 # Ignore false positive relative to App macro
6 6 SqpApplication\.h:\d+:.IPSIS_S03.*found: sqpApp
7 7 SqpApplication\.h:\d+:.IPSIS_S04_VARIABLE.*found: sqpApp
8 8
9 # Ignore false positive relative to iterators
10 QCPColorMapIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
11 QCPColorMapIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (ptrdiff_t)
12 QCPColorMapIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (value_type)
13 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (iterator_category)
14 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag)
15 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
16 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (difference_type)
17 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
18 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (pointer)
19 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (reference)
20 QCPColorMapIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
21
9 22
General Comments 0
You need to be logged in to leave comments. Login now