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(
""));
448 inline size_t getRows(
size_t column)
const;
450 inline const double* getColumnPointer(
size_t column,
size_t row=0)
const;
452 inline double* getColumnPointer(
size_t column,
size_t row=0);
454 inline size_t getRows(
int column)
const;
456 inline const double* getColumnPointer(
int column,
size_t row=0)
const;
458 inline double* getColumnPointer(
int column,
size_t row=0);
473 inline double get(
size_t column,
size_t row)
const ;
476 inline double get(
int column,
size_t row)
const ;
478 inline double get(
int column,
int row)
const ;
480 inline double get(
size_t column,
int row)
const ;
499 inline void set(
size_t column,
size_t row,
double value);
501 inline void set(
int column,
size_t row,
double value);
608 void appendToColumns(
size_t column1,
size_t column2,
size_t column3,
double value1,
double value2,
double value3);
624 void appendToColumns(
size_t column1,
size_t column2,
size_t column3,
size_t column4,
double value1,
double value2,
double value3,
double value4);
641 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);
652 template<
class TContainer>
653 inline void appendFromContainerToColumn(
size_t column,
const TContainer& values);
661 template<
class TIterator>
662 inline void appendToColumn(
size_t column, TIterator first, TIterator last);
665 inline double getPixel(
size_t column,
size_t x,
size_t y)
const ;
667 inline void setPixel(
size_t column,
size_t x,
size_t y,
double value) ;
672 inline void setAll(
size_t column,
double value);
677 inline void scaleColumnValues(
size_t column,
double factor);
682 inline void inc(
size_t column,
size_t row,
double increment=1);
687 inline void dec(
size_t column,
size_t row,
double decrement=1);
697 size_t addColumn(
size_t rows,
const QString& name=QString(
""));
724 size_t addColumn(
double* data,
size_t rows,
const QString& name=QString(
""));
756 size_t addImageColumn(
size_t width,
size_t height,
const QString& name=QString(
""));
771 size_t addImageColumn(
double* data,
size_t width,
size_t height,
const QString& name=QString(
""));
806 size_t copyColumn(
size_t old_column,
size_t start,
size_t stride,
const QString& name=QString(
""));
814 size_t copyColumn(
size_t old_column,
const QString& name=QString(
""));
835 std::pair<size_t,size_t>
addCopiedPoints(
const QList<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
836 std::pair<size_t,size_t>
addCopiedPoints(
const QList<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
837#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
838 std::pair<size_t,size_t> addCopiedPoints(
const QVector<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
839 std::pair<size_t,size_t> addCopiedPoints(
const QVector<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
841 std::pair<size_t,size_t>
addCopiedPoints(
const std::vector<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
842 std::pair<size_t,size_t>
addCopiedPoints(
const std::vector<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
843 std::pair<size_t,size_t>
addCopiedPoints(
const std::list<QPointF>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
844 std::pair<size_t,size_t>
addCopiedPoints(
const std::list<QPoint>& points,
const QString& namex=QString(
""),
const QString &namey=QString(
""));
870 template <
typename TIterator>
871 size_t addCopiedColumn(TIterator first, TIterator last,
const QString& name=QString(
"")) {
872 const size_t N=
static_cast<size_t>(std::abs(std::distance(first,last)));
873 double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(N)*
sizeof(
double)));
876 for (
auto it=first; it!=last; ++it) {
881 size_t itemid=addInternalItem(d, N);
882 return addColumnForItem(itemid, 0, name);
908 template <
typename TContainer>
910 return addCopiedColumn(data.begin(), data.end(), name);
935 template <
typename TContainer>
936 size_t addCopiedColumn(
const TContainer& data,
const QString& name,
size_t stride,
size_t start=0) {
937 const size_t N=
static_cast<size_t>(data.size()-start)/stride;
938 double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(N)*
sizeof(
double)));
941 auto it=data.begin();
942 if (start>0) it+=start;
943 for (; it!=data.end(); it+=stride) {
948 size_t itemid=addInternalItem(d, N);
949 return addColumnForItem(itemid, 0, name);
968 double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(rows)*
sizeof(
double)));
971 for (
size_t r=0; r<rows; r++) {
975 const size_t itemid=addInternalItem(d, rows);
976 return addColumnForItem(itemid, 0, name);
978 throw std::runtime_error(
"could not allocate memory in JKQTPDataStore::addCopiedColumn()");
1003 template<
typename T>
1004 size_t addCopiedColumn(
const T* data,
size_t rows,
size_t stride,
int start,
const QString& name) {
1005 double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(rows)*
sizeof(
double)));
1008 for (
size_t r=0; r<rows; r++) {
1009 d[r]=
jkqtp_todouble(data[
static_cast<size_t>(start+
static_cast<int64_t
>(r*stride))]);
1012 size_t itemid=addInternalItem(d, rows);
1013 return addColumnForItem(itemid, 0, name);
1015 throw std::runtime_error(
"could not allocate memory in JKQTPDataStore::addCopiedColumn()");
1040 template<
typename T>
1042 return addCopiedColumn<T>(data, rows, stride, 0, name);
1048 template <
typename T>
1049 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);
1060 template <
typename TContainer>
1061 inline size_t addCopiedImageAsColumn(
const TContainer& data,
size_t width,
const QString& name=QString(
""));
1079 template <
typename T>
1080 size_t addCopiedImageAsColumnTranspose(
const T* data,
size_t width,
size_t height,
const QString& name=QString(
""),
size_t stride=1,
size_t start=0);
1095 template <
typename T>
1096 inline size_t addCopiedImageAsColumnTranspose(
const QVector<T>& data,
size_t width,
const QString& name=QString(
""));
1110 template <
typename T>
1111 size_t addCopiedColumnMasked(
const T* data,
const bool* mask,
size_t rows,
const QString& name=QString(
""),
bool useIfMaskEquals=
false) {
1112 double* d=
static_cast<double*
>(calloc(rows,
sizeof(
double)));
1115 for (
size_t r=0; r<rows; r++) {
1116 if (!mask || (mask && (mask[r]==useIfMaskEquals))) {
1124 size_t col= addInternalColumn(d, rrs, name);
1149 template <
typename TContainer,
typename TContainerMask>
1150 size_t addCopiedColumnMasked(
const TContainer& data,
const TContainerMask& mask,
const QString& name=QString(
""),
bool useIfMaskEquals=
false) {
1151 const size_t N=
static_cast<size_t>(data.size());
1152 double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(N)*
sizeof(
double)));
1155 auto itmask=mask.begin();
1156 auto itdata=data.begin();
1157 for (
size_t r=0; r<N; r++) {
1158 if (
static_cast<bool>(*itmask)==useIfMaskEquals) {
1166 size_t col= addInternalColumn(d, rrs, name);
1195 template <
typename TIterator>
1196 std::pair<size_t, size_t>
addCopiedMap(TIterator first, TIterator last,
const QString& nameKey=QString(
"map_key"),
const QString& nameValue=QString(
"map_value")) {
1197 const size_t N=
static_cast<size_t>(std::abs(std::distance(first,last)));
1198 double* xvals=
static_cast<double*
>(malloc(N*
sizeof(
double)));
1199 double* yvals=
static_cast<double*
>(malloc(N*
sizeof(
double)));
1201 for (
auto it=first; it!=last; ++it) {
1206 const size_t cx=addInternalColumn(xvals, N, nameKey);
1207 const size_t cy=addInternalColumn(yvals, N, nameValue);
1208 return std::pair<size_t, size_t>(cx,cy);
1234 template <
typename TContainer>
1235 std::pair<size_t, size_t>
addCopiedMap(
const TContainer& c,
const QString& nameKey=QString(
"map_key"),
const QString& nameValue=QString(
"map_value")) {
1236 return addCopiedMap(c.begin(), c.end(), nameKey, nameValue);
1246 size_t addLinearColumn(
size_t rows,
double start,
double end,
const QString& name=QString(
""));
1251 size_t addLogColumn(
size_t rows,
double start,
double end,
const QString& name=QString(
""));
1256 size_t addDecadeLogColumn(
size_t rows,
double startDecade,
double endDecade,
const QString& name=QString(
""));
1276 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(
""));
1304 size_t addCalculatedColumn(
size_t rows,
const std::function<
double(
size_t)>& f,
const QString& name=QString(
""));
1319 size_t addCalculatedImageColumn(
size_t cols,
size_t rows,
const std::function<
double(
size_t,
size_t)>& f,
const QString& name=QString(
""));
1334 return addCalculatedColumnFromColumn(otherColumn, f, name);
1349 inline size_t addColumnCalculatedFromColumn(
size_t otherColumnX,
size_t otherColumnY,
const std::function<
double(
double,
double)>& f,
const QString& name=QString(
"")) {
1350 return addCalculatedColumnFromColumn(otherColumnX, otherColumnY, f, name);
1352 inline size_t addCalculatedColumnFromColumn(
const std::pair<size_t, size_t>& otherColumn,
const std::function<
double(
double,
double)>& f,
const QString& name=QString(
"")) {
1353 return addCalculatedColumnFromColumn(otherColumn.first, otherColumn.second, f, name);
1394 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;
1412 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;
1420 void saveSYLK(
const QString& filename,
const QSet<int>& userColumns=QSet<int>(),
const QString& floatformat=QString(
"%10.10lf"))
const;
1427 QList<QVector<double> >
getData(QStringList* columnNames=
nullptr,
const QSet<int>& userColumns=QSet<int>())
const;
1434 QVector<double>
getData(
size_t column, QString* columnName=
nullptr)
const;
1442 void saveDIF(
const QString& filename,
const QSet<int>& userColumns=QSet<int>(),
const QString& floatformat=QString(
"%10.10lf"))
const;
1449 void saveMatlab(
const QString& filename,
const QSet<int>& userColumns=QSet<int>())
const;
1455 void saveMatlab(QTextStream& txt,
const QSet<int>& userColumns=QSet<int>())
const;
1503 JKQTPColumn(
JKQTPDatastore* datastore,
const QString& name=QString(
""),
size_t datastoreItem=0,
size_t datastoreOffset=0,
size_t imageColumns=1);
1512 && (valid==other.
valid);
1538 inline double getValue(
size_t n)
const;
1544 inline double getValue(
int n)
const;
1552 inline double& at(
int n);
1560 inline const double& at(
int n)
const;
1571 inline void setValue(
size_t n,
double val);
1576 inline void incValue(
size_t n,
double increment=1.0);
1582 incValue(n, -1.0*decrement);
1592 setValue(y*width+x, val);
1602 setValue(y*imageColumns+x, val);
1611 return getValue(y*imageColumns+x);
1624 void copy(
const double* data,
size_t N,
size_t offset=0);
1638 inline quint16 calculateChecksum()
const;
1642 {
return this->datastoreItem; }
1645 {
return this->datastoreOffset; }
1649 inline iterator begin();
1652 inline iterator end();
1656 inline const_iterator begin()
const;
1659 inline const_iterator end()
const;
1670 datastoreItem=datastoreItem_;
1671 datastoreOffset=datastoreOffset_;
1674 inline void erase(
size_t row);
1676 inline void erase(
size_t row,
size_t rowEnd);
1716 pos_++;
return *
this;
1832 if ((pos_<0 || pos_>=
static_cast<int>(rhs.
col_->
getRows())) && (pos_<0 || rhs.pos_>=
static_cast<int>(rhs.
col_->
getRows())))
return true;
1901 inline operator bool()
const {
return isValid(); }
1909 if (!
isValid())
return QPoint(-1,-1);
2049 pos_++;
return *
this;
2225 if ((pos_<0 || pos_>=
static_cast<int>(rhs.
col_->
getRows())) && (pos_<0 || rhs.pos_>=
static_cast<int>(rhs.
col_->
getRows())))
return true;
2241 inline operator bool()
const {
return isValid(); }
2249 if (!
isValid())
return QPoint(-1,-1);
2358 datavec.resize(
static_cast<int>(rows_new));
2359 rows=
static_cast<size_t>(datavec.size());
2360 data=datavec.data();
2366 datavec.erase(datavec.begin()+row, datavec.end());
2367 rows=
static_cast<size_t>(datavec.size());
2368 data=datavec.data();
2371 inline void erase(
size_t row,
size_t rowEnd) {
2372 if (row>rowEnd) erase(rowEnd, row);
2373 else if (row==rowEnd) erase(row);
2376 if (rowEnd>=
static_cast<size_t>(datavec.size())) datavec.erase(datavec.begin()+row, datavec.end());
2377 else datavec.erase(datavec.begin()+row, datavec.begin()+rowEnd);
2378 rows=
static_cast<size_t>(datavec.size());
2379 data=datavec.data();
2385 inline double get(
size_t column,
size_t row) {
2386 if (data!=
nullptr)
switch(dataformat) {
2390 return data[column*rows+row];
2392 return data[row*columns+column];
2401 inline double&
at(
size_t column,
size_t row) {
2402 if (data!=
nullptr) {
2403 switch(dataformat) {
2407 return data[column*rows+row];
2409 return data[row*columns+column];
2412 throw std::out_of_range(
"index does not exist in JKQTPDatastoreItem");
2418 inline const double&
at(
size_t column,
size_t row)
const {
2419 if (data!=
nullptr) {
2420 switch(dataformat) {
2424 return data[column*rows+row];
2426 return data[row*columns+column];
2429 throw std::out_of_range(
"index does not exist in JKQTPDatastoreItem");
2435 if (data!=
nullptr)
switch(dataformat) {
2437 return &(data[row]);
2439 return &(data[column*rows+row]);
2441 return &(data[row*columns+column]);
2447 inline const double*
getPointer(
size_t column,
size_t row)
const {
2448 if (data!=
nullptr)
switch(dataformat) {
2450 return &(data[row]);
2452 return &(data[column*rows+row]);
2454 return &(data[row*columns+column]);
2459 inline void set(
size_t column,
size_t row,
double value) {
2460 if (data!=
nullptr)
switch(dataformat) {
2465 data[column*rows+row]=value;
2468 data[row*columns+column]=value;
2478 datavec.push_back(value);
2479 rows=
static_cast<size_t>(datavec.size());
2480 data=datavec.data();
2489 inline bool append(
size_t column,
double value) {
2490 return push_back(column, value);
2495 inline bool append(
size_t column,
const QVector<double>& values) {
2497 datavec.reserve(datavec.size()+values.size());
2498 for (
const double& d: values) datavec.push_back(d);
2499 data=datavec.data();
2500 rows=
static_cast<size_t>(datavec.size());
2508 inline bool append(
size_t column,
const std::vector<double>& values) {
2510 datavec.reserve(
static_cast<int>(datavec.size())+
static_cast<int>(values.size()));
2511 for (
const double& d: values) datavec.push_back(d);
2512 data=datavec.data();
2513 rows=
static_cast<size_t>(datavec.size());
2534 virtual QVariant
data(
const QModelIndex &index,
int role)
const override;
2535 virtual Qt::ItemFlags
flags(
const QModelIndex &index)
const override;
2536 virtual QVariant
headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
2537 virtual int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
2538 virtual int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
2639 return columns.value(column).getRows();
2645 if (column<0)
return nullptr;
2646 return columns.value(
static_cast<size_t>(column)).getPointer(row);
2652 if (column<0)
return nullptr;
2653 return columns[
static_cast<size_t>(column)].getPointer(row);
2658 if (column<0)
return 0;
2659 return columns.value(
static_cast<size_t>(column)).getRows();
2665 return columns.value(column).getPointer(row);
2671 return columns[column].getPointer(row);
2676 return columns[column].getValue(row);
2682 return get(
static_cast<size_t>(column),
static_cast<size_t>(row));
2689 return get(
static_cast<size_t>(column),
static_cast<size_t>(row));
2696 return get(
static_cast<size_t>(column),
static_cast<size_t>(row));
2701 columns[column].setValue(row, value);
2706 set(
static_cast<size_t>(column),
static_cast<size_t>(row), value);
2711template<
class TContainer>
2718template<
class TIterator>
2721 for(
auto it=first; it!=last; it++) {
2732 QVector<double> old_data;
2733 for (
auto it=pos.
getColumn()->
begin(); it!=pos; ++it) old_data.push_back(*it);
2737 columns[itc].replaceMemory(itemID, 0);
2750 QVector<double> old_data;
2751 for (
auto it=pos.
getColumn()->
begin(); it!=pos; ++it) old_data.push_back(*it);
2755 columns[itc].replaceMemory(itemID, 0);
2768 QVector<double> old_data;
2771 columns[itc].replaceMemory(itemID, 0);
2784 QVector<double> old_data;
2787 columns[itc].replaceMemory(itemID, 0);
2796 return columns.value(column).getPixelValue(x, y);
2801 return columns[column].setPixelValue(x, y, value);
2807 columns[column].setAll(value);
2813 columns[column].scale(factor);
2819 columns[column].incValue(row, increment);
2825 columns[column].decValue(row, decrement);
2830template <
typename T>
2832 size_t col=addCopiedColumn<T>(data, width*height, stride, start, name);
2833 columns[col].setImageColumns(width);
2838template <
typename TContainer>
2840 size_t col= addCopiedColumn<TContainer>(data, name);
2841 columns[col].setImageColumns(width);
2847template <
typename T>
2849 double* temp=
static_cast<double*
>(malloc(width*height*
sizeof(
double)));
2851 for (
size_t x=0; x<width; x++) {
2852 for (
size_t y=0; y<height; y++) {
2853 temp[x*height+y]=jkqtp_todouble<T>(data[start+(y*width+x)*stride]);
2859 columns[idx].setImageColumns(height);
2865template <
typename T>
2867 return addCopiedImageAsColumnTranspose<T>(data.data(), width,
static_cast<size_t>(data.size())/width, name);
iterator, which allows to insert into a column of a JKQTPDatastore
Definition jkqtpdatastorage.h:1954
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:1962
JKQTPColumnBackInserter & operator=(double &&val)
Definition jkqtpdatastorage.h:1982
double * pointer
Definition jkqtpdatastorage.h:1968
int difference_type
Definition jkqtpdatastorage.h:1970
JKQTPColumnBackInserter & operator=(const JKQTPColumnBackInserter &)=default
double value_type
Definition jkqtpdatastorage.h:1965
const double & const_reference
Definition jkqtpdatastorage.h:1967
std::output_iterator_tag iterator_category
Definition jkqtpdatastorage.h:1969
JKQTPDatastore * ds_
references the datastore to access
Definition jkqtpdatastorage.h:1957
self_type operator++()
Definition jkqtpdatastorage.h:1988
JKQTPColumnBackInserter(const JKQTPColumnBackInserter &)=default
JKQTPColumnBackInserter(JKQTPColumnBackInserter &&)=default
double & reference
Definition jkqtpdatastorage.h:1966
size_t col_
references the column to access
Definition jkqtpdatastorage.h:1959
JKQTPColumnBackInserter self_type
Definition jkqtpdatastorage.h:1964
JKQTPColumnBackInserter & operator=(const double &val)
Definition jkqtpdatastorage.h:1977
self_type operator*()
Definition jkqtpdatastorage.h:1989
JKQTPColumnBackInserter()
constructs an invalid iterator
Definition jkqtpdatastorage.h:1972
self_type operator++(int)
Definition jkqtpdatastorage.h:1987
iterator over the data in the column of a JKQTPDatastore
Definition jkqtpdatastorage.h:2000
difference_type operator-(self_type rhs) const
Definition jkqtpdatastorage.h:2123
const_reference operator*() const
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:2152
reference operator*()
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:2134
JKQTPColumnConstIterator(const JKQTPColumnConstIterator &)=default
friend self_type operator-(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:2098
bool operator<(const self_type &rhs) const
comparison operator (less than)
Definition jkqtpdatastorage.h:2168
bool operator>=(const self_type &rhs) const
comparison operator (larger than, or equal)
Definition jkqtpdatastorage.h:2209
const double & reference
Definition jkqtpdatastorage.h:2012
bool operator>(const self_type &rhs) const
comparison operator (larger than)
Definition jkqtpdatastorage.h:2195
JKQTPColumnConstIterator & operator=(const JKQTPColumnConstIterator &)=default
bool operator<=(const self_type &rhs) const
comparison operator (less than, or equal)
Definition jkqtpdatastorage.h:2182
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:2237
self_type operator+=(int inc)
Definition jkqtpdatastorage.h:2070
self_type operator++(int)
Definition jkqtpdatastorage.h:2042
friend self_type operator+(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:2090
self_type operator++()
Definition jkqtpdatastorage.h:2047
bool operator!=(const self_type &rhs) const
comparison operator (unequals), inverse result of operator==()
Definition jkqtpdatastorage.h:2234
self_type operator+(difference_type rhs) const
Definition jkqtpdatastorage.h:2105
JKQTPColumnConstIterator & operator=(const JKQTPColumnIterator &rhs)
Definition jkqtpdatastorage.h:2030
JKQTPColumnConstIterator & operator=(JKQTPColumnIterator &&rhs)
Definition jkqtpdatastorage.h:2035
const double * pointer
Definition jkqtpdatastorage.h:2014
self_type operator-(difference_type rhs) const
Definition jkqtpdatastorage.h:2115
JKQTPColumnConstIterator & operator=(JKQTPColumnConstIterator &&)=default
double value_type
Definition jkqtpdatastorage.h:2011
JKQTPColumnConstIterator(JKQTPColumnIterator &&rhs)
Definition jkqtpdatastorage.h:2022
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:2264
int getImagePositionY() const
returns the referenced position/row interpreted as an image pixel, y-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2258
int difference_type
Definition jkqtpdatastorage.h:2016
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:2253
QPoint getImagePosition() const
returns the referenced position/row interpreted as an image pixel, returns (-1,-1) for an invalid ope...
Definition jkqtpdatastorage.h:2248
int pos_
current row in col_ this iterator points to
Definition jkqtpdatastorage.h:2005
self_type operator--(int)
Definition jkqtpdatastorage.h:2051
self_type operator-=(int dec)
Definition jkqtpdatastorage.h:2079
bool operator==(const self_type &rhs) const
comparison operator (equals)
Definition jkqtpdatastorage.h:2222
reference const_reference
Definition jkqtpdatastorage.h:2013
int getPosition() const
returns the referenced position/row, or -1 for an invalid iterator
Definition jkqtpdatastorage.h:2243
const JKQTPColumn * col_
references the column this iterator iterates over
Definition jkqtpdatastorage.h:2003
JKQTPColumnConstIterator(const JKQTPColumn *col, int startpos=0)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:2008
std::forward_iterator_tag iterator_category
Definition jkqtpdatastorage.h:2015
const JKQTPColumn * getColumn() const
returns the referenced column
Definition jkqtpdatastorage.h:2279
self_type operator--()
Definition jkqtpdatastorage.h:2061
reference operator[](difference_type off) const
Definition jkqtpdatastorage.h:2140
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:2270
JKQTPColumnConstIterator(const JKQTPColumnIterator &rhs)
Definition jkqtpdatastorage.h:2021
JKQTPColumnConstIterator()
constructs an invalid iterator
Definition jkqtpdatastorage.h:2018
JKQTPColumnConstIterator self_type
Definition jkqtpdatastorage.h:2010
internally stores information about one data column. See JKQTPDatastore for more information.
Definition jkqtpdatastorage.h:1478
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:1483
JKQTPDatastore * datastore
pointer to the datastore object used to manage the data of the plot
Definition jkqtpdatastorage.h:1487
JKQTPColumnConstIterator const_iterator
Definition jkqtpdatastorage.h:1494
size_t getRows() const
returns the number of rows in this column (accesses the datastore)
bool isValid() const
Definition jkqtpdatastorage.h:1505
size_t getDatastoreItemNum() const
index of the item in the datastore that contains the data for this column
Definition jkqtpdatastorage.h:1641
size_t getImageColumns() const
number of columns, if interpreted as a row-major image
Definition jkqtpdatastorage.h:1523
quint16 calculateChecksum() const
calculates a checksum over the contents of the column (using qChecksum())
Definition jkqtpdatastorage.h:2567
void replaceMemory(size_t datastoreItem_=0, size_t datastoreOffset_=0)
Definition jkqtpdatastorage.h:1669
void setValue(size_t n, double val)
sets the n'th value from the column
Definition jkqtpdatastorage.h:2553
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:1481
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:1617
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:2606
const JKQTPDatastore * getDatastore() const
Definition jkqtpdatastorage.h:1668
JKQTPDatastoreItem * getDatastoreItem()
returns a pointer to the datastore item representing this column
Definition jkqtpdatastorage.h:1615
JKQTPDatastore * getDatastore()
Definition jkqtpdatastorage.h:1667
double * getPointer(size_t n=0)
gets a pointer to the n-th value in the column
JKQTPColumnIterator iterator
Definition jkqtpdatastorage.h:1493
void setImageColumns(size_t imageWidth)
number of columns, if interpreted as a row-major image
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:2560
bool valid
is this item valid?/usable?
Definition jkqtpdatastorage.h:1491
iterator begin()
returns an iterator to the internal data
Definition jkqtpdatastorage.h:2575
void erase(size_t row)
removes the entry row
Definition jkqtpdatastorage.h:2595
bool operator==(const JKQTPColumn &other) const
two columns are equal, if the same memory in the same datastore is referenced
Definition jkqtpdatastorage.h:1508
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:1489
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:2629
iterator end()
returns an iterator to the internal data
Definition jkqtpdatastorage.h:2580
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:1610
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:1601
void subtract(double value)
subtracts a given value from all members of the column
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:1591
size_t imageColumns
number of columns, if interpreted as a row-major image
Definition jkqtpdatastorage.h:1485
size_t getDatastoreOffset() const
offset, if the datastore item contains more than one column
Definition jkqtpdatastorage.h:1644
void decValue(size_t n, double decrement=1.0)
decrement the n'th value from the column
Definition jkqtpdatastorage.h:1581
iterator over the data in the column of a JKQTPDatastore
Definition jkqtpdatastorage.h:1686
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:1930
friend self_type operator-(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:1765
const JKQTPColumn * getColumn() const
returns the referenced column
Definition jkqtpdatastorage.h:1941
self_type operator++()
Definition jkqtpdatastorage.h:1714
self_type operator++(int)
Definition jkqtpdatastorage.h:1709
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:1897
bool operator>=(const self_type &rhs) const
comparison operator (larger than, or equal)
Definition jkqtpdatastorage.h:1888
bool operator!=(const self_type &rhs) const
comparison operator (unequals), inverse result of operator==()
Definition jkqtpdatastorage.h:1895
bool operator==(const self_type &rhs) const
comparison operator (equals)
Definition jkqtpdatastorage.h:1829
int difference_type
Definition jkqtpdatastorage.h:1702
bool operator<(const self_type &rhs) const
comparison operator (less than)
Definition jkqtpdatastorage.h:1847
JKQTPColumnIterator self_type
Definition jkqtpdatastorage.h:1696
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:1913
self_type operator--(int)
Definition jkqtpdatastorage.h:1718
JKQTPColumnIterator(JKQTPColumn *col, int startpos=0)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:1694
self_type operator-=(int dec)
Definition jkqtpdatastorage.h:1746
self_type operator+(difference_type rhs) const
Definition jkqtpdatastorage.h:1772
friend self_type operator+(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:1757
JKQTPColumnIterator(JKQTPColumnIterator &&)=default
reference operator*() const
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:1801
double * pointer
Definition jkqtpdatastorage.h:1700
self_type operator-(difference_type rhs) const
Definition jkqtpdatastorage.h:1782
JKQTPColumn * col_
references the column this iterator iterates over
Definition jkqtpdatastorage.h:1689
QPoint getImagePosition() const
returns the referenced position/row interpreted as an image pixel, returns (-1,-1) for an invalid ope...
Definition jkqtpdatastorage.h:1908
int pos_
current row in col_ this iterator points to
Definition jkqtpdatastorage.h:1691
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:1808
difference_type operator-(self_type rhs) const
Definition jkqtpdatastorage.h:1790
self_type operator+=(int inc)
Definition jkqtpdatastorage.h:1737
bool operator>(const self_type &rhs) const
comparison operator (larger than)
Definition jkqtpdatastorage.h:1874
JKQTPColumn * getColumn()
returns the referenced column
Definition jkqtpdatastorage.h:1939
JKQTPColumnIterator & operator=(JKQTPColumnIterator &&)=default
std::forward_iterator_tag iterator_category
Definition jkqtpdatastorage.h:1701
double & reference
Definition jkqtpdatastorage.h:1698
self_type operator--()
Definition jkqtpdatastorage.h:1728
double value_type
Definition jkqtpdatastorage.h:1697
JKQTPColumnIterator()
constructs an invalid iterator
Definition jkqtpdatastorage.h:1704
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:1924
bool operator<=(const self_type &rhs) const
comparison operator (less than, or equal)
Definition jkqtpdatastorage.h:1861
int getImagePositionY() const
returns the referenced position/row interpreted as an image pixel, y-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:1918
const double & const_reference
Definition jkqtpdatastorage.h:1699
JKQTPColumnIterator & operator=(const JKQTPColumnIterator &)=default
int getPosition() const
returns the referenced position/row, or -1 for an invalid iterator
Definition jkqtpdatastorage.h:1903
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:1360
friend class JKQTPDatastoreItem
Definition jkqtpdatastorage.h:1464
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:2712
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:2638
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:2663
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
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:1150
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:871
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:2700
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:2823
~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:1041
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:2848
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:1357
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:2795
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:1004
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:2831
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:1111
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:1333
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:2817
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:967
ColumnIterator begin()
returns an iterator to the first column in the JKQTPDatastore
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:1196
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:2811
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
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:1352
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 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
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...
std::pair< size_t, size_t > addCopiedPoints(const std::vector< QPoint > &points, const QString &namex=QString(""), const QString &namey=QString(""))
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
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.
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 eraseFromColumn(const JKQTPColumnIterator &pos)
removes the entry pos
Definition jkqtpdatastorage.h:2727
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:2805
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
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:936
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:2800
size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function< double(double, double)> &f, const QString &name=QString(""))
Definition jkqtpdatastorage.h:1349
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:1235
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
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
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.
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
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
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:2675
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:909
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:2302
JKQTPDatastoreItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows, bool storageType)
class constructor: initializes the object for external data storage
bool isVector() const
checks whether dataformat==JKQTPDatastoreItemFormat::SingleColumn and storageType==StorageType::Vecto...
Definition jkqtpdatastorage.h:2351
double get(size_t column, size_t row)
returns the data at the position (column, row ).
Definition jkqtpdatastorage.h:2385
JKQTPDatastoreItemFormat dataformat
memory format of the data in this item
Definition jkqtpdatastorage.h:2319
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:2476
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:2313
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:2459
double * data
a pointer to the actual data
Definition jkqtpdatastorage.h:2311
QVector< double > datavec
iif storageType is StorageType::Vector, the data is actually save here and data contains a pointer to...
Definition jkqtpdatastorage.h:2317
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:2418
JKQTPDatastoreItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows)
class constructor: initializes the object for external data storage
void erase(size_t row, size_t rowEnd)
if isValid() : erase all rows (and including) from row to rowEnd
Definition jkqtpdatastorage.h:2371
StorageType storageType
specifies whether the datastore manages the memory (true ) or whether the user application does this ...
Definition jkqtpdatastorage.h:2321
~JKQTPDatastoreItem()
class destructor: frees unfreed internal memory
size_t getRows() const
number of rows in this item
Definition jkqtpdatastorage.h:2344
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:2508
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:2489
void erase(size_t row)
if isValid() : erase the row row
Definition jkqtpdatastorage.h:2364
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:2495
size_t rows
number of rows in this item
Definition jkqtpdatastorage.h:2315
bool allocated
Specifies whether memory for the data has been allocated. This is only used, when internal==true.
Definition jkqtpdatastorage.h:2323
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:2347
void resize(size_t rows_new)
if isValid() : resize the row to have rows_new rows
Definition jkqtpdatastorage.h:2356
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:2434
StorageType
how data is represented in this JKQTPDatastoreItem
Definition jkqtpdatastorage.h:2305
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:2401
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
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:2447
JKQTPDatastoreItem()
hidden default constructor
QAbstractTableModel descendent that allows to view data in a JKQTPDatastore.
Definition jkqtpdatastorage.h:2527
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
JKQTPDatastore * datastore
Definition jkqtpdatastorage.h:2544
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)
@ MatrixColumn
a 1D C-array of doubles that represents a number of columns. The data is store column after column (=...
@ MatrixRow
a 1D C-array of doubles that represents a number of rows (C standard representation of matrices)....
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89