· · · ·
Public Functions | Protected Functions
QCPGrid Class Reference

Responsible for drawing the grid of a QCPAxis. More...

Inheritance diagram for QCPGrid:

## 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)
| 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)
Public Functions inherited from QCPLayerable
| QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
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)
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
bool | realVisibility () const
| QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
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)
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
bool | realVisibility () const

## Protected Functions
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const
virtual void | draw (QCPPainter *painter)
void | drawGridLines (QCPPainter *painter) const
void | drawSubGridLines (QCPPainter *painter) const
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const
virtual void | draw (QCPPainter *painter)
void | drawGridLines (QCPPainter *painter) const
void | drawSubGridLines (QCPPainter *painter) const
Protected Functions inherited from QCPLayerable
virtual void | parentPlotInitialized (QCustomPlot *parentPlot)
virtual QCP::Interaction | selectionCategory () const
virtual QRect | clipRect () const
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
virtual void | deselectEvent (bool *selectionStateChanged)
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
virtual void | parentPlotInitialized (QCustomPlot *parentPlot)
virtual QCP::Interaction | selectionCategory () const
virtual QRect | clipRect () const
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
virtual void | deselectEvent (bool *selectionStateChanged)
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

## Additional Inherited Members
Signals inherited from QCPLayerable
void | layerChanged (QCPLayer *newLayer)
void | layerChanged (QCPLayer *newLayer)

## Detailed Description

Responsible for drawing the grid of a QCPAxis.

This class is tightly bound to QCPAxis. Every axis owns a grid instance and uses it to draw the grid lines, sub grid lines and zero-line. You can interact with the grid of an axis via QCPAxis::grid. Normally, you don't need to create an instance of QCPGrid yourself.

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). Thus it is possible to have the grid in the background and the axes in the foreground, and any plottables/items in between. This described situation is the default setup, see the QCPLayer documentation.

## Constructor & Destructor Documentation

## ◆ QCPGrid()

QCPGrid::QCPGrid | ( | QCPAxis * | parentAxis | ) |
| explicit

Creates a QCPGrid instance and sets default values.

You shouldn't instantiate grids on their own, since every QCPAxis brings its own QCPGrid.

## Member Function Documentation

## ◆ setSubGridVisible()

void QCPGrid::setSubGridVisible | ( | bool | visible | ) |

Sets whether grid lines at sub tick marks are drawn.

See also
  setSubGridPen

## ◆ setAntialiasedSubGrid()

void QCPGrid::setAntialiasedSubGrid | ( | bool | enabled | ) |

Sets whether sub grid lines are drawn antialiased.

## ◆ setAntialiasedZeroLine()

void QCPGrid::setAntialiasedZeroLine | ( | bool | enabled | ) |

Sets whether zero lines are drawn antialiased.

## ◆ setPen()

void QCPGrid::setPen | ( | const QPen & | pen | ) |

Sets the pen with which (major) grid lines are drawn.

## ◆ setSubGridPen()

void QCPGrid::setSubGridPen | ( | const QPen & | pen | ) |

Sets the pen with which sub grid lines are drawn.

## ◆ setZeroLinePen()

void QCPGrid::setZeroLinePen | ( | const QPen & | pen | ) |

Sets the pen with which zero lines are drawn.

Zero lines are lines at value 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.

## ◆ applyDefaultAntialiasingHint() [1/2]

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 with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

See also
  setAntialiased

Implements QCPLayerable.

## ◆ draw()

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).

Implements QCPLayerable.

## ◆ drawGridLines()

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.

## ◆ drawSubGridLines()

void QCPGrid::drawSubGridLines | ( | QCPPainter * | painter | ) | const
| protected

Draws the sub grid lines with the specified painter.

This is a helper function called by draw.

## ◆ applyDefaultAntialiasingHint() [2/2]

virtual void QCPGrid::applyDefaultAntialiasingHint | ( | QCPPainter * | painter | ) | const
| protected virtual

This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills and scatters. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill and QCPGraph::setAntialiasedScatters. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

Implements QCPLayerable.

The documentation for this class was generated from the following files:

- src/axis/axis.h
- src/qcustomplot.h
- src/axis/axis.cpp
- src/qcustomplot.cpp