1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _CHART2_VCARTESIANAXIS_HXX
28 #define _CHART2_VCARTESIANAXIS_HXX
29 
30 #include "VAxisBase.hxx"
31 #include <basegfx/vector/b2dvector.hxx>
32 
33 #include <memory>
34 
35 //.............................................................................
36 namespace chart
37 {
38 //.............................................................................
39 
40 //-----------------------------------------------------------------------------
41 /**
42 */
43 
44 class VCartesianAxis : public VAxisBase
45 {
46     //-------------------------------------------------------------------------
47 	// public methods
48 	//-------------------------------------------------------------------------
49 public:
50     VCartesianAxis( const AxisProperties& rAxisProperties
51            , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier
52            , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
53            , PlottingPositionHelper* pPosHelper = NULL //takes ownership
54            );
55 
56     virtual ~VCartesianAxis();
57 
58     virtual void createMaximumLabels();
59     virtual void createLabels();
60     virtual void updatePositions();
61 
62     virtual void createShapes();
63 
64     virtual sal_Int32 estimateMaximumAutoMainIncrementCount();
65     virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
66     void createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition );
67 
68     ::std::auto_ptr< TickIter > createLabelTickIterator( sal_Int32 nTextLevel );
69     ::std::auto_ptr< TickIter > createMaximumLabelTickIterator( sal_Int32 nTextLevel );
70     sal_Int32 getTextLevelCount() const;
71 
72     //-------------------------------------------------------------------------
73     virtual TickFactory* createTickFactory();
74 
75     //-------------------------------------------------------------------------
76     double      getLogicValueWhereMainLineCrossesOtherAxis() const;
77     double      getLogicValueWhereLabelLineCrossesOtherAxis() const;
78     bool        getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis) const;
79     void        get2DAxisMainLine( ::basegfx::B2DVector& rStart, ::basegfx::B2DVector& rEnd, double fCrossesOtherAxis );
80 
81     //-------------------------------------------------------------------------
82     //Layout interface for cartesian axes:
83 
84     //the returned value describes the minimum size that is necessary
85     //for the text labels in the direction orthogonal to the axis
86     //(for an y-axis a width is returned; in case of an x-axis the value describes a height)
87     //the return value is measured in screen dimension
88     //As an example the MinimumOrthogonalSize of an x-axis equals the
89     //Font Height if the label properties allow for labels parallel to the axis.
90 //    sal_Int32 calculateMinimumOrthogonalSize( /*... parallel...*/ );
91     //Minimum->Preferred
92 
93     //returns true if the MinimumOrthogonalSize can be calculated
94     //with the creation of at most one text shape
95     //(this is e.g. true if the parameters allow for labels parallel to the axis.)
96 //    sal_bool  canQuicklyCalculateMinimumOrthogonalSize();
97 
98 
99     //-------------------------------------------------------------------------
100     //-------------------------------------------------------------------------
101 
102     struct ScreenPosAndLogicPos
103     {
104         double fLogicX;
105         double fLogicY;
106         double fLogicZ;
107 
108         B2DVector aScreenPos;
109     };
110 
111 protected: //methods
112     bool    createTextShapes( const ::com::sun::star::uno::Reference<
113                        ::com::sun::star::drawing::XShapes >& xTarget
114                      , TickIter& rTickIter
115                      , AxisLabelProperties& rAxisLabelProperties
116                      , TickFactory_2D* pTickFactory
117                      , sal_Int32 nScreenDistanceBetweenTicks );
118 
119     void    createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels );
120 
121     TickFactory_2D* createTickFactory2D();
122     void    hideIdenticalScreenValues(  ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const;
123 
124     void    doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties
125                             , TickFactory_2D* pTickFactory2D );
126     bool    isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
127                             , bool bIsHorizontalAxis, bool bIsVerticalAxis );
128     bool    isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis );
129 
130     ::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const;
131     ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const;
132 };
133 
134 //.............................................................................
135 } //namespace chart
136 //.............................................................................
137 #endif
138