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;
 
  472        inline double get(
size_t column, 
size_t row) 
const ;
 
  475        inline double get(
int column, 
size_t row) 
const ;
 
  477        inline double get(
int column, 
int row) 
const ;
 
  479        inline double get(
size_t column, 
int row) 
const ;
 
  498        inline void set(
size_t column, 
size_t row, 
double value);
 
  500        inline void set(
int column, 
size_t row, 
double value);
 
  607        void appendToColumns(
size_t column1, 
size_t column2, 
size_t column3, 
double value1, 
double value2, 
double value3);
 
  623        void appendToColumns(
size_t column1, 
size_t column2, 
size_t column3, 
size_t column4, 
double value1, 
double value2, 
double value3, 
double value4);
 
  640        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);
 
  651        template<
class TContainer>
 
  660        template<
class TIterator>
 
  661        inline void appendToColumn(
size_t column, TIterator first, TIterator last);
 
  664        inline double getPixel(
size_t column, 
size_t x, 
size_t y) 
const ;
 
  666        inline void setPixel(
size_t column, 
size_t x, 
size_t y, 
double value)  ;
 
  671        inline void setAll(
size_t column, 
double value);
 
  681        inline void inc(
size_t column, 
size_t row, 
double increment=1);
 
  686        inline void dec(
size_t column, 
size_t row, 
double decrement=1);
 
  696        size_t addColumn(
size_t rows, 
const QString& name=QString(
""));
 
  723        size_t addColumn(
double* data, 
size_t rows, 
const QString& name=QString(
""));
 
  788        size_t addImageColumn(
size_t width, 
size_t height, 
const QString& name=QString(
""));
 
  803        size_t addImageColumn(
double* data, 
size_t width, 
size_t height, 
const QString& name=QString(
""));
 
  838        size_t copyColumn(
size_t old_column, 
size_t start, 
size_t stride, 
const QString& name=QString(
""));
 
  846        size_t copyColumn(
size_t old_column, 
const QString& name=QString(
""));
 
  867        std::pair<size_t,size_t> 
addCopiedPoints(
const QList<QPointF>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  868        std::pair<size_t,size_t> 
addCopiedPoints(
const QList<QPoint>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  869#if QT_VERSION<QT_VERSION_CHECK(6,0,0) 
  870        std::pair<size_t,size_t> 
addCopiedPoints(
const QVector<QPointF>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  871        std::pair<size_t,size_t> 
addCopiedPoints(
const QVector<QPoint>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  873        std::pair<size_t,size_t> 
addCopiedPoints(
const std::vector<QPointF>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  874        std::pair<size_t,size_t> 
addCopiedPoints(
const std::vector<QPoint>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  875        std::pair<size_t,size_t> 
addCopiedPoints(
const std::list<QPointF>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  876        std::pair<size_t,size_t> 
addCopiedPoints(
const std::list<QPoint>& points, 
const QString& namex=QString(
""), 
const QString &namey=QString(
""));
 
  902        template <
typename TIterator>
 
  903        size_t addCopiedColumn(TIterator first, TIterator last, 
const QString& name=QString(
"")) {
 
  904            const size_t N=
static_cast<size_t>(std::abs(std::distance(first,last)));
 
  905            double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(N)*
sizeof(
double)));
 
  908                for (
auto it=first; it!=last; ++it) {
 
 
  940        template <
typename TContainer>
 
  967        template <
typename TContainer>
 
  968        size_t addCopiedColumn(
const TContainer& data, 
const QString& name, 
size_t stride, 
size_t start=0) {
 
  969            const size_t N=
static_cast<size_t>(data.size()-start)/stride;
 
  970            double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(N)*
sizeof(
double)));
 
  973                auto it=data.begin();
 
  974                if (start>0) it+=start;
 
  975                for (; it!=data.end(); it+=stride) {
 
 
 1000            double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(rows)*
sizeof(
double)));
 
 1003                    for (
size_t r=0; r<rows; r++) {
 
 1010                throw std::runtime_error(
"could not allocate memory in JKQTPDataStore::addCopiedColumn()");
 
 
 1035        template<
typename T>
 
 1036        size_t addCopiedColumn(
const T* data, 
size_t rows, 
size_t stride, 
int start, 
const QString& name) {
 
 1037            double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(rows)*
sizeof(
double)));
 
 1040                    for (
size_t r=0; r<rows; r++) {
 
 1041                        d[r]=
jkqtp_todouble(data[
static_cast<size_t>(start+
static_cast<int64_t
>(r*stride))]);
 
 1047                throw std::runtime_error(
"could not allocate memory in JKQTPDataStore::addCopiedColumn()");
 
 
 1072        template<
typename T>
 
 1080        template <
typename T>
 
 1081        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);
 
 1092        template <
typename TContainer>
 
 1093        inline size_t addCopiedImageAsColumn(
const TContainer& data, 
size_t width, 
const QString& name=QString(
""));
 
 1111        template <
typename T>
 
 1112        size_t addCopiedImageAsColumnTranspose(
const T* data, 
size_t width, 
size_t height, 
const QString& name=QString(
""), 
size_t stride=1, 
size_t start=0);
 
 1127        template <
typename T>
 
 1128        inline size_t addCopiedImageAsColumnTranspose(
const QVector<T>& data, 
size_t width, 
const QString& name=QString(
""));
 
 1142        template <
typename T>
 
 1143        size_t addCopiedColumnMasked(
const T* data, 
const bool* mask, 
size_t rows, 
const QString& name=QString(
""), 
bool useIfMaskEquals=
false) {
 
 1144            double* d=
static_cast<double*
>(calloc(rows, 
sizeof(
double)));
 
 1147                for (
size_t r=0; r<rows; r++) {
 
 1148                    if (!mask || (mask && (mask[r]==useIfMaskEquals))) {
 
 
 1181        template <
typename TContainer, 
typename TContainerMask>
 
 1182        size_t addCopiedColumnMasked(
const TContainer& data, 
const TContainerMask& mask, 
const QString& name=QString(
""), 
bool useIfMaskEquals=
false) {
 
 1183            auto itmask=std::begin(mask);
 
 1184            auto itmaskend=std::end(mask);
 
 1185            auto itdata=std::begin(data);
 
 1186            auto itdataend=std::end(data);
 
 1187            const size_t N=std::min<size_t>(std::distance(itmask,itmaskend),std::distance(itdata,itdataend));
 
 1191            for (
size_t r=0; r<N; r++) {
 
 1192                if (
static_cast<bool>(*itmask)==useIfMaskEquals) {
 
 
 1228       template <
typename TIterator>
 
 1229        std::pair<size_t, size_t> 
addCopiedMap(TIterator first, TIterator last, 
const QString& nameKey=QString(
"map_key"), 
const QString& nameValue=QString(
"map_value")) {
 
 1230            const size_t N=
static_cast<size_t>(std::abs(std::distance(first,last)));
 
 1231            QVector<double> xvals(N), yvals(N);
 
 1233            for (
auto it=first; it!=last; ++it) {
 
 1240            return std::pair<size_t, size_t>(cx,cy);
 
 
 1266        template <
typename TContainer>
 
 1267        std::pair<size_t, size_t> 
addCopiedMap(
const TContainer& c, 
const QString& nameKey=QString(
"map_key"), 
const QString& nameValue=QString(
"map_value")) {
 
 1268            return addCopiedMap(c.begin(), c.end(), nameKey, nameValue);
 
 
 1283        size_t addLogColumn(
size_t rows, 
double start, 
double end, 
const QString& name=QString(
""));
 
 1288        size_t addDecadeLogColumn(
size_t rows, 
double startDecade, 
double endDecade, 
const QString& name=QString(
""));
 
 1308        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(
""));
 
 1336        size_t addCalculatedColumn(
size_t rows, 
const std::function<
double(
size_t)>& f, 
const QString& name=QString(
""));
 
 1351        size_t addCalculatedImageColumn(
size_t cols, 
size_t rows, 
const std::function<
double(
size_t,
size_t)>& f, 
const QString& name=QString(
""));
 
 1381        inline size_t addColumnCalculatedFromColumn(
size_t otherColumnX, 
size_t otherColumnY, 
const std::function<
double(
double,
double)>& f, 
const QString& name=QString(
"")) {
 
 
 1384        inline size_t addCalculatedColumnFromColumn(
const std::pair<size_t, size_t>& otherColumn, 
const std::function<
double(
double,
double)>& f, 
const QString& name=QString(
"")) {
 
 
 1426        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;
 
 1444        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;
 
 1452        void saveSYLK(
const QString& filename, 
const QSet<int>& userColumns=QSet<int>(), 
const QString& floatformat=QString(
"%10.10lf")) 
const;
 
 1459        QList<QVector<double> > 
getData(QStringList* columnNames=
nullptr, 
const QSet<int>& userColumns=QSet<int>()) 
const;
 
 1466        QVector<double> 
getData(
size_t column, QString* columnName=
nullptr) 
const;
 
 1474        void saveDIF(
const QString& filename, 
const QSet<int>& userColumns=QSet<int>(), 
const QString& floatformat=QString(
"%10.10lf")) 
const;
 
 1481        void saveMatlab(
const QString& filename, 
const QSet<int>& userColumns=QSet<int>()) 
const;
 
 1487        void saveMatlab(QTextStream& txt, 
const QSet<int>& userColumns=QSet<int>()) 
const;
 
 
 1570    inline double getValue(
size_t n) 
const;
 
 1576    inline double getValue(
int n) 
const;
 
 1584    inline double& 
at(
int n);
 
 1592    inline const double& 
at(
int n) 
const;
 
 1603    inline void setValue(
size_t n, 
double val);
 
 1608    inline void incValue(
size_t n, 
double increment=1.0);
 
 1656    void copy(
const double* data, 
size_t N, 
size_t offset=0);
 
 1674    {   
return this->datastoreItem;   }
 
 
 1677    {   
return this->datastoreOffset;   }
 
 
 1681    inline iterator begin();
 
 1684    inline iterator end();
 
 1688    inline const_iterator begin() 
const;
 
 1691    inline const_iterator end() 
const;
 
 1711      inline void eraseFromVectorColumn(
size_t row);
 
 1715      inline void eraseFromVectorColumn(
size_t row, 
size_t rowEnd);
 
 
 1798            pos_++; 
return *
this;
 
 
 1806                pos_=
static_cast<int>(
col_->getRows())-1;
 
 
 1815                pos_=
static_cast<int>(
col_->getRows())-1;
 
 
 1824                pos_=
static_cast<int>(
col_->getRows())+inc;
 
 
 1833                pos_=
static_cast<int>(
col_->getRows())-dec;
 
 
 1893                return col_->at(
static_cast<int>(
col_->getRows())+off);
 
 
 1983        inline operator bool()
 const { 
return isValid(); }
 
 1991            if (!
isValid()) 
return QPoint(-1,-1);
 
 1992            return QPoint(
pos_ % 
static_cast<int>(
col_->getImageColumns()), 
pos_ / 
static_cast<int>(
col_->getImageColumns()));
 
 
 1997            return pos_ % 
static_cast<int>(
col_->getImageColumns());
 
 
 2002            return pos_ / 
static_cast<int>(
col_->getImageColumns());
 
 
 2008            return col_->getImageColumns();
 
 
 2014            return col_->getRows() / 
col_->getImageColumns();
 
 
 
 2062            ds_->appendToColumn(
col_, val);
 
 
 2067            ds_->appendToColumn(
col_, std::move(val));
 
 
 
 2133            pos_++; 
return *
this;
 
 
 2141                pos_=
static_cast<int>(
col_->getRows())-1;
 
 
 2150                pos_=
static_cast<int>(
col_->getRows())-1;
 
 
 2159                pos_=
static_cast<int>(
col_->getRows())+inc;
 
 
 2168                pos_=
static_cast<int>(
col_->getRows())-dec;
 
 
 2228                return col_->at(
static_cast<int>(
col_->getRows())+off);
 
 
 2325        inline operator bool()
 const { 
return isValid(); }
 
 2333            if (!
isValid()) 
return QPoint(-1,-1);
 
 2334            return QPoint(
pos_ % 
static_cast<int>(
col_->getImageColumns()), 
pos_ / 
static_cast<int>(
col_->getImageColumns()));
 
 
 2339            return pos_ % 
static_cast<int>(
col_->getImageColumns());
 
 
 2344            return pos_ / 
static_cast<int>(
col_->getImageColumns());
 
 
 2350            return col_->getImageColumns();
 
 
 2356            return col_->getRows() / 
col_->getImageColumns();
 
 
 
 2447        datavec.resize(
static_cast<int>(rows_new));
 
 
 2494    inline double get(
size_t column, 
size_t row) {
 
 
 2510    inline double& 
at(
size_t column, 
size_t row) {
 
 2511        if (
data!=
nullptr) {
 
 2521        throw std::out_of_range(
"index does not exist in JKQTPDatastoreItem");
 
 
 2527    inline const double& 
at(
size_t column, 
size_t row)
 const {
 
 2528        if (
data!=
nullptr) {
 
 2538        throw std::out_of_range(
"index does not exist in JKQTPDatastoreItem");
 
 
 2546              return &(
data[row]);
 
 
 2556    inline const double* 
getPointer(
size_t column, 
size_t row)
 const {
 
 2559              return &(
data[row]);
 
 
 2568    inline void set(
size_t column, 
size_t row, 
double value) {
 
 
 2612    inline bool append(
size_t column, 
double value) {
 
 
 2625    inline bool append(
size_t column, 
const QVector<double>& values) {
 
 2628            for (
const double& d: values) 
datavec.push_back(d);
 
 
 2645    inline bool append(
size_t column, 
const std::vector<double>& values) {
 
 2647            datavec.reserve(
static_cast<int>(
datavec.size())+
static_cast<int>(values.size()));
 
 2648            for (
const double& d: values) 
datavec.push_back(d);
 
 
 
 2671        virtual QVariant 
data(
const QModelIndex &index, 
int role) 
const override;
 
 2672        virtual Qt::ItemFlags 
flags(
const QModelIndex &index) 
const override;
 
 2673        virtual QVariant 
headerData(
int section, Qt::Orientation orientation, 
int role = Qt::DisplayRole) 
const override;
 
 2674        virtual int rowCount(
const QModelIndex &parent = QModelIndex()) 
const override;
 
 2675        virtual int columnCount(
const QModelIndex &parent = QModelIndex()) 
const  override;
 
 
 2776    return columns.value(column).getRows();
 
 
 2782    if (column<0) 
return nullptr;
 
 2783    return columns.value(
static_cast<size_t>(column)).getPointer(row);
 
 
 2789    if (column<0) 
return nullptr;
 
 2790    return columns[
static_cast<size_t>(column)].getPointer(row);
 
 
 2795    if (column<0) 
return 0;
 
 2796    return columns.value(
static_cast<size_t>(column)).getRows();
 
 
 2802    return columns.value(column).getPointer(row);
 
 
 2808    return columns[column].getPointer(row);
 
 
 2813    return columns[column].getValue(row);
 
 
 2819    return get(
static_cast<size_t>(column), 
static_cast<size_t>(row));
 
 
 2826    return get(
static_cast<size_t>(column), 
static_cast<size_t>(row));
 
 
 2833    return get(
static_cast<size_t>(column), 
static_cast<size_t>(row));
 
 
 2838    columns[column].setValue(row, value);
 
 
 2843    set(
static_cast<size_t>(column), 
static_cast<size_t>(row), value);
 
 
 2848template<
class TContainer>
 
 2855template<
class TIterator>
 
 2858    for(
auto it=first; it!=last; it++) {
 
 
 2866    return columns.value(column).getPixelValue(x, y);
 
 
 2871    return columns[column].setPixelValue(x, y, value);
 
 
 2877    columns[column].setAll(value);
 
 
 2883    columns[column].scale(factor);
 
 
 2889    columns[column].incValue(row, increment);
 
 
 2895    columns[column].decValue(row, decrement);
 
 
 2900template <
typename T>
 
 2903    columns[col].setImageColumns(width);
 
 
 2908template <
typename TContainer>
 
 2911    columns[col].setImageColumns(width);
 
 
 2917template <
typename T>
 
 2919    double* temp=
static_cast<double*
>(malloc(width*height*
sizeof(
double)));
 
 2921    for (
size_t x=0; x<width; x++) {
 
 2922        for (
size_t y=0; y<height; y++) {
 
 2928    columns[idx].setImageColumns(width);
 
 
 2934template <
typename T>
 
iterator, which allows to insert into a column of a JKQTPDatastore
Definition jkqtpdatastorage.h:2037
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:2045
JKQTPColumnBackInserter & operator=(double &&val)
Definition jkqtpdatastorage.h:2065
double * pointer
Definition jkqtpdatastorage.h:2051
int difference_type
Definition jkqtpdatastorage.h:2053
JKQTPColumnBackInserter & operator=(const JKQTPColumnBackInserter &)=default
double value_type
Definition jkqtpdatastorage.h:2048
const double & const_reference
Definition jkqtpdatastorage.h:2050
std::output_iterator_tag iterator_category
Definition jkqtpdatastorage.h:2052
JKQTPDatastore * ds_
references the datastore to access
Definition jkqtpdatastorage.h:2040
self_type operator++()
Definition jkqtpdatastorage.h:2071
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:2075
JKQTPColumnBackInserter(const JKQTPColumnBackInserter &)=default
JKQTPColumnBackInserter(JKQTPColumnBackInserter &&)=default
double & reference
Definition jkqtpdatastorage.h:2049
size_t col_
references the column to access
Definition jkqtpdatastorage.h:2042
JKQTPColumnBackInserter self_type
Definition jkqtpdatastorage.h:2047
JKQTPColumnBackInserter & operator=(const double &val)
Definition jkqtpdatastorage.h:2060
self_type operator*()
Definition jkqtpdatastorage.h:2072
JKQTPColumnBackInserter()
constructs an invalid iterator
Definition jkqtpdatastorage.h:2055
self_type operator++(int)
Definition jkqtpdatastorage.h:2070
iterator over the data in the column of a JKQTPDatastore
Definition jkqtpdatastorage.h:2083
difference_type operator-(self_type rhs) const
Definition jkqtpdatastorage.h:2207
const_reference operator*() const
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:2236
JKQTPColumnConstIterator & operator=(nonconst_variant_type &&rhs)
Definition jkqtpdatastorage.h:2119
reference operator*()
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:2218
JKQTPColumnConstIterator(const JKQTPColumnConstIterator &)=default
friend self_type operator-(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:2182
bool operator<(const self_type &rhs) const
comparison operator (less than)
Definition jkqtpdatastorage.h:2252
bool operator>=(const self_type &rhs) const
comparison operator (larger than, or equal)
Definition jkqtpdatastorage.h:2293
const double & reference
Definition jkqtpdatastorage.h:2096
bool operator>(const self_type &rhs) const
comparison operator (larger than)
Definition jkqtpdatastorage.h:2279
JKQTPColumnConstIterator & operator=(const JKQTPColumnConstIterator &)=default
JKQTPColumnIterator nonconst_variant_type
Definition jkqtpdatastorage.h:2094
bool operator<=(const self_type &rhs) const
comparison operator (less than, or equal)
Definition jkqtpdatastorage.h:2266
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:2321
self_type operator+=(int inc)
Definition jkqtpdatastorage.h:2154
JKQTPColumnConstIterator(const nonconst_variant_type &rhs)
Definition jkqtpdatastorage.h:2105
self_type operator++(int)
Definition jkqtpdatastorage.h:2126
friend self_type operator+(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:2174
self_type operator++()
Definition jkqtpdatastorage.h:2131
bool operator!=(const self_type &rhs) const
comparison operator (unequals), inverse result of operator==()
Definition jkqtpdatastorage.h:2318
self_type operator+(difference_type rhs) const
Definition jkqtpdatastorage.h:2189
friend class JKQTPColumn
Definition jkqtpdatastorage.h:2359
const double * pointer
Definition jkqtpdatastorage.h:2098
self_type operator-(difference_type rhs) const
Definition jkqtpdatastorage.h:2199
JKQTPColumnConstIterator & operator=(JKQTPColumnConstIterator &&)=default
double value_type
Definition jkqtpdatastorage.h:2095
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:2360
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:2348
int getImagePositionY() const
returns the referenced position/row interpreted as an image pixel, y-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2342
int difference_type
Definition jkqtpdatastorage.h:2100
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:2337
JKQTPColumnConstIterator(nonconst_variant_type &&rhs)
Definition jkqtpdatastorage.h:2106
QPoint getImagePosition() const
returns the referenced position/row interpreted as an image pixel, returns (-1,-1) for an invalid ope...
Definition jkqtpdatastorage.h:2332
int pos_
current row in col_ this iterator points to
Definition jkqtpdatastorage.h:2088
self_type operator--(int)
Definition jkqtpdatastorage.h:2135
self_type operator-=(int dec)
Definition jkqtpdatastorage.h:2163
bool operator==(const self_type &rhs) const
comparison operator (equals)
Definition jkqtpdatastorage.h:2306
reference const_reference
Definition jkqtpdatastorage.h:2097
int getPosition() const
returns the referenced position/row, or -1 for an invalid iterator
Definition jkqtpdatastorage.h:2327
JKQTPColumnConstIterator & operator=(const nonconst_variant_type &rhs)
Definition jkqtpdatastorage.h:2114
const JKQTPColumn * col_
references the column this iterator iterates over
Definition jkqtpdatastorage.h:2086
JKQTPColumnConstIterator(const JKQTPColumn *col, int startpos=0)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:2091
std::forward_iterator_tag iterator_category
Definition jkqtpdatastorage.h:2099
const JKQTPColumn * getColumn() const
returns the referenced column
Definition jkqtpdatastorage.h:2364
self_type operator--()
Definition jkqtpdatastorage.h:2145
reference operator[](difference_type off) const
Definition jkqtpdatastorage.h:2224
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:2354
JKQTPColumnConstIterator()
constructs an invalid iterator
Definition jkqtpdatastorage.h:2102
JKQTPColumnConstIterator self_type
Definition jkqtpdatastorage.h:2093
internally stores information about one data column. See JKQTPDatastore for more information.
Definition jkqtpdatastorage.h:1510
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:1515
JKQTPDatastore * datastore
pointer to the datastore object used to manage the data of the plot
Definition jkqtpdatastorage.h:1519
JKQTPColumnConstIterator const_iterator
Definition jkqtpdatastorage.h:1526
void eraseFromVectorColumn(size_t row)
removes the entry row
Definition jkqtpdatastorage.h:2732
size_t getRows() const
returns the number of rows in this column (accesses the datastore)
bool isValid() const
Definition jkqtpdatastorage.h:1537
friend class JKQTPColumnConstIterator
Definition jkqtpdatastorage.h:1696
size_t getDatastoreItemNum() const
index of the item in the datastore that contains the data for this column
Definition jkqtpdatastorage.h:1673
size_t getImageColumns() const
number of columns, if interpreted as a row-major image
Definition jkqtpdatastorage.h:1555
quint16 calculateChecksum() const
calculates a checksum over the contents of the column (using qChecksum())
Definition jkqtpdatastorage.h:2704
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:1703
void setValue(size_t n, double val)
sets the n'th value from the column
Definition jkqtpdatastorage.h:2690
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:1513
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:1649
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:2743
friend class JKQTPColumnIterator
Definition jkqtpdatastorage.h:1695
const JKQTPDatastore * getDatastore() const
Definition jkqtpdatastorage.h:1700
JKQTPDatastoreItem * getDatastoreItem()
returns a pointer to the datastore item representing this column
Definition jkqtpdatastorage.h:1647
JKQTPDatastore * getDatastore()
Definition jkqtpdatastorage.h:1699
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:1525
void setImageColumns(size_t imageWidth)
number of columns, if interpreted as a row-major image
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:1694
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:2697
bool valid
is this item valid?/usable?
Definition jkqtpdatastorage.h:1523
iterator begin()
returns an iterator to the internal data
Definition jkqtpdatastorage.h:2712
bool operator==(const JKQTPColumn &other) const
two columns are equal, if the same memory in the same datastore is referenced
Definition jkqtpdatastorage.h:1540
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:1521
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:2766
iterator end()
returns an iterator to the internal data
Definition jkqtpdatastorage.h:2717
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:1642
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:1633
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:1623
size_t imageColumns
number of columns, if interpreted as a row-major image
Definition jkqtpdatastorage.h:1517
size_t getDatastoreOffset() const
offset, if the datastore item contains more than one column
Definition jkqtpdatastorage.h:1676
void decValue(size_t n, double decrement=1.0)
decrement the n'th value from the column
Definition jkqtpdatastorage.h:1613
iterator over the data in the column of a JKQTPDatastore
Definition jkqtpdatastorage.h:1767
friend class JKQTPColumnConstIterator
Definition jkqtpdatastorage.h:2017
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:2012
friend self_type operator-(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:1847
const JKQTPColumn * getColumn() const
returns the referenced column
Definition jkqtpdatastorage.h:2024
self_type operator++()
Definition jkqtpdatastorage.h:1796
self_type operator++(int)
Definition jkqtpdatastorage.h:1791
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:1979
bool operator>=(const self_type &rhs) const
comparison operator (larger than, or equal)
Definition jkqtpdatastorage.h:1970
bool operator!=(const self_type &rhs) const
comparison operator (unequals), inverse result of operator==()
Definition jkqtpdatastorage.h:1977
bool operator==(const self_type &rhs) const
comparison operator (equals)
Definition jkqtpdatastorage.h:1911
int difference_type
Definition jkqtpdatastorage.h:1784
bool operator<(const self_type &rhs) const
comparison operator (less than)
Definition jkqtpdatastorage.h:1929
JKQTPColumnIterator self_type
Definition jkqtpdatastorage.h:1777
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:1995
self_type operator--(int)
Definition jkqtpdatastorage.h:1800
JKQTPColumnIterator(JKQTPColumn *col, int startpos=0)
constructs an iterator for the data represented by col, starting with row startpos
Definition jkqtpdatastorage.h:1775
self_type operator-=(int dec)
Definition jkqtpdatastorage.h:1828
self_type operator+(difference_type rhs) const
Definition jkqtpdatastorage.h:1854
friend self_type operator+(difference_type off, const self_type &right)
Definition jkqtpdatastorage.h:1839
JKQTPColumnIterator(JKQTPColumnIterator &&)=default
friend class JKQTPColumn
Definition jkqtpdatastorage.h:2018
reference operator*() const
dereferences the iterator, throws an exception if the iterator is invalid (see isValid() ) or the val...
Definition jkqtpdatastorage.h:1883
double * pointer
Definition jkqtpdatastorage.h:1782
JKQTPColumnConstIterator const_variant_type
Definition jkqtpdatastorage.h:1778
friend class JKQTPDatastore
Definition jkqtpdatastorage.h:2019
self_type operator-(difference_type rhs) const
Definition jkqtpdatastorage.h:1864
JKQTPColumn * col_
references the column this iterator iterates over
Definition jkqtpdatastorage.h:1770
QPoint getImagePosition() const
returns the referenced position/row interpreted as an image pixel, returns (-1,-1) for an invalid ope...
Definition jkqtpdatastorage.h:1990
int pos_
current row in col_ this iterator points to
Definition jkqtpdatastorage.h:1772
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:1890
difference_type operator-(self_type rhs) const
Definition jkqtpdatastorage.h:1872
self_type operator+=(int inc)
Definition jkqtpdatastorage.h:1819
bool operator>(const self_type &rhs) const
comparison operator (larger than)
Definition jkqtpdatastorage.h:1956
JKQTPColumn * getColumn()
returns the referenced column
Definition jkqtpdatastorage.h:2022
JKQTPColumnIterator & operator=(JKQTPColumnIterator &&)=default
std::forward_iterator_tag iterator_category
Definition jkqtpdatastorage.h:1783
double & reference
Definition jkqtpdatastorage.h:1780
self_type operator--()
Definition jkqtpdatastorage.h:1810
double value_type
Definition jkqtpdatastorage.h:1779
JKQTPColumnIterator()
constructs an invalid iterator
Definition jkqtpdatastorage.h:1786
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:2006
bool operator<=(const self_type &rhs) const
comparison operator (less than, or equal)
Definition jkqtpdatastorage.h:1943
int getImagePositionY() const
returns the referenced position/row interpreted as an image pixel, y-component, returns -1 for an inv...
Definition jkqtpdatastorage.h:2000
const double & const_reference
Definition jkqtpdatastorage.h:1781
JKQTPColumnIterator & operator=(const JKQTPColumnIterator &)=default
int getPosition() const
returns the referenced position/row, or -1 for an invalid iterator
Definition jkqtpdatastorage.h:1985
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:1392
friend class JKQTPDatastoreItem
Definition jkqtpdatastorage.h:1496
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:2849
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:2775
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:2800
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
friend class JKQTPDatastoreModel
Definition jkqtpdatastorage.h:1497
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:1182
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:903
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:2837
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:2893
~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:1073
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:2918
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:1389
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:2865
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:1036
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 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:2901
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:1143
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:1365
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:2887
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:777
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:766
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:999
ColumnIterator begin()
returns an iterator to the first column in the JKQTPDatastore
Definition jkqtpdatastorage.h:363
friend class JKQTPColumn
Definition jkqtpdatastorage.h:1495
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:1229
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:2881
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:1384
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.
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:2875
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:968
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:2870
size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function< double(double, double)> &f, const QString &name=QString(""))
Definition jkqtpdatastorage.h:1381
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:1267
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
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
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:2812
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:941
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:2388
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:2440
double get(size_t column, size_t row)
returns the data at the position (column, row ).
Definition jkqtpdatastorage.h:2494
JKQTPDatastoreItemFormat dataformat
memory format of the data in this item
Definition jkqtpdatastorage.h:2405
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:2592
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:2399
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:2568
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:2397
QVector< double > datavec
iif storageType is StorageType::Vector, the data is actually save here and data contains a pointer to...
Definition jkqtpdatastorage.h:2403
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:2527
JKQTPDatastoreItem(JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows)
class constructor: initializes the object for external data storage
void eraseFromVectorItem(size_t row, size_t rowEnd)
if isValid() : eraseFromVectorItem all rows (and including) from row to rowEnd
Definition jkqtpdatastorage.h:2471
StorageType storageType
specifies whether the datastore manages the memory (true ) or whether the user application does this ...
Definition jkqtpdatastorage.h:2407
~JKQTPDatastoreItem()
class destructor: frees unfreed internal memory
size_t getRows() const
number of rows in this item
Definition jkqtpdatastorage.h:2432
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:2645
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:2612
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:2625
size_t rows
number of rows in this item
Definition jkqtpdatastorage.h:2401
bool allocated
Specifies whether memory for the data has been allocated. This is only used, when internal==true.
Definition jkqtpdatastorage.h:2409
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:2436
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:2543
StorageType
how data is represented in this JKQTPDatastoreItem
Definition jkqtpdatastorage.h:2391
@ Vector
data is stored in the internal QVector<double> datavec
Definition jkqtpdatastorage.h:2394
@ Internal
data is stored in an internally managed (=owned, i.e. freed in the destructor) C-array
Definition jkqtpdatastorage.h:2392
@ External
data is stored in an externally managed (=not owned) C-array
Definition jkqtpdatastorage.h:2393
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:2510
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
void resizeVectorItem(size_t rows_new)
if isValid() : resizeVectorItem the row to have rows_new rows
Definition jkqtpdatastorage.h:2445
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:2556
void reserveVectorColumn(size_t rows)
reserves memory for the vector holding the data in this column
Definition jkqtpdatastorage.h:2487
JKQTPDatastoreItem()
hidden default constructor
void eraseFromVectorItem(size_t row)
if isValid() : eraseFromVectorItem the row row
Definition jkqtpdatastorage.h:2458
QAbstractTableModel descendent that allows to view data in a JKQTPDatastore.
Definition jkqtpdatastorage.h:2664
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
JKQTPDatastore * datastore
Definition jkqtpdatastorage.h:2681
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