Nakuja Flight Computer Testing and Simulation Engine (NaFCTSE) 1.0
A testing and verification tool for the Nakuja Rocket Project flight computers
|
A radial graph used to display data in polar plots. More...
Public Types | |
enum | LineStyle { lsNone , lsLine } |
Signals | |
void | selectionChanged (bool selected) |
void | selectionChanged (const QCPDataSelection &selection) |
void | selectableChanged (QCP::SelectionType selectable) |
Signals inherited from QCPLayerable | |
void | layerChanged (QCPLayer *newLayer) |
Public Member Functions | |
QCPPolarGraph (QCPPolarAxisAngular *keyAxis, QCPPolarAxisRadial *valueAxis) | |
QString | name () const |
bool | antialiasedFill () const |
bool | antialiasedScatters () const |
QPen | pen () const |
QBrush | brush () const |
bool | periodic () const |
QCPPolarAxisAngular * | keyAxis () const |
QCPPolarAxisRadial * | valueAxis () const |
QCP::SelectionType | selectable () const |
bool | selected () const |
QCPDataSelection | selection () const |
QSharedPointer< QCPGraphDataContainer > | data () const |
LineStyle | lineStyle () const |
QCPScatterStyle | scatterStyle () const |
void | setName (const QString &name) |
void | setAntialiasedFill (bool enabled) |
void | setAntialiasedScatters (bool enabled) |
void | setPen (const QPen &pen) |
void | setBrush (const QBrush &brush) |
void | setPeriodic (bool enabled) |
void | setKeyAxis (QCPPolarAxisAngular *axis) |
void | setValueAxis (QCPPolarAxisRadial *axis) |
Q_SLOT void | setSelectable (QCP::SelectionType selectable) |
Q_SLOT void | setSelection (QCPDataSelection selection) |
void | setData (QSharedPointer< QCPGraphDataContainer > data) |
void | setData (const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false) |
void | setLineStyle (LineStyle ls) |
void | setScatterStyle (const QCPScatterStyle &style) |
void | addData (const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false) |
void | addData (double key, double value) |
void | coordsToPixels (double key, double value, double &x, double &y) const |
const QPointF | coordsToPixels (double key, double value) const |
void | pixelsToCoords (double x, double y, double &key, double &value) const |
void | pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const |
void | rescaleAxes (bool onlyEnlarge=false) const |
void | rescaleKeyAxis (bool onlyEnlarge=false) const |
void | rescaleValueAxis (bool onlyEnlarge=false, bool inKeyRange=false) const |
bool | addToLegend (QCPLegend *legend) |
bool | addToLegend () |
bool | removeFromLegend (QCPLegend *legend) const |
bool | removeFromLegend () const |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const |
virtual QCPPlottableInterface1D * | interface1D () |
virtual QCPRange | getKeyRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const |
virtual QCPRange | getValueRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const |
Public Member Functions inherited from QCPLayerable | |
QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr) | |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayerable * | parentLayerable () const |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
Q_SLOT bool | setLayer (QCPLayer *layer) |
bool | setLayer (const QString &layerName) |
void | setAntialiased (bool enabled) |
bool | realVisibility () const |
Protected Member Functions | |
virtual QRect | clipRect () const |
virtual void | draw (QCPPainter *painter) |
virtual QCP::Interaction | selectionCategory () const |
void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) |
virtual void | deselectEvent (bool *selectionStateChanged) |
virtual void | drawLinePlot (QCPPainter *painter, const QVector< QPointF > &lines) const |
virtual void | drawFill (QCPPainter *painter, QVector< QPointF > *lines) const |
virtual void | drawScatterPlot (QCPPainter *painter, const QVector< QPointF > &scatters, const QCPScatterStyle &style) const |
virtual void | drawLegendIcon (QCPPainter *painter, const QRectF &rect) const |
void | applyFillAntialiasingHint (QCPPainter *painter) const |
void | applyScattersAntialiasingHint (QCPPainter *painter) const |
double | pointDistance (const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const |
virtual int | dataCount () const |
void | getDataSegments (QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const |
void | drawPolyline (QCPPainter *painter, const QVector< QPointF > &lineData) const |
void | getVisibleDataBounds (QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const |
void | getLines (QVector< QPointF > *lines, const QCPDataRange &dataRange) const |
void | getScatters (QVector< QPointF > *scatters, const QCPDataRange &dataRange) const |
void | getOptimizedLineData (QVector< QCPGraphData > *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const |
void | getOptimizedScatterData (QVector< QCPGraphData > *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const |
QVector< QPointF > | dataToLines (const QVector< QCPGraphData > &data) const |
Protected Member Functions inherited from QCPLayerable | |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) |
virtual void | mousePressEvent (QMouseEvent *event, const QVariant &details) |
virtual void | mouseMoveEvent (QMouseEvent *event, const QPointF &startPos) |
virtual void | mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos) |
virtual void | mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details) |
virtual void | wheelEvent (QWheelEvent *event) |
void | initializeParentPlot (QCustomPlot *parentPlot) |
void | setParentLayerable (QCPLayerable *parentLayerable) |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
Protected Attributes | |
QSharedPointer< QCPGraphDataContainer > | mDataContainer |
LineStyle | mLineStyle |
QCPScatterStyle | mScatterStyle |
QString | mName |
bool | mAntialiasedFill |
bool | mAntialiasedScatters |
QPen | mPen |
QBrush | mBrush |
bool | mPeriodic |
QPointer< QCPPolarAxisAngular > | mKeyAxis |
QPointer< QCPPolarAxisRadial > | mValueAxis |
QCP::SelectionType | mSelectable |
QCPDataSelection | mSelection |
Protected Attributes inherited from QCPLayerable | |
bool | mVisible |
QCustomPlot * | mParentPlot |
QPointer< QCPLayerable > | mParentLayerable |
QCPLayer * | mLayer |
bool | mAntialiased |
Friends | |
class | QCPPolarLegendItem |
A radial graph used to display data in polar plots.
Defines how the graph's line is represented visually in the plot. The line is drawn with the current pen of the graph (setPen).
Enumerator | |
---|---|
lsNone | data points are not connected with any lines (e.g. data only represented with symbols according to the scatter style, see setScatterStyle) |
lsLine | data points are connected by a straight line |
QCPPolarGraph::QCPPolarGraph | ( | QCPPolarAxisAngular * | keyAxis, |
QCPPolarAxisRadial * | valueAxis ) |
Constructs a graph which uses keyAxis as its angular and valueAxis as its radial axis. keyAxis and valueAxis must reside in the same QCustomPlot, and the radial axis must be associated with the angular axis. If either of these restrictions is violated, a corresponding message is printed to the debug output (qDebug), the construction is not aborted, though.
The created QCPPolarGraph is automatically registered with the QCustomPlot instance inferred from keyAxis. This QCustomPlot instance takes ownership of the QCPPolarGraph, so do not delete it manually but use QCPPolarAxisAngular::removeGraph() instead.
To directly create a QCPPolarGraph inside a plot, you shoud use the QCPPolarAxisAngular::addGraph method.
|
protectedvirtual |
Implements QCPLayerable.
|
protectedvirtual |
Reimplemented from QCPLayerable.
void QCPPolarGraph::coordsToPixels | ( | double | key, |
double | value, | ||
double & | x, | ||
double & | y ) const |
Use this method to set an own QCPSelectionDecorator (subclass) instance. This allows you to customize the visual representation of selected data ranges further than by using the default QCPSelectionDecorator.
The plottable takes ownership of the decorator.
The currently set decorator can be accessed via selectionDecorator.
|
protectedvirtual |
Reimplemented from QCPLayerable.
|
protectedvirtual |
Implements QCPLayerable.
|
protectedvirtual |
Reimplemented from QCPLayerable.
|
protectedvirtual |
Reimplemented from QCPLayerable.
|
virtual |
This function is used to decide whether a click hits a layerable object or not.
pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.
If the object is represented not by single lines but by an area like a QCPItemText or the bars of a QCPBars plottable, a click inside the area should also be considered a hit. In these cases this function thus returns a constant value greater zero but still below the parent plot's selection tolerance. (typically the selectionTolerance multiplied by 0.99).
Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).
The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/ deselectEvent methods.
details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.
In the case of 1D Plottables (QCPAbstractPlottable1D, like QCPGraph or QCPBars) details will be set to a QCPDataSelection, describing the closest data point to pos.
You may pass nullptr
as details to indicate that you are not interested in those selection details.
Reimplemented from QCPLayerable.
void QCPPolarGraph::setAntialiasedFill | ( | bool | enabled | ) |
Sets whether fills of this plottable are drawn antialiased or not.
Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
void QCPPolarGraph::setAntialiasedScatters | ( | bool | enabled | ) |
Sets whether the scatter symbols of this plottable are drawn antialiased or not.
Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
void QCPPolarGraph::setBrush | ( | const QBrush & | brush | ) |
void QCPPolarGraph::setData | ( | const QVector< double > & | keys, |
const QVector< double > & | values, | ||
bool | alreadySorted = false ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Replaces the current data with the provided points in keys and values. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.
If you can guarantee that the passed data points are sorted by keys in ascending order, you can set alreadySorted to true, to improve performance by saving a sorting run.
void QCPPolarGraph::setData | ( | QSharedPointer< QCPGraphDataContainer > | data | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Replaces the current data container with the provided data container.
Since a QSharedPointer is used, multiple QCPPolarGraphs may share the same data container safely. Modifying the data in the container will then affect all graphs that share the container. Sharing can be achieved by simply exchanging the data containers wrapped in shared pointers:
If you do not wish to share containers, but create a copy from an existing container, rather use the QCPDataContainer<DataType>::set method on the graph's data container directly:
void QCPPolarGraph::setKeyAxis | ( | QCPPolarAxisAngular * | axis | ) |
The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.
Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).
void QCPPolarGraph::setLineStyle | ( | LineStyle | ls | ) |
Sets how the single data points are connected in the plot. For scatter-only plots, set ls to lsNone and setScatterStyle to the desired scatter style.
void QCPPolarGraph::setName | ( | const QString & | name | ) |
The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). It may contain any UTF-8 characters, including newlines.
void QCPPolarGraph::setPen | ( | const QPen & | pen | ) |
void QCPPolarGraph::setScatterStyle | ( | const QCPScatterStyle & | style | ) |
Sets the visual appearance of single data points in the plot. If set to QCPScatterStyle::ssNone, no scatter points are drawn (e.g. for line-only-plots with appropriate line style).
void QCPPolarGraph::setSelectable | ( | QCP::SelectionType | selectable | ) |
Sets whether and to which granularity this plottable can be selected.
A selection can happen by clicking on the QCustomPlot surface (When QCustomPlot::setInteractions contains QCP::iSelectPlottables), by dragging a selection rect (When QCustomPlot::setSelectionRectMode is QCP::srmSelect), or programmatically by calling setSelection.
void QCPPolarGraph::setSelection | ( | QCPDataSelection | selection | ) |
Sets which data ranges of this plottable are selected. Selected data ranges are drawn differently (e.g. color) in the plot. This can be controlled via the selection decorator (see selectionDecorator).
The entire selection mechanism for plottables is handled automatically when QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when you wish to change the selection state programmatically.
Using setSelectable you can further specify for each plottable whether and to which granularity it is selectable. If selection is not compatible with the current QCP::SelectionType set via setSelectable, the resulting selection will be adjusted accordingly (see QCPDataSelection::enforceType).
emits the selectionChanged signal when selected is different from the previous selection state.
void QCPPolarGraph::setValueAxis | ( | QCPPolarAxisRadial * | axis | ) |
The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.
Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).