itom
Loading...
Searching...
No Matches
dataObjectModel.h
1/* ********************************************************************
2 itom measurement system
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2021, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 itom is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, as a special exception, the Institut für Technische
23 Optik (ITO) gives you certain additional rights.
24 These rights are described in the ITO LGPL Exception version 1.0,
25 which can be found in the file LGPL_EXCEPTION.txt in this package.
26*********************************************************************** */
27
28#pragma once
29
30#include "DataObject/dataobj.h"
31#include "common/interval.h"
32
33#include <qabstractitemmodel.h>
34#include <qsharedpointer.h>
35#include <qstringlist.h>
36#include <qcolor.h>
37#include <qlocale.h>
38
39#ifndef DATAOBJECTMODEL_TYPEDEFINED
40#define DATAOBJECTMODEL_TYPEDEFINED
41 Q_DECLARE_METATYPE(ito::complex64);
42 Q_DECLARE_METATYPE(ito::complex128);
43 Q_DECLARE_METATYPE(ito::Rgba32);
44#endif
45
46class DataObjectModel : public QAbstractItemModel
47{
48 Q_OBJECT
49
50public:
51
52
55
56 QVariant data(const QModelIndex& index, int role) const;
57 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
58
59 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
60 QModelIndex parent(const QModelIndex& index) const;
61 int rowCount(const QModelIndex& parent = QModelIndex()) const;
62 int columnCount(const QModelIndex& parent = QModelIndex()) const;
63 Qt::ItemFlags flags(const QModelIndex& index) const;
64
65 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
66
67 void setHeaderLabels(Qt::Orientation orientation, const QStringList& labels);
68 inline QStringList getHorizontalHeaderLabels() const
69 {
70 return m_horizontalHeader;
71 }
72 inline QStringList getVerticalHeaderLabels() const
73 {
74 return m_verticalHeader;
75 }
76
77 void setDataObject(QSharedPointer<ito::DataObject> dataObj);
78 inline QSharedPointer<ito::DataObject> getDataObject() const
79 {
80 return m_sharedDataObj;
81 };
82
83 inline int getType() const
84 {
85 return m_sharedDataObj.data() ? m_sharedDataObj->getType() : ito::tUInt8;
86 }
87
88 void setReadOnly(bool value);
89 inline bool getReadOnly() const
90 {
91 return m_readOnly;
92 }
93
94 void setDefaultGrid(int rows, int cols);
95 inline int getDefaultRows() const
96 {
97 return m_defaultRows;
98 }
99 inline int getDefaultCols() const
100 {
101 return m_defaultCols;
102 }
103
104 void setDecimals(const int decimals);
105 inline int getDecimals() const
106 {
107 return m_decimals;
108 }
109
110 void setSuffixes(const QStringList& suffixes);
111 inline QStringList getSuffixes() const
112 {
113 return m_suffixes;
114 }
115
116 void setAlignment(const Qt::Alignment& alignment);
117 inline Qt::Alignment getAlignment() const
118 {
119 return m_alignment;
120 }
121
122 void setNumberFormat(const char& format);
123 inline char getNumberFormat() const
124 {
125 return m_numberFormat;
126 }
127
128 void setHeatmapType(int type);
129
130 void setHeatmapInterval(const ito::AutoInterval &interval);
131 ito::AutoInterval getHeatmapInterval() const
132 {
133 return m_heatmapInterval;
134 }
135
136 static int displayRoleWithoutSuffix;
137 static int preciseDisplayRoleWithoutSuffix;
138 static int longlongDoubleOrStringRoleWithoutSuffix;
139
140protected:
141 bool setValue(const int& row, const int& column, const QVariant& value);
142
143 QString getDisplayNumber(const unsigned int& number, const int column) const;
144 QString getDisplayNumber(const int& number, const int column) const;
145 QString getDisplayNumber(const ito::float64& number, const int column, int decimals = -1) const;
146 QString getDisplayNumber(const ito::float32& number, const int column, int decimals = -1) const;
147 QString getDisplayNumber(
148 const ito::complex64& number, const int column, int decimals = -1) const;
149 QString getDisplayNumber(
150 const ito::complex128& number, const int column, int decimals = -1) const;
151 QString getDisplayNumber(
152 const ito::DateTime& number, const int column, bool longDate) const;
153 QString getDisplayNumber(
154 const ito::TimeDelta& number, const int column, bool longDate) const;
155
156 QSharedPointer<ito::DataObject> m_sharedDataObj;
157
158private:
159 QStringList m_verticalHeader;
160 QStringList m_horizontalHeader;
161 int m_defaultRows;
162 int m_defaultCols;
163 bool m_readOnly;
164 int m_decimals;
165 QStringList m_suffixes;
166 Qt::Alignment m_alignment;
167 char m_numberFormat;
168 ito::AutoInterval m_heatmapInterval;
169 bool m_enableHeatmap;
170 QColor m_colorStopLow;
171 QColor m_colorStopMiddle;
172 QColor m_colorStopHigh;
173 QLocale m_locale;
174
175 bool m_dummyData;
176};
Definition dataObjectModel.h:47
class for a interval type containing a min-max-range and an auto-flag.
Definition interval.h:50
Definition typeDefs.h:161
This class implements basic functionality for color handling in itom. \detail This class implements A...
Definition color.h:47
Definition typeDefs.h:218
@ tUInt8
Definition typeDefs.h:90