Line data Source code
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 : #ifndef _CHART2_TICKMARKS_HXX
20 : #define _CHART2_TICKMARKS_HXX
21 :
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>
29 :
30 : #include <vector>
31 :
32 : //.............................................................................
33 : namespace chart
34 : {
35 : //.............................................................................
36 :
37 116337 : struct TickInfo
38 : {
39 : double fScaledTickValue;
40 : ::com::sun::star::uno::Reference<
41 : ::com::sun::star::chart2::XScaling > xInverseScaling;
42 :
43 : ::basegfx::B2DVector aTickScreenPosition;
44 : bool bPaintIt;
45 :
46 : ::com::sun::star::uno::Reference<
47 : ::com::sun::star::drawing::XShape > xTextShape;
48 :
49 : OUString aText;//used only for complex categories so far
50 : sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category
51 :
52 : //methods:
53 : TickInfo( const ::com::sun::star::uno::Reference<
54 : ::com::sun::star::chart2::XScaling >& xInverseScaling );
55 :
56 : double getUnscaledTickValue() const;
57 : sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const;
58 : private:
59 : TickInfo();
60 : };
61 8683 : class TickIter
62 : {
63 : public:
64 8683 : virtual ~TickIter(){};
65 : virtual TickInfo* firstInfo()=0;
66 : virtual TickInfo* nextInfo()=0;
67 : };
68 :
69 : class PureTickIter : public TickIter
70 : {
71 : public:
72 : PureTickIter( ::std::vector< TickInfo >& rTickInfoVector );
73 : virtual ~PureTickIter();
74 : virtual TickInfo* firstInfo();
75 : virtual TickInfo* nextInfo();
76 :
77 : private:
78 : ::std::vector< TickInfo >& m_rTickVector;
79 : ::std::vector< TickInfo >::iterator m_aTickIter;
80 : };
81 :
82 : class TickFactory
83 : {
84 : public:
85 : TickFactory(
86 : const ExplicitScaleData& rScale
87 : , const ExplicitIncrementData& rIncrement );
88 : virtual ~TickFactory();
89 :
90 : void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
91 : void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
92 0 : virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {}
93 :
94 : private: //methods
95 : bool isDateAxis() const;
96 :
97 : protected: //member
98 : ExplicitScaleData m_rScale;
99 : ExplicitIncrementData m_rIncrement;
100 : ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >
101 : m_xInverseScaling;
102 :
103 : //minimum and maximum of the visible range after scaling
104 : double m_fScaledVisibleMin;
105 : double m_fScaledVisibleMax;
106 : };
107 :
108 : class TickFactory_2D : public TickFactory
109 : {
110 : public:
111 : TickFactory_2D(
112 : const ExplicitScaleData& rScale
113 : , const ExplicitIncrementData& rIncrement
114 : , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos
115 : , const ::basegfx::B2DVector& rAxisLineToLabelLineShift );
116 : //, double fStrech_SceneToScreen, double fOffset_SceneToScreen );
117 : virtual ~TickFactory_2D();
118 :
119 : static sal_Int32 getTickScreenDistance( TickIter& rIter );
120 :
121 : void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const;
122 : void addPointSequenceForTickLine( ::com::sun::star::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;
129 :
130 : virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
131 :
132 : bool isHorizontalAxis() const;
133 : bool isVerticalAxis() const;
134 :
135 : protected: //methods
136 : ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const;
137 :
138 : private: //member
139 : ::basegfx::B2DVector m_aAxisStartScreenPosition2D;
140 : ::basegfx::B2DVector m_aAxisEndScreenPosition2D;
141 :
142 : //labels might be posioned high or low on the border of the diagram far away from the axis
143 : //add this vector to go from the axis line to the label line (border of the diagram)
144 : ::basegfx::B2DVector m_aAxisLineToLabelLineShift;
145 :
146 : double m_fStrech_LogicToScreen;
147 : double m_fOffset_LogicToScreen;
148 : };
149 :
150 : //.............................................................................
151 : } //namespace chart
152 : //.............................................................................
153 : #endif
154 :
155 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|