JKQTPlotter
an extensive Qt4/Qt5 Plotter framework (including a fast variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies

This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter to represent data for plots. More...

#include <jkqtpdatastorage.h>

Collaboration diagram for JKQTPDatastore:

Public Member Functions

 JKQTPDatastore ()
 class constructor, generates an empty datastore More...
 
 ~JKQTPDatastore ()
 class destructor, destroys all subordered JKQTPDatastoreItem objects More...
 
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 More...
 
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 More...
 
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 calling f for each entry More...
 
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 memory management. More...
 
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. Data is not owned by the JKQTPDatastore! More...
 
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 internal memory management. More...
 
size_t addColumnCalculatedFromColumn (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 , that are calculated by calling f for each entry in otherColumn More...
 
size_t addColumnCalculatedFromColumn (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 , that are calculated by calling f for each pair of entries in otherColumnX and otherColumnY More...
 
template<typename T >
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 internal array, so afterwards you can delete the external arrayThis returns its logical column ID. More...
 
template<typename T >
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 internal array, so afterwards you can delete the external arrayThis returns its logical column ID. More...
 
template<typename T >
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 internal array, so afterwards you can delete the external arrayThis returns its logical column ID. More...
 
template<typename TContainer >
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. More...
 
template<typename TContainer >
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. More...
 
template<typename TIterator >
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 More...
 
template<typename T >
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 internal array, so afterwards you can delete the external arrayThis returns its logical column ID. More...
 
template<typename TContainer , typename TContainerMask >
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. More...
 
template<typename T >
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 assumed to be organized as a row-major image and is copied as such. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID. More...
 
template<typename TContainer >
size_t addCopiedImageAsColumn (const TContainer &data, size_t width, const QString &name=QString(""))
 add one external column to the datastore. It contains width * height rows. The external data is assumed to be organized as a row-major image and is copied as such. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID. More...
 
template<typename T >
size_t addCopiedImageAsColumnTranspose (const QVector< T > &data, size_t width, const QString &name=QString(""))
 add one external column to the datastore. It contains width * height rows. More...
 
template<typename T >
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 the given width and height. More...
 
template<typename TContainer >
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, returns the two IDs of the items as a std::pair More...
 
template<typename TIterator >
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, returns the two IDs of the items as a std::pair More...
 
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^start and ending at 10^end. the values are logarithmically spaced between 10^start end 10^end More...
 
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 column ID. Data is not owned by the JKQTPDatastore! The column is meant to represent an image in row-major order with x-dimention width and y-dimension height . More...
 
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. The new item uses internal memory management. The column is meant to represent an image in row-major order with x-dimention width and y-dimension height . More...
 
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 to the datastore More...
 
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 transfered to the datastore The column is meant to represent an image in row-major order with x-dimention width and y-dimension height . More...
 
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 start and ending at end. the values are equidistant between start end end More...
 
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 width points in x- and height points in y-direction. More...
 
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 start and ending at end. the values are logarithmically spaced between start end end More...
 
template<class TContainer >
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 rows). If the memory was externally managed before, it will be internally managed afterwards More...
 
void appendToColumn (size_t column, double value)
 adds a value value to the column column. This changes the column length (number of rows). More...
 
template<class TIterator >
void appendToColumn (size_t column, TIterator first, TIterator last)
 adds a values from a range first ... last (defined by C++ iterators) to the column column. This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
JKQTPColumnBackInserter backInserter (int i)
 returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore More...
 
JKQTPColumnBackInserter backInserter (size_t i)
 returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore More...
 
JKQTPColumnIterator begin (int i)
 returns an iterator to the first data entry in the i -th column in the JKQTPDatastore More...
 
JKQTPColumnConstIterator begin (int i) const
 returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore More...
 
JKQTPColumnIterator begin (size_t i)
 returns an iterator to the first data entry in the i -th column in the JKQTPDatastore More...
 
JKQTPColumnConstIterator begin (size_t i) const
 returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore More...
 
void clear ()
 deletes all items from the datastore and possibly frees the memory they manage More...
 
size_t copyColumn (size_t old_column, const QString &name=QString(""))
 copies the given old_column into a new one More...
 
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 More...
 
void dec (size_t column, size_t row, double decrement=1)
 decrements entry in row row of column column by decrement More...
 
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 column and removeItems is true, the item will be removed More...
 
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 datastore item of the column and removeItems is true, the item will be removed More...
 
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 removeItems is true, the item will be removed More...
 
JKQTPColumnIterator end (int i)
 returns an iterator behind the last data entry data in the i -th column in the JKQTPDatastore More...
 
JKQTPColumnConstIterator end (int i) const
 returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore More...
 
JKQTPColumnIterator end (size_t i)
 returns an iterator behind the last data entry data in the i -th column in the JKQTPDatastore More...
 
JKQTPColumnConstIterator end (size_t i) const
 returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore More...
 
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 with no rows and returns its num More...
 
void eraseFromColumn (const JKQTPColumnConstIterator &pos)
 removes the entry pos More...
 
void eraseFromColumn (const JKQTPColumnConstIterator &pos, const JKQTPColumnConstIterator &posEnd)
 removes the entries pos to posEnd More...
 
void eraseFromColumn (const JKQTPColumnIterator &pos)
 removes the entry pos More...
 
void eraseFromColumn (const JKQTPColumnIterator &pos, const JKQTPColumnIterator &posEnd)
 removes the entries pos to posEnd More...
 
double get (int column, int row) const
 returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)
More...
 
double get (int column, size_t row) const
 returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)
More...
 
double get (size_t column, int row) const
 returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)
More...
 
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 according memory block internally!)
More...
 
quint16 getColumnChecksum (int column) const
 returns the data checksum of the given column More...
 
size_t getColumnCount () const
 returns the number of (logical) columns currently managed by the datastore More...
 
QList< size_t > getColumnIDs () const
 returns a list with all available column IDs More...
 
QVector< int > getColumnIDsIntVec () const
 returns a list with all available column IDs More...
 
size_t getColumnImageHeight (int column) const
 returns the height of the image, represented by column (in row-major ordering) More...
 
size_t getColumnImageWidth (int column) const
 returns the width of the image, represented by column (in row-major ordering). Internally this returns the imageColumns or image width, if set in the column More...
 
QString getColumnName (size_t column)
 return the title of the first column with the given name, or -1 if none was found More...
 
QStringList getColumnNames () const
 return a list with all columns available in the datastore More...
 
int getColumnNum (const QString &name)
 return the num of the first column with the given name, or -1 if none was found More...
 
double * getColumnPointer (int column, size_t row=0)
 returns a pointer to the data in column column, starting ar row row More...
 
const double * getColumnPointer (int column, size_t row=0) const
 returns a pointer to the data in column column, starting ar row row More...
 
double * getColumnPointer (size_t column, size_t row=0)
 returns a pointer to the data in column column, starting ar row row More...
 
const double * getColumnPointer (size_t column, size_t row=0) const
 returns a pointer to the data in column column, starting ar row row More...
 
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 More...
 
QVector< double > getData (size_t column, QString *columnName=nullptr) const
 return contents of a given column as QVector<double> More...
 
size_t getMaxRows () const
 returns the maximum number of rows in all columns More...
 
int getNextHigherIndex (int column, size_t row) const
 gets the index of the datapoint with the nearest, but higher value in the column More...
 
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 inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column) More...
 
int getNextHigherIndex (size_t column, size_t row) const
 gets the index of the datapoint with the nearest, but higher value in the column More...
 
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 inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column) More...
 
int getNextLowerIndex (int column, size_t row) const
 gets the index of the datapoint with the nearest, but lower value in the column More...
 
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 row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column) More...
 
int getNextLowerIndex (size_t column, size_t row) const
 gets the index of the datapoint with the nearest, but lower value in the column More...
 
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 row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column) More...
 
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 imageWidth stored in that column
More...
 
size_t getRows (int column) const
 returns the number of rows in the column column More...
 
size_t getRows (size_t column) const
 returns the number of rows in the column column More...
 
bool hasColumn (size_t i) const
 determines whether a column with the given ID exists More...
 
void inc (size_t column, size_t row, double increment=1)
 increases entry in row row of column column by increment More...
 
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 More...
 
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 More...
 
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) More...
 
void saveMatlab (const QString &filename, const QSet< int > &userColumns=QSet< int >()) const
 save contents of datastore as a Matlab script More...
 
void saveMatlab (QTextStream &txt, const QSet< int > &userColumns=QSet< int >()) const
 save contents of datastore as a Matlab script More...
 
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) More...
 
void scaleColumnValues (size_t column, double factor)
 scales (multiplies) all entries in column column by factor More...
 
void set (int column, size_t row, double value)
 sets the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!) More...
 
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 according memory block internally!) More...
 
void setAll (size_t column, double value)
 sets all entries in column column to value More...
 
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 imageWidth stored in that column
More...
 

Protected Types

typedef QMap< size_t, JKQTPColumn >::iterator ColumnIterator
 mutable iterator for columns in the JKQTPDatastore (ColumnIterator::first: column number, ColumnIterator::second: column data) More...
 
typedef QMap< size_t, JKQTPColumn >::const_iterator ConstColumnIterator
 constant iterator for columns in the JKQTPDatastore (ColumnIterator::first: column number, ColumnIterator::second: column data) More...
 

Protected Member Functions

size_t addColumn (JKQTPColumn col)
 add a new column to the datastore and return its ID More...
 
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. More...
 
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 managed internally This function retuns an item ID (which can be used with getItem() ), not a column ID! More...
 
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. The data is copied and the copy managed internally This function retuns an item ID (which can be used with getItem() ), not a column ID! More...
 
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 (which can be used with getItem() ), not a column ID! More...
 
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 (which can be used with getItem() ), not a column ID! More...
 
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 with getItem() ), not a column ID! More...
 
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. dataformat determined the memory layout. This function retuns an item ID (which can be used with getItem() ), not a column ID! More...
 
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. The item uses internal memory management. This function retuns an item ID (which can be used with getItem() ), not a column ID! More...
 
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 memory management. This function retuns an item ID (which can be used with getItem() ), not a column ID! More...
 
ColumnIterator begin ()
 returns an iterator to the first column in the JKQTPDatastore More...
 
ConstColumnIterator begin () const
 returns a const iterator to the first column in the JKQTPDatastore More...
 
ColumnIterator end ()
 returns an iterator behind the last column in the JKQTPDatastore More...
 
ConstColumnIterator end () const
 returns a const iterator behind the last column in the JKQTPDatastore More...
 
JKQTPColumn getColumn (int i) const
 returns the JKQTPColumn object for the i -th column in the store More...
 
JKQTPColumn getColumn (size_t i) const
 returns the JKQTPColumn object for the i -th column in the store More...
 
JKQTPDatastoreItemgetItem (size_t i)
 returns the JKQTPDatastoreItem object for the i -th item in the store More...
 
const JKQTPDatastoreItemgetItem (size_t i) const
 returns the JKQTPDatastoreItem object for the i -th item in the store More...
 

Private Attributes

QMap< size_t, JKQTPColumncolumns
 a std::vector of all columns that may be used to access the managed chunks of memory. More...
 
QMap< size_t, JKQTPDatastoreItem * > items
 a std::vector that contains all items managed by this datastore More...
 
std::unique_ptr< JKQTPColumnm_invalidColumn
 an internal invalid column object, used e.g. to return invalid column iterators More...
 
size_t maxColumnsID
 internal variable to keep track about the highest column ID (in columns) used so far More...
 
size_t maxItemID
 internal variable to keep track about the highest item ID (in items) used so far More...
 

Friends

class JKQTPColumn
 
class JKQTPDatastoreItem
 
class JKQTPDatastoreModel
 

Detailed Description

This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter to represent data for plots.

See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore for a detailed description of how to use this class for data management!

Column Management

Column Generation/Deletion

A JKQTPDatastore manages a set of data columns. Each column is a continuous vector of numbers. Optionally it can be interpreted as a 2D image. In the latter case, the data is assumed to be ordered in row-major ordering (i.e. row for row).

You can generate new columns e.g. by:

  • addColumn() which either generates internally managed (and extensible) columns, or accepts a simple double* pointer to external. In the latter case owner-ship may be transferred to the datastore, but can also retain externally.
  • addImageColumn() adds a column that should be interpreted as an image with given width and height (i.e. a row-major matrix with width columns and height rows.
  • copyColumn() duplicates an existing column
  • addCopiedColumn() copies an external dataset into the datastore. e.g. with code like:
    QVector<double> X, Y;
    const int Ndata=100;
    for (int i=0; i<Ndata; i++) {
    * const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
    X<<x;
    Y<<sin(x);
    }
    plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
    // by calling JKQTPDatastore::addCopiedColumn() the data is COPIED from the vector into the datastore
    linegraph->setXColumn(datastore->addCopiedColumn(X, "x"));
    linegraph->setYColumn(datastore->addCopiedColumn(Y, "y"));

addLinearColumn() adds a column with linearly increasing numbers (in a given range)

Of course columns can also be deleted by calling:

Column Properties

The properties of columns may be accessed using:

Modify Column Contents

You can modify all data in a column by functions like:

Also you can access a single entry from a column, using:

  • set() / get() set/read a column entry
  • inc() / dec() increment/decrement a column entry
  • appendToColumn() (adds a single row/new value to a column, if the column was not internally managed before, it will be copied into a new internal memory segment by the first call to this function!)
  • appendToColumns() (adds several values to several columns simultaneously, i.e. a shortcut to prevents writing several consecutive appendToColumn() for each column separately)
  • appendFromContainerToColumn() (adds several rows from a container to a column, if the column was not internally managed before, it will be copied into a new internal memory segment by the first call to this function!)

Iterator Interface

In addition to teh fucntions above, JKQTPDatastore also provides C++-style iteratos to read the data from a column:

... and also a std::back_inserter -style interface to append data to columns:

These allow to use the C++ standard algorithms to work with columns and also enabled the library Statistical Computations in this software package. You can use the functions above e.g. for code like:

auto inserter it=datastore->backInserter(datastore->addColumn("new column"));
for (auto it=datastore->begin(col1); it!=datastore->begin(col1) ++it) {
*++inserter=sqrt(*it);
}

or simply

// mean of a column in a JKQTPDatastore:
double mean=jkqtpstatAverage(datastore1->begin(col1), datastore1->end(col1));

Also there are functions to add data from iterator-defined ranges, e.g.:

See also
Tutorial (JKQTPDatastore): Iterator-Based usage of JKQTPDatastore

Image Column

JKQTPDatastore stores the width and height of the represented image as metadata with any image column. This metadata is used to provide convenience access to the image pixels with:

The image width/height are read using:

This allows to write code like:

for (int iy=0; iy<10; iy++) {
for (int ix=0; ix<10; ix++) {
datastore->setPixel(imgColumn, ix, iy, sin(ix*iy/30.0));
}
}

Data Output

JKQTPDatastore provides several functions that allow to store its contents into files:

... and function to read data into different data structures:

Internal Working

This class manages a list if JKQTPDatastoreItem onjects that may each contain a chunk of memory, containig one or more columns of data. Each item can be accessed with get() by a specific ID which is returned by add(). JKQTPColumn. You may only clear all chunks of memory/items. If you no longer need some of the data, but still want to access the rest you will simply have to destroy all JKQTPColumn that point to the item with their JKQTPColumns:datastoreItem property.

+- JKQTPDatastore ---------------------+               std::vector<JKQTPColumn>:
|                                      |                   +- JKQTPColumn ----------------+
|    +- JKQTPDatastoreItem --------+   |                 0 |   datastore                  |
|  0 |     JKQTPSingleColumn       |<--|-------------------|---datastoreItem = 0          |
|    |   0 # # # # # # # # # # #<--|---|-------------------|---datastoreOffset = 0        |
|    |                             |   |                   |                              |
|    +- JKQTPDatastoreItem --------+   |                   +- JKQTPColumn ----------------+
|  1 |     JKQTPSingleColumn       |<--|---\             1 |   datastore                  |
|    |   0 # # # # # # # # # # #<--|---|-\  \--------------|---datastoreItem = 1          |
|    |                             |   |  \----------------|---datastoreOffset = 0        |
|    +- JKQTPDatastoreItem --------+   |                   |                              |
|    :                             :   |                   +------------------------------+
|    :                             :   |                   :                              :
|    :                             :   |                   :                              :
|    +- JKQTPDatastoreItem --------+   |                   :                              :
|N-1 |     JKQTPMatrixRow          |<--|---\               :                              :
|    |   0 # # # # # # # # # # #   |   |    \              +- JKQTPColumn ----------------+
|    |   1 # # # # # # # # # # #   |   |     \         M-1 |   datastore                  |
|    |   2 # # # # # # # # # # #<--|---|--\   \------------|---datastoreItem = N-1        |
|    |                             |   |   \---------------|---datastoreOffset = 2        |
|    +-----------------------------+   |                   |                              |
|                                      |                   +------------------------------+
+--------------------------------------+
In addition the JKQTPDatastore manages a std::vector<JKQTPColumn> which may be used to access the data chunks in the logical
notion of data columns. This class provides a set of interface methods for this list:

Member Typedef Documentation

◆ ColumnIterator

typedef QMap<size_t, JKQTPColumn>::iterator JKQTPDatastore::ColumnIterator
protected

mutable iterator for columns in the JKQTPDatastore (ColumnIterator::first: column number, ColumnIterator::second: column data)

◆ ConstColumnIterator

typedef QMap<size_t, JKQTPColumn>::const_iterator JKQTPDatastore::ConstColumnIterator
protected

constant iterator for columns in the JKQTPDatastore (ColumnIterator::first: column number, ColumnIterator::second: column data)

Constructor & Destructor Documentation

◆ JKQTPDatastore()

JKQTPDatastore::JKQTPDatastore ( )

class constructor, generates an empty datastore

◆ ~JKQTPDatastore()

JKQTPDatastore::~JKQTPDatastore ( )

class destructor, destroys all subordered JKQTPDatastoreItem objects

Member Function Documentation

◆ addCalculatedColumn() [1/2]

size_t JKQTPDatastore::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

Pseudocode:

for (i=0; i<rows; i++) {
newColumn.push_back(f(i));
}
return newColumn;
See also
addColumnCalculatedFromColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCalculatedColumn() [2/2]

size_t JKQTPDatastore::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

Pseudocode:

for (i=0; i<rows; i++) {
newColumn.push_back(f(i, this));
}
return newColumn;
See also
addColumnCalculatedFromColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCalculatedImageColumn()

size_t JKQTPDatastore::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 calling f for each entry

Pseudocode:

for (y=0; y<rows; y++) {
for (x=0; x<cols; x++) {
newColumn.push_back(f(x,y));
}
}
return newColumn;
See also
addColumnCalculatedFromColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addColumn() [1/4]

size_t JKQTPDatastore::addColumn ( const QString &  name = QString(""))

add a new and empty column to the datastore and return its column ID. The new item uses internal memory management.

Parameters
namename for the column
Returns
the ID of the newly created column
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addColumn() [2/4]

size_t JKQTPDatastore::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. Data is not owned by the JKQTPDatastore!

Parameters
datadata array to be copied
rowsnumber of rows in the data array
namename for the column
Returns
the ID of the newly created column
#define NDATA 5
double XCA[NDATA]= { 1, 2, 3, 4, 5 };
double YCA[NDATA]= { 1, 0, 1, 0, 1 };
plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
linegraph->setXColumn(datastore->addColumn(XCA, NDATA, "xca (C-array)"));
linegraph->setYColumn(datastore->addColumn(YCA, NDATA, "yca (C-array)"));
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addColumn() [3/4]

size_t JKQTPDatastore::addColumn ( JKQTPColumn  col)
protected

add a new column to the datastore and return its ID

◆ addColumn() [4/4]

size_t JKQTPDatastore::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 internal memory management.

Parameters
rowsnumber of rows in the data array
namename for the column
Returns
the ID of the newly created column
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addColumnCalculatedFromColumn() [1/2]

size_t JKQTPDatastore::addColumnCalculatedFromColumn ( 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 , that are calculated by calling f for each entry in otherColumn

Pseudocode:

for (i=0; i<rows(otherColumn); i++) {
newColumn.push_back(f(getValue(otherColumn, i));
}
return newColumn;
See also
addCalculatedColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addColumnCalculatedFromColumn() [2/2]

size_t JKQTPDatastore::addColumnCalculatedFromColumn ( 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 , that are calculated by calling f for each pair of entries in otherColumnX and otherColumnY

Pseudocode:

for (i=0; i<min(rows(otherColumnX), rows(otherColumnY)); i++) {
newColumn.push_back(f(getValue(otherColumnX, i), getValue(otherColumnY, i));
}
return newColumn;
See also
addCalculatedColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addColumnForItem()

size_t JKQTPDatastore::addColumnForItem ( size_t  itemID,
size_t  columnInItem,
const QString &  name = QString("") 
)
protected

add a new columns which references a specified item and a specified column therein.

See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumn() [1/6]

template<typename T >
size_t JKQTPDatastore::addCopiedColumn ( const T *  data,
size_t  rows,
const QString &  name = QString("") 
)
inline

copy an external column to the datastore. It contains rows rows. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

Template Parameters
Tdatatype of the element in the vector, this has to be convertible to double!
Parameters
datapointer to the data to be copied
rowsitems in data
namename for the column
Returns
the ID of the newly created column
Note
This function converts the input array data into an array of double!
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumn() [2/6]

template<typename T >
size_t JKQTPDatastore::addCopiedColumn ( const T *  data,
size_t  rows,
size_t  stride,
const QString &  name 
)
inline

copy an external column to the datastore. It contains rows rows. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

Template Parameters
Tdatatype of the element in the vector, this has to be convertible to double!
Parameters
datapointer to the data to be copied
rowsitems in data
namename for the column
stridewhen copying, this function steps throught the data with the given stride, so only eleemnts [0, stride, 2*stride, ... (rows-1)*stride] are copied!
Returns
the ID of the newly created column

Pseudocode:

for (i=0; i<rows; i+=stride) {
newColumn.push_back(jkqtp_todouble(data[i]));
}
Note
This function converts the input array data into an array of double!
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumn() [3/6]

template<typename T >
size_t JKQTPDatastore::addCopiedColumn ( const T *  data,
size_t  rows,
size_t  stride,
int  start,
const QString &  name 
)
inline

copy an external column to the datastore. It contains rows rows. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

Template Parameters
Tdatatype of the element in the vector, this has to be convertible to double!
Parameters
datapointer to the data to be copied
rowsnumber of items to copy from data
stridewhen copying, this function steps throught the data with the given stride, so only eleemnts [start, start+stride, start+2*stride, ... start+(rows-1)*stride] are copied!
startfirst element to copy
namename for the column
Returns
the ID of the newly created column

Pseudocode:

for (i=start; i<rows; i+=stride) {
newColumn.push_back(jkqtp_todouble(data[i]));
}
Note
This function converts the input array data into an array of double!
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumn() [4/6]

template<typename TContainer >
size_t JKQTPDatastore::addCopiedColumn ( const TContainer &  data,
const QString &  name,
size_t  stride,
size_t  start = 0 
)
inline

add one external column to the datastore. It will be filled with the contents of vector data.

Template Parameters
TContainerdatatype of the container, which need to support standard C++ iterators and the function size(). The contents needs to be convertible to double. The iterator of TContainer needs to support ++ and +=
Parameters
datadata vector to be copied
namename for the column
stridestrides through the container data with the given stride
startstarts copying from data with the element start
Returns
the ID of the newly created column

Pseudocode:

it=data.begin();
it += start; // shift by start items
while (it!=data.end()) {
newColumn.push_back(jkqtp_todouble(*it));
it += stride;
}
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumn() [5/6]

template<typename TContainer >
size_t JKQTPDatastore::addCopiedColumn ( const TContainer &  data,
const QString &  name = QString("") 
)
inline

add one external column to the datastore. It will be filled with the contents of vector data.

Template Parameters
TContainerdatatype of the container, which need to support standard C++ iterators. The contents needs to be convertible to double.
Parameters
datadata vector to be copied
namename for the column
Returns
the ID of the newly created column
QVector<double> X, Y;
const int Ndata=100;
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
X<<x;
Y<<sin(x);
}
plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
// by calling JKQTPDatastore::addCopiedColumn() the data is COPIED from the vector into the datastore
linegraph->setXColumn(datastore->addCopiedColumn(X, "x"));
linegraph->setYColumn(datastore->addCopiedColumn(Y, "y"));
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumn() [6/6]

template<typename TIterator >
size_t JKQTPDatastore::addCopiedColumn ( TIterator  first,
TIterator  last,
const QString &  name = QString("") 
)
inline

add one column to the datastore. It will be filled with the values from first ... last

Template Parameters
TIteratora standard C++ iterator
Parameters
firstpoints to the first value in the range of values to add
lastpoints behind the last value in the range of values to add
namename for the column
Returns
the ID of the newly created column
QVector<double> X, Y;
const int Ndata=100;
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
X<<x;
Y<<sin(x);
}
plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
// by calling JKQTPDatastore::addCopiedColumn() the data is COPIED from the vector into the datastore
linegraph->setXColumn(datastore->addCopiedColumn(X.begin(), X.end(), "x"));
linegraph->setYColumn(datastore->addCopiedColumn(Y.begin(), Y.end(), "y"));
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumnMasked() [1/2]

template<typename T >
size_t JKQTPDatastore::addCopiedColumnMasked ( const T *  data,
const bool *  mask,
size_t  rows,
const QString &  name = QString(""),
bool  useIfMaskEquals = false 
)
inline

add one external column to the datastore. It contains rows rows. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

Template Parameters
Tdatatype of the element in the vector, this has to be convertible to double!
Parameters
datapointer to the data to be copied
maskboolean array with rows entries, used to mask data when copying from data
rowsitems in data
namename for the column
useIfMaskEqualsdata from data is copied if and only if the corresponding entry of mask equals this value
Note
This function converts the input array data into an array of double!
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addCopiedColumnMasked() [2/2]

template<typename TContainer , typename TContainerMask >
size_t JKQTPDatastore::addCopiedColumnMasked ( const TContainer &  data,
const TContainerMask &  mask,
const QString &  name = QString(""),
bool  useIfMaskEquals = false 
)
inline

add one external column to the datastore. It will be filled with the contents of vector data.

Template Parameters
TContainerdatatype of the container data, which need to support standard C++ iterators and the function size(). The contents needs to be convertible to double.
TContainerMaskdatatype of the container mask, which need to support standard C++ iterators and the function size(). The contents needs to be convertible to bool.
Parameters
datadata vector to be copied
maskdata vector to be copied
namename for the column
useIfMaskEqualsdata from data is copied if and only if the corresponding entry of mask equals this value
Returns
the ID of the newly created column
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

Pseudocode:

for (i=0; i<data.size(); i++) {
if (static_cast<bool>(mask[i])==useIfMaskEquals) {
newColumn.push_back(jkqtp_todouble(data[i]));
}
}
return newColumn;

◆ addCopiedImageAsColumn() [1/2]

template<typename T >
size_t JKQTPDatastore::addCopiedImageAsColumn ( const T *  data,
size_t  width,
size_t  height,
const QString &  name = QString(""),
size_t  stride = 1,
size_t  start = 0 
)
inline

add one external column to the datastore. It contains width * height rows. The external data is assumed to be organized as a row-major image and is copied as such. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

◆ addCopiedImageAsColumn() [2/2]

template<typename TContainer >
size_t JKQTPDatastore::addCopiedImageAsColumn ( const TContainer &  data,
size_t  width,
const QString &  name = QString("") 
)
inline

add one external column to the datastore. It contains width * height rows. The external data is assumed to be organized as a row-major image and is copied as such. The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

Template Parameters
TContainerdatatype of the container, which need to support standard C++ iterators and the function size(). The contents needs to be convertible to double.
Parameters
datadata vector to be copied
widthwidth of the image, stored in data
namename for the column
Returns
the ID of the newly created column

◆ addCopiedImageAsColumnTranspose() [1/2]

template<typename T >
size_t JKQTPDatastore::addCopiedImageAsColumnTranspose ( const QVector< T > &  data,
size_t  width,
const QString &  name = QString("") 
)
inline

add one external column to the datastore. It contains width * height rows.

The external data is assumed to be organized as a column-major image and is copied as row-major (i.e. is transposed). The external data is copied to an internal array, so afterwards you can delete the external array This returns its logical column ID.

Template Parameters
Tdata type of the array data, needs to be convertible to double by jkqtp_todouble()
Parameters
datadata vector to be copied
widthwidth of the image, stored in data
namename for the column
Returns
the ID of the newly created column

◆ addCopiedImageAsColumnTranspose() [2/2]

template<typename T >
size_t JKQTPDatastore::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 the given width and height.

The external data is assumed to be organized as a column-major image and is copied as row-major (i.e. is transposed). The external data is copied to an internal array, so afterwards you can delete the external arrayThis returns its logical column ID.

Template Parameters
Tdata type of the array data, needs to be convertible to double by jkqtp_todouble()
Parameters
dataa column major image
widthwidth of data
heightheight of data
namename of the new column
stridestride to use, when reading data. Use this to e.g. read one channel from a packed RGB-image (stride=3, start=0/1/2 )
startfirst entry from data top copy data. Use this to e.g. read one channel from a packed RGB-image (stride=3, start=0/1/2 )
Returns
ID of the newly added column

◆ addCopiedItem() [1/2]

size_t JKQTPDatastore::addCopiedItem ( const double *  data,
size_t  rows 
)
protected

add one external column to the datastore. It contains rows rows. The data is copied and the copy managed internally This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addCopiedItem() [2/2]

size_t JKQTPDatastore::addCopiedItem ( JKQTPDatastoreItemFormat  dataformat,
double *  data,
size_t  columns,
size_t  rows 
)
protected

add one external data block to the datastore. It contains rows rows and columns columns. The data is copied and the copy managed internally This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addCopiedMap() [1/2]

template<typename TContainer >
std::pair<size_t, size_t> JKQTPDatastore::addCopiedMap ( const TContainer &  c,
const QString &  nameKey = QString("map_key"),
const QString &  nameValue = QString("map_value") 
)
inline

copies the contents of the map-like container c into two columns of the datastore, returns the two IDs of the items as a std::pair

See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore, jkqtp_todouble()
Template Parameters
TContainerdatatype of the map-typed container (e.g. std::map or QMap ) The requiremen to this container is that it supports standard iterators with begin() and end() .
Parameters
cthe map to copy to the datastore
nameKeyname for the column with the map keys
nameValuename for the column with the map values
Returns
a pair of IDs to the newly created columns (IDkeyColumn, IDvalueColumn) Example of usage:
std::map<int, double> datamap;
datamap[1]=1.1;
datamap[2]=1.4;
datamap[4]=1.2;
datamap[5]=1.8;
datamap[7]=0.9;
plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
linegraph->setXYColumns(datastore->addCopiedMap(datamap, "map_x", "map_y"));
linegraph->setTitle(QObject::tr("copied map"));

◆ addCopiedMap() [2/2]

template<typename TIterator >
std::pair<size_t, size_t> JKQTPDatastore::addCopiedMap ( TIterator  first,
TIterator  last,
const QString &  nameKey = QString("map_key"),
const QString &  nameValue = QString("map_value") 
)
inline

copies the contents of the map-like container c into two columns of the datastore, returns the two IDs of the items as a std::pair

See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore, jkqtp_todouble()
Template Parameters
TIteratora standard C++ iterator for a map, dereferencing with it->first and it->second
Parameters
firstpoints to the first value in the range of values to add
lastpoints behind the last value in the range of values to add
nameKeyname for the column with the map keys
nameValuename for the column with the map values
Returns
a pair of IDs to the newly created columns (IDkeyColumn, IDvalueColumn) Example of usage:
std::map<int, double> datamap;
datamap[1]=1.1;
datamap[2]=1.4;
datamap[4]=1.2;
datamap[5]=1.8;
datamap[7]=0.9;
plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
linegraph->setXYColumns(datastore->addCopiedMap(datamap.begin(), datamap.end(), "map_x", "map_y"));
linegraph->setTitle(QObject::tr("copied map"));

◆ addDecadeLogColumn()

size_t JKQTPDatastore::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^start and ending at 10^end. the values are logarithmically spaced between 10^start end 10^end

See also
addLinearColumn(), addLogColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addImageColumn() [1/2]

size_t JKQTPDatastore::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 column ID. Data is not owned by the JKQTPDatastore! The column is meant to represent an image in row-major order with x-dimention width and y-dimension height .

Parameters
datadata array to be copied
widthwidth of the image represented by the data array
heightheight of the image represented by the data array
namename for the column
Returns
the ID of the newly created column
See also
addColumn(), addImageColumn(), addInternalImageColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addImageColumn() [2/2]

size_t JKQTPDatastore::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. The new item uses internal memory management. The column is meant to represent an image in row-major order with x-dimention width and y-dimension height .

Parameters
widthwidth of the image represented by the data array
heightheight of the image represented by the data array
namename for the column
Returns
the ID of the newly created column
See also
addImageColumn(), addInternalImageColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addInternalColumn()

size_t JKQTPDatastore::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 to the datastore

Parameters
datadata array to be copied
rowsnumber of rows in the data array
namename for the column
Returns
the ID of the newly created column
#define NDATA 5
double* XCA=(double*)malloc(NDATA, sizeof(double));
double* YCA=(double*)malloc(NDATA, sizeof(double));
...
plot.addGraph(linegraph=new JKQTPXYLineGraph(&plot));
linegraph->setXColumn(datastore->addInternalColumn(XCA, NDATA, "x"));
linegraph->setXColumn(datastore->addInternalColumn(YCA, NDATA, "y"));
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addInternalImageColumn()

size_t JKQTPDatastore::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 transfered to the datastore The column is meant to represent an image in row-major order with x-dimention width and y-dimension height .

Parameters
datadata array to be copied
widthwidth of the image represented by the data array
heightheight of the image represented by the data array
namename for the column
Returns
the ID of the newly created column
See also
addInternalColumn(), addImageColumn(), addInternalImageColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addInternalItem()

size_t JKQTPDatastore::addInternalItem ( double *  data,
size_t  rows 
)
protected

add one internal column to the datastore. It contains rows rows. This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addItem() [1/5]

size_t JKQTPDatastore::addItem ( double *  data,
size_t  rows 
)
protected

add one external column to the datastore. It contains rows rows. This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addItem() [2/5]

size_t JKQTPDatastore::addItem ( JKQTPDatastoreItem item)
protected

add a new item to the datastore and return its ID This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addItem() [3/5]

size_t JKQTPDatastore::addItem ( JKQTPDatastoreItemFormat  dataformat,
double *  data,
size_t  columns,
size_t  rows 
)
protected

add an external memory block to the datastore. It contains rows rows and columns columns. dataformat determined the memory layout. This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addItem() [4/5]

size_t JKQTPDatastore::addItem ( size_t  columns,
size_t  rows 
)
protected

add a new item with rows rows and columns columns to the datastore and return its ID. The item uses internal memory management. This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addItem() [5/5]

size_t JKQTPDatastore::addItem ( size_t  rows)
protected

add a new columns/item with rows rows to the datastore and return its ID. The item uses internal memory management. This function retuns an item ID (which can be used with getItem() ), not a column ID!

◆ addLinearColumn()

size_t JKQTPDatastore::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 start and ending at end. the values are equidistant between start end end

See also
addLogColumn(), addDecadeLogColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addLinearGridColumns()

std::pair<size_t,size_t> JKQTPDatastore::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 width points in x- and height points in y-direction.

Parameters
widthnumber of columns in the mesh grid
startXx-coordinate of the first column of the mesh grid
endXx-coordinate of the last column of the mesh grid
heightnumber of rows in the mesh grid
startYy-coordinate of the first row of the mesh grid
endYy-coordinate of the last row of the mesh grid
nameXname for the x-coordinate column
nameYname for the y-coordinate column
Returns
IDs of two column that contain the x- and y- coordinates od the mesh points (in row-major order), where the x-coordinates are linearly distributed between startX and endX and the x-coordinates are linearly distributed between startY and endY .
See also
addLogGridColumns(), addDecadeLogGridColumns(), addColumnCalculatedFromColumn(), JKQTPXYParametrizedScatterGraph, Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ addLogColumn()

size_t JKQTPDatastore::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 start and ending at end. the values are logarithmically spaced between start end end

See also
addLinearColumn(), addDecadeLogColumn(), Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ appendFromContainerToColumn()

template<class TContainer >
void JKQTPDatastore::appendFromContainerToColumn ( size_t  column,
const TContainer &  values 
)
inline

adds a values in container values to the column column. This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards

Template Parameters
TContainera container with standard iterators
Parameters
columnthe column to extend
valuesvector with data to append to column column

◆ appendToColumn() [1/2]

void JKQTPDatastore::appendToColumn ( size_t  column,
double  value 
)

adds a value value to the column column. This changes the column length (number of rows).

Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumns()

◆ appendToColumn() [2/2]

template<class TIterator >
void JKQTPDatastore::appendToColumn ( size_t  column,
TIterator  first,
TIterator  last 
)
inline

adds a values from a range first ... last (defined by C++ iterators) to the column column. This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards

Template Parameters
TIteratora standard C++ iterator
Parameters
columnthe column to extend
firstpoints to the first value in the range of values to add
lastpoints behind the last value in the range of values to add

◆ appendToColumns() [1/6]

void JKQTPDatastore::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.

This is equivalent to

appendToColumn(column1, value1);
appendToColumn(column2, value2);
Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumn()

◆ appendToColumns() [2/6]

void JKQTPDatastore::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.

This is equivalent to

appendToColumn(column1, value1);
appendToColumn(column2, value2);
appendToColumn(column3, value3);
Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumn()

◆ appendToColumns() [3/6]

void JKQTPDatastore::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.

This is equivalent to

appendToColumn(column1, value1);
appendToColumn(column2, value2);
appendToColumn(column3, value3);
appendToColumn(column4, value4);
Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumn()

◆ appendToColumns() [4/6]

void JKQTPDatastore::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.

This is equivalent to

appendToColumn(column1, value1);
appendToColumn(column2, value2);
appendToColumn(column3, value3);
appendToColumn(column4, value4);
appendToColumn(column5, value5);
Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumn()

◆ appendToColumns() [5/6]

void JKQTPDatastore::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.

This is equivalent to

appendToColumn(columnX, value.x());
appendToColumn(columnY, value.y());
Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumn()

◆ appendToColumns() [6/6]

void JKQTPDatastore::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.

This is equivalent to

appendToColumn(columnX, value.x());
appendToColumn(columnY, value.y());
Warning
This changes the column length (number of rows). If the memory was externally managed before, it will be internally managed afterwards .
See also
appendToColumn()

◆ backInserter() [1/2]

JKQTPColumnBackInserter JKQTPDatastore::backInserter ( int  i)

returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore

See also
JKQTPColumnBackInserter

◆ backInserter() [2/2]

JKQTPColumnBackInserter JKQTPDatastore::backInserter ( size_t  i)

returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore

See also
JKQTPColumnBackInserter

◆ begin() [1/6]

ColumnIterator JKQTPDatastore::begin ( )
protected

returns an iterator to the first column in the JKQTPDatastore

See also
ColumnIterator

◆ begin() [2/6]

ConstColumnIterator JKQTPDatastore::begin ( ) const
protected

returns a const iterator to the first column in the JKQTPDatastore

See also
ConstColumnIterator

◆ begin() [3/6]

JKQTPColumnIterator JKQTPDatastore::begin ( int  i)

returns an iterator to the first data entry in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::iterator

◆ begin() [4/6]

JKQTPColumnConstIterator JKQTPDatastore::begin ( int  i) const

returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::const_iterator

◆ begin() [5/6]

JKQTPColumnIterator JKQTPDatastore::begin ( size_t  i)

returns an iterator to the first data entry in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::iterator

◆ begin() [6/6]

JKQTPColumnConstIterator JKQTPDatastore::begin ( size_t  i) const

returns a const iterator to the first data entry in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::const_iterator

◆ clear()

void JKQTPDatastore::clear ( )

deletes all items from the datastore and possibly frees the memory they manage

◆ copyColumn() [1/2]

size_t JKQTPDatastore::copyColumn ( size_t  old_column,
const QString &  name = QString("") 
)

copies the given old_column into a new one

Parameters
old_columnthe column to be duplicated
namename for the new column
Returns
ID of the newly created column
See also
Tutorial (JKQTPDatastore): Basic Usage of JKQTPDatastore

◆ copyColumn() [2/2]

size_t JKQTPDatastore::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

Parameters
old_columnthe column to be duplicated
startfor row in column old_column to copy
stridestride for iterating through old_column when copying
namename for the new column
Returns
ID of the newly created column

Pseuo-Code:

newColumn=addColumn(rowcount(old_column), name)
forall ( r: rows(old_column)) {
set(newColumn, r, get(old_column, r))
}
return newColumn;

◆ dec()

void JKQTPDatastore::dec ( size_t  column,
size_t  row,
double  decrement = 1 
)
inline

decrements entry in row row of column column by decrement

See also
Example (JKQTPlotter): Filled Curve Plots

◆ deleteAllColumns()

void JKQTPDatastore::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 column and removeItems is true, the item will be removed

◆ deleteAllPrefixedColumns()

void JKQTPDatastore::deleteAllPrefixedColumns ( QString  prefix,
bool  removeItems = true 
)

delete all columns where the name starts with a given prefix, if no other columns points to the datastore item of the column and removeItems is true, the item will be removed

◆ deleteColumn()

void JKQTPDatastore::deleteColumn ( size_t  column,
bool  removeItems = true 
)

delete the given column, if no other columns points to the datastore item of the column and removeItems is true, the item will be removed

◆ end() [1/6]

ColumnIterator JKQTPDatastore::end ( )
protected

returns an iterator behind the last column in the JKQTPDatastore

See also
ColumnIterator

◆ end() [2/6]

ConstColumnIterator JKQTPDatastore::end ( ) const
protected

returns a const iterator behind the last column in the JKQTPDatastore

See also
ConstColumnIterator

◆ end() [3/6]

JKQTPColumnIterator JKQTPDatastore::end ( int  i)

returns an iterator behind the last data entry data in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::iterator

◆ end() [4/6]

JKQTPColumnConstIterator JKQTPDatastore::end ( int  i) const

returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::const_iterator

◆ end() [5/6]

JKQTPColumnIterator JKQTPDatastore::end ( size_t  i)

returns an iterator behind the last data entry data in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::iterator

◆ end() [6/6]

JKQTPColumnConstIterator JKQTPDatastore::end ( size_t  i) const

returns a const iterator behind the last data entry data in the i -th column in the JKQTPDatastore

See also
JKQTPColumn::const_iterator

◆ ensureColumnNum()

int JKQTPDatastore::ensureColumnNum ( const QString &  name)

return the num of the first column with the given name, if none was found this creates a new column with no rows and returns its num

◆ eraseFromColumn() [1/4]

void JKQTPDatastore::eraseFromColumn ( const JKQTPColumnConstIterator pos)
inline

removes the entry pos

Warning
If the memory was externally managed before, it will be internally managed afterwards
the iterator pos is rendered invalid by this column, as the in some cases the internal column is redefined!

◆ eraseFromColumn() [2/4]

void JKQTPDatastore::eraseFromColumn ( const JKQTPColumnConstIterator pos,
const JKQTPColumnConstIterator posEnd 
)
inline

removes the entries pos to posEnd

Warning
If the memory was externally managed before, it will be internally managed afterwards
the iterator pos is rendered invalid by this column, as the in some cases the internal column is redefined!

◆ eraseFromColumn() [3/4]

void JKQTPDatastore::eraseFromColumn ( const JKQTPColumnIterator pos)
inline

removes the entry pos

Warning
If the memory was externally managed before, it will be internally managed afterwards
the iterator pos is rendered invalid by this column, as the in some cases the internal column is redefined!

◆ eraseFromColumn() [4/4]

void JKQTPDatastore::eraseFromColumn ( const JKQTPColumnIterator pos,
const JKQTPColumnIterator posEnd 
)
inline

removes the entries pos to posEnd

Warning
If the memory was externally managed before, it will be internally managed afterwards
the iterator pos is rendered invalid by this column, as the in some cases the internal column is redefined!

◆ get() [1/4]

double JKQTPDatastore::get ( int  column,
int  row 
) const
inline

returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)

◆ get() [2/4]

double JKQTPDatastore::get ( int  column,
size_t  row 
) const
inline

returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)

◆ get() [3/4]

double JKQTPDatastore::get ( size_t  column,
int  row 
) const
inline

returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)

◆ get() [4/4]

double JKQTPDatastore::get ( size_t  column,
size_t  row 
) const
inline

returns the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)

◆ getColumn() [1/2]

JKQTPColumn JKQTPDatastore::getColumn ( int  i) const
protected

returns the JKQTPColumn object for the i -th column in the store

Warning
This function copies the pointers/references to the internal data into a new object. Therefore you should delete it as soon as possible and not store the return value over long durations, as the data may get moved in the meantime and then the object gets invalid, but is not informed of this fact!

◆ getColumn() [2/2]

JKQTPColumn JKQTPDatastore::getColumn ( size_t  i) const
protected

returns the JKQTPColumn object for the i -th column in the store

Warning
This function copies the pointers/references to the internal data into a new object. Therefore you should delete it as soon as possible and not store the return value over long durations, as the data may get moved in the meantime and then the object gets invalid, but is not informed of this fact!

◆ getColumnChecksum()

quint16 JKQTPDatastore::getColumnChecksum ( int  column) const

returns the data checksum of the given column

◆ getColumnCount()

size_t JKQTPDatastore::getColumnCount ( ) const
inline

returns the number of (logical) columns currently managed by the datastore

◆ getColumnIDs()

QList<size_t> JKQTPDatastore::getColumnIDs ( ) const
inline

returns a list with all available column IDs

◆ getColumnIDsIntVec()

QVector<int> JKQTPDatastore::getColumnIDsIntVec ( ) const

returns a list with all available column IDs

◆ getColumnImageHeight()

size_t JKQTPDatastore::getColumnImageHeight ( int  column) const
inline

returns the height of the image, represented by column (in row-major ordering)

◆ getColumnImageWidth()

size_t JKQTPDatastore::getColumnImageWidth ( int  column) const
inline

returns the width of the image, represented by column (in row-major ordering). Internally this returns the imageColumns or image width, if set in the column

◆ getColumnName()

QString JKQTPDatastore::getColumnName ( size_t  column)

return the title of the first column with the given name, or -1 if none was found

◆ getColumnNames()

QStringList JKQTPDatastore::getColumnNames ( ) const

return a list with all columns available in the datastore

◆ getColumnNum()

int JKQTPDatastore::getColumnNum ( const QString &  name)

return the num of the first column with the given name, or -1 if none was found

◆ getColumnPointer() [1/4]

double * JKQTPDatastore::getColumnPointer ( int  column,
size_t  row = 0 
)
inline

returns a pointer to the data in column column, starting ar row row

◆ getColumnPointer() [2/4]

const double * JKQTPDatastore::getColumnPointer ( int  column,
size_t  row = 0 
) const
inline

returns a pointer to the data in column column, starting ar row row

◆ getColumnPointer() [3/4]

double * JKQTPDatastore::getColumnPointer ( size_t  column,
size_t  row = 0 
)
inline

returns a pointer to the data in column column, starting ar row row

◆ getColumnPointer() [4/4]

const double * JKQTPDatastore::getColumnPointer ( size_t  column,
size_t  row = 0 
) const
inline

returns a pointer to the data in column column, starting ar row row

◆ getData() [1/2]

QList<QVector<double> > JKQTPDatastore::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

Parameters
columnNamesif !=nullptr this will afterwards conatin the column titles
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()

◆ getData() [2/2]

QVector<double> JKQTPDatastore::getData ( size_t  column,
QString *  columnName = nullptr 
) const

return contents of a given column as QVector<double>

Parameters
columncolumn to copy
columnNameif !=nullptr this will afterwards conatin the column title

◆ getItem() [1/2]

JKQTPDatastoreItem* JKQTPDatastore::getItem ( size_t  i)
inlineprotected

returns the JKQTPDatastoreItem object for the i -th item in the store

◆ getItem() [2/2]

const JKQTPDatastoreItem* JKQTPDatastore::getItem ( size_t  i) const
inlineprotected

returns the JKQTPDatastoreItem object for the i -th item in the store

◆ getMaxRows()

size_t JKQTPDatastore::getMaxRows ( ) const

returns the maximum number of rows in all columns

◆ getNextHigherIndex() [1/4]

int JKQTPDatastore::getNextHigherIndex ( int  column,
size_t  row 
) const

gets the index of the datapoint with the nearest, but higher value in the column

◆ getNextHigherIndex() [2/4]

int JKQTPDatastore::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 inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column)

◆ getNextHigherIndex() [3/4]

int JKQTPDatastore::getNextHigherIndex ( size_t  column,
size_t  row 
) const

gets the index of the datapoint with the nearest, but higher value in the column

◆ getNextHigherIndex() [4/4]

int JKQTPDatastore::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 inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column)

◆ getNextLowerIndex() [1/4]

int JKQTPDatastore::getNextLowerIndex ( int  column,
size_t  row 
) const

gets the index of the datapoint with the nearest, but lower value in the column

◆ getNextLowerIndex() [2/4]

int JKQTPDatastore::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 row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column)

◆ getNextLowerIndex() [3/4]

int JKQTPDatastore::getNextLowerIndex ( size_t  column,
size_t  row 
) const

gets the index of the datapoint with the nearest, but lower value in the column

◆ getNextLowerIndex() [4/4]

int JKQTPDatastore::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 row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column)

◆ getPixel()

double JKQTPDatastore::getPixel ( size_t  column,
size_t  x,
size_t  y 
) const
inline

returns the value at position (x, y) in the column-th column, which is interpreted with the imageWidth stored in that column

◆ getRows() [1/2]

size_t JKQTPDatastore::getRows ( int  column) const
inline

returns the number of rows in the column column

◆ getRows() [2/2]

size_t JKQTPDatastore::getRows ( size_t  column) const
inline

returns the number of rows in the column column

◆ hasColumn()

bool JKQTPDatastore::hasColumn ( size_t  i) const

determines whether a column with the given ID exists

◆ inc()

void JKQTPDatastore::inc ( size_t  column,
size_t  row,
double  increment = 1 
)
inline

increases entry in row row of column column by increment

See also
Example (JKQTPlotter): Filled Curve Plots

◆ saveCSV() [1/2]

void JKQTPDatastore::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

Parameters
filenamethe file to create
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()
separatorthe column separator char
decimal_separatorthe decimal separator ('.' by default)
commentcomments are started with this string and end with a linebreak. If this parameter is empty no comments will be output
aroundStringsstrings (in column headers) are surrounded by these characters!
floatformata printf format string that is used to print floating point numbers to the file

Here are some default configuration:

  • saveCSV(filename, ", ", ".", "#") will generate a standard CSV file with commas between the columns and a point as decimal separator. Comments start with #
  • saveCSV(filename, "; ", ",", "") will generate a CSV file which may be read by a german Excel version: separated by ; and comma as decimal separator
  • saveCSV(filename, "\t", ".", "#") will generate a tab separated values file
  • ...

◆ saveCSV() [2/2]

void JKQTPDatastore::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

Parameters
txtQTextStream to write to
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()
separatorthe column separator char
decimal_separatorthe decimal separator ('.' by default)
commentcomments are started with this string and end with a linebreak. If this parameter is empty no comments will be output
aroundStringsstrings (in column headers) are surrounded by these characters!
floatformata printf format string that is used to print floating point numbers to the file

Here are some default configuration:

  • saveCSV(filename, ", ", ".", "#") will generate a standard CSV file with commas between the columns and a point as decimal separator. Comments start with #
  • saveCSV(filename, "; ", ",", "") will generate a CSV file which may be read by a german Excel version: separated by ; and comma as decimal separator
  • saveCSV(filename, "\t", ".", "#") will generate a tab separated values file
  • ...

◆ saveDIF()

void JKQTPDatastore::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)

Parameters
filenamethe file to create
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()
floatformata printf format string that is used to print floating point numbers to the file

◆ saveMatlab() [1/2]

void JKQTPDatastore::saveMatlab ( const QString &  filename,
const QSet< int > &  userColumns = QSet< int >() 
) const

save contents of datastore as a Matlab script

Parameters
filenamethe file to create
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()

◆ saveMatlab() [2/2]

void JKQTPDatastore::saveMatlab ( QTextStream &  txt,
const QSet< int > &  userColumns = QSet< int >() 
) const

save contents of datastore as a Matlab script

Parameters
txtthe QTextStream to write to
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()

◆ saveSYLK()

void JKQTPDatastore::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)

Parameters
filenamethe file to create
userColumnsa list of all columns to export, an empty list means: export all, the indexes in the list refer to getColumnsNames()
floatformata printf format string that is used to print floating point numbers to the file

◆ scaleColumnValues()

void JKQTPDatastore::scaleColumnValues ( size_t  column,
double  factor 
)
inline

scales (multiplies) all entries in column column by factor

See also
Example (JKQTPlotter): Filled Curve Plots

◆ set() [1/2]

void JKQTPDatastore::set ( int  column,
size_t  row,
double  value 
)
inline

sets the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)

◆ set() [2/2]

void JKQTPDatastore::set ( size_t  column,
size_t  row,
double  value 
)
inline

sets the value at position (column, row). column is the logical column and will be mapped to the according memory block internally!)

◆ setAll()

void JKQTPDatastore::setAll ( size_t  column,
double  value 
)
inline

sets all entries in column column to value

See also
Example (JKQTPlotter): Filled Curve Plots

◆ setPixel()

void JKQTPDatastore::setPixel ( size_t  column,
size_t  x,
size_t  y,
double  value 
)
inline

returns the value at position (x, y) in the column-th column, which is interpreted with the imageWidth stored in that column

Friends And Related Function Documentation

◆ JKQTPColumn

friend class JKQTPColumn
friend

◆ JKQTPDatastoreItem

friend class JKQTPDatastoreItem
friend

◆ JKQTPDatastoreModel

friend class JKQTPDatastoreModel
friend

Member Data Documentation

◆ columns

QMap<size_t, JKQTPColumn> JKQTPDatastore::columns
private

a std::vector of all columns that may be used to access the managed chunks of memory.

◆ items

QMap<size_t, JKQTPDatastoreItem*> JKQTPDatastore::items
private

a std::vector that contains all items managed by this datastore

◆ m_invalidColumn

std::unique_ptr<JKQTPColumn> JKQTPDatastore::m_invalidColumn
private

an internal invalid column object, used e.g. to return invalid column iterators

◆ maxColumnsID

size_t JKQTPDatastore::maxColumnsID
private

internal variable to keep track about the highest column ID (in columns) used so far

See also
columns

◆ maxItemID

size_t JKQTPDatastore::maxItemID
private

internal variable to keep track about the highest item ID (in items) used so far

See also
items

The documentation for this class was generated from the following file:
JKQTPDatastore::addInternalColumn
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...
fontcoverage.start
start
Definition: fontcoverage.py:11
JKQTPDatastore::get
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:2584
JKQTPDatastore::addCopiedMap
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:1123
JKQTPSTATISTICS_PI
#define JKQTPSTATISTICS_PI
Definition: jkqtpmathtools.h:43
jkqtpstatAverage
double jkqtpstatAverage(InputIt first, InputIt last, size_t *Noutput=nullptr)
calculates the average of a given data range first ... last
Definition: jkqtpstatbasics.h:61
JKQTPDatastore::setPixel
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:2709
JKQTPDatastore::set
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:2609
jkqtp_todouble
constexpr double jkqtp_todouble(const T &d)
converts a boolean to a double, is used to convert boolean to double by JKQTPDatastore
Definition: jkqtpmathtools.h:93
JKQTPXYLineGraph
This implements xy line plots. This also alows to draw symbols at the data points.
Definition: jkqtpscatter.h:56
JKQTPDatastore::begin
ColumnIterator begin()
returns an iterator to the first column in the JKQTPDatastore
JKQTPDatastore::end
ColumnIterator end()
returns an iterator behind the last column in the JKQTPDatastore
JKQTPDatastore::appendToColumn
void appendToColumn(size_t column, double value)
adds a value value to the column column. This changes the column length (number of rows).
JKQTPDatastore::backInserter
JKQTPColumnBackInserter backInserter(int i)
returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore
fontcoverage.i
i
Definition: fontcoverage.py:31
JKQTPDatastore::addCopiedColumn
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:806
JKQTPDatastore::addColumn
size_t addColumn(JKQTPColumn col)
add a new column to the datastore and return its ID