KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Chart library. 00005 ** 00006 ** Licensees holding valid commercial KD Chart licenses may use this file in 00007 ** accordance with the KD Chart Commercial License Agreement provided with 00008 ** the Software. 00009 ** 00010 ** 00011 ** This file may be distributed and/or modified under the terms of the 00012 ** GNU General Public License version 2 and version 3 as published by the 00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** Contact info@kdab.com if any conditions of this licensing are not 00019 ** clear to you. 00020 ** 00021 **********************************************************************/ 00022 00023 #include "KDChartPlotter_p.h" 00024 #include "KDChartPlotter.h" 00025 00026 #include "KDChartPainterSaver_p.h" 00027 #include "KDChartValueTrackerAttributes.h" 00028 #include "PaintingHelpers_p.h" 00029 00030 using namespace KDChart; 00031 00032 Plotter::Private::Private( const Private& rhs ) 00033 : QObject() 00034 , AbstractCartesianDiagram::Private( rhs ) 00035 , useCompression( rhs.useCompression ) 00036 { 00037 } 00038 00039 void Plotter::Private::init() 00040 { 00041 AbstractCartesianDiagram::Private::init(); 00042 useCompression = Plotter::NONE; 00043 } 00044 00045 void Plotter::Private::setCompressorResolution( 00046 const QSizeF& size, 00047 const AbstractCoordinatePlane* plane ) 00048 { 00049 compressor.setResolution( static_cast<int>( size.width() * plane->zoomFactorX() ), 00050 static_cast<int>( size.height() * plane->zoomFactorY() ) ); 00051 } 00052 00053 void Plotter::Private::changedProperties() 00054 { 00055 if ( CartesianCoordinatePlane* plane = dynamic_cast< CartesianCoordinatePlane* > ( diagram->coordinatePlane() ) ) 00056 { 00057 QPair< qreal, qreal > verticalRange = plane->verticalRange(); 00058 if ( verticalRange.first != verticalRange.second ) 00059 implementor->plotterCompressor().setForcedDataBoundaries( verticalRange, Qt::Vertical ); 00060 QPair< qreal, qreal > horizontalRange = plane->horizontalRange(); 00061 if ( verticalRange.first != horizontalRange.second ) 00062 implementor->plotterCompressor().setForcedDataBoundaries( horizontalRange, Qt::Horizontal ); 00063 } 00064 } 00065 00066 AttributesModel* Plotter::PlotterType::attributesModel() const 00067 { 00068 return m_private->attributesModel; 00069 } 00070 00071 ReverseMapper& Plotter::PlotterType::reverseMapper() 00072 { 00073 return m_private->reverseMapper; 00074 } 00075 00076 Plotter* Plotter::PlotterType::diagram() const 00077 { 00078 return static_cast< Plotter* >( m_private->diagram ); 00079 } 00080 00081 void Plotter::PlotterType::addLabel( LabelPaintCache *lpc, 00082 const QModelIndex& index, const PositionPoints& points, 00083 const Position& autoPositionPositive, 00084 const Position& autoPositionNegative, qreal value ) 00085 { 00086 m_private->addLabel( lpc, index, 0, points, autoPositionPositive, autoPositionNegative, value ); 00087 } 00088 00089 CartesianDiagramDataCompressor& Plotter::PlotterType::compressor() const 00090 { 00091 return m_private->compressor; 00092 } 00093 00094 PlotterDiagramCompressor& Plotter::PlotterType::plotterCompressor() const 00095 { 00096 return m_private->plotterCompressor; 00097 } 00098 00099 Plotter::CompressionMode Plotter::PlotterType::useCompression() const 00100 { 00101 return m_private->useCompression; 00102 } 00103 00104 void Plotter::PlotterType::setUseCompression( Plotter::CompressionMode value ) 00105 { 00106 m_private->useCompression = value; 00107 }