LibreOffice Module chart2 (master) 1
VCoordinateSystem.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
22#include <ThreeDHelper.hxx>
23#include "VSeriesPlotter.hxx"
25#include <com/sun/star/drawing/HomogenMatrix.hpp>
26#include <com/sun/star/uno/Sequence.h>
27#include <rtl/ref.hxx>
28#include <svx/unoshape.hxx>
29
30#include <map>
31#include <memory>
32#include <vector>
33
34namespace com::sun::star::awt { struct Rectangle; }
35namespace com::sun::star::awt { struct Size; }
36namespace com::sun::star::beans { class XPropertySet; }
37namespace com::sun::star::chart2 { class XAxis; }
38namespace com::sun::star::chart2 { class XChartDocument; }
39namespace com::sun::star::chart2 { class XCoordinateSystem; }
40namespace com::sun::star::drawing { class XShapes; }
41namespace com::sun::star::lang { class XMultiServiceFactory; }
42namespace com::sun::star::uno { class XComponentContext; }
43
44namespace chart
45{
46class ExplicitCategoriesProvider;
47class ScaleAutomatism;
48class ChartModel;
49class Axis;
50class BaseCoordinateSystem;
51class GridProperties;
52class VAxisBase;
53
55{
56public:
57 virtual ~VCoordinateSystem();
58
59 static std::unique_ptr<VCoordinateSystem> createCoordinateSystem( const rtl::Reference<
60 ::chart::BaseCoordinateSystem >& xCooSysModel );
61
64 const rtl::Reference< SvxShapeGroupAnyD >& xLogicTarget
65 , const rtl::Reference< SvxShapeGroupAnyD >& xFinalTarget
66 , rtl::Reference<SvxShapeGroupAnyD>& xLogicTargetForSeriesBehindAxis );
67
68 void setParticle( const OUString& rCooSysParticle );
69
70 void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix );
71 const css::drawing::HomogenMatrix& getTransformationSceneToScreen() const { return m_aMatrixSceneToScreen;}
72
73 //better performance for big data
74 virtual css::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const css::awt::Size& rPageSize
75 , const css::awt::Size& rPageResolution );
76
77 ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
78 ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
79
82
83 // returns a complete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis
84 std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
85 // returns a complete increment set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis
86 std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
87
88 void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
89 bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
91
106 void prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex );
107
108 void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
109 , const ExplicitScaleData& rExplicitScale
110 , const ExplicitIncrementData& rExplicitIncrement );
111
112 void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos );
113
115 getModel() const { return m_xCooSysModel;}
116
120 virtual void createVAxisList(
121 const rtl::Reference<::chart::ChartModel> & xChartDoc,
122 const css::awt::Size& rFontReferenceSize,
123 const css::awt::Rectangle& rMaximumSpaceForLabels,
124 bool bLimitSpaceForLabels,
125 std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList,
126 css::uno::Reference<css::uno::XComponentContext> const& rComponentContext);
127
128 virtual void initVAxisInList();
129 virtual void updateScalesAndIncrementsOnAxes();
130
132 void createAxesLabels();
133 void updatePositions();
134 void createAxesShapes();
135
136 virtual void createGridShapes();
137
138 bool getPropertySwapXAndYAxis() const;
139
140 sal_Int32 getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const;
141
142 bool needSeriesNamesForAxis() const;
143 void setSeriesNamesForAxis( const css::uno::Sequence< OUString >& rSeriesNames );
144
145protected: //methods
147
149 getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
150 static std::vector< rtl::Reference< ::chart::GridProperties > >
152
153 VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
154
155 OUString createCIDForAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
156 OUString createCIDForGrid( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
157
159 , const rtl::Reference<::chart::ChartModel>& xChartDoc);
160
161private: //methods
162 static void impl_adjustDimension( sal_Int32& rDimensionIndex );
163 void impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const;
164
165protected: //member
167
169
170 typedef std::pair< sal_Int32, sal_Int32 > tFullAxisIndex; //first index is the dimension, second index is the axis index that indicates whether this is a main or secondary axis
171
175 css::drawing::HomogenMatrix m_aMatrixSceneToScreen;
176
180
187
188 css::uno::Sequence< OUString > m_aSeriesNamesForZAxis;
189
190 typedef std::map< tFullAxisIndex, std::shared_ptr< VAxisBase > > tVAxisMap;
191
193
194private:
195 std::vector< ExplicitScaleData > m_aExplicitScales;
196 std::vector< ExplicitIncrementData > m_aExplicitIncrements;
197
198 typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap;
199 typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap;
200
203
204 std::unique_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider;
205};
206
207} //namespace chart
208
209/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class implements the calculation of automatic axis limits.
ExplicitCategoriesProvider * getExplicitCategoriesProvider()
virtual void updateScalesAndIncrementsOnAxes()
std::vector< ExplicitIncrementData > getExplicitIncrements(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
MergedMinimumAndMaximumSupplier m_aMergedMinMaxSupplier
Collection of min-max suppliers which are basically different chart types present in the same coordin...
virtual void createVAxisList(const rtl::Reference<::chart::ChartModel > &xChartDoc, const css::awt::Size &rFontReferenceSize, const css::awt::Rectangle &rMaximumSpaceForLabels, bool bLimitSpaceForLabels, std::vector< std::unique_ptr< VSeriesPlotter > > &rSeriesPlotterList, css::uno::Reference< css::uno::XComponentContext > const &rComponentContext)
Create "view" axis objects 'VAxis' from the coordinate system model.
void setParticle(const OUString &rCooSysParticle)
static std::vector< rtl::Reference< ::chart::GridProperties > > getGridListFromAxis(const rtl::Reference< ::chart::Axis > &xAxis)
std::unique_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider
void addMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
sal_Int32 getMaximumAxisIndexByDimension(sal_Int32 nDimensionIndex) const
rtl::Reference< SvxShapeGroupAnyD > m_xLogicTargetForGrids
void setExplicitScaleAndIncrement(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex, const ExplicitScaleData &rExplicitScale, const ExplicitIncrementData &rExplicitIncrement)
void setExplicitCategoriesProvider(ExplicitCategoriesProvider *)
VAxisBase * getVAxis(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
std::vector< ExplicitScaleData > getExplicitScales(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
OUString createCIDForGrid(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
static void impl_adjustDimension(sal_Int32 &rDimensionIndex)
void impl_adjustDimensionAndIndex(sal_Int32 &rDimensionIndex, sal_Int32 &rAxisIndex) const
void setSeriesNamesForAxis(const css::uno::Sequence< OUString > &rSeriesNames)
css::uno::Sequence< OUString > m_aSeriesNamesForZAxis
void set3DWallPositions(CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos)
void initPlottingTargets(const rtl::Reference< SvxShapeGroupAnyD > &xLogicTarget, const rtl::Reference< SvxShapeGroupAnyD > &xFinalTarget, rtl::Reference< SvxShapeGroupAnyD > &xLogicTargetForSeriesBehindAxis)
VCoordinateSystem(rtl::Reference< ::chart::BaseCoordinateSystem > xCooSys)
ExplicitScaleData getExplicitScale(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
ExplicitIncrementData getExplicitIncrement(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
sal_Int32 getNumberFormatKeyForAxis(const rtl::Reference< ::chart::Axis > &xAxis, const rtl::Reference<::chart::ChartModel > &xChartDoc)
std::map< tFullAxisIndex, std::shared_ptr< VAxisBase > > tVAxisMap
void prepareAutomaticAxisScaling(ScaleAutomatism &rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex)
It sets the scaling parameters for the passed ScaleAutomatism object.
CuboidPlanePosition m_eLeftWallPos
OUString createCIDForAxis(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
rtl::Reference< ::chart::Axis > getAxisByDimension(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
std::vector< ExplicitIncrementData > m_aExplicitIncrements
std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap
bool hasMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
tFullExplicitScaleMap m_aSecondaryExplicitScales
std::pair< sal_Int32, sal_Int32 > tFullAxisIndex
rtl::Reference< SvxShapeGroupAnyD > m_xLogicTargetForAxes
static std::unique_ptr< VCoordinateSystem > createCoordinateSystem(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSysModel)
void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix)
std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap
virtual css::uno::Sequence< sal_Int32 > getCoordinateSystemResolution(const css::awt::Size &rPageSize, const css::awt::Size &rPageResolution)
css::drawing::HomogenMatrix m_aMatrixSceneToScreen
std::vector< ExplicitScaleData > m_aExplicitScales
rtl::Reference< ::chart::BaseCoordinateSystem > m_xCooSysModel
const rtl::Reference< ::chart::BaseCoordinateSystem > & getModel() const
CuboidPlanePosition m_eBackWallPos
rtl::Reference< SvxShapeGroupAnyD > m_xFinalTarget
tFullExplicitIncrementMap m_aSecondaryExplicitIncrements
const css::drawing::HomogenMatrix & getTransformationSceneToScreen() const
CuboidPlanePosition m_eBottomPos
CuboidPlanePosition
class SAL_NO_VTABLE XPropertySet
describes how tickmarks are positioned on the scale of an axis.
This structure contains the explicit values for a scale like Minimum and Maximum.