Column
C++ SDK API Documentation - Column
-
class Column : public AbstractColumn
Aspect that manages a column.
This class represents a column, i.e., (mathematically) a 1D vector of values with a header. It provides a public reading and (undo aware) writing interface as defined in AbstractColumn. A column can have one of currently three data types: double, QString, or QDateTime. The string representation of the values can differ depending on the mode of the column.
Column inherits from AbstractAspect and is intended to be a child of the corresponding Spreadsheet in the aspect hierarchy. Columns don’t have a view as they are intended to be displayed inside a spreadsheet.
type specific functions
-
virtual QIcon icon() const override
Return an icon to be used for decorating the views and spreadsheet column headers.
-
bool hasValues() const
return
true
if the column has at least one valid (not empty) value,false
otherwise.
-
bool hasValueAt(int row) const
return
true
if the column has a valid value in the row \row.
-
virtual Properties properties() const override
Column::properties Returns the column properties of this curve (monoton increasing, monoton decreasing, … )
See also
-
virtual QString textAt(int) const override
Return the content of row ‘row’.
Use this only when columnMode() is Text
-
virtual void setTextAt(int, const QString&) override
Set the content of row ‘row’.
Use this only when columnMode() is Text
-
virtual void replaceTexts(int, const QVector<QString>&) override
Replace a range of values.
Use this only when columnMode() is Text
-
virtual int dictionaryIndex(int row) const override
Return the position/index in the dictionary for the text value at.
Use this only when columnMode() is Text
- Parameters:
row –
-
virtual QDate dateAt(int) const override
Return the date part of row ‘row’.
Use this only when columnMode() is DateTime, Month or Day
-
virtual void setDateAt(int, QDate) override
Set the content of row ‘row’.
Use this only when columnMode() is DateTime, Month or Day
-
virtual QTime timeAt(int) const override
Return the time part of row ‘row’.
Use this only when columnMode() is DateTime, Month or Day
-
virtual void setTimeAt(int, QTime) override
Set the content of row ‘row’.
Use this only when columnMode() is DateTime, Month or Day
-
virtual QDateTime dateTimeAt(int) const override
Return the QDateTime in row ‘row’.
Use this only when columnMode() is DateTime, Month or Day
-
virtual void setDateTimeAt(int, const QDateTime&) override
Set the content of row ‘row’.
Use this only when columnMode() is DateTime, Month or Day
-
virtual void replaceDateTimes(int, const QVector<QDateTime>&) override
Replace a range of values.
Use this only when columnMode() is DateTime, Month or Day
-
virtual double doubleAt(int) const override
Return the double value in row ‘row’.
Use this only when columnMode() is Numeric
-
virtual double valueAt(int) const override
Return the double value in row ‘row’.
-
virtual void setValueAt(int, double) override
Set the content of row ‘row’.
Use this only when columnMode() is Numeric
-
virtual void replaceValues(int, const QVector<double>&) override
Replace a range of values.
Use this only when columnMode() is Numeric
-
virtual int integerAt(int) const override
Return the int value in row ‘row’.
-
virtual void setIntegerAt(int, int) override
Set the content of row ‘row’.
Use this only when columnMode() is Integer
-
virtual void replaceInteger(int, const QVector<int>&) override
Replace a range of values.
Use this only when columnMode() is Integer
-
virtual qint64 bigIntAt(int) const override
Return the bigint value in row ‘row’.
-
virtual void setBigIntAt(int, qint64) override
Set the content of row ‘row’.
Use this only when columnMode() is BigInt
-
virtual void replaceBigInt(int, const QVector<qint64>&) override
Replace a range of values.
Use this only when columnMode() is BigInt
serialize/deserialize
-
virtual AbstractColumn::ColumnMode columnMode() const override
Return the column mode.
This function is mostly used by spreadsheets but can also be used by plots. The column mode specifies how to interpret the values in the column additional to the data type.
-
virtual AbstractColumn::PlotDesignation plotDesignation() const override
Return the column plot designation.
-
virtual bool isReadOnly() const override
Return whether the object is read-only.
-
virtual int rowCount() const override
Return the data vector size.
-
virtual int availableRowCount(int max = -1) const override
Return the number of available data rows.
This returns the number of rows that actually contain data. Rows beyond this can be masked etc. but should be ignored by filters, plots etc.
-
ColumnStringIO *asStringColumn() const
Return a wrapper column object used for String I/O.
-
virtual void save(QXmlStreamWriter*) const override
Save the column as XML.
-
virtual bool load(XmlStreamReader*, bool preview) override
Load the column from XML.
-
void setFormula(const QString &formula, const QStringList &variableNames, const QVector<Column*> &columns, bool autoUpdate = false, bool autoResize = true)
Sets the formula used to generate column values.
-
QString formula() const
Returns the formula used to generate column values.
-
void clearFormula()
Clears the formula used to generate column values.
-
virtual void setFormula(const Interval<int>&, const QString&) override
Set a formula string for an interval of rows.
-
virtual void setFormula(int, const QString&) override
Overloaded function for convenience.
-
virtual void clearFormulas() override
Clear all formulas.
-
void updateFormula()
in case the cell values are calculated via a global column formula, updates the values on data changes in all the dependent changes in the “variable columns”.
-
virtual QString formula(int) const override
Return the formula associated with row ‘row’.
-
virtual QVector<Interval<int>> formulaIntervals() const override
Return the intervals that have associated formulas.
This can be used to make a list of formulas with their intervals. Here is some example code:
QStringList list; QVector< Interval<int> > intervals = my_column.formulaIntervals(); foreach(Interval<int> interval, intervals) list << QString(interval.toString() + ": " + my_column.formula(interval.start()));
-
virtual double maximum(int count = 0) const override
calculates the maximal value in the column. for
count
= 0, the maximum of all elements is returned. forcount
> 0, the maximum of the firstcount
elements is returned. forcount
< 0, the maximum of the lastcount
elements is returned.
-
virtual double maximum(int startIndex, int endIndex) const override
Column::maximum Calculates the maximum value in the column between the
startIndex
andendIndex
. If startIndex is greater than endIndex the indices are swappedstartIndex
endIndex
.
-
virtual double minimum(int count = 0) const override
calculates the minimal value in the column. for
count
= 0, the minimum of all elements is returned. forcount
> 0, the minimum of the firstcount
elements is returned. forcount
< 0, the minimum of the lastcount
elements is returned.
-
virtual double minimum(int startIndex, int endIndex) const override
Column::minimum Calculates the minimum value in the column between the
startIndex
andendIndex
, endIndex is excluded. If startIndex is greater than endIndex the indices are swappedstartIndex
endIndex
.
-
virtual bool indicesMinMax(double v1, double v2, int &start, int &end) const override
-
Finds the minimal and maximal index which are between v1 and v2
- Parameters:
v1 –
v2 –
start –
end –
- Returns:
-
static int calculateMaxSteps(unsigned int value)
calculates log2(x)+1 for an integer value. Used in y(double x) to calculate the maximum steps source: https://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers source: https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup
- Parameters:
value –
- Returns:
returns calculated value
-
static int indexForValue(double x, QVector<double> &column, Properties properties = Properties::No)
Find index which corresponds to a
x
. In a vector of values When monotonic increasing or decreasing a different algorithm will be used, which needs less steps (mean) (log_2(rowCount)) to find the value.- Parameters:
x –
- Returns:
-1 if index not found, otherwise the index
-
static int indexForValue(const double x, const QVector<QPointF> &column, Properties properties = Properties::No)
Find index which corresponds to a
x
. In a vector of values When monotonic increasing or decreasing a different algorithm will be used, which needs less steps (mean) (log_2(rowCount)) to find the value.- Parameters:
x –
- Returns:
-1 if index not found, otherwise the index
-
static int indexForValue(double x, QVector<QLineF> &lines, Properties properties = Properties::No)
Find index which corresponds to a
x
. In a vector of values When monotonic increasing or decreasing a different algorithm will be used, which needs less steps (mean) (log_2(rowCount)) to find the value.- Parameters:
x –
- Returns:
-1 if index not found, otherwise the index
Public Functions
-
void init()
Common part of ctors.
-
virtual QMenu *createContextMenu() override
Return a new context menu.
The caller takes ownership of the menu.
-
virtual void setColumnMode(AbstractColumn::ColumnMode) override
Set the column mode.
This sets the column mode and, if necessary, converts it to another datatype.
-
virtual bool copy(const AbstractColumn*) override
Copy another column of the same type.
This function will return false if the data type of ‘other’ is not the same as the type of ‘this’. Use a filter to convert a column to another type.
-
virtual bool copy(const AbstractColumn *source, int source_start, int dest_start, int num_rows) override
Copies a part of another column of the same type.
This function will return false if the data type of ‘other’ is not the same as the type of ‘this’.
- Parameters:
source – pointer to the column to copy
source_start – first row to copy in the column to copy
dest_start – first row to copy in
num_rows – the number of rows to copy
-
virtual void setPlotDesignation(AbstractColumn::PlotDesignation) override
Set the column plot designation.
-
int width() const
Get width.
-
void setWidth(const int)
Set width.
-
virtual void clear(QUndoCommand *parent = nullptr) override
Clear the content of the column (data and formula definition)
-
struct FormulaData
-
struct RandomValuesData
-
template<typename T>
struct ValueLabel
-
virtual QIcon icon() const override