1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "VAxisBase.hxx"
22 #include <basegfx/vector/b2dvector.hxx>
26 class VCartesianAxis
: public VAxisBase
30 VCartesianAxis( const AxisProperties
& rAxisProperties
31 , const css::uno::Reference
< css::util::XNumberFormatsSupplier
>& xNumberFormatsSupplier
32 , sal_Int32 nDimensionIndex
, sal_Int32 nDimensionCount
33 , PlottingPositionHelper
* pPosHelper
= nullptr //takes ownership
36 virtual ~VCartesianAxis() override
;
38 virtual void createMaximumLabels() override
;
39 virtual void createLabels() override
;
40 virtual void updatePositions() override
;
42 virtual void createShapes() override
;
44 virtual sal_Int32
estimateMaximumAutoMainIncrementCount() override
;
45 virtual void createAllTickInfos( TickInfoArraysType
& rAllTickInfos
) override
;
46 void createAllTickInfosFromComplexCategories( TickInfoArraysType
& rAllTickInfos
, bool bShiftedPosition
);
48 TickIter
* createLabelTickIterator( sal_Int32 nTextLevel
);
49 TickIter
* createMaximumLabelTickIterator( sal_Int32 nTextLevel
);
50 sal_Int32
getTextLevelCount() const;
52 virtual TickFactory
* createTickFactory() override
;
55 * Get the value at which the other axis crosses.
57 double getAxisIntersectionValue() const;
60 * Get the value at which label line crosses the other axis.
62 double getLabelLineIntersectionValue() const;
65 * Get the value at which extra line crosses the other axis.
67 * @return a NaN if the line doesn't cross the other axis, a non-NaN value
70 double getExtraLineIntersectionValue() const;
72 void get2DAxisMainLine(
73 basegfx::B2DVector
& rStart
, basegfx::B2DVector
& rEnd
, AxisLabelAlignment
& rLabelAlignment
,
74 double fCrossesOtherAxis
) const;
76 //Layout interface for cartesian axes:
78 //the returned value describes the minimum size that is necessary
79 //for the text labels in the direction orthogonal to the axis
80 //(for an y-axis a width is returned; in case of an x-axis the value describes a height)
81 //the return value is measured in screen dimension
82 //As an example the MinimumOrthogonalSize of an x-axis equals the
83 //Font Height if the label properties allow for labels parallel to the axis.
84 // sal_Int32 calculateMinimumOrthogonalSize( /*... parallel...*/ );
87 //returns true if the MinimumOrthogonalSize can be calculated
88 //with the creation of at most one text shape
89 //(this is e.g. true if the parameters allow for labels parallel to the axis.)
90 // sal_bool canQuicklyCalculateMinimumOrthogonalSize();
92 struct ScreenPosAndLogicPos
98 ::basegfx::B2DVector aScreenPos
;
101 void createDataTableView(std::vector
<std::unique_ptr
<VSeriesPlotter
>>& rSeriesPlotterList
,
102 css::uno::Reference
<css::util::XNumberFormatsSupplier
> const& xNumberFormatsSupplier
,
103 rtl::Reference
<::chart::ChartModel
> const& xChartDoc
,
104 css::uno::Reference
<css::uno::XComponentContext
> const& rComponentContext
) override
;
107 * Go through all tick label positions and decide which labels to display
108 * based on the text shape geometry, overlap setting, tick interval,
109 * auto-stagger setting etc.
111 * When the auto-stagger setting is on, try to avoid overlaps by
112 * staggering labels or set the labels at an angle. This method may
113 * change the axis label properties especially when the auto staggering is
114 * performed. But the screen label positions will not be shifted in this
115 * method; it will be done in the doStaggeringOfLabels method.
117 * @return true if the text shapes have been successfully created,
118 * otherwise false. Returning false means the AxisLabelProperties
119 * have changed during the call, and the caller needs to call this
120 * method once again to get the text shapes created.
122 bool createTextShapes(
123 const rtl::Reference
< SvxShapeGroupAnyD
>& xTarget
,
124 TickIter
& rTickIter
, AxisLabelProperties
& rAxisLabelProperties
,
125 TickFactory2D
const * pTickFactory
, sal_Int32 nScreenDistanceBetweenTicks
);
128 * Variant of createTextShapes where none of auto-staggering and
129 * link-breaking are allowed in case of overlaps. Overlaps of text shapes
130 * are to be resolved only by adjusting the label tick interval.
132 bool createTextShapesSimple(
133 const rtl::Reference
< SvxShapeGroupAnyD
>& xTarget
,
134 TickIter
& rTickIter
, AxisLabelProperties
& rAxisLabelProperties
,
135 TickFactory2D
const * pTickFactory
);
137 void createTickMarkLineShapes( TickInfoArrayType
& rTickInfos
, const TickmarkProperties
& rTickmarkProperties
, TickFactory2D
const & rTickFactory2D
, bool bOnlyAtLabels
);
139 TickFactory2D
* createTickFactory2D();
140 void hideIdenticalScreenValues( TickInfoArraysType
& rTickInfos
) const;
143 * Shift the screen positions of the tick labels according to the stagger
144 * settings. Final stagger setting is decided during the createTextShapes
145 * call, but this method does the physical shifting of the label
146 * positions based on the final stagger setting.
148 void doStaggeringOfLabels( const AxisLabelProperties
& rAxisLabelProperties
149 , TickFactory2D
const * pTickFactory2D
);
152 * @return true if we can break a single line label text into multiple
153 * lines for better fitting, otherwise false.
155 bool isBreakOfLabelsAllowed( const AxisLabelProperties
& rAxisLabelProperties
, bool bIsHorizontalAxis
, bool bIsVerticalAxis
) const;
157 ::basegfx::B2DVector
getScreenPosition( double fLogicX
, double fLogicY
, double fLogicZ
) const;
158 ScreenPosAndLogicPos
getScreenPosAndLogicPos( double fLogicX
, double fLogicY
, double fLogicZ
) const;
160 void createDataTableShape(std::unique_ptr
<TickFactory2D
> const& rTickFactory2D
);
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */