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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_chartview.hxx" 26 27 #include "VPolarRadiusAxis.hxx" 28 #include "VCartesianAxis.hxx" 29 #include "PlottingPositionHelper.hxx" 30 #include "CommonConverters.hxx" 31 #include "Tickmarks_Equidistant.hxx" 32 #include <rtl/math.hxx> 33 34 //............................................................................. 35 namespace chart 36 { 37 //............................................................................. 38 using namespace ::com::sun::star; 39 using namespace ::com::sun::star::chart2; 40 using namespace ::rtl::math; 41 42 VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties 43 , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier 44 , sal_Int32 nDimensionCount ) 45 : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount ) 46 { 47 m_aAxisProperties.m_fLabelDirectionSign=0.0; 48 m_aAxisProperties.m_fInnerDirectionSign=0.0; 49 m_aAxisProperties.m_bIsMainAxis=false; 50 m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT; 51 m_aAxisProperties.init(); 52 53 m_apAxisWithLabels = std::auto_ptr<VCartesianAxis>( new VCartesianAxis( 54 m_aAxisProperties,xNumberFormatsSupplier,1/*nDimensionIndex*/,nDimensionCount 55 ,new PolarPlottingPositionHelper() ) ); 56 } 57 58 VPolarRadiusAxis::~VPolarRadiusAxis() 59 { 60 delete m_pPosHelper; 61 m_pPosHelper = NULL; 62 } 63 64 void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) 65 { 66 VPolarAxis::setTransformationSceneToScreen( rMatrix ); 67 m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix ); 68 } 69 70 void VPolarRadiusAxis::setExplicitScaleAndIncrement( 71 const ExplicitScaleData& rScale 72 , const ExplicitIncrementData& rIncrement ) 73 { 74 VPolarAxis::setExplicitScaleAndIncrement( rScale, rIncrement ); 75 m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement ); 76 } 77 78 void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget 79 , const uno::Reference< drawing::XShapes >& xFinalTarget 80 , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory 81 , const rtl::OUString& rCID ) 82 { 83 VPolarAxis::initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID ); 84 m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID ); 85 } 86 87 void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) 88 { 89 VPolarAxis::setScales( rScales, bSwapXAndYAxis ); 90 m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis ); 91 } 92 93 void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize 94 , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ) 95 { 96 VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels ); 97 m_apAxisWithLabels->initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels ); 98 } 99 100 sal_Int32 VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount() 101 { 102 return 2; 103 } 104 105 bool VPolarRadiusAxis::prepareShapeCreation() 106 { 107 //returns true if all is ready for further shape creation and any shapes need to be created 108 if( !isAnythingToDraw() ) 109 return false; 110 111 if( m_xGroupShape_Shapes.is() ) 112 return true; 113 114 return true; 115 } 116 117 void VPolarRadiusAxis::createMaximumLabels() 118 { 119 m_apAxisWithLabels->createMaximumLabels(); 120 } 121 122 void VPolarRadiusAxis::updatePositions() 123 { 124 m_apAxisWithLabels->updatePositions(); 125 } 126 127 void VPolarRadiusAxis::createLabels() 128 { 129 m_apAxisWithLabels->createLabels(); 130 } 131 132 void VPolarRadiusAxis::createShapes() 133 { 134 if( !prepareShapeCreation() ) 135 return; 136 137 const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0]; 138 const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0]; 139 140 ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos; 141 TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement ); 142 aAngleTickFactory.getAllTicks( aAngleTickInfos ); 143 144 uno::Reference< XScaling > xInverseScaling( NULL ); 145 if( rAngleScale.Scaling.is() ) 146 xInverseScaling = rAngleScale.Scaling->getInverseScaling(); 147 148 AxisProperties aAxisProperties(m_aAxisProperties); 149 150 sal_Int32 nTick = 0; 151 EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 ); 152 for( TickInfo* pTickInfo = aIter.firstInfo() 153 ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ ) 154 { 155 if( nTick == 0 ) 156 { 157 m_apAxisWithLabels->createShapes(); 158 continue; 159 } 160 161 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); 162 aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() ); 163 aAxisProperties.m_bDisplayLabels=false; 164 165 //------------------- 166 VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier 167 ,1,2,new PolarPlottingPositionHelper()); 168 aAxis.setExplicitScaleAndIncrement( m_aScale, m_aIncrement ); 169 aAxis.initPlotter(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory, m_aCID ); 170 aAxis.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene ) ); 171 aAxis.setScales( m_pPosHelper->getScales(), false ); 172 aAxis.initAxisLabelProperties(m_aAxisLabelProperties.m_aFontReferenceSize,m_aAxisLabelProperties.m_aMaximumSpaceForLabels); 173 aAxis.createShapes(); 174 } 175 } 176 177 //............................................................................. 178 } //namespace chart 179 //............................................................................. 180