Aquila  2.0 prealpha
Cognitive Robotics Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
QCPPainter Class Reference

QPainter subclass used internally. More...

#include <plot2d.h>

Inheritance diagram for QCPPainter:

Public Member Functions

 QCPPainter ()
 
 QCPPainter (QPaintDevice *device)
 
 ~QCPPainter ()
 
QPixmap scatterPixmap () const
 
bool antialiasing () const
 
bool pdfExportMode () const
 
bool scaledExportMode () const
 
void setScatterPixmap (const QPixmap pm)
 
void setAntialiasing (bool enabled)
 
void setPdfExportMode (bool enabled)
 
void setScaledExportMode (bool enabled)
 
void setPen (const QPen &pen)
 
void setPen (const QColor &color)
 
void setPen (Qt::PenStyle penStyle)
 
void drawLine (const QLineF &line)
 
void drawLine (const QPointF &p1, const QPointF &p2)
 
void save ()
 
void restore ()
 
void fixScaledPen ()
 
void drawScatter (double x, double y, double size, QCP::ScatterStyle style)
 

Protected Attributes

QPixmap mScatterPixmap
 
bool mScaledExportMode
 
bool mPdfExportMode
 
bool mIsAntialiasing
 
QStack< bool > mAntialiasingStack
 

Detailed Description

QPainter subclass used internally.

This internal class is used to provide some extended functionality e.g. for tweaking position consistency between antialiased and non-antialiased painting and drawing common shapes (like scatter symbols). Further it provides workarounds for QPainter quirks.

Warning
This class intentionally hides non-virtual functions of QPainter, e.g. setPen, save and restore. So while it is possible to pass a QCPPainter instance to a function that expects a QPainter pointer, some of the workarounds and tweaks will be unavailable to the function (because it will call the base class implementations of the functions actually hidden by QCPPainter).

Constructor & Destructor Documentation

QCPPainter::QCPPainter ( )

Creates a new QCPPainter instance and sets default values

QCPPainter::QCPPainter ( QPaintDevice *  device)

Creates a new QCPPainter instance on the specified paint device and sets default values. Just like the analogous QPainter constructor, begins painting on device immediately.

QCPPainter::~QCPPainter ( )

Member Function Documentation

bool QCPPainter::antialiasing ( ) const
inline
void QCPPainter::drawLine ( const QLineF &  line)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Works around a Qt bug introduced with Qt 4.8 which makes drawing QLineF unpredictable when antialiasing is disabled.

Note
this function hides the non-virtual base class implementation.
void QCPPainter::drawLine ( const QPointF &  p1,
const QPointF &  p2 
)
inline
void QCPPainter::drawScatter ( double  x,
double  y,
double  size,
QCP::ScatterStyle  style 
)

Draws a single scatter point with the specified style and size in pixels at the pixel position x and y.

If the style is ssPixmap, make sure to pass the respective pixmap with setScatterPixmap before calling this function.

void QCPPainter::fixScaledPen ( )

Provides a workaround for a QPainter bug that prevents scaling of pen widths for pens with width 0, although the QPainter::NonCosmeticDefaultPen render hint is set.

Changes the pen width from 0 to 1, if appropriate.

Does nothing if the QCPPainter is not in scaled export mode (setScaledExportMode).

bool QCPPainter::pdfExportMode ( ) const
inline
void QCPPainter::restore ( )

Restores the painter (see QPainter::restore). Since QCPPainter adds some new internal state to QPainter, the save/restore functions are reimplemented to also save/restore those members.

Note
this function hides the non-virtual base class implementation.
See Also
save
void QCPPainter::save ( )

Saves the painter (see QPainter::save). Since QCPPainter adds some new internal state to QPainter, the save/restore functions are reimplemented to also save/restore those members.

Note
this function hides the non-virtual base class implementation.
See Also
restore
bool QCPPainter::scaledExportMode ( ) const
inline
QPixmap QCPPainter::scatterPixmap ( ) const
inline
void QCPPainter::setAntialiasing ( bool  enabled)

Sets whether painting uses antialiasing or not. Use this method instead of using setRenderHint with QPainter::Antialiasing directly, as it allows QCPPainter to regain pixel exactness between antialiased and non-antialiased painting (Since Qt uses slightly different coordinate systems for AA/Non-AA painting).

void QCPPainter::setPdfExportMode ( bool  enabled)

Sets whether the painter shall adjust its fixes/workarounds optimized for vectorized pdf export.

This means for example, that the antialiasing/non-antialiasing fix introduced with setAntialiasing is not used, since PDF is not rastered and thus works with floating point data natively.

void QCPPainter::setPen ( const QPen &  pen)

Sets the pen of the painter and applies certain fixes to it, depending on the mode of this QCPPainter.

Note
this function hides the non-virtual base class implementation.
void QCPPainter::setPen ( const QColor &  color)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the pen (by color) of the painter and applies certain fixes to it, depending on the mode of this QCPPainter.

Note
this function hides the non-virtual base class implementation.
void QCPPainter::setPen ( Qt::PenStyle  penStyle)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the pen (by style) of the painter and applies certain fixes to it, depending on the mode of this QCPPainter.

Note
this function hides the non-virtual base class implementation.
void QCPPainter::setScaledExportMode ( bool  enabled)

Sets whether the painter shall adjust its fixes/workarounds optimized for scaled export to rastered image formats.

For example this provides a workaround for a QPainter bug that prevents scaling of pen widths for pens with width 0, although the QPainter::NonCosmeticDefaultPen render hint is set.

void QCPPainter::setScatterPixmap ( const QPixmap  pm)

Sets the pixmap that will be used to draw scatters with drawScatter, when the style is QCP::ssPixmap.

Member Data Documentation

QStack<bool> QCPPainter::mAntialiasingStack
protected
bool QCPPainter::mIsAntialiasing
protected
bool QCPPainter::mPdfExportMode
protected
bool QCPPainter::mScaledExportMode
protected
QPixmap QCPPainter::mScatterPixmap
protected

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