Responsible for drawing the grid of a QCPAxis. More...
Public Functions | |
QCPGrid (QCPAxis *parentAxis) | |
bool | subGridVisible () const |
bool | antialiasedSubGrid () const |
bool | antialiasedZeroLine () const |
QPen | pen () const |
QPen | subGridPen () const |
QPen | zeroLinePen () const |
void | setSubGridVisible (bool visible) |
void | setAntialiasedSubGrid (bool enabled) |
void | setAntialiasedZeroLine (bool enabled) |
void | setPen (const QPen &pen) |
void | setSubGridPen (const QPen &pen) |
void | setZeroLinePen (const QPen &pen) |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
bool | setLayer (QCPLayer *layer) |
bool | setLayer (const QString &layerName) |
void | setAntialiased (bool enabled) |
Protected Functions | |
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
virtual void | draw (QCPPainter *painter) |
void | drawGridLines (QCPPainter *painter) const |
void | drawSubGridLines (QCPPainter *painter) const |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
virtual QRect | clipRect () const |
Responsible for drawing the grid of a QCPAxis.
This class is tightly bound to QCPAxis. Every axis owns a grid instance internally and uses it to draw the grid. Normally, you don't need to interact with the QCPGrid instance, because QCPAxis reproduces the grid interface in its own interface.
The axis and grid drawing was split into two classes to allow them to be placed on different layers (both QCPAxis and QCPGrid inherit from QCPLayerable). So it is possible to have the grid at the background and the axes in the foreground, and any plottables/items in between. This described situation is the default setup, see QCPLayer documentation.
QCPGrid::QCPGrid | ( | QCPAxis * | parentAxis | ) |
void QCPGrid::setSubGridVisible | ( | bool | visible | ) |
Sets whether grid lines at sub tick marks are drawn.
void QCPGrid::setAntialiasedSubGrid | ( | bool | enabled | ) |
Sets whether sub grid lines are drawn antialiased.
void QCPGrid::setAntialiasedZeroLine | ( | bool | enabled | ) |
Sets whether zero lines are drawn antialiased.
void QCPGrid::setPen | ( | const QPen & | pen | ) |
Sets the pen with which (major) grid lines are drawn.
void QCPGrid::setSubGridPen | ( | const QPen & | pen | ) |
Sets the pen with which sub grid lines are drawn.
void QCPGrid::setZeroLinePen | ( | const QPen & | pen | ) |
Sets the pen with which zero lines are drawn.
Zero lines are lines at coordinate 0 which may be drawn with a different pen than other grid lines. To disable zero lines and just draw normal grid lines at zero, set pen to Qt::NoPen.
void QCPGrid::applyDefaultAntialiasingHint | ( | QCPPainter * | painter | ) | const [protected, virtual] |
A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing the major grid lines.
This is the antialiasing state the painter passed to the draw method is in by default.
This function takes into account the local setting of the antialiasing flag as well as the overrides set e.g. with QCustomPlot::setNotAntialiasedElements.
Implements QCPLayerable.
void QCPGrid::draw | ( | QCPPainter * | painter | ) | [protected, virtual] |
Draws grid lines and sub grid lines at the positions of (sub) ticks of the parent axis, spanning over the complete axis rect. Also draws the zero line, if appropriate (setZeroLinePen).
Called by QCustomPlot::draw to draw the grid of an axis.
Implements QCPLayerable.
void QCPGrid::drawGridLines | ( | QCPPainter * | painter | ) | const [protected] |
Draws the main grid lines and possibly a zero line with the specified painter.
This is a helper function called by draw.
void QCPGrid::drawSubGridLines | ( | QCPPainter * | painter | ) | const [protected] |
Draws the sub grid lines with the specified painter.
This is a helper function called by draw.
void QCPLayerable::setVisible | ( | bool | on | ) | [inherited] |
Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click/selection) is not possible.
bool QCPLayerable::setLayer | ( | QCPLayer * | layer | ) | [inherited] |
Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.
Returns true on success, i.e. if layer is a valid layer.
bool QCPLayerable::setLayer | ( | const QString & | layerName | ) | [inherited] |
This is an overloaded function.
Sets the layer of this layerable object by name
Returns true on success, i.e. if layerName is a valid layer name.
void QCPLayerable::setAntialiased | ( | bool | enabled | ) | [inherited] |
Sets whether this object will be drawn antialiased or not.
Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
bool QCPLayerable::moveToLayer | ( | QCPLayer * | layer, |
bool | prepend | ||
) | [protected, inherited] |
Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.
Returns true on success, i.e. if layer is a valid layer.
void QCPLayerable::applyAntialiasingHint | ( | QCPPainter * | painter, |
bool | localAntialiased, | ||
QCP::AntialiasedElement | overrideElement | ||
) | const [protected, inherited] |
Sets the QPainter::Antialiasing render hint on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.
QRect QCPLayerable::clipRect | ( | ) | const [protected, virtual, inherited] |
Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.
The returned clipping rect is set on the painter before the draw function of the respective object is called.
Reimplemented in QCPAbstractItem, and QCPAbstractPlottable.