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 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 #include "VPolarCoordinateSystem.hxx" 31 #include "VPolarGrid.hxx" 32 #include "VPolarAxis.hxx" 33 #include "AxisIndexDefines.hxx" 34 #include "AxisHelper.hxx" 35 36 //............................................................................. 37 namespace chart 38 { 39 //............................................................................. 40 using namespace ::com::sun::star; 41 using namespace ::com::sun::star::chart2; 42 using ::com::sun::star::uno::Reference; 43 44 VPolarCoordinateSystem::VPolarCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys ) 45 : VCoordinateSystem(xCooSys) 46 { 47 } 48 49 VPolarCoordinateSystem::~VPolarCoordinateSystem() 50 { 51 } 52 53 //better performance for big data 54 uno::Sequence< sal_Int32 > VPolarCoordinateSystem::getCoordinateSystemResolution( 55 const awt::Size& rPageSize, const awt::Size& rPageResolution ) 56 { 57 uno::Sequence< sal_Int32 > aResolution( VCoordinateSystem::getCoordinateSystemResolution( rPageSize, rPageResolution) ); 58 59 if( aResolution.getLength() >= 2 ) 60 { 61 if( this->getPropertySwapXAndYAxis() ) 62 { 63 aResolution[0]/=2;//radius 64 aResolution[1]*=4;//outer circle resolution 65 } 66 else 67 { 68 aResolution[0]*=4;//outer circle resolution 69 aResolution[1]/=2;//radius 70 } 71 } 72 73 return aResolution; 74 } 75 76 void VPolarCoordinateSystem::createVAxisList( 77 const uno::Reference< util::XNumberFormatsSupplier > & xNumberFormatsSupplier 78 , const awt::Size& rFontReferenceSize 79 , const awt::Rectangle& rMaximumSpaceForLabels 80 ) 81 { 82 m_aAxisMap.clear(); 83 84 //if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() ) 85 // return; 86 87 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); 88 // bool bSwapXAndY = this->getPropertySwapXAndYAxis(); 89 90 sal_Int32 nDimensionIndex = 0; 91 92 //create angle axis (dimension index 0) 93 for( nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ ) 94 { 95 sal_Int32 nMaxAxisIndex = m_xCooSysModel->getMaximumAxisIndexByDimension(nDimensionIndex); 96 for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ ) 97 { 98 Reference< XAxis > xAxis( this->getAxisByDimension(nDimensionIndex,nAxisIndex) ); 99 if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel )) 100 continue; 101 AxisProperties aAxisProperties(xAxis,this->getExplicitCategoriesProvider()); 102 aAxisProperties.init(); 103 if(aAxisProperties.m_bDisplayLabels) 104 aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier ); 105 //------------------- 106 ::boost::shared_ptr< VAxisBase > apVAxis( VPolarAxis::createAxis( aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) ); 107 tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex ); 108 m_aAxisMap[aFullAxisIndex] = apVAxis; 109 110 apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); 111 } 112 } 113 } 114 115 void VPolarCoordinateSystem::initVAxisInList() 116 { 117 if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() ) 118 return; 119 120 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); 121 bool bSwapXAndY = this->getPropertySwapXAndYAxis(); 122 123 tVAxisMap::iterator aIt( m_aAxisMap.begin() ); 124 tVAxisMap::const_iterator aEnd( m_aAxisMap.end() ); 125 for( ; aIt != aEnd; ++aIt ) 126 { 127 VAxisBase* pVAxis = aIt->second.get(); 128 if( pVAxis ) 129 { 130 sal_Int32 nDimensionIndex = aIt->first.first; 131 sal_Int32 nAxisIndex = aIt->first.second; 132 pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) ); 133 pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory 134 , this->createCIDForAxis( getAxisByDimension( nDimensionIndex, nAxisIndex ), nDimensionIndex, nAxisIndex ) ); 135 VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis ); 136 if( pVPolarAxis ) 137 pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) ); 138 if(2==nDimensionCount) 139 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen ); 140 pVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY ); 141 } 142 } 143 } 144 145 void VPolarCoordinateSystem::updateScalesAndIncrementsOnAxes() 146 { 147 if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() ) 148 return; 149 150 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); 151 bool bSwapXAndY = this->getPropertySwapXAndYAxis(); 152 153 tVAxisMap::iterator aIt( m_aAxisMap.begin() ); 154 tVAxisMap::const_iterator aEnd( m_aAxisMap.end() ); 155 for( ; aIt != aEnd; ++aIt ) 156 { 157 VAxisBase* pVAxis = aIt->second.get(); 158 if( pVAxis ) 159 { 160 sal_Int32 nDimensionIndex = aIt->first.first; 161 sal_Int32 nAxisIndex = aIt->first.second; 162 pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) ); 163 VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis ); 164 if( pVPolarAxis ) 165 pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) ); 166 if(2==nDimensionCount) 167 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen ); 168 pVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY ); 169 } 170 } 171 } 172 173 void VPolarCoordinateSystem::createGridShapes() 174 { 175 if(!m_xLogicTargetForGrids.is() || !m_xFinalTarget.is() ) 176 return; 177 178 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); 179 bool bSwapXAndY = this->getPropertySwapXAndYAxis(); 180 181 for( sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++) 182 { 183 sal_Int32 nAxisIndex = MAIN_AXIS_INDEX; 184 185 Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, m_xCooSysModel ) ); 186 if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel )) 187 continue; 188 189 VPolarGrid aGrid(nDimensionIndex,nDimensionCount,this->getGridListFromAxis( xAxis )); 190 aGrid.setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) ); 191 aGrid.initPlotter(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory 192 , this->createCIDForGrid( xAxis, nDimensionIndex, nAxisIndex ) ); 193 if(2==nDimensionCount) 194 aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen ); 195 aGrid.setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex), bSwapXAndY ); 196 aGrid.createShapes(); 197 } 198 } 199 200 //............................................................................. 201 } //namespace chart 202 //............................................................................. 203