Aquila
2.0 prealpha
Cognitive Robotics Architecture
|
Manages the position of an item. More...
#include <plot2d.h>
Public Types | |
enum | PositionType { ptAbsolute, ptViewportRatio, ptAxisRectRatio, ptPlotCoords } |
Public Member Functions | |
QCPItemPosition (QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name) | |
virtual | ~QCPItemPosition () |
PositionType | type () const |
QCPItemAnchor * | parentAnchor () const |
double | key () const |
double | value () const |
QPointF | coords () const |
QCPAxis * | keyAxis () const |
QCPAxis * | valueAxis () const |
virtual QPointF | pixelPoint () const |
void | setType (PositionType type) |
bool | setParentAnchor (QCPItemAnchor *parentAnchor, bool keepPixelPosition=false) |
void | setCoords (double key, double value) |
void | setCoords (const QPointF &coords) |
void | setAxes (QCPAxis *keyAxis, QCPAxis *valueAxis) |
void | setPixelPoint (const QPointF &pixelPoint) |
Public Member Functions inherited from QCPItemAnchor | |
QCPItemAnchor (QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1) | |
virtual | ~QCPItemAnchor () |
QString | name () const |
Protected Attributes | |
PositionType | mPositionType |
QCPAxis * | mKeyAxis |
QCPAxis * | mValueAxis |
double | mKey |
double | mValue |
QCPItemAnchor * | mParentAnchor |
Protected Attributes inherited from QCPItemAnchor | |
QCustomPlot * | mParentPlot |
QCPAbstractItem * | mParentItem |
int | mAnchorId |
QString | mName |
QSet< QCPItemPosition * > | mChildren |
Additional Inherited Members | |
Protected Member Functions inherited from QCPItemAnchor | |
void | addChild (QCPItemPosition *pos) |
void | removeChild (QCPItemPosition *pos) |
Manages the position of an item.
Every item has at least one public QCPItemPosition member pointer which provides ways to position the item on the QCustomPlot surface. Some items have multiple positions, for example QCPItemRect has two: topLeft and bottomRight.
QCPItemPosition has a type (PositionType) that can be set with setType. This type defines how coordinates passed to setCoords are to be interpreted, e.g. as absolute pixel coordinates, as plot coordinates of certain axes, etc.
Further, QCPItemPosition may have a parent QCPItemAnchor, see setParentAnchor. (Note that every QCPItemPosition inherits from QCPItemAnchor and thus can itself be used as parent anchor for other positions.) This way you can tie multiple items together. If the QCPItemPosition has a parent, the coordinates set with setCoords are considered to be absolute values in the reference frame of the parent anchor, where (0, 0) means directly ontop of the parent anchor. For example, You could attach the start position of a QCPItemLine to the bottom anchor of a QCPItemText to make the starting point of the line always be centered under the text label, no matter where the text is moved to, or is itself tied to.
To set the apparent pixel position on the QCustomPlot surface directly, use setPixelPoint. This works no matter what type this QCPItemPosition is or what parent-child situation it is in, as setPixelPoint transforms the coordinates appropriately, to make the position appear at the specified pixel values.
Defines the ways an item position can be specified. Thus it defines what the numbers passed to setCoords actually mean.
Enumerator | |
---|---|
ptAbsolute |
Static positioning in pixels, starting from the top left corner of the viewport/widget. |
ptViewportRatio |
Static positioning given by a ratio of the current viewport (coordinates 0 to 1). |
ptAxisRectRatio |
Static positioning given by a ratio of the current axis rect (coordinates 0 to 1). |
ptPlotCoords |
Dynamic positioning at a plot coordinate defined by two axes (see setAxes). |
QCPItemPosition::QCPItemPosition | ( | QCustomPlot * | parentPlot, |
QCPAbstractItem * | parentItem, | ||
const QString | name | ||
) |
Creates a new QCPItemPosition. You shouldn't create QCPItemPosition instances directly, even if you want to make a new item subclass. Use QCPAbstractItem::createPosition instead, as explained in the subclassing section of the QCPAbstractItem documentation.
|
virtual |
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Returns the final absolute pixel position of the QCPItemPosition on the QCustomPlot surface. It includes all effects of type (setType) and possible parent anchors (setParentAnchor).
Reimplemented from QCPItemAnchor.
void QCPItemPosition::setCoords | ( | double | key, |
double | value | ||
) |
Sets the coordinates of this QCPItemPosition. What the coordinates mean, is defined by the type (setType).
For example, if the type is ptAbsolute, key and value mean the x and y pixel position on the QCustomPlot surface where the origin (0, 0) is in the top left corner of the QCustomPlot viewport. If the type is ptPlotCoords, key and value mean a point in the plot coordinate system defined by the axes set by setAxes. (By default the QCustomPlot's x- and yAxis.)
void QCPItemPosition::setCoords | ( | const QPointF & | pos | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the coordinates as a QPointF pos where pos.x has the meaning of key and pos.y the meaning of value of the setCoords(double key, double value) function.
bool QCPItemPosition::setParentAnchor | ( | QCPItemAnchor * | parentAnchor, |
bool | keepPixelPosition = false |
||
) |
Sets the parent of this QCPItemPosition to parentAnchor. This means the position will now follow any position changes of the anchor. The local coordinate system of positions with a parent anchor always is absolute with (0, 0) being exactly on top of the parent anchor. (Hence the type shouldn't be ptPlotCoords for positions with parent anchors.)
if keepPixelPosition is true, the current pixel position of the QCPItemPosition is preserved during reparenting. If it's set to false, the coordinates are set to (0, 0), i.e. the position will be exactly on top of the parent anchor.
To remove this QCPItemPosition from any parent anchor, set parentAnchor to 0.
void QCPItemPosition::setPixelPoint | ( | const QPointF & | pixelPoint | ) |
Sets the apparent pixel position. This works no matter what type this QCPItemPosition is or what parent-child situation it is in, as setPixelPoint transforms the coordinates appropriately, to make the position appear at the specified pixel values.
Only if the type is ptAbsolute and no parent anchor is set, this function is identical to setCoords.
void QCPItemPosition::setType | ( | QCPItemPosition::PositionType | type | ) |
Sets the type of the position. The type defines how the coordinates passed to setCoords should be handled and how the QCPItemPosition should behave in the plot. Note that the position type ptPlotCoords is only available (and sensible) when the position has no parent anchor (setParentAnchor).
The possible values for type can be separated in two main categories:
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |