tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / view / axes / Tickmarks.hxx
blob2266c03c91d271128e5eda69a176d944f20957ee
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 #pragma once
21 #include <chartview/ExplicitScaleValues.hxx>
22 #include <basegfx/vector/b2dvector.hxx>
23 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
24 #include <rtl/ref.hxx>
25 #include <svx/unoshape.hxx>
26 #include <vector>
28 namespace chart { struct AxisProperties; }
29 namespace chart { struct TickmarkProperties; }
30 namespace com::sun::star::chart2 { class XScaling; }
31 namespace com::sun::star::drawing { class XShape; }
33 namespace chart {
35 struct TickInfo
37 double fScaledTickValue;
38 css::uno::Reference<css::chart2::XScaling> xInverseScaling;
39 rtl::Reference<SvxShapeText> xTextShape;
40 OUString aText;//used only for complex categories so far
41 ::basegfx::B2DVector aTickScreenPosition;
42 sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category
43 bool bPaintIt;
45 //methods:
46 TickInfo() = delete;
47 explicit TickInfo( css::uno::Reference<css::chart2::XScaling> xInverse );
49 /**
50 * Return a value associated with the tick mark. It's normally an original
51 * value from the data source, or 1-based integer index in case the axis
52 * is a category axis.
54 double getUnscaledTickValue() const;
55 sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const;
58 typedef std::vector<TickInfo> TickInfoArrayType;
59 typedef std::vector<TickInfoArrayType> TickInfoArraysType;
61 class TickIter
63 public:
64 virtual ~TickIter() {}
65 virtual TickInfo* firstInfo() = 0;
66 virtual TickInfo* nextInfo() = 0;
69 class PureTickIter : public TickIter
71 public:
72 explicit PureTickIter( TickInfoArrayType& rTickInfoVector );
73 virtual ~PureTickIter() override;
74 virtual TickInfo* firstInfo() override;
75 virtual TickInfo* nextInfo() override;
77 private:
78 TickInfoArrayType& m_rTickVector;
79 TickInfoArrayType::iterator m_aTickIter;
82 class TickFactory
84 public:
85 TickFactory(
86 ExplicitScaleData aScale
87 , ExplicitIncrementData aIncrement );
88 virtual ~TickFactory();
90 void getAllTicks( TickInfoArraysType& rAllTickInfos ) const;
91 void getAllTicksShifted( TickInfoArraysType& rAllTickInfos ) const;
93 private: //methods
94 bool isDateAxis() const;
96 protected: //member
97 ExplicitScaleData m_rScale;
98 ExplicitIncrementData m_rIncrement;
99 css::uno::Reference< css::chart2::XScaling > m_xInverseScaling;
101 //minimum and maximum of the visible range after scaling
102 double m_fScaledVisibleMin;
103 double m_fScaledVisibleMax;
106 class TickFactory2D final : public TickFactory
108 public:
109 TickFactory2D(
110 const ExplicitScaleData& rScale
111 , const ExplicitIncrementData& rIncrement
112 , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos
113 , const ::basegfx::B2DVector& rAxisLineToLabelLineShift );
115 virtual ~TickFactory2D() override;
117 static sal_Int32 getTickScreenDistance( TickIter& rIter );
119 void createPointSequenceForAxisMainLine( css::drawing::PointSequenceSequence& rPoints ) const;
120 void addPointSequenceForTickLine( css::drawing::PointSequenceSequence& rPoints
121 , sal_Int32 nSequenceIndex
122 , double fScaledLogicTickValue, double fInnerDirectionSign
123 , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const;
124 ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties
125 , bool bIncludeFarAwayDistanceIfSo = false
126 , bool bIncludeSpaceBetweenTickAndText = true ) const;
129 * Determine the screen positions of all ticks based on their numeric values.
131 void updateScreenValues( TickInfoArraysType& rAllTickInfos ) const;
133 bool isHorizontalAxis() const;
134 bool isVerticalAxis() const;
136 const ::basegfx::B2DVector & getXaxisStartPos() const
138 return m_aAxisStartScreenPosition2D;
141 const ::basegfx::B2DVector & getXaxisEndPos() const
143 return m_aAxisEndScreenPosition2D;
146 private:
147 ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const;
149 ::basegfx::B2DVector m_aAxisStartScreenPosition2D;
150 ::basegfx::B2DVector m_aAxisEndScreenPosition2D;
152 //labels might be positioned high or low on the border of the diagram far away from the axis
153 //add this vector to go from the axis line to the label line (border of the diagram)
154 ::basegfx::B2DVector m_aAxisLineToLabelLineShift;
156 double m_fStretch_LogicToScreen;
157 double m_fOffset_LogicToScreen;
160 } //namespace chart
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */