Column

Aspect that manages a column.

Public Methods

void

Column(const QString &name, AbstractColumn::ColumnMode=ColumnMode::Double)

void

Column(const QString &name, const QVector< double > &data)

void

Column(const QString &name, const QVector< int > &data)

void

Column(const QString &name, const QVector< qint64 > &data)

void

Column(const QString &name, const QVector< QString > &data)

void

Column(const QString &name, const QVector< QDateTime > &data, ColumnMode)

void

addUsedInPlots(QVector< CartesianPlot * > &)

void

addValueLabel(qint64, const QString &)

void

addValueLabel(int, const QString &)

void

addValueLabel(double, const QString &)

void

addValueLabel(const QDateTime &, const QString &)

void

addValueLabel(const QString &, const QString &)

ColumnStringIO*

asStringColumn() const

int

availableRowCount(int max=-1) const override

qint64

bigIntAt(int) const override

const QVector< ValueLabel< qint64 > >*

bigIntValueLabels() const

QString

caption() const override

void

clear() override

void

clearFormula()

void

clearFormulas() override

AbstractColumn::ColumnMode

columnMode() const override

QString

columnModeString() const

bool

copy(const AbstractColumn *) override

bool

copy(const AbstractColumn *source, int source_start, int dest_start, int num_rows) override

QMenu*

createContextMenu() override

void*

data() const

QDate

dateAt(int) const override

QDateTime

dateTimeAt(int) const override

const QVector< ValueLabel< QDateTime > >*

dateTimeValueLabels() const

int

dictionaryIndex(int row) const override

double

doubleAt(int) const override

QVector< AspectType >

dropableOn() const override

void

finalizeLoad()

QString

formula() const

QString

formula(int) const override

bool

formulaAutoResize() const

bool

formulaAutoUpdate() const

const QVector< FormulaData >&

formulaData() const

QVector< Interval< int > >

formulaIntervals() const override

const QMap< QString, int >&

frequencies() const

bool

hasValueAt(int row) const

bool

hasValues() const

QIcon

icon() const override

int

indexForValue(double x, bool smaller) const override

int

indexForValue(double x, QVector< double > &column, Properties properties, bool smaller)

int

indexForValue(const double x, const QVector< QPointF > &column, Properties properties, bool smaller)

int

indexForValue(double x, QVector< QLineF > &lines, Properties properties, bool smaller)

bool

indicesMinMax(double v1, double v2, int &start, int &end) const override

void

init()

const QVector< ValueLabel< int > >*

intValueLabels() const

int

integerAt(int) const override

void

invalidateProperties() override

bool

isDraggable() const override

bool

isReadOnly() const override

bool

isValid(int row) const override

AbstractColumn::ColumnMode

labelsMode() const

bool

load(XmlStreamReader *, bool preview) override

double

maximum(int count=0) const override

double

maximum(int startIndex, int endIndex) const override

double

minimum(int count=0) const override

double

minimum(int startIndex, int endIndex) const override

AbstractSimpleFilter*

outputFilter() const

AbstractColumn::PlotDesignation

plotDesignation() const override

QString

plotDesignationString(bool withBrackets=true) const

Properties

properties() const override

RandomValuesData

randomValuesData() const

void

removeValueLabel(const QString &)

void

replaceBigInt(int, const QVector< qint64 > &) override

void

replaceDateTimes(int, const QVector< QDateTime > &) override

void

replaceInteger(int, const QVector< int > &) override

void

replaceTexts(int, const QVector< QString > &) override

void

replaceValues(int, const QVector< double > &) override

void

resizeTo(int)

int

rowCount() const override

int

rowCount(double min, double max) const override

void

save(QXmlStreamWriter *) const override

void

setAllValid()

void

setBigIntAt(int, qint64) override

void

setBigInts(const QVector< qint64 > &)

void

setColumnMode(AbstractColumn::ColumnMode) override

void

setColumnModeFast(AbstractColumn::ColumnMode)

void

setData(void *)

void

setDateAt(int, QDate) override

void

setDateTimeAt(int, const QDateTime &) override

void

setDateTimes(const QVector< QDateTime > &)

void

setFormulVariableColumn(int index, Column *)

void

setFormulVariableColumnsPath(int index, const QString &path)

void

setFormula(const QString &formula, const QStringList &variableNames, const QVector< Column * > &columns, bool autoUpdate=false, bool autoResize=true)

void

setFormula(const QString &formula, bool autoUpdate=false, bool autoResize=true)

void

setFormula(const Interval< int > &, const QString &) override

void

setFormula(int, const QString &) override

void

setFormulaVariableColumn(Column *)

void

setFromColumn(int, AbstractColumn *, int)

void

setIntegerAt(int, int) override

void

setIntegers(const QVector< int > &)

void

setLabelsMode(ColumnMode mode)

void

setPlotDesignation(AbstractColumn::PlotDesignation) override

void

setRandomValuesData(const RandomValuesData &)

void

setText(const QVector< QString > &)

void

setTextAt(int, const QString &) override

void

setTimeAt(int, QTime) override

void

setValid(int row, bool valid)

void

setValueAt(int, double) override

void

setValues(const QVector< double > &)

void

setWidth(const int)

const AbstractColumn::ColumnStatistics&

statistics() const

QString

textAt(int) const override

const QVector< ValueLabel< QString > >*

textValueLabels() const

QTime

timeAt(int) const override

void

updateLocale()

double

valueAt(int) const override

QString

valueLabelAt(int index) const

const QVector< ValueLabel< double > >*

valueLabels() const

int

valueLabelsCount() const

int

valueLabelsCount(double min, double max) const

int

valueLabelsIndexForValue(double x, bool smaller) const

bool

valueLabelsInitialized() const

double

valueLabelsMaximum() const

double

valueLabelsMinimum() const

void

valueLabelsRemoveAll()

double

valueLabelsValueAt(int index) const

int

width() const

Detailed Description

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, … )

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 bool isValid(int row) const override

Convenience method for mode-independent testing of validity.

void setAllValid()

Set all rows as valid.

Has to be called when the data is written directly to the data vector without using setValueAt() etc. and thus bypassing the validity tracking in the setters.

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 with explicit variable mapping.

Use this overload when you need full control over variable-to-column mapping, such as when referencing columns from different spreadsheets or when variable names in the formula don’t match the actual column names.

See also

setFormula(const QString&, bool, bool) for auto-discovery of columns

Note

Call updateFormula() after this to evaluate the formula.

Parameters:
  • formula – The formula expression (e.g., “x + y * 2”)

  • variableNames – List of variable names used in the formula (e.g., [“x”, “y”])

  • columns – List of Column pointers corresponding to each variable name

  • autoUpdate – If true, the formula recalculates when source columns change

  • autoResize – If true, the column resizes to match source column sizes

void setFormula(const QString &formula, bool autoUpdate = false, bool autoResize = true)

Sets the formula with auto-discovery of variable columns from the parent spreadsheet.

This convenience overload parses the formula to find variable names and automatically looks them up as columns in the parent spreadsheet. Use this for simple cases where variable names in the formula match column names in the same spreadsheet.

Note

Variables that don’t match any column name are ignored.

Note

Call updateFormula() after this to evaluate the formula.

Parameters:
  • formula – The formula expression (e.g., “x + y * 2”)

  • autoUpdate – If true, the formula recalculates when source columns change

  • autoResize – If true, the column resizes to match source column sizes

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. for count > 0, the maximum of the first count elements is returned. for count < 0, the maximum of the last count elements is returned.

virtual double maximum(int startIndex, int endIndex) const override

Column::maximum Calculates the maximum value in the column between the startIndex and endIndex. If startIndex is greater than endIndex the indices are swapped startIndex 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. for count > 0, the minimum of the first count elements is returned. for count < 0, the minimum of the last count elements is returned.

virtual double minimum(int startIndex, int endIndex) const override

Column::minimum Calculates the minimum value in the column between the startIndex and endIndex, endIndex is excluded. If startIndex is greater than endIndex the indices are swapped startIndex endIndex.

virtual bool indicesMinMax(double v1, double v2, int &start, int &end) const override

Column::indicesMinMax.

Finds the minimal and maximal index which are between v1 and v2

Parameters:
  • v1 –

  • v2 –

  • start –

  • end –

Returns:

static int indexForValue(double x, QVector<double> &column, Properties properties, bool smaller)

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, bool smaller)

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, bool smaller)

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() override

Clear the content of the column (data and formula definition)

struct FormulaData
struct RandomValuesData
template<typename T>
struct ValueLabel