Loading...
Searching...
No Matches
qwt_painter_command.cpp
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_painter_command.h"
QwtPainterCommand::QwtPainterCommand()
: m_type( Invalid )
{
}
QwtPainterCommand::QwtPainterCommand( const QPainterPath& path )
: m_type( Path )
{
m_path = new QPainterPath( path );
}
QwtPainterCommand::QwtPainterCommand( const QRectF& rect,
const QPixmap& pixmap, const QRectF& subRect )
: m_type( Pixmap )
{
m_pixmapData = new PixmapData();
m_pixmapData->rect = rect;
m_pixmapData->pixmap = pixmap;
m_pixmapData->subRect = subRect;
}
QwtPainterCommand::QwtPainterCommand( const QRectF& rect,
const QImage& image, const QRectF& subRect,
Qt::ImageConversionFlags flags )
: m_type( Image )
{
m_imageData = new ImageData();
m_imageData->rect = rect;
m_imageData->image = image;
m_imageData->subRect = subRect;
m_imageData->flags = flags;
}
QwtPainterCommand::QwtPainterCommand( const QPaintEngineState& state )
: m_type( State )
{
m_stateData = new StateData();
m_stateData->flags = state.state();
if ( m_stateData->flags & QPaintEngine::DirtyPen )
m_stateData->pen = state.pen();
if ( m_stateData->flags & QPaintEngine::DirtyBrush )
m_stateData->brush = state.brush();
if ( m_stateData->flags & QPaintEngine::DirtyBrushOrigin )
m_stateData->brushOrigin = state.brushOrigin();
if ( m_stateData->flags & QPaintEngine::DirtyFont )
m_stateData->font = state.font();
if ( m_stateData->flags & QPaintEngine::DirtyBackground )
{
m_stateData->backgroundMode = state.backgroundMode();
m_stateData->backgroundBrush = state.backgroundBrush();
}
if ( m_stateData->flags & QPaintEngine::DirtyTransform )
m_stateData->transform = state.transform();
if ( m_stateData->flags & QPaintEngine::DirtyClipEnabled )
m_stateData->isClipEnabled = state.isClipEnabled();
if ( m_stateData->flags & QPaintEngine::DirtyClipRegion )
{
m_stateData->clipRegion = state.clipRegion();
m_stateData->clipOperation = state.clipOperation();
}
if ( m_stateData->flags & QPaintEngine::DirtyClipPath )
{
m_stateData->clipPath = state.clipPath();
m_stateData->clipOperation = state.clipOperation();
}
if ( m_stateData->flags & QPaintEngine::DirtyHints )
m_stateData->renderHints = state.renderHints();
if ( m_stateData->flags & QPaintEngine::DirtyCompositionMode )
m_stateData->compositionMode = state.compositionMode();
if ( m_stateData->flags & QPaintEngine::DirtyOpacity )
m_stateData->opacity = state.opacity();
}
QwtPainterCommand::QwtPainterCommand( const QwtPainterCommand& other )
{
copy( other );
}
QwtPainterCommand::~QwtPainterCommand()
{
reset();
}
QwtPainterCommand& QwtPainterCommand::operator=( const QwtPainterCommand& other )
{
reset();
copy( other );
return *this;
}
void QwtPainterCommand::copy( const QwtPainterCommand& other )
{
m_type = other.m_type;
switch( other.m_type )
{
case Path:
{
m_path = new QPainterPath( *other.m_path );
break;
}
case Pixmap:
{
m_pixmapData = new PixmapData( *other.m_pixmapData );
break;
}
case Image:
{
m_imageData = new ImageData( *other.m_imageData );
break;
}
case State:
{
m_stateData = new StateData( *other.m_stateData );
break;
}
default:
break;
}
}
void QwtPainterCommand::reset()
{
switch( m_type )
{
case Path:
{
delete m_path;
break;
}
case Pixmap:
{
delete m_pixmapData;
break;
}
case Image:
{
delete m_imageData;
break;
}
case State:
{
delete m_stateData;
break;
}
default:
break;
}
m_type = Invalid;
}
QPainterPath* QwtPainterCommand::path()
{
return m_path;
}
QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData()
{
return m_pixmapData;
}
QwtPainterCommand::ImageData* QwtPainterCommand::imageData()
{
return m_imageData;
}
QwtPainterCommand::StateData* QwtPainterCommand::stateData()
{
return m_stateData;
}
QwtPainterCommand
Definition qwt_painter_command.h:33
QwtPainterCommand::operator=
QwtPainterCommand & operator=(const QwtPainterCommand &)
Definition qwt_painter_command.cpp:145
QwtPainterCommand::QwtPainterCommand
QwtPainterCommand()
Construct an invalid command.
Definition qwt_painter_command.cpp:13
QwtPainterCommand::path
QPainterPath * path()
Definition qwt_painter_command.cpp:216
QwtPainterCommand::Pixmap
@ Pixmap
Draw a QPixmap.
Definition qwt_painter_command.h:45
QwtPainterCommand::Invalid
@ Invalid
Invalid command.
Definition qwt_painter_command.h:39
QwtPainterCommand::Path
@ Path
Draw a QPainterPath.
Definition qwt_painter_command.h:42
QwtPainterCommand::Image
@ Image
Draw a QImage.
Definition qwt_painter_command.h:48
QwtPainterCommand::State
@ State
QPainter state change.
Definition qwt_painter_command.h:51
QwtPainterCommand::pixmapData
PixmapData * pixmapData()
Definition qwt_painter_command.cpp:222
QwtPainterCommand::imageData
ImageData * imageData()
Definition qwt_painter_command.cpp:228
QwtPainterCommand::stateData
StateData * stateData()
Definition qwt_painter_command.cpp:234
QwtPainterCommand::~QwtPainterCommand
~QwtPainterCommand()
Destructor.
Definition qwt_painter_command.cpp:134