1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_chart2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "VPolarRadiusAxis.hxx" 32*cdf0e10cSrcweir #include "VCartesianAxis.hxx" 33*cdf0e10cSrcweir #include "PlottingPositionHelper.hxx" 34*cdf0e10cSrcweir #include "CommonConverters.hxx" 35*cdf0e10cSrcweir #include "Tickmarks_Equidistant.hxx" 36*cdf0e10cSrcweir #include <rtl/math.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir //............................................................................. 39*cdf0e10cSrcweir namespace chart 40*cdf0e10cSrcweir { 41*cdf0e10cSrcweir //............................................................................. 42*cdf0e10cSrcweir using namespace ::com::sun::star; 43*cdf0e10cSrcweir using namespace ::com::sun::star::chart2; 44*cdf0e10cSrcweir using namespace ::rtl::math; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties 47*cdf0e10cSrcweir , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier 48*cdf0e10cSrcweir , sal_Int32 nDimensionCount ) 49*cdf0e10cSrcweir : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount ) 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign=0.0; 52*cdf0e10cSrcweir m_aAxisProperties.m_fInnerDirectionSign=0.0; 53*cdf0e10cSrcweir m_aAxisProperties.m_bIsMainAxis=false; 54*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT; 55*cdf0e10cSrcweir m_aAxisProperties.init(); 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir m_apAxisWithLabels = std::auto_ptr<VCartesianAxis>( new VCartesianAxis( 58*cdf0e10cSrcweir m_aAxisProperties,xNumberFormatsSupplier,1/*nDimensionIndex*/,nDimensionCount 59*cdf0e10cSrcweir ,new PolarPlottingPositionHelper() ) ); 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir VPolarRadiusAxis::~VPolarRadiusAxis() 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir delete m_pPosHelper; 65*cdf0e10cSrcweir m_pPosHelper = NULL; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir VPolarAxis::setTransformationSceneToScreen( rMatrix ); 71*cdf0e10cSrcweir m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix ); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir void VPolarRadiusAxis::setExplicitScaleAndIncrement( 75*cdf0e10cSrcweir const ExplicitScaleData& rScale 76*cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement ) 77*cdf0e10cSrcweir throw (uno::RuntimeException) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir VPolarAxis::setExplicitScaleAndIncrement( rScale, rIncrement ); 80*cdf0e10cSrcweir m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement ); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget 84*cdf0e10cSrcweir , const uno::Reference< drawing::XShapes >& xFinalTarget 85*cdf0e10cSrcweir , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory 86*cdf0e10cSrcweir , const rtl::OUString& rCID ) 87*cdf0e10cSrcweir throw (uno::RuntimeException) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir VPolarAxis::initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID ); 90*cdf0e10cSrcweir m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID ); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir VPolarAxis::setScales( rScales, bSwapXAndYAxis ); 96*cdf0e10cSrcweir m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis ); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize 100*cdf0e10cSrcweir , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels ); 103*cdf0e10cSrcweir m_apAxisWithLabels->initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir sal_Int32 VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir return 2; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir bool VPolarRadiusAxis::prepareShapeCreation() 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir //returns true if all is ready for further shape creation and any shapes need to be created 114*cdf0e10cSrcweir if( !isAnythingToDraw() ) 115*cdf0e10cSrcweir return false; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir if( m_xGroupShape_Shapes.is() ) 118*cdf0e10cSrcweir return true; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir return true; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void VPolarRadiusAxis::createMaximumLabels() 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir m_apAxisWithLabels->createMaximumLabels(); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir void VPolarRadiusAxis::updatePositions() 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir m_apAxisWithLabels->updatePositions(); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void VPolarRadiusAxis::createLabels() 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir m_apAxisWithLabels->createLabels(); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void VPolarRadiusAxis::createShapes() 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir if( !prepareShapeCreation() ) 141*cdf0e10cSrcweir return; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0]; 144*cdf0e10cSrcweir const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0]; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos; 147*cdf0e10cSrcweir TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement ); 148*cdf0e10cSrcweir aAngleTickFactory.getAllTicks( aAngleTickInfos ); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir uno::Reference< XScaling > xInverseScaling( NULL ); 151*cdf0e10cSrcweir if( rAngleScale.Scaling.is() ) 152*cdf0e10cSrcweir xInverseScaling = rAngleScale.Scaling->getInverseScaling(); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir AxisProperties aAxisProperties(m_aAxisProperties); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir sal_Int32 nTick = 0; 157*cdf0e10cSrcweir EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 ); 158*cdf0e10cSrcweir for( TickInfo* pTickInfo = aIter.firstInfo() 159*cdf0e10cSrcweir ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir if( nTick == 0 ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir m_apAxisWithLabels->createShapes(); 164*cdf0e10cSrcweir continue; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); 168*cdf0e10cSrcweir aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() ); 169*cdf0e10cSrcweir aAxisProperties.m_bDisplayLabels=false; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir //------------------- 172*cdf0e10cSrcweir VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier 173*cdf0e10cSrcweir ,1,2,new PolarPlottingPositionHelper()); 174*cdf0e10cSrcweir aAxis.setExplicitScaleAndIncrement( m_aScale, m_aIncrement ); 175*cdf0e10cSrcweir aAxis.initPlotter(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory, m_aCID ); 176*cdf0e10cSrcweir aAxis.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene ) ); 177*cdf0e10cSrcweir aAxis.setScales( m_pPosHelper->getScales(), false ); 178*cdf0e10cSrcweir aAxis.initAxisLabelProperties(m_aAxisLabelProperties.m_aFontReferenceSize,m_aAxisLabelProperties.m_aMaximumSpaceForLabels); 179*cdf0e10cSrcweir aAxis.createShapes(); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir //............................................................................. 184*cdf0e10cSrcweir } //namespace chart 185*cdf0e10cSrcweir //............................................................................. 186