1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CHART2_VCARTESIANAXIS_HXX 24 #define _CHART2_VCARTESIANAXIS_HXX 25 26 #include "VAxisBase.hxx" 27 #include <basegfx/vector/b2dvector.hxx> 28 29 #include <memory> 30 31 //............................................................................. 32 namespace chart 33 { 34 //............................................................................. 35 36 //----------------------------------------------------------------------------- 37 /** 38 */ 39 40 class VCartesianAxis : public VAxisBase 41 { 42 //------------------------------------------------------------------------- 43 // public methods 44 //------------------------------------------------------------------------- 45 public: 46 VCartesianAxis( const AxisProperties& rAxisProperties 47 , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier 48 , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount 49 , PlottingPositionHelper* pPosHelper = NULL //takes ownership 50 ); 51 52 virtual ~VCartesianAxis(); 53 54 virtual void createMaximumLabels(); 55 virtual void createLabels(); 56 virtual void updatePositions(); 57 58 virtual void createShapes(); 59 60 virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); 61 virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ); 62 void createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition ); 63 64 ::std::auto_ptr< TickIter > createLabelTickIterator( sal_Int32 nTextLevel ); 65 ::std::auto_ptr< TickIter > createMaximumLabelTickIterator( sal_Int32 nTextLevel ); 66 sal_Int32 getTextLevelCount() const; 67 68 //------------------------------------------------------------------------- 69 virtual TickFactory* createTickFactory(); 70 71 //------------------------------------------------------------------------- 72 double getLogicValueWhereMainLineCrossesOtherAxis() const; 73 double getLogicValueWhereLabelLineCrossesOtherAxis() const; 74 bool getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis) const; 75 void get2DAxisMainLine( ::basegfx::B2DVector& rStart, ::basegfx::B2DVector& rEnd, double fCrossesOtherAxis ); 76 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 95 //------------------------------------------------------------------------- 96 //------------------------------------------------------------------------- 97 98 struct ScreenPosAndLogicPos 99 { 100 double fLogicX; 101 double fLogicY; 102 double fLogicZ; 103 104 B2DVector aScreenPos; 105 }; 106 107 protected: //methods 108 bool createTextShapes( const ::com::sun::star::uno::Reference< 109 ::com::sun::star::drawing::XShapes >& xTarget 110 , TickIter& rTickIter 111 , AxisLabelProperties& rAxisLabelProperties 112 , TickFactory_2D* pTickFactory 113 , sal_Int32 nScreenDistanceBetweenTicks ); 114 115 void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ); 116 117 TickFactory_2D* createTickFactory2D(); 118 void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const; 119 120 void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties 121 , TickFactory_2D* pTickFactory2D ); 122 bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties 123 , bool bIsHorizontalAxis, bool bIsVerticalAxis ); 124 bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ); 125 126 ::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const; 127 ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const; 128 }; 129 130 //............................................................................. 131 } //namespace chart 132 //............................................................................. 133 #endif 134