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