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 <chartview/ExplicitScaleValues.hxx>
22 #include <basegfx/vector/b2dvector.hxx>
23 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
27 namespace chart
{ struct AxisProperties
; }
28 namespace chart
{ struct TickmarkProperties
; }
29 namespace com::sun::star::chart2
{ class XScaling
; }
30 namespace com::sun::star::drawing
{ class XShape
; }
36 double fScaledTickValue
;
37 css::uno::Reference
<css::chart2::XScaling
> xInverseScaling
;
39 ::basegfx::B2DVector aTickScreenPosition
;
42 css::uno::Reference
<css::drawing::XShape
> xTextShape
;
44 OUString aText
;//used only for complex categories so far
45 sal_Int32 nFactorForLimitedTextWidth
;//categories in higher levels of complex categories can have more place than a single simple category
49 explicit TickInfo( const css::uno::Reference
<css::chart2::XScaling
>& xInverse
);
52 * Return a value associated with the tick mark. It's normally an original
53 * value from the data source, or 1-based integer index in case the axis
56 double getUnscaledTickValue() const;
57 sal_Int32
getScreenDistanceBetweenTicks( const TickInfo
& rOherTickInfo
) const;
60 typedef std::vector
<TickInfo
> TickInfoArrayType
;
61 typedef std::vector
<TickInfoArrayType
> TickInfoArraysType
;
66 virtual ~TickIter() {}
67 virtual TickInfo
* firstInfo() = 0;
68 virtual TickInfo
* nextInfo() = 0;
71 class PureTickIter
: public TickIter
74 explicit PureTickIter( TickInfoArrayType
& rTickInfoVector
);
75 virtual ~PureTickIter() override
;
76 virtual TickInfo
* firstInfo() override
;
77 virtual TickInfo
* nextInfo() override
;
80 TickInfoArrayType
& m_rTickVector
;
81 TickInfoArrayType::iterator m_aTickIter
;
88 const ExplicitScaleData
& rScale
89 , const ExplicitIncrementData
& rIncrement
);
90 virtual ~TickFactory();
92 void getAllTicks( TickInfoArraysType
& rAllTickInfos
) const;
93 void getAllTicksShifted( TickInfoArraysType
& rAllTickInfos
) const;
96 bool isDateAxis() const;
99 ExplicitScaleData m_rScale
;
100 ExplicitIncrementData m_rIncrement
;
101 css::uno::Reference
< css::chart2::XScaling
> m_xInverseScaling
;
103 //minimum and maximum of the visible range after scaling
104 double m_fScaledVisibleMin
;
105 double m_fScaledVisibleMax
;
108 class TickFactory2D final
: public TickFactory
112 const ExplicitScaleData
& rScale
113 , const ExplicitIncrementData
& rIncrement
114 , const ::basegfx::B2DVector
& rStartScreenPos
, const ::basegfx::B2DVector
& rEndScreenPos
115 , const ::basegfx::B2DVector
& rAxisLineToLabelLineShift
);
117 virtual ~TickFactory2D() override
;
119 static sal_Int32
getTickScreenDistance( TickIter
& rIter
);
121 void createPointSequenceForAxisMainLine( css::drawing::PointSequenceSequence
& rPoints
) const;
122 void addPointSequenceForTickLine( css::drawing::PointSequenceSequence
& rPoints
123 , sal_Int32 nSequenceIndex
124 , double fScaledLogicTickValue
, double fInnerDirectionSign
125 , const TickmarkProperties
& rTickmarkProperties
, bool bPlaceAtLabels
) const;
126 ::basegfx::B2DVector
getDistanceAxisTickToText( const AxisProperties
& rAxisProperties
127 , bool bIncludeFarAwayDistanceIfSo
= false
128 , bool bIncludeSpaceBetweenTickAndText
= true ) const;
131 * Determine the screen positions of all ticks based on their numeric values.
133 void updateScreenValues( TickInfoArraysType
& rAllTickInfos
) const;
135 bool isHorizontalAxis() const;
136 bool isVerticalAxis() const;
137 ::basegfx::B2DVector
getXaxisStartPos() const;
140 ::basegfx::B2DVector
getTickScreenPosition2D( double fScaledLogicTickValue
) const;
142 ::basegfx::B2DVector m_aAxisStartScreenPosition2D
;
143 ::basegfx::B2DVector m_aAxisEndScreenPosition2D
;
145 //labels might be positioned high or low on the border of the diagram far away from the axis
146 //add this vector to go from the axis line to the label line (border of the diagram)
147 ::basegfx::B2DVector m_aAxisLineToLabelLineShift
;
149 double m_fStretch_LogicToScreen
;
150 double m_fOffset_LogicToScreen
;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */