![]() |
JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
|
Manages one column of data. Data may either be stored internally as double* array or QVector<double> or the object may reference an external array of data. This class also provides basic tools to edit the data, change column size etc. More...
#include <jkqtpdatastorage.h>
Public Types | |
| typedef JKQTPColumnConstIterator | const_iterator |
| enum | DataTransferMode { TransferOwnership , ExternallyOwned , CopyData } |
| typedef JKQTPColumnIterator | iterator |
| enum class | StorageType { External , Internal , Vector } |
Public Member Functions | |
| JKQTPColumn (const JKQTPColumn &)=delete | |
| JKQTPColumn (JKQTPColumn &&) | |
| JKQTPColumn (JKQTPDatastore *datastore_, const QString &name_, const double *data_, size_t datasize_, size_t imageColumns_=1) | |
| class constructor that creates a column, which is initialized by c copy of the array data_ (size datasize_ ). | |
| JKQTPColumn (JKQTPDatastore *datastore_, const QString &name_, const QVector< double > &data, size_t imageColumns_=1) | |
| class constructor that fills the column with data from datavec_ (by copy). | |
| JKQTPColumn (JKQTPDatastore *datastore_, const QString &name_, DataTransferMode transferMode, double *data_, size_t datasize_, size_t imageColumns_=1) | |
| class constructor that binds the column to a specific array data_ (size datasize_ ) of externally managed data. Depending on transferMode the data is either copied into the column, managed as internally owned or externally owned array | |
| JKQTPColumn (JKQTPDatastore *datastore_, const QString &name_, QVector< double > &&data, size_t imageColumns_=1) | |
| class constructor that fills the column with data from datavec_ (by move). | |
| JKQTPColumn (JKQTPDatastore *datastore_, const QString &name_, size_t imageColumns_=1) | |
| class constructor that constructs a new empty vector column | |
| JKQTPColumn (JKQTPDatastore *datastore_, const QString &name_, size_t rows, double initialVal=0.0, size_t imageColumns_=1) | |
| class constructor that constructs a new vector column with rows rows that are all equal to initialVal | |
| JKQTPColumn (JKQTPDatastore *datastore_=nullptr) | |
| constructs an invalid column | |
| ~JKQTPColumn () | |
| void | append (double val) |
| append value to the column, Possibly converts the column to a vector column, if necessary | |
| double & | at (int n) |
| returns a reference to the n -th row in this column (possibly throwing an exception if it does not exist!) | |
| const double & | at (int n) const |
| returns a reference to the n -th row in this column (possibly throwing an exception if it does not exist!) | |
| iterator | begin () |
| returns an iterator to the internal data | |
| const_iterator | begin () const |
| returns an iterator to the internal data | |
| quint16 | calculateChecksum () const |
| calculates a checksum over the contents of the column (using qChecksum()) | |
| void | clear () |
clears the contents, frees any associated memory (if storageType==StorageType::Internal or storageType==StorageType::Vector ) | |
| size_t | copy (const double *data, size_t N, size_t offset=0) |
| copy data from the given array into the column | |
| QVector< double > | copyData () |
| returns a QVector with the contained data (as a copy) | |
| void | copyData (QVector< double > ©To) const |
| copies the contained data into a QVector | |
| void | decValue (size_t n, double decrement=1.0) |
| decrement the n'th value from the column | |
| iterator | end () |
| returns an iterator to the internal data | |
| const_iterator | end () const |
| returns an iterator to the internal data | |
| void | exchange (double value, double replace) |
| exchange every occurence of a given value by a replace value | |
| size_t | getImageColumns () const |
| number of image columns, if the data in this column is interpreted as a row-major image (e.g. for display in a JKQTPMathImage ) | |
| QString | getName () const |
| a name describing the column | |
| 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 Matrix of the width imageWidth | |
| double * | getPointer (size_t n=0) |
| gets a pointer to the n -th value in the column | |
| const double * | getPointer (size_t n=0) const |
| gets a pointer to the n -th value in the column | |
| size_t | getRows () const noexcept |
| returns the number of rows in this column (accesses the datastore) | |
| StorageType | getStorageType () const |
| retrurnsthe storage type of the data in this column | |
| double | getValue (int n) const |
| reads the n'th value from the column | |
| double | getValue (size_t n) const |
| reads the n'th value from the column | |
| void | incValue (size_t n, double increment=1.0) |
| increment the n'th value from the column | |
| bool | isValid () const noexcept |
return true if the column is valid i.e. is properly initialized | |
| bool | isVectorColumn () const |
returns true if data is managed in a vector, i.e. operations like append are possible without copying the data into a vector | |
| JKQTPColumn & | operator= (const JKQTPColumn &)=delete |
| JKQTPColumn & | operator= (JKQTPColumn &&) |
| bool | operator== (const JKQTPColumn &other) const |
| two columns are equal, if the same memory in the same datastore is referenced | |
| double & | operator[] (int n) |
| returns a reference to the n -th row in this column | |
| const double & | operator[] (int n) const |
| returns a reference to the n -th row in this column (possibly throwing an exception if it does not exist!) | |
| void | push_back (double val) |
| append value to the column, Possibly converts the column to a vector column, if necessary | |
| void | resize (size_t new_size, double added_vala=0.0) |
| resize the column to new_size (possibly filling with added_vala ), Possibly converts the column to a vector column, if necessary | |
| void | scale (double factor) |
| scales all members of the column with the given factor | |
| void | setAll (double value) |
| set all values in the column to a specific value | |
| void | setImageColumns (size_t imageWidth) |
| number of image columns, if the data in this column is interpreted as a row-major image (e.g. for display in a JKQTPMathImage ) | |
| void | setName (const QString &__value) |
| a name describing the column | |
| 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 of the width imageWidth | |
| 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 of the given width | |
| void | setValue (size_t n, double val) |
| sets the n'th value from the column | |
| void | subtract (double value) |
| subtracts a given value from all members of the column | |
Protected Member Functions | |
| bool | convertToVectorColumn () |
| if the column's data is \u not stored in an internal vector , this copies the data into a vector This does copies all data. | |
| void | convertToVectorColumnFromRange (size_t start1, size_t end1) |
| if the column's data is \u not stored in an internal vector , this copies the data into a vector This does not copy all data, but only the inclusive row range [start1..end1]. | |
| void | convertToVectorColumnFromRanges (size_t start1, size_t end1, size_t start2, size_t end2) |
| if the column's data is \u not stored in an internal vector, this copies the data into a vector This does not copy all data, but only the inclusive row ranges [start1..end1] and [start2..end2]. | |
| void | eraseFromVectorColumn (size_t row) |
| removes the entry row | |
| void | eraseFromVectorColumn (size_t row, size_t rowEnd) |
| removes the entries row to rowEnd (inclusive) | |
| JKQTPDatastore * | getDatastore () |
| const JKQTPDatastore * | getDatastore () const |
Private Attributes | |
| double * | data |
| how data is represented in this JKQTPColumn | |
| JKQTPDatastore * | datastore |
| pointer to the datastore object used to manage the data of the plot | |
| QVector< double > | datavec |
iif storageType is StorageType::Vector, the data is actually save here | |
| size_t | imageColumns |
| number of image columns, if the data in this column is interpreted as a row-major image (e.g. for display in a JKQTPMathImage ) | |
| QString | name |
| a name describing the column | |
| size_t | rows |
| number of rows in data | |
| StorageType | storageType |
specifies whether the datastore manages the memory (true , i.e. may also free the data) or whether the user application does this (false , i.e. the datastore never frees the data) . | |
| bool | valid |
| is this item valid/usable? | |
Friends | |
| class | JKQTPColumnConstIterator |
| class | JKQTPColumnIterator |
| class | JKQTPDatastore |
Manages one column of data. Data may either be stored internally as double* array or QVector<double> or the object may reference an external array of data. This class also provides basic tools to edit the data, change column size etc.
| Enumerator | |
|---|---|
| TransferOwnership | data is owned by the JKQTPColumn afterwards (and if necessary \C std::free() 's ) |
| ExternallyOwned | data is referenced, but \u not owned by the JKQTPColumn afterwards |
| CopyData | data is owned by the JKQTPColumn and internally managed as a QVector<double> which makes this data item easily editable (also append/erase operations!) |
|
strong |
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_ = nullptr | ) |
constructs an invalid column
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_, |
| const QString & | name_, | ||
| DataTransferMode | transferMode, | ||
| double * | data_, | ||
| size_t | datasize_, | ||
| size_t | imageColumns_ = 1 ) |
class constructor that binds the column to a specific array data_ (size datasize_ ) of externally managed data. Depending on transferMode the data is either copied into the column, managed as internally owned or externally owned array
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_, |
| const QString & | name_, | ||
| const double * | data_, | ||
| size_t | datasize_, | ||
| size_t | imageColumns_ = 1 ) |
class constructor that creates a column, which is initialized by c copy of the array data_ (size datasize_ ).
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_, |
| const QString & | name_, | ||
| const QVector< double > & | data, | ||
| size_t | imageColumns_ = 1 ) |
class constructor that fills the column with data from datavec_ (by copy).
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_, |
| const QString & | name_, | ||
| QVector< double > && | data, | ||
| size_t | imageColumns_ = 1 ) |
class constructor that fills the column with data from datavec_ (by move).
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_, |
| const QString & | name_, | ||
| size_t | rows, | ||
| double | initialVal = 0.0, | ||
| size_t | imageColumns_ = 1 ) |
class constructor that constructs a new vector column with rows rows that are all equal to initialVal
| JKQTPColumn::JKQTPColumn | ( | JKQTPDatastore * | datastore_, |
| const QString & | name_, | ||
| size_t | imageColumns_ = 1 ) |
class constructor that constructs a new empty vector column
| JKQTPColumn::~JKQTPColumn | ( | ) |
|
inlinedelete |
|
inline |
|
inline |
append value to the column, Possibly converts the column to a vector column, if necessary
|
inline |
returns a reference to the n -th row in this column (possibly throwing an exception if it does not exist!)
|
inline |
returns a reference to the n -th row in this column (possibly throwing an exception if it does not exist!)
|
inline |
returns an iterator to the internal data
|
inline |
returns an iterator to the internal data
|
inline |
calculates a checksum over the contents of the column (using qChecksum())
| void JKQTPColumn::clear | ( | ) |
clears the contents, frees any associated memory (if storageType==StorageType::Internal or storageType==StorageType::Vector )
Afterwards the column has storageType==StorageType::Vector and is valid!
|
protected |
if the column's data is \u not stored in an internal vector , this copies the data into a vector This does copies all data.
true if a conversion was performed, or false if the column already linked to a vector item. Especially this returns false if isVectorColumn()==true!!!
|
protected |
if the column's data is \u not stored in an internal vector , this copies the data into a vector This does not copy all data, but only the inclusive row range [start1..end1].
| start1 | start of first range. If start1>getRows() or end1<start1 the range [start1..end1] is ignored. If start1==end1==getRows() all data is copied. |
| end1 | end of first range |
true if a conversion was performed, or false if the column already linked to a vector item. In the latter case the range [start1..end1] are ignored (i.e. a vector column is not modified!!!)!!! Especially this returns false if isVectorColumn()==true!!!
|
protected |
if the column's data is \u not stored in an internal vector, this copies the data into a vector This does not copy all data, but only the inclusive row ranges [start1..end1] and [start2..end2].
| start1 | start of first range. If start1>getRows() or end1<start1 the range [start1..end1] is ignored. |
| end1 | end of first range |
| start2 | start of second range. If start2>getRows() or end2<start2 the range [start2..end2] is ignored. |
| end2 | end of second range |
true if a conversion was performed, or false if the column already linked to a vector item. In the latter case the ranges [start1..end1] and [start2..end2] are ignored (i.e. a vector column is not modified!!!)!!! Especially this returns false if isVectorColumn()==true!!!| size_t JKQTPColumn::copy | ( | const double * | data, |
| size_t | N, | ||
| size_t | offset = 0 ) |
copy data from the given array into the column
This copies N elements from data into the column where the first overwritten row is offset, so you can shift the location where the copy process starts.
| QVector< double > JKQTPColumn::copyData | ( | ) |
returns a QVector with the contained data (as a copy)
| void JKQTPColumn::copyData | ( | QVector< double > & | copyTo | ) | const |
copies the contained data into a QVector
|
inline |
decrement the n'th value from the column
if the referenced entry does not exist for any reason, this function does not throw but simply exits!
|
inline |
returns an iterator to the internal data
|
inline |
returns an iterator to the internal data
|
inlineprotected |
removes the entry row
|
inlineprotected |
removes the entries row to rowEnd (inclusive)
| void JKQTPColumn::exchange | ( | double | value, |
| double | replace ) |
exchange every occurence of a given value by a replace value
|
inlineprotected |
|
inlineprotected |
|
inline |
number of image columns, if the data in this column is interpreted as a row-major image (e.g. for display in a JKQTPMathImage )
|
inline |
a name describing the column
|
inline |
returns the element at (x,y) in the column, where the data is interpreted as a row-major ordered Matrix of the width imageWidth
This method accesses the datastore and returns the double value stored in the (y*imageColumns+x)'th row of the according column.
|
inline |
gets a pointer to the n -th value in the column
|
inline |
gets a pointer to the n -th value in the column
|
inlinenoexcept |
returns the number of rows in this column (accesses the datastore)
|
inline |
retrurnsthe storage type of the data in this column
|
inline |
reads the n'th value from the column
This method accesses the datastore and returns the double value stored in the n'th row of the according column.
|
inline |
reads the n'th value from the column
This method accesses the datastore and returns the double value stored in the n'th row of the according column.
If data is not available (e.g. no data in column of n out of range, this function return JKQTP_NAN )
|
inline |
increment the n'th value from the column
if the referenced entry does not exist for any reason, this function does not throw but simply exits!
|
inlinenoexcept |
return true if the column is valid i.e. is properly initialized
|
inline |
returns true if data is managed in a vector, i.e. operations like append are possible without copying the data into a vector
|
inlinedelete |
|
inline |
| bool JKQTPColumn::operator== | ( | const JKQTPColumn & | other | ) | const |
two columns are equal, if the same memory in the same datastore is referenced
|
inline |
returns a reference to the n -th row in this column
This may cause an access violation if the data is not present or referenced correctly. It does not throw explicit exceptions as at() does! On the other side, this function is faster that at().
|
inline |
returns a reference to the n -th row in this column (possibly throwing an exception if it does not exist!)
This may cause an access violation if the data is not present or referenced correctly. It does not throw explicit exceptions as at() does! On the other side, this function is faster that at().
|
inline |
append value to the column, Possibly converts the column to a vector column, if necessary
|
inline |
resize the column to new_size (possibly filling with added_vala ), Possibly converts the column to a vector column, if necessary
| void JKQTPColumn::scale | ( | double | factor | ) |
scales all members of the column with the given factor
| void JKQTPColumn::setAll | ( | double | value | ) |
set all values in the column to a specific value
| void JKQTPColumn::setImageColumns | ( | size_t | imageWidth | ) |
number of image columns, if the data in this column is interpreted as a row-major image (e.g. for display in a JKQTPMathImage )
| void JKQTPColumn::setName | ( | const QString & | __value | ) |
a name describing the column
|
inline |
sets the element at (x,y) in the column, where the data is interpreted as a row-major ordered Matrix of the width imageWidth
This method accesses the datastore and returns the double value stored in the (y*imageColumns+x)'th row of the according column.
|
inline |
sets the element at (x,y) in the column, where the data is interpreted as a row-major ordered Matrix of the given width
This method accesses the datastore and returns the double value stored in the (y*width+x)'th row of the according column.
|
inline |
sets the n'th value from the column
if the referenced entry does not exist for any reason, this function does not throw but simply exits!
| void JKQTPColumn::subtract | ( | double | value | ) |
subtracts a given value from all members of the column
|
friend |
|
friend |
|
friend |
|
private |
how data is represented in this JKQTPColumn
a pointer to the actual data (if storageType==StorageType::External )
|
private |
pointer to the datastore object used to manage the data of the plot
|
private |
iif storageType is StorageType::Vector, the data is actually save here
|
private |
number of image columns, if the data in this column is interpreted as a row-major image (e.g. for display in a JKQTPMathImage )
|
private |
a name describing the column
|
private |
number of rows in data
|
private |
specifies whether the datastore manages the memory (true , i.e. may also free the data) or whether the user application does this (false , i.e. the datastore never frees the data) .
|
private |
is this item valid/usable?