Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / view / axes / Tickmarks.hxx
blobf08d2d9aff66471f2ca2ccbddc37cb18c7ae0f65
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_AXES_TICKMARKS_HXX
20 #define INCLUDED_CHART2_SOURCE_VIEW_AXES_TICKMARKS_HXX
22 #include "TickmarkProperties.hxx"
23 #include "VAxisProperties.hxx"
24 #include <chartview/ExplicitScaleValues.hxx>
25 #include <basegfx/vector/b2dvector.hxx>
26 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/uno/Sequence.h>
30 #include <vector>
32 namespace chart {
34 struct TickInfo
36 double fScaledTickValue;
37 css::uno::Reference<css::chart2::XScaling> xInverseScaling;
39 ::basegfx::B2DVector aTickScreenPosition;
40 bool bPaintIt;
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
47 //methods:
48 TickInfo() = delete;
49 explicit TickInfo( const css::uno::Reference<css::chart2::XScaling>& xInverse );
51 /**
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
54 * is a category 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;
63 class TickIter
65 public:
66 virtual ~TickIter() {}
67 virtual TickInfo* firstInfo() = 0;
68 virtual TickInfo* nextInfo() = 0;
71 class PureTickIter : public TickIter
73 public:
74 explicit PureTickIter( TickInfoArrayType& rTickInfoVector );
75 virtual ~PureTickIter() override;
76 virtual TickInfo* firstInfo() override;
77 virtual TickInfo* nextInfo() override;
79 private:
80 TickInfoArrayType& m_rTickVector;
81 TickInfoArrayType::iterator m_aTickIter;
84 class TickFactory
86 public:
87 TickFactory(
88 const ExplicitScaleData& rScale
89 , const ExplicitIncrementData& rIncrement );
90 virtual ~TickFactory();
92 void getAllTicks( TickInfoArraysType& rAllTickInfos ) const;
93 void getAllTicksShifted( TickInfoArraysType& rAllTickInfos ) const;
95 private: //methods
96 bool isDateAxis() const;
98 protected: //member
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
110 public:
111 TickFactory2D(
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;
138 private:
139 ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const;
141 ::basegfx::B2DVector m_aAxisStartScreenPosition2D;
142 ::basegfx::B2DVector m_aAxisEndScreenPosition2D;
144 //labels might be positioned high or low on the border of the diagram far away from the axis
145 //add this vector to go from the axis line to the label line (border of the diagram)
146 ::basegfx::B2DVector m_aAxisLineToLabelLineShift;
148 double m_fStretch_LogicToScreen;
149 double m_fOffset_LogicToScreen;
152 } //namespace chart
154 #endif
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */