File indexing completed on 2024-12-15 04:02:32
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #include "KChartPlotter_p.h" 0010 0011 #include "KChartPainterSaver_p.h" 0012 #include "KChartValueTrackerAttributes.h" 0013 #include "PaintingHelpers_p.h" 0014 0015 using namespace KChart; 0016 0017 Plotter::Private::Private( const Private& rhs ) 0018 : QObject() 0019 , AbstractCartesianDiagram::Private( rhs ) 0020 , useCompression( rhs.useCompression ) 0021 { 0022 } 0023 0024 void Plotter::Private::init() 0025 { 0026 AbstractCartesianDiagram::Private::init(); 0027 useCompression = Plotter::NONE; 0028 } 0029 0030 void Plotter::Private::setCompressorResolution( 0031 const QSizeF& size, 0032 const AbstractCoordinatePlane* plane ) 0033 { 0034 compressor.setResolution( static_cast<int>( size.width() * plane->zoomFactorX() ), 0035 static_cast<int>( size.height() * plane->zoomFactorY() ) ); 0036 } 0037 0038 void Plotter::Private::changedProperties() 0039 { 0040 if ( CartesianCoordinatePlane* plane = dynamic_cast< CartesianCoordinatePlane* > ( diagram->coordinatePlane() ) ) 0041 { 0042 QPair< qreal, qreal > verticalRange = plane->verticalRange(); 0043 if ( verticalRange.first != verticalRange.second ) 0044 implementor->plotterCompressor().setForcedDataBoundaries( verticalRange, Qt::Vertical ); 0045 QPair< qreal, qreal > horizontalRange = plane->horizontalRange(); 0046 if ( verticalRange.first != horizontalRange.second ) 0047 implementor->plotterCompressor().setForcedDataBoundaries( horizontalRange, Qt::Horizontal ); 0048 } 0049 } 0050 0051 AttributesModel* Plotter::PlotterType::attributesModel() const 0052 { 0053 return m_private->attributesModel; 0054 } 0055 0056 ReverseMapper& Plotter::PlotterType::reverseMapper() 0057 { 0058 return m_private->reverseMapper; 0059 } 0060 0061 Plotter* Plotter::PlotterType::diagram() const 0062 { 0063 return static_cast< Plotter* >( m_private->diagram ); 0064 } 0065 0066 CartesianDiagramDataCompressor& Plotter::PlotterType::compressor() const 0067 { 0068 return m_private->compressor; 0069 } 0070 0071 PlotterDiagramCompressor& Plotter::PlotterType::plotterCompressor() const 0072 { 0073 return m_private->plotterCompressor; 0074 } 0075 0076 Plotter::CompressionMode Plotter::PlotterType::useCompression() const 0077 { 0078 return m_private->useCompression; 0079 } 0080 0081 void Plotter::PlotterType::setUseCompression( Plotter::CompressionMode value ) 0082 { 0083 m_private->useCompression = value; 0084 }