Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / view / inc / VCoordinateSystem.hxx
blob7a4a7110a2e4d205487b02f2f274cc4b568eea8e
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 "ScaleAutomatism.hxx"
24 #include <ThreeDHelper.hxx>
25 #include <ExplicitCategoriesProvider.hxx>
26 #include <chartview/ExplicitScaleValues.hxx>
28 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
29 #include <com/sun/star/awt/Rectangle.hpp>
30 #include <com/sun/star/drawing/HomogenMatrix.hpp>
31 #include <com/sun/star/drawing/XShapes.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
35 #include <map>
36 #include <memory>
37 #include <vector>
39 namespace chart
42 class VAxisBase;
44 class VCoordinateSystem
46 public:
47 virtual ~VCoordinateSystem();
49 static VCoordinateSystem* createCoordinateSystem( const css::uno::Reference<
50 css::chart2::XCoordinateSystem >& xCooSysModel );
52 /// @throws css::uno::RuntimeException
53 void initPlottingTargets(
54 const css::uno::Reference< css::drawing::XShapes >& xLogicTarget
55 , const css::uno::Reference< css::drawing::XShapes >& xFinalTarget
56 , const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory
57 , css::uno::Reference< css::drawing::XShapes >& xLogicTargetForSeriesBehindAxis );
59 void setParticle( const OUString& rCooSysParticle );
61 void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix );
62 const css::drawing::HomogenMatrix& getTransformationSceneToScreen() { return m_aMatrixSceneToScreen;}
64 //better performance for big data
65 virtual css::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const css::awt::Size& rPageSize
66 , const css::awt::Size& rPageResolution );
68 ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
69 ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
71 void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ );
72 ExplicitCategoriesProvider* getExplicitCategoriesProvider();
74 // 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
75 std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
76 // 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
77 std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
79 void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
80 bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
81 void clearMinimumAndMaximumSupplierList();
83 /**
84 * It sets the scaling parameters for the passed `ScaleAutomatism` object.
85 * Especially it sets the `m_fValueMinimum` and the `m_fValueMaximum`
86 * parameters (see `ScaleAutomatism::expandValueRange`).
87 * The value to be assigned to these two parameters is retrieved by
88 * invoking the `getMinimum` and `getMaximum` methods of the minimum-maximum
89 * supplier object that belongs to the given coordinate system.
90 * The minimum-maximum supplier object is set in the
91 * `SeriesPlotterContainer::initializeCooSysAndSeriesPlotter` method to the
92 * series plotter which is based on the coordinate system (see notes for
93 * the method). For instance for a pie chart the `m_fValueMinimum` and the
94 * `m_fValueMaximum` parameters are initialized by the `PieChart::getMinimum`
95 * and `PieChart::getMaximum` methods.
97 void prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex );
99 void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
100 , const ExplicitScaleData& rExplicitScale
101 , const ExplicitIncrementData& rExplicitIncrement );
103 void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos );
105 const css::uno::Reference< css::chart2::XCoordinateSystem >&
106 getModel() const { return m_xCooSysModel;}
109 * Create "view" axis obejcts 'VAxis' from the coordinate system model.
111 virtual void createVAxisList(
112 const css::uno::Reference< css::chart2::XChartDocument> & xChartDoc
113 , const css::awt::Size& rFontReferenceSize
114 , const css::awt::Rectangle& rMaximumSpaceForLabels
115 , bool bLimitSpaceForLabels );
117 virtual void initVAxisInList();
118 virtual void updateScalesAndIncrementsOnAxes();
120 void createMaximumAxesLabels();
121 void createAxesLabels();
122 void updatePositions();
123 void createAxesShapes();
125 virtual void createGridShapes();
127 bool getPropertySwapXAndYAxis() const;
129 sal_Int32 getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const;
131 bool needSeriesNamesForAxis() const;
132 void setSeriesNamesForAxis( const css::uno::Sequence< OUString >& rSeriesNames );
134 protected: //methods
135 VCoordinateSystem( const css::uno::Reference<
136 css::chart2::XCoordinateSystem >& xCooSys );
138 css::uno::Reference< css::chart2::XAxis >
139 getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
140 static css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > >
141 getGridListFromAxis( const css::uno::Reference< css::chart2::XAxis >& xAxis );
143 VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
145 OUString createCIDForAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
146 OUString createCIDForGrid( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
148 sal_Int32 getNumberFormatKeyForAxis( const css::uno::Reference<
149 css::chart2::XAxis >& xAxis
150 , const css::uno::Reference<
151 css::chart2::XChartDocument>& xChartDoc);
153 private: //methods
154 static void impl_adjustDimension( sal_Int32& rDimensionIndex );
155 void impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const;
157 protected: //member
158 css::uno::Reference< css::chart2::XCoordinateSystem > m_xCooSysModel;
160 OUString m_aCooSysParticle;
162 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
164 css::uno::Reference< css::drawing::XShapes > m_xLogicTargetForGrids;
165 css::uno::Reference< css::drawing::XShapes > m_xLogicTargetForAxes;
166 css::uno::Reference< css::drawing::XShapes > m_xFinalTarget;
167 css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory;
168 css::drawing::HomogenMatrix m_aMatrixSceneToScreen;
170 CuboidPlanePosition m_eLeftWallPos;
171 CuboidPlanePosition m_eBackWallPos;
172 CuboidPlanePosition m_eBottomPos;
175 * Collection of min-max suppliers which are basically different chart
176 * types present in the same coordinate system. This is used only for
177 * auto-scaling purposes.
179 MergedMinimumAndMaximumSupplier m_aMergedMinMaxSupplier;
181 css::uno::Sequence< OUString > m_aSeriesNamesForZAxis;
183 typedef std::map< tFullAxisIndex, std::shared_ptr< VAxisBase > > tVAxisMap;
185 tVAxisMap m_aAxisMap;
187 private:
188 std::vector< ExplicitScaleData > m_aExplicitScales;
189 std::vector< ExplicitIncrementData > m_aExplicitIncrements;
191 typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap;
192 typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap;
194 tFullExplicitScaleMap m_aSecondaryExplicitScales;
195 tFullExplicitIncrementMap m_aSecondaryExplicitIncrements;
197 std::unique_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider;
200 } //namespace chart
201 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */