logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

QwtGraphic - A paint device for scalable graphics.

Author

       Generated automatically by Doxygen for Qwt User's Guide from the source code.

Version 6.1.4                                    Wed Jan 2 2019                                    QwtGraphic(3)

Constructor & Destructor Documentation

QwtGraphic::QwtGraphic()
       Constructor. Initializes a null graphic

       Seealso:isNull()QwtGraphic::QwtGraphic(constQwtGraphic&other)
       Copy constructor.

       Parameters:other Source

       Seealso:operator=()

Detailed Description

       A paint device for scalable graphics.

       QwtGraphic is the representation of a graphic that is tailored for scalability. Like QPicture it will be
       initialized by QPainter operations and can be replayed later to any target paint device.

       While the usual image representations QImage and QPixmap are not scalable Qt offers two paint devices,
       that might be candidates for representing a vector graphic:

       • QPicture
          Unfortunately  QPicture  had  been forgotten, when Qt4 introduced floating point based render engines.
         Its API is still on integers, what make it unusable for proper scaling.

       • QSvgRenderer/QSvgGenerator
          Unfortunately QSvgRenderer hides to much information about  its  nodes  in  internal  APIs,  that  are
         necessary  for  proper  layout  calculations.  Also it is derived from QObject and can't be copied like
         QImage/QPixmap.

       QwtGraphic maps all scalable drawing primitives to a QPainterPath  and  stores  them  together  with  the
       painter  state  changes  (  pen,  brush,  transformation ... ) in a list of QwtPaintCommands. For being a
       complete QPaintDevice it also stores pixmaps or images, what is somehow against the idea  of  the  class,
       because these objects can't be scaled without a loss in quality.

       The  main  issue  about  scaling  a  QwtGraphic  object are the pens used for drawing the outlines of the
       painter paths. While non cosmetic pens ( QPen::isCosmetic() ) are scaled with the same ratio as the path,
       cosmetic pens have a fixed width. A graphic might have paths with different  pens  -  cosmetic  and  non-
       cosmetic.

       QwtGraphic caches 2 different rectangles:

       • control point rectangle
          The  control  point rectangle is the bounding rectangle of all control point rectangles of the painter
         paths, or the target rectangle of the pixmaps/images.

       • bounding rectangle
          The bounding rectangle extends the control point rectangle by what is needed for rendering the outline
         with an unscaled pen.

       Because the offset for drawing the outline depends on the shape of the painter  path  (  the  peak  of  a
       triangle  is  different  than  the  flat  side  )  scaling  with  a fixed aspect ratio always needs to be
       calculated from the control point rectangle.

       Seealso:QwtPainterCommand

Member Enumeration Documentation

enumQwtGraphic::RenderHint
       Hint how to render a graphic

       Seealso:setRenderHint(), testRenderHint()EnumeratorRenderPensUnscaled
              When rendering a QwtGraphic a specific scaling between the controlPointRect() and the  coordinates
              of the target rectangle is set up internally in render().

       When  RenderPensUnscaled is set this specific scaling is applied for the control points only, but not for
       the pens. All other painter transformations ( set up by application code )  are  supposed  to  work  like
       usual.

       Seealso:render();

Member Function Documentation

QRectFQwtGraphic::boundingRect()const
       The  bounding rectangle is the controlPointRect() extended by the areas needed for rendering the outlines
       with unscaled pens.

       Returns:
           Bounding rectangle of the graphic

       Seealso:controlPointRect(), scaledBoundingRect()constQVector<QwtPainterCommand>&QwtGraphic::commands()constReturns:
           List of recorded paint commands

       Seealso:setCommands()QRectFQwtGraphic::controlPointRect()const
       The control point rectangle is the bounding rectangle of all control points of the paths and  the  target
       rectangles of the images/pixmaps.

       Returns:
           Control point rectangle

       Seealso:boundingRect(), scaledBoundingRect()QSizeFQwtGraphic::defaultSize()const
       Default  size.  When  a  non empty size has been assigned by setDefaultSize() this size will be returned.
       Otherwise the default size is the size of the bounding rectangle.

       The default size is used in all methods rendering the graphic, where no size is explicitly specified.

       Returns:
           Default size

       Seealso:setDefaultSize(), boundingRect()voidQwtGraphic::drawImage(constQRectF&rect,constQImage&image,constQRectF&subRect,Qt::ImageConversionFlagsflags)[protected],[virtual]
       Store a image command in the command list.

       Parameters:rect traget rectangle
           image Image to be painted
           subRect Reactangle of the pixmap to be painted
           flags Image conversion flags

       Seealso:
           QPaintEngine::drawImage()

       Reimplemented from QwtNullPaintDevice.

   voidQwtGraphic::drawPath(constQPainterPath&path)[protected],[virtual]
       Store a path command in the command list

       Parameters:path Painter path

       Seealso:
           QPaintEngine::drawPath()

       Reimplemented from QwtNullPaintDevice.

   voidQwtGraphic::drawPixmap(constQRectF&rect,constQPixmap&pixmap,constQRectF&subRect)[protected],[virtual]
       Store a pixmap command in the command list.

       Parameters:rect target rectangle
           pixmap Pixmap to be painted
           subRect Reactangle of the pixmap to be painted

       Seealso:
           QPaintEngine::drawPixmap()

       Reimplemented from QwtNullPaintDevice.

   boolQwtGraphic::isEmpty()constReturns:
           True, when the bounding rectangle is empty

       Seealso:boundingRect(), isNull()boolQwtGraphic::isNull()constReturns:
           True, when no painter commands have been stored

       Seealso:isEmpty(), commands()QwtGraphic&QwtGraphic::operator=(constQwtGraphic&other)
       Assignment operator.

       Parameters:other Source

       Returns:
           A reference of this object

   voidQwtGraphic::render(QPainter*painter)const
       Replay all recorded painter commands.

       Parameters:painter Qt painter

   voidQwtGraphic::render(QPainter*painter,constQSizeF&size,Qt::AspectRatioModeaspectRatioMode=Qt::IgnoreAspectRatio)const
       Replay  all  recorded painter commands. The graphic is scaled to fit into the rectangle of the given size
       starting at ( 0, 0 ).

       Parameters:painter Qt painter
           size Size for the scaled graphic
           aspectRatioMode Mode how to scale - See Qt::AspectRatioMode

   voidQwtGraphic::render(QPainter*painter,constQRectF&rect,Qt::AspectRatioModeaspectRatioMode=Qt::IgnoreAspectRatio)const
       Replay all recorded painter commands. The graphic is scaled to fit into the given rectangle

       Parameters:painter Qt painter
           rect Rectangle for the scaled graphic
           aspectRatioMode Mode how to scale - See Qt::AspectRatioMode

   voidQwtGraphic::render(QPainter*painter,constQPointF&pos,Qt::Alignmentalignment=Qt::AlignTop|Qt::AlignLeft)const
       Replay all recorded painter commands. The graphic is  scaled  to  the  defaultSize()  and  aligned  to  a
       position.

       Parameters:painter Qt painter
           pos Reference point, where to render
           alignment Flags how to align the target rectangle to pos.

   voidQwtGraphic::reset()
       Clear all stored commands.

       Seealso:isNull()QRectFQwtGraphic::scaledBoundingRect(doublesx,doublesy)const
       Calculate the target rectangle for scaling the graphic.

       Parameters:sx Horizontal scaling factor
           sy Vertical scaling factor

       Note:
           In case of paths that are painted with a cosmetic pen ( see QPen::isCosmetic() ) the target rectangle
           is different to multiplying the bounding rectangle.

       Returns:
           Scaled bounding rectangle

       Seealso:boundingRect(), controlPointRect()voidQwtGraphic::setCommands(QVector<QwtPainterCommand>&commands)
       Append paint commands.

       Parameters:commands Paint commands

       Seealso:commands()voidQwtGraphic::setDefaultSize(constQSizeF&size)
       Set  a  default  size.  The  default  size is used in all methods rendering the graphic, where no size is
       explicitly specified. Assigning an empty size means, that the default size will be  calculated  from  the
       bounding rectangle.

       The default setting is an empty size.

       Parameters:size Default size

       Seealso:defaultSize(), boundingRect()voidQwtGraphic::setRenderHint(RenderHinthint,boolon=true)
       Toggle an render hint

       Parameters:hint Render hint
           on true/false

       Seealso:testRenderHint(), RenderHintQSizeQwtGraphic::sizeMetrics()const[protected],[virtual]Returns:
           Ceiled defaultSize()

       Implements QwtNullPaintDevice.

   boolQwtGraphic::testRenderHint(RenderHinthint)const
       Test a render hint

       Parameters:hint Render hint

       Returns:
           true/false

       Seealso:setRenderHint(), RenderHintQImageQwtGraphic::toImage()const
       Convert  the graphic to a QImage. All pixels of the image get initialized by 0 ( transparent ) before the
       graphic is scaled and rendered on it.

       The format of the image is QImage::Format_ARGB32_Premultiplied.

       The size of the image is the default size ( ceiled to integers ) of the graphic.

       Returns:
           The graphic as image in default size

       Seealso:defaultSize(), toPixmap(), render()QImageQwtGraphic::toImage(constQSize&size,Qt::AspectRatioModeaspectRatioMode=Qt::IgnoreAspectRatio)const
       Convert  the graphic to a QImage. All pixels of the image get initialized by 0 ( transparent ) before the
       graphic is scaled and rendered on it.

       The format of the image is QImage::Format_ARGB32_Premultiplied.

       Parameters:size Size of the image
           aspectRatioMode Aspect ratio how to scale the graphic

       Returns:
           The graphic as image

       Seealso:toPixmap(), render()QPixmapQwtGraphic::toPixmap()const
       Convert the graphic to a QPixmap. All pixels of the pixmap get initialized by Qt::transparent before  the
       graphic is scaled and rendered on it.

       The size of the pixmap is the default size ( ceiled to integers ) of the graphic.

       Returns:
           The graphic as pixmap in default size

       Seealso:defaultSize(), toImage(), render()QPixmapQwtGraphic::toPixmap(constQSize&size,Qt::AspectRatioModeaspectRatioMode=Qt::IgnoreAspectRatio)const
       Convert the graphic to a QPixmap. All pixels of the pixmap get initialized by Qt::transparent before  the
       graphic is scaled and rendered on it.

       Parameters:size Size of the image
           aspectRatioMode Aspect ratio how to scale the graphic

       Returns:
           The graphic as pixmap

       Seealso:toImage(), render()voidQwtGraphic::updateState(constQPaintEngineState&state)[protected],[virtual]
       Store a state command in the command list.

       Parameters:state State to be stored

       Seealso:
           QPaintEngine::updateState()

       Reimplemented from QwtNullPaintDevice.

Member Typedef Documentation

typedefQFlags<RenderHint>QwtGraphic::RenderHints
       Render hints. The default setting is to disable all hints

Name

       QwtGraphic - A paint device for scalable graphics.

Synopsis

       #include <qwt_graphic.h>

       Inherits QwtNullPaintDevice.

   PublicTypes
       enum RenderHint { RenderPensUnscaled = 0x1 }
       typedef QFlags< RenderHint > RenderHints
           Render hints.

   PublicMemberFunctionsQwtGraphic ()
           Constructor.
       QwtGraphic (const QwtGraphic &)
           Copy constructor.
       virtual ~QwtGraphic ()
           Destructor.
       QwtGraphic & operator= (const QwtGraphic &)
           Assignment operator.
       void reset ()
           Clear all stored commands.
       bool isNull () const
       bool isEmpty () const
       void render (QPainter *) const
           Replay all recorded painter commands.
       void render (QPainter *, const QSizeF &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
           Replay all recorded painter commands.
       void render (QPainter *, const QRectF &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
           Replay all recorded painter commands.
       void render (QPainter *, const QPointF &, Qt::Alignment=Qt::AlignTop|Qt::AlignLeft) const
           Replay all recorded painter commands.
       QPixmap toPixmap () const
           Convert the graphic to a QPixmap.
       QPixmap toPixmap (const QSize &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
           Convert the graphic to a QPixmap.
       QImage toImage () const
           Convert the graphic to a QImage.
       QImage toImage (const QSize &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
           Convert the graphic to a QImage.
       QRectF scaledBoundingRect (double sx, double sy) const
           Calculate the target rectangle for scaling the graphic.
       QRectF boundingRect () const
       QRectF controlPointRect () const
       const QVector< QwtPainterCommand > & commands () const
       void setCommands (QVector< QwtPainterCommand > &)
           Append paint commands.
       void setDefaultSize (const QSizeF &)
           Set a default size.
       QSizeF defaultSize () const
           Default size.
       void setRenderHint (RenderHint, bool on=true)
       bool testRenderHint (RenderHint) const

   ProtectedMemberFunctions
       virtual QSize sizeMetrics () const
       virtual void drawPath (const QPainterPath &)
       virtual void drawPixmap (const QRectF &, const QPixmap &, const QRectF &)
           Store a pixmap command in the command list.
       virtual void drawImage (const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags)
           Store a image command in the command list.
       virtual void updateState (const QPaintEngineState &state)
           Store a state command in the command list.

See Also