File indexing completed on 2024-06-09 04:18:26

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 #ifndef KCHARTCARTESIANCOORDINATEPLANE_P_H
0010 #define KCHARTCARTESIANCOORDINATEPLANE_P_H
0011 
0012 //
0013 //  W A R N I N G
0014 //  -------------
0015 //
0016 // This file is not part of the KD Chart API.  It exists purely as an
0017 // implementation detail.  This header file may change from version to
0018 // version without notice, or even be removed.
0019 //
0020 // We mean it.
0021 //
0022 
0023 #include "KChartAbstractCoordinatePlane_p.h"
0024 #include "CartesianCoordinateTransformation.h"
0025 #include "KChartCartesianGrid.h"
0026 #include "KChartZoomParameters.h"
0027 
0028 #include "KChartMath_p.h"
0029 
0030 
0031 namespace KChart {
0032 
0033 /**
0034  * \internal
0035  */
0036 class Q_DECL_HIDDEN CartesianCoordinatePlane::Private : public AbstractCoordinatePlane::Private
0037 {
0038     friend class CartesianCoordinatePlane;
0039 public:
0040     explicit Private();
0041     ~Private() override {  }
0042 
0043     void initialize() override
0044     {
0045         bPaintIsRunning = false;
0046         coordinateTransformation.axesCalcModeX = Linear;
0047         coordinateTransformation.axesCalcModeY = Linear;
0048         grid = new CartesianGrid();
0049     }
0050 
0051     static Private *get( CartesianCoordinatePlane *plane )
0052     {
0053         return static_cast< Private * >( plane->d_func() );
0054     }
0055 
0056     bool isVisiblePoint( const AbstractCoordinatePlane * plane, const QPointF& point ) const override
0057     {
0058         QPointF p = point;
0059         const CartesianCoordinatePlane* const ref =
0060             qobject_cast< const CartesianCoordinatePlane* >(
0061                               const_cast< AbstractCoordinatePlane* >( plane )->sharedAxisMasterPlane() );
0062         const CartesianCoordinatePlane* const cartPlane =
0063             dynamic_cast< const CartesianCoordinatePlane* >( plane );
0064         if ( ref != nullptr && ref != cartPlane ) {
0065             const QPointF logical = ref->translateBack( point ) - cartPlane->visibleDataRange().topLeft()
0066                                                                 + ref->visibleDataRange().topLeft();
0067             p = ref->translate( logical );
0068         }
0069         const QRectF geo( plane->geometry() );
0070         return geo.contains( p );
0071     }
0072 
0073 
0074     // the coordinate plane will calculate the coordinate transformation:
0075     CoordinateTransformation coordinateTransformation;
0076 
0077     bool bPaintIsRunning;
0078 
0079     // true after setGridAttributes( Qt::Orientation ) was used,
0080     // false if resetGridAttributes( Qt::Orientation ) was called
0081     bool hasOwnGridAttributesHorizontal;
0082     bool hasOwnGridAttributesVertical;
0083 
0084     // true after the first resize event came in
0085     // bool initialResizeEventReceived;
0086 
0087     // true if the coordinate plane scales isometrically
0088     // (same scaling ratio from data to screen space for both axes)
0089     bool isometricScaling;
0090 
0091     GridAttributes gridAttributesHorizontal;
0092     GridAttributes gridAttributesVertical;
0093 
0094     qreal horizontalMin;
0095     qreal horizontalMax;
0096     qreal verticalMin;
0097     qreal verticalMax;
0098 
0099     // autoAdjustHorizontalRangeToData determines if and how much the horizontal range is adjusted.
0100     // A value of 100 means that the fixed horizontal range will be used (e.g. set by the user),
0101     // otherwise the value will be the percentage of the diagram's horizontal range that is to be
0102     // left empty (i.e., it resembles the 'gap' between the horizontal extrema and the border of the
0103     // diagram).
0104     unsigned int autoAdjustHorizontalRangeToData;
0105 
0106     // autoAdjustVerticalRangeToData determines if and how much the vertical range is adjusted.
0107     // A value of 100 means that the fixed vertical range will be used (e.g. set by the user),
0108     // otherwise the value will be the percentage of the diagram's vertical range that is to be
0109     // left empty (i.e., it resembles the 'gap' between the vertical extrema and the border of the
0110     // diagram).
0111     unsigned int autoAdjustVerticalRangeToData;
0112     bool autoAdjustGridToZoom;
0113 
0114     bool fixedDataCoordinateSpaceRelation;
0115     bool xAxisStartAtZero;
0116     QSizeF fixedDataCoordinateSpaceRelationPinnedSize;
0117     ZoomParameters fixedDataCoordinateSpaceRelationPinnedZoom;
0118 
0119     DataDimensionsList dimensions;
0120 
0121     bool reverseVerticalPlane;
0122     bool reverseHorizontalPlane;
0123 };
0124 
0125 
0126 KCHART_IMPL_DERIVED_PLANE(CartesianCoordinatePlane, AbstractCoordinatePlane)
0127 
0128 }
0129 
0130 #endif /* KCHARTBARDIAGRAM_P_H */