qwt_painter_command.cpp
Go to the documentation of this file.
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #include "qwt_painter_command.h"
00011 
00013 QwtPainterCommand::QwtPainterCommand():
00014     d_type( Invalid )
00015 {
00016 }
00017 
00019 QwtPainterCommand::QwtPainterCommand( const QPainterPath &path ):
00020     d_type( Path )
00021 {
00022     d_path = new QPainterPath( path );
00023 }
00024 
00034 QwtPainterCommand::QwtPainterCommand( const QRectF &rect,
00035         const QPixmap &pixmap, const QRectF& subRect ):
00036     d_type( Pixmap )
00037 {
00038     d_pixmapData = new PixmapData();
00039     d_pixmapData->rect = rect;
00040     d_pixmapData->pixmap = pixmap;
00041     d_pixmapData->subRect = subRect;
00042 }
00043 
00054 QwtPainterCommand::QwtPainterCommand( const QRectF &rect,
00055         const QImage &image, const QRectF& subRect,
00056         Qt::ImageConversionFlags flags ):
00057     d_type( Image )
00058 {
00059     d_imageData = new ImageData();
00060     d_imageData->rect = rect;
00061     d_imageData->image = image;
00062     d_imageData->subRect = subRect;
00063     d_imageData->flags = flags;
00064 }
00065 
00070 QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
00071     d_type( State )
00072 {
00073     d_stateData = new StateData();
00074 
00075     d_stateData->flags = state.state();
00076 
00077     if ( d_stateData->flags & QPaintEngine::DirtyPen ) 
00078         d_stateData->pen = state.pen();
00079 
00080     if ( d_stateData->flags & QPaintEngine::DirtyBrush ) 
00081         d_stateData->brush = state.brush();
00082 
00083     if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin ) 
00084         d_stateData->brushOrigin = state.brushOrigin();
00085 
00086     if ( d_stateData->flags & QPaintEngine::DirtyFont ) 
00087         d_stateData->font = state.font();
00088 
00089     if ( d_stateData->flags & QPaintEngine::DirtyBackground ) 
00090     {
00091         d_stateData->backgroundMode = state.backgroundMode();
00092         d_stateData->backgroundBrush = state.backgroundBrush();
00093     }
00094 
00095     if ( d_stateData->flags & QPaintEngine::DirtyTransform ) 
00096         d_stateData->transform = state.transform();
00097 
00098     if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled ) 
00099         d_stateData->isClipEnabled = state.isClipEnabled();
00100 
00101     if ( d_stateData->flags & QPaintEngine::DirtyClipRegion ) 
00102     {
00103         d_stateData->clipRegion = state.clipRegion();
00104         d_stateData->clipOperation = state.clipOperation();
00105     }
00106 
00107     if ( d_stateData->flags & QPaintEngine::DirtyClipPath ) 
00108     {
00109         d_stateData->clipPath = state.clipPath();
00110         d_stateData->clipOperation = state.clipOperation();
00111     }
00112 
00113     if ( d_stateData->flags & QPaintEngine::DirtyHints ) 
00114         d_stateData->renderHints = state.renderHints();
00115 
00116     if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode ) 
00117         d_stateData->compositionMode = state.compositionMode();
00118 
00119     if ( d_stateData->flags & QPaintEngine::DirtyOpacity ) 
00120         d_stateData->opacity = state.opacity();
00121 }
00122 
00128 QwtPainterCommand::QwtPainterCommand(const QwtPainterCommand &other)
00129 {
00130     copy( other );
00131 }
00132 
00134 QwtPainterCommand::~QwtPainterCommand()
00135 {
00136     reset();
00137 }
00138 
00145 QwtPainterCommand &QwtPainterCommand::operator=(const QwtPainterCommand &other)
00146 {
00147     reset();
00148     copy( other );
00149 
00150     return *this;
00151 }
00152 
00153 void QwtPainterCommand::copy( const QwtPainterCommand &other )
00154 {
00155     d_type = other.d_type;
00156 
00157     switch( other.d_type )
00158     {
00159         case Path:
00160         {
00161             d_path = new QPainterPath( *other.d_path );
00162             break;
00163         }
00164         case Pixmap:
00165         {
00166             d_pixmapData = new PixmapData( *other.d_pixmapData );
00167             break;
00168         }
00169         case Image:
00170         {
00171             d_imageData = new ImageData( *other.d_imageData );
00172             break;
00173         }
00174         case State:
00175         {
00176             d_stateData = new StateData( *other.d_stateData );
00177             break;
00178         }
00179         default:
00180             break;
00181     }
00182 }
00183 
00184 void QwtPainterCommand::reset()
00185 {
00186     switch( d_type )
00187     {
00188         case Path:
00189         {
00190             delete d_path;
00191             break;
00192         }
00193         case Pixmap:
00194         {
00195             delete d_pixmapData;
00196             break;
00197         }
00198         case Image:
00199         {
00200             delete d_imageData;
00201             break;
00202         }
00203         case State:
00204         {
00205             delete d_stateData;
00206             break;
00207         }
00208         default:
00209             break;
00210     }
00211 
00212     d_type = Invalid;
00213 }
00214 
00216 QPainterPath *QwtPainterCommand::path() 
00217 {
00218     return d_path;
00219 }
00220 
00222 QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData() 
00223 {
00224     return d_pixmapData;
00225 }
00226 
00228 QwtPainterCommand::ImageData* QwtPainterCommand::imageData() 
00229 {
00230     return d_imageData;
00231 }
00232 
00234 QwtPainterCommand::StateData* QwtPainterCommand::stateData() 
00235 {
00236     return d_stateData;
00237 }


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:56