Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / view / inc / VCoordinateSystem.hxx
blob895ac94f00a679d5650182f3aee994a8c34da462
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_VCOORDINATESYSTEM_HXX
20 #define INCLUDED_CHART2_SOURCE_VIEW_INC_VCOORDINATESYSTEM_HXX
22 #include "MinimumAndMaximumSupplier.hxx"
23 #include <ThreeDHelper.hxx>
24 #include <chartview/ExplicitScaleValues.hxx>
25 #include <com/sun/star/drawing/HomogenMatrix.hpp>
26 #include <com/sun/star/uno/Sequence.h>
28 #include <map>
29 #include <memory>
30 #include <vector>
32 namespace chart { class ExplicitCategoriesProvider; }
33 namespace chart { class ScaleAutomatism; }
34 namespace com { namespace sun { namespace star { namespace awt { struct Rectangle; } } } }
35 namespace com { namespace sun { namespace star { namespace awt { struct Size; } } } }
36 namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
37 namespace com { namespace sun { namespace star { namespace chart2 { class XAxis; } } } }
38 namespace com { namespace sun { namespace star { namespace chart2 { class XChartDocument; } } } }
39 namespace com { namespace sun { namespace star { namespace chart2 { class XCoordinateSystem; } } } }
40 namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } } } }
41 namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } }
44 namespace chart
47 class VAxisBase;
49 class VCoordinateSystem
51 public:
52 virtual ~VCoordinateSystem();
54 static std::unique_ptr<VCoordinateSystem> createCoordinateSystem( const css::uno::Reference<
55 css::chart2::XCoordinateSystem >& xCooSysModel );
57 /// @throws css::uno::RuntimeException
58 void initPlottingTargets(
59 const css::uno::Reference< css::drawing::XShapes >& xLogicTarget
60 , const css::uno::Reference< css::drawing::XShapes >& xFinalTarget
61 , const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory
62 , css::uno::Reference< css::drawing::XShapes >& xLogicTargetForSeriesBehindAxis );
64 void setParticle( const OUString& rCooSysParticle );
66 void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix );
67 const css::drawing::HomogenMatrix& getTransformationSceneToScreen() const { return m_aMatrixSceneToScreen;}
69 //better performance for big data
70 virtual css::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const css::awt::Size& rPageSize
71 , const css::awt::Size& rPageResolution );
73 ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
74 ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
76 void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ );
77 ExplicitCategoriesProvider* getExplicitCategoriesProvider();
79 // 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
80 std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
81 // 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
82 std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
84 void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
85 bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
86 void clearMinimumAndMaximumSupplierList();
88 /**
89 * It sets the scaling parameters for the passed `ScaleAutomatism` object.
90 * Especially it sets the `m_fValueMinimum` and the `m_fValueMaximum`
91 * parameters (see `ScaleAutomatism::expandValueRange`).
92 * The value to be assigned to these two parameters is retrieved by
93 * invoking the `getMinimum` and `getMaximum` methods of the minimum-maximum
94 * supplier object that belongs to the given coordinate system.
95 * The minimum-maximum supplier object is set in the
96 * `SeriesPlotterContainer::initializeCooSysAndSeriesPlotter` method to the
97 * series plotter which is based on the coordinate system (see notes for
98 * the method). For instance for a pie chart the `m_fValueMinimum` and the
99 * `m_fValueMaximum` parameters are initialized by the `PieChart::getMinimum`
100 * and `PieChart::getMaximum` methods.
102 void prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex );
104 void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
105 , const ExplicitScaleData& rExplicitScale
106 , const ExplicitIncrementData& rExplicitIncrement );
108 void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos );
110 const css::uno::Reference< css::chart2::XCoordinateSystem >&
111 getModel() const { return m_xCooSysModel;}
114 * Create "view" axis obejcts 'VAxis' from the coordinate system model.
116 virtual void createVAxisList(
117 const css::uno::Reference< css::chart2::XChartDocument> & xChartDoc
118 , const css::awt::Size& rFontReferenceSize
119 , const css::awt::Rectangle& rMaximumSpaceForLabels
120 , bool bLimitSpaceForLabels );
122 virtual void initVAxisInList();
123 virtual void updateScalesAndIncrementsOnAxes();
125 void createMaximumAxesLabels();
126 void createAxesLabels();
127 void updatePositions();
128 void createAxesShapes();
130 virtual void createGridShapes();
132 bool getPropertySwapXAndYAxis() const;
134 sal_Int32 getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const;
136 bool needSeriesNamesForAxis() const;
137 void setSeriesNamesForAxis( const css::uno::Sequence< OUString >& rSeriesNames );
139 protected: //methods
140 VCoordinateSystem( const css::uno::Reference<
141 css::chart2::XCoordinateSystem >& xCooSys );
143 css::uno::Reference< css::chart2::XAxis >
144 getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
145 static css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > >
146 getGridListFromAxis( const css::uno::Reference< css::chart2::XAxis >& xAxis );
148 VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
150 OUString createCIDForAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
151 OUString createCIDForGrid( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
153 sal_Int32 getNumberFormatKeyForAxis( const css::uno::Reference<
154 css::chart2::XAxis >& xAxis
155 , const css::uno::Reference<
156 css::chart2::XChartDocument>& xChartDoc);
158 private: //methods
159 static void impl_adjustDimension( sal_Int32& rDimensionIndex );
160 void impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const;
162 protected: //member
163 css::uno::Reference< css::chart2::XCoordinateSystem > m_xCooSysModel;
165 OUString m_aCooSysParticle;
167 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
169 css::uno::Reference< css::drawing::XShapes > m_xLogicTargetForGrids;
170 css::uno::Reference< css::drawing::XShapes > m_xLogicTargetForAxes;
171 css::uno::Reference< css::drawing::XShapes > m_xFinalTarget;
172 css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory;
173 css::drawing::HomogenMatrix m_aMatrixSceneToScreen;
175 CuboidPlanePosition m_eLeftWallPos;
176 CuboidPlanePosition m_eBackWallPos;
177 CuboidPlanePosition m_eBottomPos;
180 * Collection of min-max suppliers which are basically different chart
181 * types present in the same coordinate system. This is used only for
182 * auto-scaling purposes.
184 MergedMinimumAndMaximumSupplier m_aMergedMinMaxSupplier;
186 css::uno::Sequence< OUString > m_aSeriesNamesForZAxis;
188 typedef std::map< tFullAxisIndex, std::shared_ptr< VAxisBase > > tVAxisMap;
190 tVAxisMap m_aAxisMap;
192 private:
193 std::vector< ExplicitScaleData > m_aExplicitScales;
194 std::vector< ExplicitIncrementData > m_aExplicitIncrements;
196 typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap;
197 typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap;
199 tFullExplicitScaleMap m_aSecondaryExplicitScales;
200 tFullExplicitIncrementMap m_aSecondaryExplicitIncrements;
202 std::unique_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider;
205 } //namespace chart
206 #endif
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */