/src/libreoffice/chart2/source/view/main/SeriesPlotterContainer.hxx
Line | Count | Source |
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 | | |
20 | | #include <VSeriesPlotter.hxx> |
21 | | #include <BaseCoordinateSystem.hxx> |
22 | | #include "AxisUsage.hxx" |
23 | | |
24 | | namespace chart |
25 | | { |
26 | | /** This class is a container of `SeriesPlotter` objects (such as `PieChart` |
27 | | * instances). It is used for initializing coordinate systems, axes and scales |
28 | | * of all series plotters which belongs to the container. |
29 | | */ |
30 | | class SeriesPlotterContainer |
31 | | { |
32 | | public: |
33 | | explicit SeriesPlotterContainer(std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList); |
34 | | ~SeriesPlotterContainer(); |
35 | | |
36 | | /** It is used to set coordinate systems (`m_rVCooSysList`), this method |
37 | | * is invoked by `ChartView::createShapes2D` before of |
38 | | * `ChartView::impl_createDiagramAndContent`. |
39 | | * Coordinate systems are retrieved through the `XCoordinateSystemContainer` |
40 | | * interface implemented by a diagram object which is provided by the |
41 | | * `ChartModel` object passed to the method (`rChartModel.getFirstDiagram()`). |
42 | | * |
43 | | * It is used for creating series plotters and appending them |
44 | | * to `m_aSeriesPlotterList`. The created series plotters are initialized |
45 | | * through data (number formats supplier, color scheme, data series), |
46 | | * extracted from the chart model or the diagram objects. An exception is |
47 | | * the explicit category provider that is retrieved through the |
48 | | * `VCoordinateSystem` object used by the series plotter. |
49 | | * |
50 | | * It sets the minimum-maximum supplier for a coordinate system: |
51 | | * this supplier is the series plotter itself which utilizes the given |
52 | | * coordinate system. In fact `VSeriesPlotter` has `MinimumMaximumSupplier` |
53 | | * as one of its base classes. |
54 | | * Hence, for instance, a `PieChart`, which is a series plotter, is |
55 | | * a `MinimumMaximumSupplier`, too. |
56 | | */ |
57 | | void initializeCooSysAndSeriesPlotter(ChartModel& rModel); |
58 | | |
59 | | /** This method is invoked by `ChartView::impl_createDiagramAndContent`. |
60 | | * It iterates on every axis of every coordinate systems, and if the axis |
61 | | * is not yet present in `m_aAxisUsageList` it creates a new `AxisUsage` |
62 | | * object and initialize its `aAutoScaling` member to the `ScaleData` |
63 | | * object of the current axis. |
64 | | */ |
65 | | void initAxisUsageList(const Date& rNullDate); |
66 | | |
67 | | /** |
68 | | * Perform automatic axis scaling and determine the amount and spacing of |
69 | | * increments. It assumes that the caller has determined the size of the |
70 | | * largest axis label text object prior to calling this method. |
71 | | * |
72 | | * The new axis scaling data will be stored in the VCoordinateSystem |
73 | | * objects. The label alignment direction for each axis will also get |
74 | | * determined during this process, and stored in VAxis. |
75 | | * |
76 | | * This method is invoked by `ChartView::impl_createDiagramAndContent` |
77 | | * soon after `initAxisUsageList`. |
78 | | * It initializes explicit scale and increment objects for all coordinate |
79 | | * systems in `m_rVCooSysList`. |
80 | | * This action is achieved by iterating on the `m_aAxisUsageList` container, |
81 | | * and performing 3 steps: |
82 | | * 1- call `VCoordinateSystem::prepareAutomaticAxisScaling` for setting |
83 | | * scaling parameters of the `aAutoScaling` member (a `ScaleAutomatism` |
84 | | * object) for the current `AxisUsage` instance |
85 | | * (see `VCoordinateSystem::prepareAutomaticAxisScaling`); |
86 | | * 2- calculate the explicit scale and increment objects |
87 | | * (see ScaleAutomatism::calculateExplicitScaleAndIncrement); |
88 | | * 3- set the explicit scale and increment objects for each coordinate |
89 | | * system. |
90 | | */ |
91 | | void doAutoScaling(ChartModel& rModel); |
92 | | |
93 | | /** |
94 | | * After auto-scaling is performed, call this method to set the explicit |
95 | | * scaling and increment data to all relevant VAxis objects. |
96 | | */ |
97 | | void updateScalesAndIncrementsOnAxes(); |
98 | | |
99 | | /** |
100 | | * After auto-scaling is performed, call this method to set the explicit |
101 | | * scaling data to all the plotters. |
102 | | */ |
103 | | void setScalesFromCooSysToPlotter(); |
104 | | |
105 | | void setNumberFormatsFromAxes(); |
106 | | css::drawing::Direction3D getPreferredAspectRatio(); |
107 | | |
108 | | std::vector<std::unique_ptr<VSeriesPlotter>>& getSeriesPlotterList() |
109 | 0 | { |
110 | 0 | return m_aSeriesPlotterList; |
111 | 0 | } |
112 | 0 | std::vector<std::unique_ptr<VCoordinateSystem>>& getCooSysList() { return m_rVCooSysList; } |
113 | | std::vector<LegendEntryProvider*> getLegendEntryProviderList(); |
114 | | |
115 | | void AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel& rModel); |
116 | | |
117 | | bool isCategoryPositionShifted(const css::chart2::ScaleData& rSourceScale, |
118 | | bool bHasComplexCategories); |
119 | | |
120 | | static VCoordinateSystem* |
121 | | getCooSysForPlotter(const std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList, |
122 | | MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier); |
123 | | static VCoordinateSystem* |
124 | | addCooSysToList(std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList, |
125 | | const rtl::Reference<BaseCoordinateSystem>& xCooSys, ChartModel& rChartModel); |
126 | | static VCoordinateSystem* |
127 | | findInCooSysList(const std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList, |
128 | | const rtl::Reference<BaseCoordinateSystem>& xCooSys); |
129 | | |
130 | | private: |
131 | | /** A vector of series plotters. |
132 | | */ |
133 | | std::vector<std::unique_ptr<VSeriesPlotter>> m_aSeriesPlotterList; |
134 | | |
135 | | /** A vector of coordinate systems. |
136 | | */ |
137 | | std::vector<std::unique_ptr<VCoordinateSystem>>& m_rVCooSysList; |
138 | | |
139 | | /** A map whose key is a `XAxis` interface and the related value is |
140 | | * an object of `AxisUsage` type. |
141 | | */ |
142 | | std::map<rtl::Reference<Axis>, AxisUsage> m_aAxisUsageList; |
143 | | |
144 | | /** |
145 | | * Max axis index of all dimensions. Currently this can be either 0 or 1 |
146 | | * since we only support primary and secondary axes per dimension. The |
147 | | * value of 0 means all dimensions have only primary axis, while 1 means |
148 | | * at least one dimension has a secondary axis. |
149 | | */ |
150 | | sal_Int32 m_nMaxAxisIndex; |
151 | | |
152 | | bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; |
153 | | bool m_bTableShiftPosition = false; |
154 | | sal_Int32 m_nDefaultDateNumberFormat; |
155 | | }; |
156 | | |
157 | | } //end chart2 namespace |
158 | | |
159 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |