• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

Software development tool for distributed control systems

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • GUI - CDP Graph Widgets
  • DatabaseGraphWidget

DatabaseGraphWidget Class

(CDP::GraphWidgets::DatabaseGraphWidget)

The Database Graph widget allows users to plot values saved to database. More...

Header: #include <cdp/graphwidgets/databasegraphwidget.h>
  • List of all members, including inherited members

Properties

  • activeCursorColor : QColor
  • cdpLoggerRouting : QString
  • cssFile : const QString
  • currentTimeOffsetMs : int
  • databaseUrl : QUrl
  • disconnectOnHide : bool
  • exportFormat : CDP::GraphWidgets::GraphExport::Format
  • exportPath : QString
  • graphBackgroundColorEnd : QColor
  • graphBackgroundColorStart : QColor
  • graphPlottingMode : CDP::GraphWidgets::GraphPlotting::Mode
  • gridPenColorX : QColor
  • gridPenColorY : QColor
  • gridPenStyleX : Qt::PenStyle
  • gridPenStyleY : Qt::PenStyle
  • hoverCursorColor : QColor
  • legendFont : QFont
  • legendTextColor : QColor
  • legendVisible : bool
  • paintIntervalMs : int
  • pausedCursorColor : QColor
  • signalContentType : CDP::GraphWidgets::SignalContent::Type
  • table : QString
  • updateIntervalMs : uint
  • xAxisColumn : QString
  • xAxisFont : QFont
  • xAxisIntervalMSecs : qint64
  • xAxisMajorTickCount : uint
  • xAxisMinorTickCount : uint
  • xAxisPenColor : QColor
  • xAxisTextColor : QColor
  • xAxisTextSelectedColor : QColor
  • yAxisColumns : QStringList
  • yAxisFont : QFont
  • yAxisMajorTickCount : uint
  • yAxisMaxValue : double
  • yAxisMinValue : double
  • yAxisMinorTickCount : uint
  • yAxisPenColor : QColor
  • yAxisSumColumnEnabled : bool
  • yAxisTextColor : QColor
  • yAxisTextSelectedColor : QColor
  • yAxisValueMinPrecision : int

Public Functions

DatabaseGraphWidget(QWidget *parent = 0)
virtual ~DatabaseGraphWidget()
QColor activeCursorColor() const
QString cdpLoggerRouting()
int currentTimeOffsetMs() const
const QUrl &databaseUrl() const
bool disconnectOnHide() const
GraphExportFormat exportFormat() const
QString exportPath() const
const QColor &graphBackgroundColorEnd() const
const QColor &graphBackgroundColorStart() const
GraphPlottingMode graphPlottingMode() const
QColor gridPenColorX() const
QColor gridPenColorY() const
Qt::PenStyle gridPenStyleX() const
Qt::PenStyle gridPenStyleY() const
QColor hoverCursorColor() const
bool isLegendVisible() const
bool isYAxisSumColumnEnabled() const
const QFont &legendFont() const
const QColor &legendTextColor() const
int paintIntervalMs() const
QColor pausedCursorColor() const
void setActiveCursorColor(const QColor &color)
void setCdpLoggerRouting(const QString &routing)
void setExportFormat(GraphExportFormat format)
void setExportPath(const QString &path)
void setGraphBackgroundColorEnd(const QColor &color)
void setGraphBackgroundColorStart(const QColor &color)
void setGraphPlottingMode(GraphPlottingMode mode)
void setGridPenColorX(const QColor &color)
void setGridPenColorY(const QColor &color)
void setGridPenStyleX(Qt::PenStyle style)
void setGridPenStyleY(Qt::PenStyle style)
void setHoverCursorColor(const QColor &color)
void setLegendFont(const QFont &font)
void setLegendTextColor(const QColor &color)
void setPaintIntervalMs(int interval)
void setPausedCursorColor(const QColor &color)
void setSignalContentType(SignalContentType type)
void setUpdateIntervalMs(uint interval)
void setXAxisFont(const QFont &font)
void setXAxisMajorTickCount(uint count)
void setXAxisMinorTickCount(uint count)
void setXAxisPenColor(const QColor &color)
void setXAxisTextColor(const QColor &color)
void setXAxisTextSelectedColor(const QColor &color)
void setYAxisFont(const QFont &font)
void setYAxisMajorTickCount(uint count)
void setYAxisMinorTickCount(uint count)
void setYAxisPenColor(const QColor &color)
void setYAxisTextColor(const QColor &color)
void setYAxisTextSelectedColor(const QColor &color)
SignalContentType signalContentType() const
const QString &table() const
uint updateIntervalMs() const
const QString &xAxisColumn() const
const QFont &xAxisFont() const
qint64 xAxisIntervalMSecs() const
uint xAxisMajorTickCount() const
uint xAxisMinorTickCount() const
QColor xAxisPenColor() const
const QColor &xAxisTextColor() const
const QColor &xAxisTextSelectedColor() const
QStringList yAxisColumns() const
const QFont &yAxisFont() const
uint yAxisMajorTickCount() const
double yAxisMaxValue() const
double yAxisMinValue() const
uint yAxisMinorTickCount() const
QColor yAxisPenColor() const
const QColor &yAxisTextColor() const
const QColor &yAxisTextSelectedColor() const
int yAxisValueMinPrecision() const

Public Slots

void autoScale()
void exportData()
void hideWidget()
void pause()
void reconnectToDatabase()
void resume()
void scaleXAxis()
void scaleYAxis()
void setCurrentTimeOffsetMs(int offsetMs)
void setDatabaseUrl(const QUrl &url)
void setDisconnectOnHide(bool enabled)
void setInCommand(bool cmd)
void setLegendVisible(bool visible)
void setPauseEnabled(bool enabled)
void setSmoothPixmap(bool smooth)
void setTable(const QString &table)
void setWidgetFont(const QString &font)
void setWidgetStyle(int style)
void setWidgetTheme(const QString &theme)
void setXAxisColumn(const QString &column)
void setXAxisIntervalMSecs(qint64 msecs)
void setYAxisColumns(const QStringList &columns)
void setYAxisColumns(const ColumnList &columns)
void setYAxisMaxValue(double value)
void setYAxisMinValue(double value)
void setYAxisSumColumnEnabled(bool enabled)
void setYAxisValueMinPrecision(int precision)
void showWidget()

Signals

void connectedChanged(bool status)
void connectionStatus(const QString &statusString)
void databaseUrlChanged(const QUrl &url)
void exportFailed()
void exportFinished(bool success)
void exportProgressChanged(int progress)
void exportStarted()
void loadingChanged(bool status)
void pauseEnabledChanged(bool enabled)
void xAxisRangeReceived()

Detailed Description

The Database Graph widget allows users to plot values saved to database.

The widget is able to:

  • Open any SQLite database file. Just select the table and specify which column is x-axis and which is y-axis.
  • Connect directly to CDP Logger built-in server.
  • Open the database file created by CDP Logger default back-end CDPCompactDatastore (custom format is automatically detected).

Modes

There are three different plotting modes: standstill, wrapping and scrolling. The first one is meant for analyzing static data. Latter two however are useful when values are dynamically added to database, for example when connecting to a running CDP Logger.

  • Standstill mode is meant for analyzing static data. When opening database, the widget will fit on screen all values. After that the user may zoom in and pan.
  • Wrapping mode has steady x-axis where data is changing along with updated beam. The beam indicates current time, while in pause it shows the time the graph was paused.
  • Scrolling mode has moving x-axis on the graph where current time is always on the right side of the plotting area.

Configuring

SQL Database

To open a generic database file, you must first specify the databaseUrl property. At the moment SQLite and MySQL database systems are supported.

Examples:

Database systemdatabaseUrl
SQLitePath to the database file, e.g. "file:///directory-path/database-file.db"
MySQLThe connection string, e.g. "mysql://user:password@127.0.0.1:3306/database-name"

Next set the following properties:

PropertyValue
tableName of the database table to plot
xAxisColumnName of the column in selected table to use as x-axis on the plot
yAxisColumnsList of columns in the same table that are used for y-axis.

CDP Logger Database

The preffered way to view logged data is to connect to the built-in server of a running CDP Logger. In case the logger is configured to log to a local database file using CDPCompactDatastore, it is also possible to open the file directly.

First the databaseUrl property must be filled:

TargetdatabaseUrl example
CDP Logger built-in serverip://127.0.0.1:17000
CDPCompactDatastore database filefile:///directory-path/database-file.db

The hardcoded path in databaseUrl can be avoided using the optional cdpLoggerRouting property. Configure it with routing to the CDP Logger component. Ip and port will be retrieved in run-time:

PropertyValue
cdpLoggerRoutingApplication.CDPLogger

After that you must set the y-axis columns to display. The list of available values can be found by looking at the Name column of the LoggedValues table in your CDP Logger configuration.

PropertyValue
yAxisColumnsList of values logged by CDP Logger.

It is not necessary to fill table and xAxisColumn properties.

Selecting Columns Dynamically

Alternative to filling the yAxisColumns described in previous section is to use either DB Graph Signal Selector widget or DB Graph Configuration widget. The output of these widgets must be connected to setYAxisColumns() slot. Then it is possible to select during runtime which values to plot.

Property Documentation

activeCursorColor : QColor

Access functions:

QColor activeCursorColor() const
void setActiveCursorColor(const QColor &color)

cdpLoggerRouting : QString

This property holds routing to CDP Logger component to connect. Will override connection string set in databaseUrl.

Access functions:

QString cdpLoggerRouting()
void setCdpLoggerRouting(const QString &routing)

See also databaseUrl.

cssFile : const QString

This property holds the css file to style the widget.

currentTimeOffsetMs : int

This property holds the offset to current time.

Affects scrolling and wrapping mode. Useful when database connection has some latency, meaning that data appearing on the graph is "behind" current time.

Access functions:

int currentTimeOffsetMs() const
void setCurrentTimeOffsetMs(int offsetMs)

databaseUrl : QUrl

This property holds connection string to the database.

Examples:

TargetConnection string
CDP Logger built-in serverip://127.0.0.1:17000
CDPCompactDatastore filefile:///directory-path/log.db
SQLite database filefile:///directory-path/database-file.db
MySQL databasemysql://user:password@127.0.0.1:3306/database-name

Note: Consider using cdpLoggerRouting instead of hardcoded string when connecting to CDP Logger built-in server.

Access functions:

const QUrl &databaseUrl() const
void setDatabaseUrl(const QUrl &url)

See also cdpLoggerRouting.

disconnectOnHide : bool

This property specifies if we should disconnect and pause the graph while hidden to reduce cpu usage.

Access functions:

bool disconnectOnHide() const
void setDisconnectOnHide(bool enabled)

exportFormat : CDP::GraphWidgets::GraphExport::Format

This property specifies the file format used in export data.

  • CSV for comma-seperated values to be used by third party tools.
  • DB for CDP Compact Datastore that can be opened with Database Graph Widget and CDP Studio Analyze mode.

Access functions:

GraphExportFormat exportFormat() const
void setExportFormat(GraphExportFormat format)

exportPath : QString

This property holds directory path where the plot data is exported. For each export a new file is created in that directory. If left empty, application directory is used.

Access functions:

QString exportPath() const
void setExportPath(const QString &path)

graphBackgroundColorEnd : QColor

Graph's plotting area background is drawn as gradient from upper-left to lower-right corner. This is the gradient's ending color.

Access functions:

const QColor &graphBackgroundColorEnd() const
void setGraphBackgroundColorEnd(const QColor &color)

See also graphBackgroundColorStart.

graphBackgroundColorStart : QColor

Graph's plotting area background is drawn as gradient from upper-left to lower-right corner. This is the gradient's starting color.

Access functions:

const QColor &graphBackgroundColorStart() const
void setGraphBackgroundColorStart(const QColor &color)

See also graphBackgroundColorEnd.

graphPlottingMode : CDP::GraphWidgets::GraphPlotting::Mode

This property holds the plotting mode.

Access functions:

GraphPlottingMode graphPlottingMode() const
void setGraphPlottingMode(GraphPlottingMode mode)

gridPenColorX : QColor

This property holds the color of vertical grid lines.

Access functions:

QColor gridPenColorX() const
void setGridPenColorX(const QColor &color)

gridPenColorY : QColor

This property holds the color of horizontal grid lines.

Access functions:

QColor gridPenColorY() const
void setGridPenColorY(const QColor &color)

gridPenStyleX : Qt::PenStyle

This property holds the style of vertical grid lines.

Access functions:

Qt::PenStyle gridPenStyleX() const
void setGridPenStyleX(Qt::PenStyle style)

gridPenStyleY : Qt::PenStyle

This property holds the style of horizontal grid lines.

Access functions:

Qt::PenStyle gridPenStyleY() const
void setGridPenStyleY(Qt::PenStyle style)

hoverCursorColor : QColor

Access functions:

QColor hoverCursorColor() const
void setHoverCursorColor(const QColor &color)

legendFont : QFont

This property holds the font of signal names in legend.

Access functions:

const QFont &legendFont() const
void setLegendFont(const QFont &font)

legendTextColor : QColor

This property holds the color of signal names in legend.

Access functions:

const QColor &legendTextColor() const
void setLegendTextColor(const QColor &color)

legendVisible : bool

Access functions:

bool isLegendVisible() const
void setLegendVisible(bool visible)

paintIntervalMs : int

This property specifies how often the graph should get painted. Increase the number to reduce the load on slow hardware. When the x-axis range is large, the graph will update just as smooth.

Access functions:

int paintIntervalMs() const
void setPaintIntervalMs(int interval)

pausedCursorColor : QColor

Access functions:

QColor pausedCursorColor() const
void setPausedCursorColor(const QColor &color)

signalContentType : CDP::GraphWidgets::SignalContent::Type

This property specifies whether to display signal name or full path (when both are available).

Access functions:

SignalContentType signalContentType() const
void setSignalContentType(SignalContentType type)

table : QString

This property holds the name of the table to plot.

Access functions:

const QString &table() const
void setTable(const QString &table)

updateIntervalMs : uint

This property specifies how often data is refreshed from the database.

Access functions:

uint updateIntervalMs() const
void setUpdateIntervalMs(uint interval)

xAxisColumn : QString

This property holds the column whose values are displayed on the horizontal axis.

Access functions:

const QString &xAxisColumn() const
void setXAxisColumn(const QString &column)

xAxisFont : QFont

This property holds the font of x-axis labels.

Access functions:

const QFont &xAxisFont() const
void setXAxisFont(const QFont &font)

xAxisIntervalMSecs : qint64

This property holds the x-axis interval in milliseconds.

Access functions:

qint64 xAxisIntervalMSecs() const
void setXAxisIntervalMSecs(qint64 msecs)

xAxisMajorTickCount : uint

This property holds the number of x-axis major ticks which determine vertical grid line and labels count.

Note: The count is taken as a hint. The actual number of ticks may be different.

Access functions:

uint xAxisMajorTickCount() const
void setXAxisMajorTickCount(uint count)

xAxisMinorTickCount : uint

This property holds the number of ticks between x-axis major ticks (both edges included).

Note: The count is taken as a hint. The actual number of ticks may be different.

Access functions:

uint xAxisMinorTickCount() const
void setXAxisMinorTickCount(uint count)

See also xAxisMajorTickCount.

xAxisPenColor : QColor

This property holds the color of x-axis line and ticks.

Access functions:

QColor xAxisPenColor() const
void setXAxisPenColor(const QColor &color)

xAxisTextColor : QColor

This property holds the color of x-axis label text.

Access functions:

const QColor &xAxisTextColor() const
void setXAxisTextColor(const QColor &color)

xAxisTextSelectedColor : QColor

This property holds the color of x-axis label text when the axis is selected.

Access functions:

const QColor &xAxisTextSelectedColor() const
void setXAxisTextSelectedColor(const QColor &color)

yAxisColumns : QStringList

This property holds the list of column names for the y-axis.

Access functions:

QStringList yAxisColumns() const
void setYAxisColumns(const QStringList &columns)
void setYAxisColumns(const ColumnList &columns)

yAxisFont : QFont

This property holds the font of y-axis labels.

Access functions:

const QFont &yAxisFont() const
void setYAxisFont(const QFont &font)

yAxisMajorTickCount : uint

This property holds the number of y-axis major ticks, which determine vertical grid line and labels count.

Note: The count is taken as a hint. The actual number of ticks may be different.

Access functions:

uint yAxisMajorTickCount() const
void setYAxisMajorTickCount(uint count)

yAxisMaxValue : double

This property holds the y-axis maximum value.

Access functions:

double yAxisMaxValue() const
void setYAxisMaxValue(double value)

yAxisMinValue : double

This property holds the y-axis minimum value.

Access functions:

double yAxisMinValue() const
void setYAxisMinValue(double value)

yAxisMinorTickCount : uint

This property holds the number of ticks between y-axis major ticks (both edges included).

Note: The count is taken as a hint. The actual number of ticks may be different.

Access functions:

uint yAxisMinorTickCount() const
void setYAxisMinorTickCount(uint count)

See also yAxisMajorTickCount.

yAxisPenColor : QColor

This property holds the color of y-axis line and ticks.

Access functions:

QColor yAxisPenColor() const
void setYAxisPenColor(const QColor &color)

yAxisSumColumnEnabled : bool

This property holds whether to display an additional line that is the sum of all other plotted values.

Access functions:

bool isYAxisSumColumnEnabled() const
void setYAxisSumColumnEnabled(bool enabled)

yAxisTextColor : QColor

This property holds the color of y-axis label text.

Access functions:

const QColor &yAxisTextColor() const
void setYAxisTextColor(const QColor &color)

yAxisTextSelectedColor : QColor

This property holds the color of y-axis label text when the axis is selected.

Access functions:

const QColor &yAxisTextSelectedColor() const
void setYAxisTextSelectedColor(const QColor &color)

yAxisValueMinPrecision : int

This property holds the minimim precision for y-axis value labels.

Access functions:

int yAxisValueMinPrecision() const
void setYAxisValueMinPrecision(int precision)

Member Function Documentation

DatabaseGraphWidget::DatabaseGraphWidget(QWidget *parent = 0)

Constructs an instance of DatabaseGraphWidget with parent

[virtual] DatabaseGraphWidget::~DatabaseGraphWidget()

Destroys the instance of DatabaseGraphWidget. The destructor is virtual.

[slot] void DatabaseGraphWidget::autoScale()

Fits signals data into the plotting area. Functionality is dependant on axis selection.

[signal] void DatabaseGraphWidget::connectedChanged(bool status)

Emitted when connection to database status is changed. Argument status is true if connection was established and false if connection was lost.

[signal] void DatabaseGraphWidget::connectionStatus(const QString &statusString)

Emitted when connection to database status is changed. Argument statusString is the name of the new status.

[signal] void DatabaseGraphWidget::databaseUrlChanged(const QUrl &url)

Emitted when database url is changed. Argument url is the name of the new url.

[slot] void DatabaseGraphWidget::exportData()

Exports visible data to CSV file. See exportDir for location of files.

[signal] void DatabaseGraphWidget::exportFailed()

Emitted when export has failed.

[signal] void DatabaseGraphWidget::exportFinished(bool success)

Emitted when export is finished. Argument success is True when export succeeds, otherwise false.

[signal] void DatabaseGraphWidget::exportProgressChanged(int progress)

Emitted when export progress is changed. Argument progress value ranges between 0 and 100.

[signal] void DatabaseGraphWidget::exportStarted()

Emitted when export is started.

[slot] void DatabaseGraphWidget::hideWidget()

[signal] void DatabaseGraphWidget::loadingChanged(bool status)

Emitted when loading status is changed. Argument status is true if any database queries are loading.

[slot] void DatabaseGraphWidget::pause()

Enables pause. This convenience function is equivalent to calling setPauseEnabled(true).

See also setPauseEnabled() and resume().

[signal] void DatabaseGraphWidget::pauseEnabledChanged(bool enabled)

Emitted when widget is paused or resumed. Argument enabled is true if widget has been paused.

[slot] void DatabaseGraphWidget::reconnectToDatabase()

Tries to reconnects if connection to database has been lost.

[slot] void DatabaseGraphWidget::resume()

Disables pause. This convenience function is equivalent to calling setPauseEnabled(false).

See also setPauseEnabled() and pause().

[slot] void DatabaseGraphWidget::scaleXAxis()

Scales the x-axis to fit signal data into the plotting area.

[slot] void DatabaseGraphWidget::scaleYAxis()

Scales the y-axis to fit signal data into the plotting area.

[slot] void DatabaseGraphWidget::setInCommand(bool cmd)

[slot] void DatabaseGraphWidget::setPauseEnabled(bool enabled)

Enables pause if enabled is true. Otherwise disables pause. When pause is enabled, y-axis range and plots are not updated.

See also pause() and resume().

[slot] void DatabaseGraphWidget::setSmoothPixmap(bool smooth)

[slot] void DatabaseGraphWidget::setWidgetFont(const QString &font)

[slot] void DatabaseGraphWidget::setWidgetStyle(int style)

[slot] void DatabaseGraphWidget::setWidgetTheme(const QString &theme)

[slot] void DatabaseGraphWidget::showWidget()

[signal] void DatabaseGraphWidget::xAxisRangeReceived()

Emitted after database initial connection is made and the x-axis range of plotted columns is received. This signal can be connected to the autoScale() slot to make sure data fits into the plotting area.

See also autoScale(), scaleXAxis(), and scaleYAxis().

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

Follow CDP

    © Copyright 2021 CDP Technologies. Privacy and cookie policy.

    Return to top