20#ifndef JKQTPDATASTORAGE_H
21#define JKQTPDATASTORAGE_H
24#include "jkqtplotter/jkqtplotter_imexport.h"
25#include "jkqtplotter/jkqtptools.h"
26#include "jkqtcommon/jkqtpdebuggingtools.h"
27#include "jkqtcommon/jkqttools.h"
40#include <QAbstractTableModel>
285 QMap<size_t, JKQTPDatastoreItem*>
items;
343 return items.value(i,
nullptr);
348 return items.value(i,
nullptr);
354 size_t addColumnForItem(
size_t itemID,
size_t columnInItem,
const QString& name=QString(
""));
447 inline size_t getRows(
size_t column)
const;
453 inline size_t getRows(
int column)
const;
493 inline double get(
size_t column,
size_t row)
const ;
496 inline double get(
int column,
size_t row)
const ;
498 inline double get(
int column,
int row)
const ;
500 inline double get(
size_t column,
int row)
const ;
519 inline void set(
size_t column,
size_t row,
double value);
521 inline void set(
int column,
size_t row,
double value);
628 void appendToColumns(
size_t column1,
size_t column2,
size_t column3,
double value1,
double value2,
double value3);
644 void appendToColumns(
size_t column1,
size_t column2,
size_t column3,
size_t column4,
double value1,
double value2,
double value3,
double value4);
661 void appendToColumns(
size_t column1,
size_t column2,
size_t column3,
size_t column4,
size_t column5,
double value1,
double value2,
double value3,
double value4,
double value5);
672 template<
class TContainer>
681 template<
class TIterator>
682 inline void appendToColumn(
size_t column, TIterator first, TIterator last);
685 inline double getPixel(
size_t column,
size_t x,
size_t y)
const ;
687 inline void setPixel(
size_t column,
size_t x,
size_t y,
double value) ;
692 inline void setAll(
size_t column,
double value);
702 inline void inc(
size_t column,
size_t row,
double increment=1);
707 inline void dec(
size_t column,
size_t row,
double decrement=1);
717 size_t addColumn(
size_t rows,
const QString& name=QString(
""));
744 size_t addColumn(
double* data,
size_t rows,
const QString& name=QString(
""));
809 size_t addImageColumn(
size_t width,
size_t height,
const QString& name=QString(
""));
824 size_t addImageColumn(
double* data,
size_t width,
size_t height,
const QString& name=QString(
""));
859 size_t copyColumn(
size_t old_column,
size_t start,
size_t stride,
const QString& name=QString(
""));
867 size_t copyColumn(
size_t old_column,
const QString& name=QString(
""));
888 std::pair<size_t,size_t>
addCopiedPoints(
const QList<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
889 std::pair<size_t,size_t>
addCopiedPoints(
const QList<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
890#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
891 std::pair<size_t,size_t>
addCopiedPoints(
const QVector<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
892 std::pair<size_t,size_t>
addCopiedPoints(
const QVector<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
894 std::pair<size_t,size_t>
addCopiedPoints(
const std::vector<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
895 std::pair<size_t,size_t>
addCopiedPoints(
const std::vector<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
896 std::pair<size_t,size_t>
addCopiedPoints(
const std::list<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
897 std::pair<size_t,size_t>
addCopiedPoints(
const std::list<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
923 template <
typename TIterator>
924 size_t addCopiedColumn(TIterator first, TIterator last,
const QString& name=QString(
"")) {
925 const size_t N=
static_cast<size_t>(std::abs(std::distance(first,last)));
926 QVector<double> d; d.reserve(N);
929 for (
auto it=first; it!=last; ++it) {
960 template <
typename TContainer>
987 template <
typename TContainer>
988 size_t addCopiedColumn(
const TContainer& data,
const QString& name,
size_t stride,
size_t start=0) {
989 const size_t N=
static_cast<size_t>(data.size()-start)/stride;
990 QVector<double> d; d.reserve(N);
992 auto it=data.begin();
993 if (start>0) it+=start;
994 for (; it!=data.end(); it+=stride) {
1015 template<
typename T>
1017 QVector<double> d(rows);
1019 for (
size_t r=0; r<rows; r++) {
1047 template<
typename T>
1048 size_t addCopiedColumn(
const T* data,
size_t rows,
size_t stride,
int start,
const QString& name) {
1049 QVector<double> d; d.reserve(rows);
1051 for (
size_t r=0; r<rows; r++) {
1052 d.push_back(
jkqtp_todouble(data[
static_cast<size_t>(start+
static_cast<int64_t
>(r*stride))]));
1079 template<
typename T>
1087 template <
typename T>
1088 inline size_t addCopiedImageAsColumn(
const T* data,
size_t width,
size_t height,
const QString& name=QString(
""),
size_t stride=1,
size_t start=0);
1099 template <
typename TContainer>
1100 inline size_t addCopiedImageAsColumn(
const TContainer& data,
size_t width,
const QString& name=QString(
""));
1118 template <
typename T>
1119 size_t addCopiedImageAsColumnTranspose(
const T* data,
size_t width,
size_t height,
const QString& name=QString(
""),
size_t stride=1,
size_t start=0);
1134 template <
typename T>
1135 inline size_t addCopiedImageAsColumnTranspose(
const QVector<T>& data,
size_t width,
const QString& name=QString(
""));
1149 template <
typename T>
1150 size_t addCopiedColumnMasked(
const T* data,
const bool* mask,
size_t rows,
const QString& name=QString(
""),
bool useIfMaskEquals=
false) {
1151 QVector<double> d; d.reserve(rows);
1153 for (
size_t r=0; r<rows; r++) {
1154 if (!mask || (mask && (mask[r]==useIfMaskEquals))) {
1186 template <
typename TContainer,
typename TContainerMask>
1187 size_t addCopiedColumnMasked(
const TContainer& data,
const TContainerMask& mask,
const QString& name=QString(
""),
bool useIfMaskEquals=
false) {
1188 auto itmask=std::begin(mask);
1189 auto itmaskend=std::end(mask);
1190 auto itdata=std::begin(data);
1191 auto itdataend=std::end(data);
1192 const size_t N=std::min<size_t>(std::distance(itmask,itmaskend),std::distance(itdata,itdataend));
1195 for (
size_t r=0; r<N; r++) {
1196 if (
static_cast<bool>(*itmask)==useIfMaskEquals) {
1231 template <
typename TIterator>
1232 std::pair<size_t, size_t>
addCopiedMap(TIterator first, TIterator last,
const QString& nameKey=QString(
"map_key"),
const QString& nameValue=QString(
"map_value")) {
1233 const size_t N=
static_cast<size_t>(std::abs(std::distance(first,last)));
1234 QVector<double> xvals, yvals;
1237 for (
auto it=first; it!=last; ++it) {
1243 return std::pair<size_t, size_t>(cx,cy);
1269 template <
typename TContainer>
1270 std::pair<size_t, size_t>
addCopiedMap(
const TContainer& c,
const QString& nameKey=QString(
"map_key"),
const QString& nameValue=QString(
"map_value")) {
1271 return addCopiedMap(c.begin(), c.end(), nameKey, nameValue);
1286 size_t addLogColumn(
size_t rows,
double start,
double end,
const QString& name=QString(
""));
1291 size_t addDecadeLogColumn(
size_t rows,
double startDecade,
double endDecade,
const QString& name=QString(
""));
1311 std::pair<size_t,size_t>
addLinearGridColumns(
size_t width,
double startX,
double endX,
size_t height,
double startY,
double endY,
const QString& nameX=QString(
""),
const QString& nameY=QString(
""));
1339 size_t addCalculatedColumn(
size_t rows,
const std::function<
double(
size_t)>& f,
const QString& name=QString(
""));
1354 size_t addCalculatedImageColumn(
size_t cols,
size_t rows,
const std::function<
double(
size_t,
size_t)>& f,
const QString& name=QString(
""));
1384 inline size_t addColumnCalculatedFromColumn(
size_t otherColumnX,
size_t otherColumnY,
const std::function<
double(
double,
double)>& f,
const QString& name=QString(
"")) {
1387 inline size_t addCalculatedColumnFromColumn(
const std::pair<size_t, size_t>& otherColumn,
const std::function<
double(
double,
double)>& f,
const QString& name=QString(
"")) {
1429 void saveCSV(
const QString& filename,
const QSet<int>& userColumns=QSet<int>(),
const QString& separator=QString(
", "),
const QString& decimal_separator=QString(
"."),
const QString& comment=QString(
"#"),
const QString& aroundStrings=QString(
""),
char floatformat=
'g')
const;
1447 void saveCSV(QTextStream& txt,
const QSet<int>& userColumns=QSet<int>(),
const QString& separator=QString(
", "),
const QString& decimal_separator=QString(
"."),
const QString& comment=QString(
"#"),
const QString& aroundStrings=QString(
""),
char floatformat=
'g')
const;
1455 void saveSYLK(
const QString& filename,
const QSet<int>& userColumns=QSet<int>(),
const QString& floatformat=QString(
"%10.10lf"))
const;
1462 QList<QVector<double> >
getData(QStringList* columnNames=
nullptr,
const QSet<int>& userColumns=QSet<int>())
const;
1469 QVector<double>
getData(
size_t column, QString* columnName=
nullptr)
const;
1477 void saveDIF(
const QString& filename,
const QSet<int>& userColumns=QSet<int>(),
const QString& floatformat=QString(
"%10.10lf"))
const;
1484 void saveMatlab(
const QString& filename,
const QSet<int>& userColumns=QSet<int>())
const;
1490 void saveMatlab(QTextStream& txt,
const QSet<int>& userColumns=QSet<int>())
const;
1573 inline double getValue(
size_t n)
const;
1579 inline double getValue(
int n)
const;
1587 inline double&
at(
int n);
1595 inline const double&
at(
int n)
const;
1606 inline void setValue(
size_t n,
double val);
1611 inline void incValue(
size_t n,
double increment=1.0);
1662 void copy(
const double* data,
size_t N,
size_t offset=0);
1680 {
return this->datastoreItem; }
1683 {
return this->datastoreOffset; }
1687 inline iterator begin();
1690 inline iterator end();
1694 inline const_iterator begin()
const;
1697 inline const_iterator end()
const;
1717 inline void eraseFromVectorColumn(
size_t row);
1721 inline void eraseFromVectorColumn(
size_t row,
size_t rowEnd);
1804 pos_++;
return *
this;
1812 pos_=
static_cast<int>(
col_->getRows())-1;
1821 pos_=
static_cast<int>(
col_->getRows())-1;
1830 pos_=
static_cast<int>(
col_->getRows())+inc;
1839 pos_=
static_cast<int>(
col_->getRows())-dec;
1899 return col_->at(
static_cast<int>(
col_->getRows())+off);
1989 inline operator bool()
const {
return isValid(); }
1997 if (!
isValid())
return QPoint(-1,-1);
1998 return QPoint(
pos_ %
static_cast<int>(
col_->getImageColumns()),
pos_ /
static_cast<int>(
col_->getImageColumns()));
2003 return pos_ %
static_cast<int>(
col_->getImageColumns());
2008 return pos_ /
static_cast<int>(
col_->getImageColumns());
2014 return col_->getImageColumns();
2020 return col_->getRows() /
col_->getImageColumns();
2068 ds_->appendToColumn(
col_, val);
2073 ds_->appendToColumn(
col_, std::move(val));
2139 pos_++;
return *
this;
2147 pos_=
static_cast<int>(
col_->getRows())-1;
2156 pos_=
static_cast<int>(
col_->getRows())-1;
2165 pos_=
static_cast<int>(
col_->getRows())+inc;
2174 pos_=
static_cast<int>(
col_->getRows())-dec;
2234 return col_->at(
static_cast<int>(
col_->getRows())+off);
2331 inline operator bool()
const {
return isValid(); }
2339 if (!
isValid())
return QPoint(-1,-1);
2340 return QPoint(
pos_ %
static_cast<int>(
col_->getImageColumns()),
pos_ /
static_cast<int>(
col_->getImageColumns()));
2345 return pos_ %
static_cast<int>(
col_->getImageColumns());
2350 return pos_ /
static_cast<int>(
col_->getImageColumns());
2356 return col_->getImageColumns();
2362 return col_->getRows() /
col_->getImageColumns();
2475 datavec.resize(
static_cast<int>(rows_new));
2524 inline double get(
size_t column,
size_t row) {
2540 inline double&
at(
size_t column,
size_t row) {
2541 if (
data!=
nullptr) {
2551 throw std::out_of_range(
"index does not exist in JKQTPDatastoreItem");
2557 inline const double&
at(
size_t column,
size_t row)
const {
2558 if (
data!=
nullptr) {
2568 throw std::out_of_range(
"index does not exist in JKQTPDatastoreItem");
2576 return &(
data[row]);
2586 inline const double*
getPointer(
size_t column,
size_t row)
const {
2589 return &(
data[row]);
2598 inline void set(
size_t column,
size_t row,
double value) {
2642 inline bool append(
size_t column,
double value) {
2655 inline bool append(
size_t column,
const QVector<double>& values) {
2658 for (
const double& d: values)
datavec.push_back(d);
2675 inline bool append(
size_t column,
const std::vector<double>& values) {
2677 datavec.reserve(
static_cast<int>(
datavec.size())+
static_cast<int>(values.size()));
2678 for (
const double& d: values)
datavec.push_back(d);
2701 virtual QVariant
data(
const QModelIndex &index,
int role)
const override;
2702 virtual Qt::ItemFlags
flags(
const QModelIndex &index)
const override;
2703 virtual QVariant
headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
2704 virtual int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
2705 virtual int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
2775 const size_t rows =
getRows();
2792 return getValue(
static_cast<size_t>(n));
2814 return columns.value(column).getRows();
2820 if (column<0)
return nullptr;
2821 return columns.value(
static_cast<size_t>(column)).getPointer(row);
2827 if (column<0)
return nullptr;
2828 return columns[
static_cast<size_t>(column)].getPointer(row);
2833 if (column<0)
return 0;
2834 return columns.value(
static_cast<size_t>(column)).getRows();
2840 return columns.value(column).getPointer(row);
2846 return columns[column].getPointer(row);
2851 return columns[column].getValue(row);
2857 return get(
static_cast<size_t>(column),
static_cast<size_t>(row));
2864 return get(
static_cast<size_t>(column),
static_cast<size_t>(row));
2871 return get(
static_cast<size_t>(column),
static_cast<size_t>(row));
2876 columns[column].setValue(row, value);
2881 set(
static_cast<size_t>(column),
static_cast<size_t>(row), value);
2886template<
class TContainer>
2893template<
class TIterator>
2896 for(
auto it=first; it!=last; it++) {
2904 return columns.value(column).getPixelValue(x, y);
2909 return columns[column].setPixelValue(x, y, value);
2915 columns[column].setAll(value);
2921 columns[column].scale(factor);
2927 columns[column].incValue(row, increment);
2933 columns[column].decValue(row, decrement);
2938template <
typename T>
2941 columns[col].setImageColumns(width);
2946template <
typename TContainer>
2949 columns[col].setImageColumns(width);
2955template <
typename T>
2957 QVector<double> temp(width*height);
2959 for (
size_t x=0; x<width; x++) {
2960 for (
size_t y=0; y<height; y++) {
2966 columns[idx].setImageColumns(width);
2972template <
typename T>
iterator, which allows to insert into a column of a JKQTPDatastore
Definition jkqtpdatastorage.h:2043
JKQTPColumnBackInserter & operator=(JKQTPColumnBackInserter &&)=default
JKQTPColumnBackInserter(JKQTPDatastore *ds, size_t col)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:2051
JKQTPColumnBackInserter & operator=(double &&val)
Definition jkqtpdatastorage.h:2071
double * pointer
Definition jkqtpdatastorage.h:2057
int difference_type
Definition jkqtpdatastorage.h:2059
JKQTPColumnBackInserter & operator=(const JKQTPColumnBackInserter &)=default
double value_type
Definition jkqtpdatastorage.h:2054
const double & const_reference
Definition jkqtpdatastorage.h:2056
std::output_iterator_tag iterator_category
Definition jkqtpdatastorage.h:2058
JKQTPDatastore * ds_
references the datastore to access
Definition jkqtpdatastorage.h:2046
self_type operator++()
Definition jkqtpdatastorage.h:2077
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:2081
JKQTPColumnBackInserter(const JKQTPColumnBackInserter &)=default
JKQTPColumnBackInserter(JKQTPColumnBackInserter &&)=default
double & reference
Definition jkqtpdatastorage.h:2055
size_t col_
references the column to access
Definition jkqtpdatastorage.h:2048
JKQTPColumnBackInserter self_type
Definition jkqtpdatastorage.h:2053
JKQTPColumnBackInserter & operator=(const double &val)
Definition jkqtpdatastorage.h:2066
self_type operator*()
Definition jkqtpdatastorage.h:2078
JKQTPColumnBackInserter()
constructs an invalid iterator
Definition jkqtpdatastorage.h:2061
self_type operator++(int)
Definition jkqtpdatastorage.h:2076
iterator over the data in the column of a JKQTPDatastore
Definition jkqtpdatastorage.h:2089
difference_type operator-(self_type rhs) const
Definition jkqtpdatastorage.h:2213
const_reference operator*() const
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:2242
JKQTPColumnConstIterator & operator=(nonconst_variant_type &&rhs)
Definition jkqtpdatastorage.h:2125
reference operator*()
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:2224
JKQTPColumnConstIterator(const JKQTPColumnConstIterator &)=default
friend self_type operator-(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:2188
bool operator<(const self_type &rhs) const
comparison operator (less than)
Definition jkqtpdatastorage.h:2258
bool operator>=(const self_type &rhs) const
comparison operator (larger than, or equal)
Definition jkqtpdatastorage.h:2299
const double & reference
Definition jkqtpdatastorage.h:2102
bool operator>(const self_type &rhs) const
comparison operator (larger than)
Definition jkqtpdatastorage.h:2285
JKQTPColumnConstIterator & operator=(const JKQTPColumnConstIterator &)=default
JKQTPColumnIterator nonconst_variant_type
Definition jkqtpdatastorage.h:2100
bool operator<=(const self_type &rhs) const
comparison operator (less than, or equal)
Definition jkqtpdatastorage.h:2272
bool isValid() const
checks the iterator for validity (i.e. points to an existing column and position is in a valid range)
Definition jkqtpdatastorage.h:2327
self_type operator+=(int inc)
Definition jkqtpdatastorage.h:2160
JKQTPColumnConstIterator(const nonconst_variant_type &rhs)
Definition jkqtpdatastorage.h:2111
self_type operator++(int)
Definition jkqtpdatastorage.h:2132
friend self_type operator+(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:2180
self_type operator++()
Definition jkqtpdatastorage.h:2137
bool operator!=(const self_type &rhs) const
comparison operator (unequals), inverse result of operator==()
Definition jkqtpdatastorage.h:2324
self_type operator+(difference_type rhs) const
Definition jkqtpdatastorage.h:2195
friend class JKQTPColumn
Definition jkqtpdatastorage.h:2365
const double * pointer
Definition jkqtpdatastorage.h:2104
self_type operator-(difference_type rhs) const
Definition jkqtpdatastorage.h:2205
JKQTPColumnConstIterator & operator=(JKQTPColumnConstIterator &&)=default
double value_type
Definition jkqtpdatastorage.h:2101
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:2366
size_t getImageColumns() const
if the data in the column is interpreted as an image, this is the number of columns (x-dimension) of ...
Definition jkqtpdatastorage.h:2354
int getImagePositionY() const
returns the referenced position/row interpreted as an image pixel, y-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2348
int difference_type
Definition jkqtpdatastorage.h:2106
JKQTPColumnConstIterator(JKQTPColumnConstIterator &&)=default
int getImagePositionX() const
returns the referenced position/row interpreted as an image pixel, x-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2343
JKQTPColumnConstIterator(nonconst_variant_type &&rhs)
Definition jkqtpdatastorage.h:2112
QPoint getImagePosition() const
returns the referenced position/row interpreted as an image pixel, returns (-1,-1) for an invalid ope...
Definition jkqtpdatastorage.h:2338
int pos_
current row in col_ this iterator points to
Definition jkqtpdatastorage.h:2094
self_type operator--(int)
Definition jkqtpdatastorage.h:2141
self_type operator-=(int dec)
Definition jkqtpdatastorage.h:2169
bool operator==(const self_type &rhs) const
comparison operator (equals)
Definition jkqtpdatastorage.h:2312
reference const_reference
Definition jkqtpdatastorage.h:2103
int getPosition() const
returns the referenced position/row, or -1 for an invalid iterator
Definition jkqtpdatastorage.h:2333
JKQTPColumnConstIterator & operator=(const nonconst_variant_type &rhs)
Definition jkqtpdatastorage.h:2120
const JKQTPColumn * col_
references the column this iterator iterates over
Definition jkqtpdatastorage.h:2092
JKQTPColumnConstIterator(const JKQTPColumn *col, int startpos=0)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:2097
std::forward_iterator_tag iterator_category
Definition jkqtpdatastorage.h:2105
const JKQTPColumn * getColumn() const
returns the referenced column
Definition jkqtpdatastorage.h:2370
self_type operator--()
Definition jkqtpdatastorage.h:2151
reference operator[](difference_type off) const
Definition jkqtpdatastorage.h:2230
size_t getImageRows() const
if the data in the column is interpreted as an image, this is the number of rows (y-dimension) of the...
Definition jkqtpdatastorage.h:2360
JKQTPColumnConstIterator()
constructs an invalid iterator
Definition jkqtpdatastorage.h:2108
JKQTPColumnConstIterator self_type
Definition jkqtpdatastorage.h:2099
internally stores information about one data column. See JKQTPDatastore for more information.
Definition jkqtpdatastorage.h:1513
void setName(const QString &__value)
a name describing the column
size_t datastoreOffset
offset, if the datastore item contains more than one column
Definition jkqtpdatastorage.h:1518
JKQTPDatastore * datastore
pointer to the datastore object used to manage the data of the plot
Definition jkqtpdatastorage.h:1522
JKQTPColumnConstIterator const_iterator
Definition jkqtpdatastorage.h:1529
void eraseFromVectorColumn(size_t row)
removes the entry row
Definition jkqtpdatastorage.h:2762
size_t getRows() const
returns the number of rows in this column (accesses the datastore)
bool isValid() const
Definition jkqtpdatastorage.h:1540
friend class JKQTPColumnConstIterator
Definition jkqtpdatastorage.h:1702
size_t getDatastoreItemNum() const
index of the item in the datastore that contains the data for this column
Definition jkqtpdatastorage.h:1679
size_t getImageColumns() const
number of columns, if interpreted as a row-major image
Definition jkqtpdatastorage.h:1558
quint16 calculateChecksum() const
calculates a checksum over the contents of the column (using qChecksum())
Definition jkqtpdatastorage.h:2734
void replaceMemory(size_t datastoreItem_=0, size_t datastoreOffset_=0)
lets the column point to another datastore item with id datastoreItem_ (of type JKQTPDatastoreItem) i...
Definition jkqtpdatastorage.h:1709
void setValue(size_t n, double val)
sets the n'th value from the column
Definition jkqtpdatastorage.h:2720
void setAll(double value)
set all values in the column to a specific value
size_t datastoreItem
index of the item in the datastore that contains the data for this column
Definition jkqtpdatastorage.h:1516
void copyData(QVector< double > ©To) const
copies the contained data into a QVector
const JKQTPDatastoreItem * getDatastoreItem() const
returns a pointer to the datastore item representing this column
Definition jkqtpdatastorage.h:1652
void scale(double factor)
scales all members of the column with the given factor
double getValue(size_t n) const
reads the n'th value from the column
Definition jkqtpdatastorage.h:2773
friend class JKQTPColumnIterator
Definition jkqtpdatastorage.h:1701
const JKQTPDatastore * getDatastore() const
Definition jkqtpdatastorage.h:1706
JKQTPDatastoreItem * getDatastoreItem()
returns a pointer to the datastore item representing this column
Definition jkqtpdatastorage.h:1650
JKQTPDatastore * getDatastore()
Definition jkqtpdatastorage.h:1705
double * getPointer(size_t n=0)
gets a pointer to the n-th value in the column
bool convertVectorItemFromRanges(size_t start1, size_t end1, size_t start2, size_t end2, size_t *usedVectorItem=nullptr)
if the column's data is \u not stored in an internal vector item, this copies the data into a vector ...
bool convertVectorItemFromRange(size_t start1, size_t end1, size_t *usedVectorItem=nullptr)
if the column's data is \u not stored in an internal vector item, this copies the data into a vector ...
JKQTPColumnIterator iterator
Definition jkqtpdatastorage.h:1528
void setImageColumns(size_t imageWidth)
number of columns, if interpreted as a row-major image
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:1700
const double * getPointer(size_t n=0) const
gets a pointer to the n-th value in the column
void incValue(size_t n, double increment=1.0)
increment the n'th value from the column
Definition jkqtpdatastorage.h:2727
bool valid
is this item valid?/usable?
Definition jkqtpdatastorage.h:1526
iterator begin()
returns an iterator to the internal data
Definition jkqtpdatastorage.h:2742
bool operator==(const JKQTPColumn &other) const
two columns are equal, if the same memory in the same datastore is referenced
Definition jkqtpdatastorage.h:1543
void copy(const double *data, size_t N, size_t offset=0)
copy data from the given array into the column
QString name
a name describing the column
Definition jkqtpdatastorage.h:1524
double & at(int n)
returns a reference to the n -th row in this column (possibly throwing an exception if it does not ex...
Definition jkqtpdatastorage.h:2804
iterator end()
returns an iterator to the internal data
Definition jkqtpdatastorage.h:2747
double getPixelValue(size_t x, size_t y) const
returns the element at (x,y) in the column, where the data is interpreted as a row-major ordered Matr...
Definition jkqtpdatastorage.h:1645
void exchange(double value, double replace)
exchange every occurence of a given value by a replace value
void setPixelValue(size_t x, size_t y, double val)
sets the element at (x,y) in the column, where the data is interpreted as a row-major ordered Matrix ...
Definition jkqtpdatastorage.h:1636
void subtract(double value)
subtracts a given value from all members of the column
bool convertVectorItem(size_t *usedVectorItem=nullptr)
if the column's data is \u not stored in an internal vector item, this copies the data into a vector ...
JKQTPColumn(JKQTPDatastore *datastore, const QString &name=QString(""), size_t datastoreItem=0, size_t datastoreOffset=0, size_t imageColumns=1)
class constructor that binds the column to a specific datastore object.
QVector< double > copyData()
returns a QVector with the contained data (as a copy)
QString getName() const
a name describing the column
void setPixelValue(size_t x, size_t y, size_t width, double val)
sets the element at (x,y) in the column, where the data is interpreted as a row-major ordered Matrix ...
Definition jkqtpdatastorage.h:1626
size_t imageColumns
number of columns, if interpreted as a row-major image
Definition jkqtpdatastorage.h:1520
size_t getDatastoreOffset() const
offset, if the datastore item contains more than one column
Definition jkqtpdatastorage.h:1682
void decValue(size_t n, double decrement=1.0)
decrement the n'th value from the column
Definition jkqtpdatastorage.h:1616
iterator over the data in the column of a JKQTPDatastore
Definition jkqtpdatastorage.h:1773
friend class JKQTPColumnConstIterator
Definition jkqtpdatastorage.h:2023
size_t getImageRows() const
if the data in the column is interpreted as an image, this is the number of rows (y-dimension) of the...
Definition jkqtpdatastorage.h:2018
friend self_type operator-(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:1853
const JKQTPColumn * getColumn() const
returns the referenced column
Definition jkqtpdatastorage.h:2030
self_type operator++()
Definition jkqtpdatastorage.h:1802
self_type operator++(int)
Definition jkqtpdatastorage.h:1797
bool isValid() const
checks the iterator for validity (i.e. points to an existing column and position is in a valid range)
Definition jkqtpdatastorage.h:1985
bool operator>=(const self_type &rhs) const
comparison operator (larger than, or equal)
Definition jkqtpdatastorage.h:1976
bool operator!=(const self_type &rhs) const
comparison operator (unequals), inverse result of operator==()
Definition jkqtpdatastorage.h:1983
bool operator==(const self_type &rhs) const
comparison operator (equals)
Definition jkqtpdatastorage.h:1917
int difference_type
Definition jkqtpdatastorage.h:1790
bool operator<(const self_type &rhs) const
comparison operator (less than)
Definition jkqtpdatastorage.h:1935
JKQTPColumnIterator self_type
Definition jkqtpdatastorage.h:1783
JKQTPColumnIterator(const JKQTPColumnIterator &)=default
int getImagePositionX() const
returns the referenced position/row interpreted as an image pixel, x-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2001
self_type operator--(int)
Definition jkqtpdatastorage.h:1806
JKQTPColumnIterator(JKQTPColumn *col, int startpos=0)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:1781
self_type operator-=(int dec)
Definition jkqtpdatastorage.h:1834
self_type operator+(difference_type rhs) const
Definition jkqtpdatastorage.h:1860
friend self_type operator+(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:1845
JKQTPColumnIterator(JKQTPColumnIterator &&)=default
friend class JKQTPColumn
Definition jkqtpdatastorage.h:2024
reference operator*() const
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:1889
double * pointer
Definition jkqtpdatastorage.h:1788
JKQTPColumnConstIterator const_variant_type
Definition jkqtpdatastorage.h:1784
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:2025
self_type operator-(difference_type rhs) const
Definition jkqtpdatastorage.h:1870
JKQTPColumn * col_
references the column this iterator iterates over
Definition jkqtpdatastorage.h:1776
QPoint getImagePosition() const
returns the referenced position/row interpreted as an image pixel, returns (-1,-1) for an invalid ope...
Definition jkqtpdatastorage.h:1996
int pos_
current row in col_ this iterator points to
Definition jkqtpdatastorage.h:1778
reference operator[](difference_type off) const
dereferences the iterator at offset off, throws an exception if the iterator is invalid (see isValid(...
Definition jkqtpdatastorage.h:1896
difference_type operator-(self_type rhs) const
Definition jkqtpdatastorage.h:1878
self_type operator+=(int inc)
Definition jkqtpdatastorage.h:1825
bool operator>(const self_type &rhs) const
comparison operator (larger than)
Definition jkqtpdatastorage.h:1962
JKQTPColumn * getColumn()
returns the referenced column
Definition jkqtpdatastorage.h:2028
JKQTPColumnIterator & operator=(JKQTPColumnIterator &&)=default
std::forward_iterator_tag iterator_category
Definition jkqtpdatastorage.h:1789
double & reference
Definition jkqtpdatastorage.h:1786
self_type operator--()
Definition jkqtpdatastorage.h:1816
double value_type
Definition jkqtpdatastorage.h:1785
JKQTPColumnIterator()
constructs an invalid iterator
Definition jkqtpdatastorage.h:1792
size_t getImageColumns() const
if the data in the column is interpreted as an image, this is the number of columns (x-dimension) of ...
Definition jkqtpdatastorage.h:2012
bool operator<=(const self_type &rhs) const
comparison operator (less than, or equal)
Definition jkqtpdatastorage.h:1949
int getImagePositionY() const
returns the referenced position/row interpreted as an image pixel, y-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2006
const double & const_reference
Definition jkqtpdatastorage.h:1787
JKQTPColumnIterator & operator=(const JKQTPColumnIterator &)=default
int getPosition() const
returns the referenced position/row, or -1 for an invalid iterator
Definition jkqtpdatastorage.h:1991
This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter t...
Definition jkqtpdatastorage.h:282
size_t maxItemID
internal variable to keep track about the highest item ID (in items) used so far
Definition jkqtpdatastorage.h:298
size_t addCalculatedImageColumn(size_t cols, size_t rows, const std::function< double(size_t, size_t)> &f, const QString &name=QString(""))
add an image column with width cols and height rows (i.e. rows * cols entries), that is calculated by...
JKQTPDatastore()
class constructor, generates an empty datastore
QList< size_t > getColumnIDs() const
returns a list with all available column IDs
Definition jkqtpdatastorage.h:1395
bool isColumnDataExternal(int column) const
returns true, if the data in the column column is internally managed
friend class JKQTPDatastoreItem
Definition jkqtpdatastorage.h:1499
QMap< size_t, JKQTPColumn >::const_iterator ConstColumnIterator
constant iterator for columns in the JKQTPDatastore (ColumnIterator::first: column number,...
Definition jkqtpdatastorage.h:360
void appendFromContainerToColumn(size_t column, const TContainer &values)
adds a values in container values to the column column. This changes the column length (number of row...
Definition jkqtpdatastorage.h:2887
QString getColumnName(size_t column)
return the title of the first column with the given name, or -1 if none was found
size_t getRows(size_t column) const
returns the number of rows in the column column
Definition jkqtpdatastorage.h:2813
JKQTPColumnConstIterator cbegin(size_t i) const
returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore
void eraseFromColumn(JKQTPColumnConstIterator pos)
removes the entry pos
const JKQTPDatastoreItem * getItem(size_t i) const
returns the JKQTPDatastoreItem object for the i -th item in the store
Definition jkqtpdatastorage.h:347
QMap< size_t, JKQTPColumn >::iterator ColumnIterator
mutable iterator for columns in the JKQTPDatastore (ColumnIterator::first: column number,...
Definition jkqtpdatastorage.h:358
size_t addImageColumn(double *data, size_t width, size_t height, const QString &name=QString(""))
add one external column to the datastore. It contains width * height rows. This returns its logical c...
int getNextLowerIndex(size_t column, size_t row, int start, int end) const
gets the index of the datapoint with the nearest, but lower value in the column (in a given inclusive...
void saveSYLK(const QString &filename, const QSet< int > &userColumns=QSet< int >(), const QString &floatformat=QString("%10.10lf")) const
save contents of datastore as SYLK file (SYmbolic LinK)
const double * getColumnPointer(size_t column, size_t row=0) const
returns a pointer to the data in column column, starting ar row row
Definition jkqtpdatastorage.h:2838
std::pair< size_t, size_t > addCopiedPoints(const std::list< QPoint > &points, const QString &namex=QString(""), const QString &namey=QString(""))
QMap< size_t, JKQTPDatastoreItem * > items
a std::vector that contains all items managed by this datastore
Definition jkqtpdatastorage.h:285
int ensureColumnNum(const QString &name)
return the num of the first column with the given name, if none was found this creates a new column w...
JKQTPColumnBackInserter backInserter(int i)
returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore
int getNextLowerIndex(size_t column, size_t row) const
gets the index of the datapoint with the nearest, but lower value in the column
bool isColumnDataInternal(int column) const
returns true, if the data in the column column is internally managed
Definition jkqtpdatastorage.h:480
friend class JKQTPDatastoreModel
Definition jkqtpdatastorage.h:1500
size_t addItem(size_t columns, size_t rows)
add a new item with rows rows and columns columns to the datastore and return its ID....
size_t addColumn(double *data, size_t rows, const QString &name=QString(""))
add one external column to the datastore. It contains rows rows. This returns its logical column ID....
size_t addInternalItem(double *data, size_t rows)
add one internal column to the datastore. It contains rows rows. This function retuns an item ID (whi...
size_t addCopiedColumnMasked(const TContainer &data, const TContainerMask &mask, const QString &name=QString(""), bool useIfMaskEquals=false)
add one external column to the datastore. It will be filled with the contents of vector data.
Definition jkqtpdatastorage.h:1187
JKQTPColumnConstIterator end(int i) const
returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore
JKQTPColumnConstIterator begin(int i) const
returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore
void deleteAllColumns(const QString &name, bool removeItems=true)
delete all columns with the given name, if no other columns points to the datastore item of the colum...
void setColumnData(size_t toColumn, const QVector< double > &data)
copies the data from data into an existing column toColumn
void saveDIF(const QString &filename, const QSet< int > &userColumns=QSet< int >(), const QString &floatformat=QString("%10.10lf")) const
save contents of datastore as DIF file (data interchange format)
void appendToColumn(size_t column, double value)
adds a value value to the column column. This changes the column length (number of rows).
size_t addImageColumn(size_t width, size_t height, const QString &name=QString(""))
add a new columns with width * height rows to the datastore and return its column ID....
size_t addCopiedColumn(TIterator first, TIterator last, const QString &name=QString(""))
add one column to the datastore. It will be filled with the values from first ... last
Definition jkqtpdatastorage.h:924
void saveCSV(QTextStream &txt, const QSet< int > &userColumns=QSet< int >(), const QString &separator=QString(", "), const QString &decimal_separator=QString("."), const QString &comment=QString("#"), const QString &aroundStrings=QString(""), char floatformat='g') const
save contents of datastore as Comma Separated Values (CSV) file
JKQTPColumnIterator begin(size_t i)
returns an iterator to the first data entry in the i -th column in the JKQTPDatastore
void set(size_t column, size_t row, double value)
sets the value at position (column, row). column is the logical column and will be mapped to the acco...
Definition jkqtpdatastorage.h:2875
JKQTPColumnBackInserter backInserter(size_t i)
returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore
void dec(size_t column, size_t row, double decrement=1)
decrements entry in row row of column column by decrement
Definition jkqtpdatastorage.h:2931
~JKQTPDatastore()
class destructor, destroys all subordered JKQTPDatastoreItem objects
size_t addCopiedColumn(const T *data, size_t rows, size_t stride, const QString &name)
copy an external column to the datastore. It contains rows rows. The external data is copied to an in...
Definition jkqtpdatastorage.h:1080
std::pair< size_t, size_t > addCopiedPoints(const std::list< QPointF > &points, const QString &namex=QString(""), const QString &namey=QString(""))
size_t addCopiedImageAsColumnTranspose(const T *data, size_t width, size_t height, const QString &name=QString(""), size_t stride=1, size_t start=0)
add a new column to the datastore, which is filled from the transposed column-major array data with t...
Definition jkqtpdatastorage.h:2956
size_t addCopiedItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows)
add one external data block to the datastore. It contains rows rows and columns columns....
void saveMatlab(QTextStream &txt, const QSet< int > &userColumns=QSet< int >()) const
save contents of datastore as a Matlab script
size_t maxColumnsID
internal variable to keep track about the highest column ID (in columns) used so far
Definition jkqtpdatastorage.h:303
size_t getColumnCount() const
returns the number of (logical) columns currently managed by the datastore
Definition jkqtpdatastorage.h:1392
size_t addItem(JKQTPDatastoreItem *item)
add a new item to the datastore and return its ID This function retuns an item ID (which can be used ...
void setColumnCopiedImageData(size_t toColumn, const double *data, size_t width, size_t height)
copies the image data from data into an existing column toColumn
double getPixel(size_t column, size_t x, size_t y) const
returns the value at position (x, y) in the column-th column, which is interpreted with the imageWidt...
Definition jkqtpdatastorage.h:2903
size_t addCopiedColumn(const T *data, size_t rows, size_t stride, int start, const QString &name)
copy an external column to the datastore. It contains rows rows. The external data is copied to an in...
Definition jkqtpdatastorage.h:1048
JKQTPColumnConstIterator cend(size_t i) const
returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore
bool isColumnDataInternal(size_t column) const
returns true, if the data in the column column is internally managed
Definition jkqtpdatastorage.h:476
bool hasColumn(size_t i) const
determines whether a column with the given ID exists
size_t addCopiedImageAsColumn(const T *data, size_t width, size_t height, const QString &name=QString(""), size_t stride=1, size_t start=0)
add one external column to the datastore. It contains width * height rows. The external data is assum...
Definition jkqtpdatastorage.h:2939
size_t addLinearColumn(size_t rows, double start, double end, const QString &name=QString(""))
add a column to the datastore that contains rows rows with monotonely increasing value starting at st...
size_t addCopiedColumnMasked(const T *data, const bool *mask, size_t rows, const QString &name=QString(""), bool useIfMaskEquals=false)
add one external column to the datastore. It contains rows rows. The external data is copied to an in...
Definition jkqtpdatastorage.h:1150
std::pair< size_t, size_t > addCopiedPoints(const QList< QPoint > &points, const QString &namex=QString(""), const QString &namey=QString(""))
size_t addInternalColumn(double *data, size_t rows, const QString &name)
add a column with rows entries from the array data, ownership of the memory behind data is transfered...
size_t addColumnCalculatedFromColumn(size_t otherColumn, const std::function< double(double)> &f, const QString &name=QString(""))
Definition jkqtpdatastorage.h:1368
void resizeColumn(size_t column, size_t new_rows)
resizes the column column to have new_rows rows
void inc(size_t column, size_t row, double increment=1)
increases entry in row row of column column by increment
Definition jkqtpdatastorage.h:2925
size_t addCopiedColumn(QVector< double > &&data, const QString &name)
add a column with data from data, ownership of the memory behind data is transfered to the datastore
Definition jkqtpdatastorage.h:798
size_t addColumn(QVector< double > &&data, const QString &name)
add a column with data from data, ownership of the memory behind data is transfered to the datastore
Definition jkqtpdatastorage.h:787
QVector< double > getData(size_t column, QString *columnName=nullptr) const
return contents of a given column as QVector<double>
size_t addCopiedColumn(const T *data, size_t rows, const QString &name=QString(""))
copy an external column to the datastore. It contains rows rows. The external data is copied to an in...
Definition jkqtpdatastorage.h:1016
ColumnIterator begin()
returns an iterator to the first column in the JKQTPDatastore
Definition jkqtpdatastorage.h:363
bool isColumnDataExternal(size_t column) const
returns true, if the data in the column column is internally managed
friend class JKQTPColumn
Definition jkqtpdatastorage.h:1498
size_t addColumnForItem(size_t itemID, size_t columnInItem, const QString &name=QString(""))
add a new columns which references a specified item and a specified column therein.
int getNextHigherIndex(int column, size_t row, int start, int end) const
gets the index of the datapoint with the nearest, but higher value in the column (in a given inclusiv...
JKQTPColumnConstIterator begin(size_t i) const
returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore
size_t addItem(double *data, size_t rows)
add one external column to the datastore. It contains rows rows. This function retuns an item ID (whi...
std::pair< size_t, size_t > addCopiedMap(TIterator first, TIterator last, const QString &nameKey=QString("map_key"), const QString &nameValue=QString("map_value"))
copies the contents of the map-like container c into two columns of the datastore,...
Definition jkqtpdatastorage.h:1232
size_t addDecadeLogColumn(size_t rows, double startDecade, double endDecade, const QString &name=QString(""))
add a column to the datastore that contains rows rows with monotonely increasing value starting at 10...
void scaleColumnValues(size_t column, double factor)
scales (multiplies) all entries in column column by factor
Definition jkqtpdatastorage.h:2919
size_t getColumnImageHeight(int column) const
returns the height of the image, represented by column (in row-major ordering)
size_t getMaxRows() const
returns the maximum number of rows in all columns
void convertToVectorColumn(size_t column)
converts datastoreage of column column to an internally managed vector (with vector coulmns,...
size_t addCalculatedColumnFromColumn(const std::pair< size_t, size_t > &otherColumn, const std::function< double(double, double)> &f, const QString &name=QString(""))
Definition jkqtpdatastorage.h:1387
JKQTPColumnIterator end(int i)
returns an iterator behind the last data entry data in the i -th column in the JKQTPDatastore
size_t addCalculatedColumn(size_t rows, const std::function< double(size_t, JKQTPDatastore *)> &f, const QString &name=QString(""))
add a column with rows entries, that is calculated by calling f for each entry
size_t addInternalColumn(QVector< double > &&data, const QString &name)
add a column with data from data, ownership of the memory behind data is transfered to the datastore
size_t addItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows)
add an external memory block to the datastore. It contains rows rows and columns columns....
void deleteAllPrefixedColumns(QString prefix, bool removeItems=true)
delete all columns where the name starts with a given prefix, if no other columns points to the datas...
void clear()
deletes all items from the datastore and possibly frees the memory they manage
JKQTPColumnIterator begin(int i)
returns an iterator to the first data entry in the i -th column in the JKQTPDatastore
int getNextHigherIndex(size_t column, size_t row) const
gets the index of the datapoint with the nearest, but higher value in the column
QList< QVector< double > > getData(QStringList *columnNames=nullptr, const QSet< int > &userColumns=QSet< int >()) const
return contents of datastore as QList<QVector<double> >, i.e. a list of column-vectors
QStringList getColumnNames() const
return a list with all columns available in the datastore
int getNextLowerIndex(int column, size_t row) const
gets the index of the datapoint with the nearest, but lower value in the column
void eraseFromColumn(JKQTPColumnConstIterator pos, JKQTPColumnConstIterator posEnd)
removes the entries pos to posEnd
size_t addColumn(size_t rows, const QString &name=QString(""))
add a new columns with rows rows to the datastore and return its column ID. The new item uses interna...
QVector< int > getColumnIDsIntVec() const
returns a list with all available column IDs
JKQTPDatastoreItem * getItem(size_t i)
returns the JKQTPDatastoreItem object for the i -th item in the store
Definition jkqtpdatastorage.h:342
std::pair< size_t, size_t > addCopiedPoints(const std::vector< QPointF > &points, const QString &namex=QString(""), const QString &namey=QString(""))
void appendToColumns(size_t columnX, size_t columnY, const QPoint &value)
adds a the x-coordinate of value to the column columnX and the y-coordinate to columnY.
JKQTPColumnIterator end(size_t i)
returns an iterator behind the last data entry data in the i -th column in the JKQTPDatastore
void deleteColumn(size_t column, bool removeItems=true)
delete the given column, if no other columns points to the datastore item of the column and removeIte...
size_t addCopiedItem(const double *data, size_t rows)
add one external column to the datastore. It contains rows rows. The data is copied and the copy mana...
ConstColumnIterator cend() const
returns a const iterator behind the last column in the JKQTPDatastore
Definition jkqtpdatastorage.h:373
std::pair< size_t, size_t > addCopiedPoints(const std::vector< QPoint > &points, const QString &namex=QString(""), const QString &namey=QString(""))
JKQTPColumnConstIterator cend(int i) const
returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore
std::pair< size_t, size_t > addLinearGridColumns(size_t width, double startX, double endX, size_t height, double startY, double endY, const QString &nameX=QString(""), const QString &nameY=QString(""))
add two columns to the datastore that contains the x- and y- coordinates of a rectangular grid with w...
void resizeImageColumn(size_t column, size_t new_image_width, size_t new_image_height)
resizes the column column to have enough rows to be interpreted as an image of size new_image_width *...
size_t addCalculatedColumn(size_t rows, const std::function< double(size_t)> &f, const QString &name=QString(""))
add a column with rows entries, that is calculated by calling f for each entry
QMap< size_t, JKQTPColumn > columns
a std::vector of all columns that may be used to access the managed chunks of memory.
Definition jkqtpdatastorage.h:287
void appendToColumns(size_t column1, size_t column2, size_t column3, size_t column4, double value1, double value2, double value3, double value4)
adds a value value1 to the column column1, a value value2 to column2, etc.
ColumnIterator end()
returns an iterator behind the last column in the JKQTPDatastore
Definition jkqtpdatastorage.h:365
void appendToColumns(size_t column1, size_t column2, size_t column3, double value1, double value2, double value3)
adds a value value1 to the column column1, a value value2 to column2, etc.
bool isVectorColumn(size_t column) const
returns true, if the data in the column column is internally managed as a vector (with vector coulmns...
int getNextLowerIndex(int column, size_t row, int start, int end) const
gets the index of the datapoint with the nearest, but lower value in the column (in a given inclusive...
void setColumnCopiedData(size_t toColumn, const double *data, size_t N)
copies the data from data into an existing column toColumn
void setAll(size_t column, double value)
sets all entries in column column to value
Definition jkqtpdatastorage.h:2913
void appendToColumns(size_t column1, size_t column2, size_t column3, size_t column4, size_t column5, double value1, double value2, double value3, double value4, double value5)
adds a value value1 to the column column1, a value value2 to column2, etc.
std::unique_ptr< JKQTPColumn > m_invalidColumn
an internal invalid column object, used e.g. to return invalid column iterators
Definition jkqtpdatastorage.h:292
ConstColumnIterator cbegin() const
returns a const iterator to the first column in the JKQTPDatastore
Definition jkqtpdatastorage.h:371
size_t addCopiedColumn(const TContainer &data, const QString &name, size_t stride, size_t start=0)
add one external column to the datastore. It will be filled with the contents of vector data.
Definition jkqtpdatastorage.h:988
JKQTPColumnConstIterator end(size_t i) const
returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore
size_t getColumnImageWidth(int column) const
returns the width of the image, represented by column (in row-major ordering). Internally this return...
size_t addItem(size_t rows)
add a new columns/item with rows rows to the datastore and return its ID. The item uses internal memo...
void setPixel(size_t column, size_t x, size_t y, double value)
returns the value at position (x, y) in the column-th column, which is interpreted with the imageWidt...
Definition jkqtpdatastorage.h:2908
size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function< double(double, double)> &f, const QString &name=QString(""))
Definition jkqtpdatastorage.h:1384
std::pair< size_t, size_t > addCopiedMap(const TContainer &c, const QString &nameKey=QString("map_key"), const QString &nameValue=QString("map_value"))
copies the contents of the map-like container c into two columns of the datastore,...
Definition jkqtpdatastorage.h:1270
void copyColumnData(size_t toColumn, size_t fromColumn)
copies the data from fromColumn into an existing column toColumn
size_t addInternalImageColumn(double *data, size_t width, size_t height, const QString &name)
add a column with width * height entries from the array data, ownership of the memory behind data is ...
ConstColumnIterator end() const
returns a const iterator behind the last column in the JKQTPDatastore
Definition jkqtpdatastorage.h:369
size_t addCalculatedColumnFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function< double(double, double)> &f, const QString &name=QString(""))
add a column with the same number of entries, as in the other column otherColumn ,...
size_t addColumn(JKQTPColumn col)
add a new column to the datastore and return its ID
void setColumnImageWidth(size_t column, size_t imageWidth)
sets the width of the image, represented by column (in row-major ordering) to imageWidth
void saveMatlab(const QString &filename, const QSet< int > &userColumns=QSet< int >()) const
save contents of datastore as a Matlab script
bool isVectorColumn(int column) const
returns true, if the data in the column column is internally managed as a vector (with vector coulmns...
size_t copyColumn(size_t old_column, const QString &name=QString(""))
copies the given old_column into a new one
void appendToColumns(size_t column1, size_t column2, double value1, double value2)
adds a value value1 to the column column1 and a value value2 to column2.
void convertToVectorColumn(int column)
converts datastoreage of column column to an internally managed vector (with vector coulmns,...
size_t addCalculatedColumnFromColumn(size_t otherColumn, const std::function< double(double)> &f, const QString &name=QString(""))
add a column with the same number of entries, as in the other column otherColumn ,...
void appendToColumns(size_t columnX, size_t columnY, const QPointF &value)
adds a the x-coordinate of value to the column columnX and the y-coordinate to columnY.
quint16 getColumnChecksum(int column) const
returns the data checksum of the given column column
void setColumnImageHeight(size_t column, size_t imageHeight)
sets the height of the image, represented by column (in row-major ordering) to imageHeight
int getNextHigherIndex(size_t column, size_t row, int start, int end) const
gets the index of the datapoint with the nearest, but higher value in the column (in a given inclusiv...
size_t addColumn(const QString &name=QString(""))
add a new and empty column to the datastore and return its column ID. The new item uses internal memo...
int getColumnNum(const QString &name)
return the num of the first column with the given name, or -1 if none was found
std::pair< size_t, size_t > addCopiedPoints(const QList< QPointF > &points, const QString &namex=QString(""), const QString &namey=QString(""))
add two columns to the datastore. They will be filled with the values from points (first column: x-va...
ConstColumnIterator begin() const
returns a const iterator to the first column in the JKQTPDatastore
Definition jkqtpdatastorage.h:367
JKQTPColumnConstIterator cbegin(int i) const
returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore
double get(size_t column, size_t row) const
returns the value at position (column, row). column is the logical column and will be mapped to the a...
Definition jkqtpdatastorage.h:2850
void saveCSV(const QString &filename, const QSet< int > &userColumns=QSet< int >(), const QString &separator=QString(", "), const QString &decimal_separator=QString("."), const QString &comment=QString("#"), const QString &aroundStrings=QString(""), char floatformat='g') const
save contents of datastore as Comma Separated Values (CSV) file
size_t copyColumn(size_t old_column, size_t start, size_t stride, const QString &name=QString(""))
copies the given old_column into a new one, reading the data with the given start column and stride
size_t addCopiedColumn(const TContainer &data, const QString &name=QString(""))
add one external column to the datastore. It will be filled with the contents of vector data.
Definition jkqtpdatastorage.h:961
int getNextHigherIndex(int column, size_t row) const
gets the index of the datapoint with the nearest, but higher value in the column
size_t addLogColumn(size_t rows, double start, double end, const QString &name=QString(""))
add a column to the datastore that contains rows rows with monotonely increasing value starting at st...
this represents one chunk of memory which can represent one or more columns of data for JKQTBasePlott...
Definition jkqtpdatastorage.h:2394
bool isVector() const
checks whether dataformat==JKQTPDatastoreItemFormat::SingleColumn and storageType==StorageType::Vecto...
Definition jkqtpdatastorage.h:2468
double get(size_t column, size_t row)
returns the data at the position (column, row ).
Definition jkqtpdatastorage.h:2524
JKQTPDatastoreItemFormat dataformat
memory format of the data in this item
Definition jkqtpdatastorage.h:2412
bool push_back(size_t column, double value)
adds a new row to the given column. Returns true on success and false else
Definition jkqtpdatastorage.h:2622
size_t columns
as data may also point to a matrix, this specifies the number of columns in this element (default: 1)
Definition jkqtpdatastorage.h:2406
void set(size_t column, size_t row, double value)
set the data at the position (column, row ) to value. The column index specifies the column inside TH...
Definition jkqtpdatastorage.h:2598
JKQTPDatastoreItem(QVector< double > &&data)
class constructor: initializes the object for internal data storage with the given data
double * data
a pointer to the actual data
Definition jkqtpdatastorage.h:2404
QVector< double > datavec
iif storageType is StorageType::Vector, the data is actually save here and data contains a pointer to...
Definition jkqtpdatastorage.h:2410
const double & at(size_t column, size_t row) const
returns a const reference to the data at the position (column, row ). Throws an exception when the en...
Definition jkqtpdatastorage.h:2557
JKQTPDatastoreItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows)
class constructor: initializes the object for external data storage
JKQTPDatastoreItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows, bool internalStorage)
class constructor: initializes the object for external or internal data storage
void eraseFromVectorItem(size_t row, size_t rowEnd)
if isValid() : eraseFromVectorItem all rows (and including) from row to rowEnd
Definition jkqtpdatastorage.h:2499
StorageType storageType
specifies whether the datastore manages the memory (true ) or whether the user application does this ...
Definition jkqtpdatastorage.h:2414
~JKQTPDatastoreItem()
class destructor: frees unfreed internal memory
size_t getRows() const
number of rows in this item
Definition jkqtpdatastorage.h:2460
bool append(size_t column, const std::vector< double > &values)
adds new rows to the given column. Returns true on success and false else
Definition jkqtpdatastorage.h:2675
bool append(size_t column, double value)
adds a new row to the given column. Returns true on success and false else
Definition jkqtpdatastorage.h:2642
bool resizeColumns(size_t rows)
change the size of all columns to the givne number of rows. Returns true if the old data could be ret...
bool append(size_t column, const QVector< double > &values)
adds new rows to the given column. Returns true on success and false else
Definition jkqtpdatastorage.h:2655
size_t rows
number of rows in this item
Definition jkqtpdatastorage.h:2408
bool allocated
Specifies whether memory for the data has been allocated. This is only used, when internal==true.
Definition jkqtpdatastorage.h:2416
size_t getColumns() const
as data may also point to a matrix, this specifies the number of columns in this element (default: 1)
Definition jkqtpdatastorage.h:2464
double * getPointer(size_t column, size_t row)
returns the data at the position (column, row ). The column index specifies the column inside THIS it...
Definition jkqtpdatastorage.h:2573
StorageType
how data is represented in this JKQTPDatastoreItem
Definition jkqtpdatastorage.h:2397
@ Vector
data is stored in the internal QVector<double> datavec
Definition jkqtpdatastorage.h:2400
@ Internal
data is stored in an internally managed (=owned, i.e. freed in the destructor) C-array
Definition jkqtpdatastorage.h:2398
@ External
data is stored in an externally managed (=not owned) C-array
Definition jkqtpdatastorage.h:2399
double & at(size_t column, size_t row)
returns a reference to the data at the position (column, row ). Throws an exception when the entry do...
Definition jkqtpdatastorage.h:2540
JKQTPDatastoreItem(const QVector< double > &data)
class constructor: initializes the object for internal data storage with the given data
JKQTPDatastoreItem(size_t columns, size_t rows)
class constructor: initializes the object for internal data storage with columns columns and rows row...
void resizeVectorItem(size_t rows_new)
if isValid() : resizeVectorItem the row to have rows_new rows
Definition jkqtpdatastorage.h:2473
StorageType getStorageType() const
returns whether the datastore manages the memory externally, internally or internally as vector .
Definition jkqtpdatastorage.h:2455
const double * getPointer(size_t column, size_t row) const
returns the data at the position (column, row ). The column index specifies the column inside THIS it...
Definition jkqtpdatastorage.h:2586
void reserveVectorColumn(size_t rows)
reserves memory for the vector holding the data in this column
Definition jkqtpdatastorage.h:2517
JKQTPDatastoreItem()
hidden default constructor
void eraseFromVectorItem(size_t row)
if isValid() : eraseFromVectorItem the row row
Definition jkqtpdatastorage.h:2486
QAbstractTableModel descendent that allows to view data in a JKQTPDatastore.
Definition jkqtpdatastorage.h:2694
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
JKQTPDatastore * datastore
Definition jkqtpdatastorage.h:2711
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
JKQTPDatastoreModel(JKQTPDatastore *datastore, QObject *parent=nullptr)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
virtual QVariant data(const QModelIndex &index, int role) const override
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
virtual ~JKQTPDatastoreModel() override
JKQTPDatastoreItemFormat
the types of data in one JKQTdatastoreItem
Definition jkqtpdatastorage.h:82
@ SingleColumn
a 1D C-array of doubles. (default option)
Definition jkqtpdatastorage.h:83
@ MatrixColumn
a 1D C-array of doubles that represents a number of columns. The data is store column after column (=...
Definition jkqtpdatastorage.h:84
@ MatrixRow
a 1D C-array of doubles that represents a number of rows (C standard representation of matrices)....
Definition jkqtpdatastorage.h:85
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89