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 INCLUDED_CHART2_SOURCE_VIEW_AXES_VCARTESIANAXIS_HXX
20 : #define INCLUDED_CHART2_SOURCE_VIEW_AXES_VCARTESIANAXIS_HXX
21 :
22 : #include "VAxisBase.hxx"
23 : #include <basegfx/vector/b2dvector.hxx>
24 :
25 : namespace chart
26 : {
27 :
28 : class VCartesianAxis : public VAxisBase
29 : {
30 : // public methods
31 : public:
32 : VCartesianAxis( const AxisProperties& rAxisProperties
33 : , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier
34 : , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
35 : , PlottingPositionHelper* pPosHelper = NULL //takes ownership
36 : );
37 :
38 : virtual ~VCartesianAxis();
39 :
40 : virtual void createMaximumLabels() SAL_OVERRIDE;
41 : virtual void createLabels() SAL_OVERRIDE;
42 : virtual void updatePositions() SAL_OVERRIDE;
43 :
44 : virtual void createShapes() SAL_OVERRIDE;
45 :
46 : virtual sal_Int32 estimateMaximumAutoMainIncrementCount() SAL_OVERRIDE;
47 : virtual void createAllTickInfos( TickInfoArraysType& rAllTickInfos ) SAL_OVERRIDE;
48 : void createAllTickInfosFromComplexCategories( TickInfoArraysType& rAllTickInfos, bool bShiftedPosition );
49 :
50 : TickIter* createLabelTickIterator( sal_Int32 nTextLevel );
51 : TickIter* createMaximumLabelTickIterator( sal_Int32 nTextLevel );
52 : sal_Int32 getTextLevelCount() const;
53 :
54 : virtual TickFactory* createTickFactory() SAL_OVERRIDE;
55 :
56 : /**
57 : * Get the value at which the other axis crosses.
58 : */
59 : double getAxisIntersectionValue() const;
60 :
61 : /**
62 : * Get the value at which label line crosses the other axis.
63 : */
64 : double getLabelLineIntersectionValue() const;
65 :
66 : /**
67 : * Get the value at which extra line crosses the other axis.
68 : *
69 : * @return a NaN if the line doesn't cross the other axis, a non-NaN value
70 : * otherwise.
71 : */
72 : double getExtraLineIntersectionValue() const;
73 :
74 : void get2DAxisMainLine(
75 : basegfx::B2DVector& rStart, basegfx::B2DVector& rEnd, AxisLabelAlignment& rLabelAlignment,
76 : double fCrossesOtherAxis ) const;
77 :
78 : //Layout interface for cartesian axes:
79 :
80 : //the returned value describes the minimum size that is necessary
81 : //for the text labels in the direction orthogonal to the axis
82 : //(for an y-axis a width is returned; in case of an x-axis the value describes a height)
83 : //the return value is measured in screen dimension
84 : //As an example the MinimumOrthogonalSize of an x-axis equals the
85 : //Font Height if the label properties allow for labels parallel to the axis.
86 : // sal_Int32 calculateMinimumOrthogonalSize( /*... parallel...*/ );
87 : //Minimum->Preferred
88 :
89 : //returns true if the MinimumOrthogonalSize can be calculated
90 : //with the creation of at most one text shape
91 : //(this is e.g. true if the parameters allow for labels parallel to the axis.)
92 : // sal_bool canQuicklyCalculateMinimumOrthogonalSize();
93 :
94 0 : struct ScreenPosAndLogicPos
95 : {
96 : double fLogicX;
97 : double fLogicY;
98 : double fLogicZ;
99 :
100 : ::basegfx::B2DVector aScreenPos;
101 : };
102 :
103 : protected: //methods
104 : /**
105 : * @return true if the text shapes have been successfully created,
106 : * otherwise false. Returning false means the AxisLabelProperties
107 : * have changed during the call, and the caller needs to call this
108 : * method once again to get the text shapes created.
109 : */
110 : bool createTextShapes( const ::com::sun::star::uno::Reference<
111 : ::com::sun::star::drawing::XShapes >& xTarget
112 : , TickIter& rTickIter
113 : , AxisLabelProperties& rAxisLabelProperties
114 : , TickFactory2D* pTickFactory
115 : , sal_Int32 nScreenDistanceBetweenTicks );
116 :
117 : void createTickMarkLineShapes( TickInfoArrayType& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory2D& rTickFactory2D, bool bOnlyAtLabels );
118 :
119 : TickFactory2D* createTickFactory2D();
120 : void hideIdenticalScreenValues( TickInfoArraysType& rTickInfos ) const;
121 :
122 : void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties
123 : , TickFactory2D* pTickFactory2D );
124 : bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
125 : , bool bIsHorizontalAxis, bool bIsVerticalAxis );
126 : bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis );
127 :
128 : ::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const;
129 : ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const;
130 : };
131 :
132 : } //namespace chart
133 : #endif
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|