update dev300-m58
[ooovba.git] / chart2 / source / view / axes / VPolarRadiusAxis.cxx
blobd6859a540320dff70f57be6e3987d791d7a37b40
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VPolarRadiusAxis.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "VPolarRadiusAxis.hxx"
35 #include "VCartesianAxis.hxx"
36 #include "PlottingPositionHelper.hxx"
37 #include "CommonConverters.hxx"
38 #include <rtl/math.hxx>
40 //.............................................................................
41 namespace chart
43 //.............................................................................
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::chart2;
46 using namespace ::rtl::math;
48 VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
49 , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
50 , sal_Int32 nDimensionCount )
51 : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount )
53 m_aAxisProperties.m_fLabelDirectionSign=0.0;
54 m_aAxisProperties.m_fInnerDirectionSign=0.0;
55 m_aAxisProperties.m_bLabelsOutside=true;
56 m_aAxisProperties.m_bIsMainAxis=false;
57 m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
58 m_aAxisProperties.init();
60 m_apAxisWithLabels = std::auto_ptr<VCartesianAxis>( new VCartesianAxis(
61 m_aAxisProperties,xNumberFormatsSupplier,1/*nDimensionIndex*/,nDimensionCount
62 ,new PolarPlottingPositionHelper() ) );
65 VPolarRadiusAxis::~VPolarRadiusAxis()
67 delete m_pPosHelper;
68 m_pPosHelper = NULL;
71 void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
73 VPolarAxis::setTransformationSceneToScreen( rMatrix );
74 m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix );
77 void SAL_CALL VPolarRadiusAxis::setExplicitScaleAndIncrement(
78 const ExplicitScaleData& rScale
79 , const ExplicitIncrementData& rIncrement )
80 throw (uno::RuntimeException)
82 VPolarAxis::setExplicitScaleAndIncrement( rScale, rIncrement );
83 m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement );
86 void SAL_CALL VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget
87 , const uno::Reference< drawing::XShapes >& xFinalTarget
88 , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
89 , const rtl::OUString& rCID )
90 throw (uno::RuntimeException)
92 VPolarAxis::initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
93 m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
96 void SAL_CALL VPolarRadiusAxis::setScales( const uno::Sequence< ExplicitScaleData >& rScales
97 , sal_Bool bSwapXAndYAxis )
98 throw (uno::RuntimeException)
100 VPolarAxis::setScales( rScales, bSwapXAndYAxis );
101 m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis );
104 void SAL_CALL VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize
105 , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels )
107 VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
108 m_apAxisWithLabels->initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
111 sal_Int32 VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount()
113 return 2;
116 bool VPolarRadiusAxis::prepareShapeCreation()
118 //returns true if all is ready for further shape creation and any shapes need to be created
119 if( !isAnythingToDraw() )
120 return false;
122 if( m_xGroupShape_Shapes.is() )
123 return true;
125 return true;
128 void SAL_CALL VPolarRadiusAxis::createMaximumLabels()
130 m_apAxisWithLabels->createMaximumLabels();
133 void SAL_CALL VPolarRadiusAxis::updatePositions()
135 m_apAxisWithLabels->updatePositions();
138 void SAL_CALL VPolarRadiusAxis::createLabels()
140 m_apAxisWithLabels->createLabels();
143 void SAL_CALL VPolarRadiusAxis::createShapes()
145 if( !prepareShapeCreation() )
146 return;
148 const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
149 const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
151 ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos;
152 TickmarkHelper aAngleTickmarkHelper( rAngleScale, rAngleIncrement );
153 aAngleTickmarkHelper.getAllTicks( aAngleTickInfos );
155 uno::Reference< XScaling > xInverseScaling( NULL );
156 if( rAngleScale.Scaling.is() )
157 xInverseScaling = rAngleScale.Scaling->getInverseScaling();
159 AxisProperties aAxisProperties(m_aAxisProperties);
161 sal_Int32 nTick = 0;
162 TickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
163 for( TickInfo* pTickInfo = aIter.firstInfo()
164 ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
166 if( nTick == 0 )
168 m_apAxisWithLabels->createShapes();
169 continue;
172 pTickInfo->updateUnscaledValue( xInverseScaling );
173 aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->fUnscaledTickValue );
174 aAxisProperties.m_bDisplayLabels=false;
176 //-------------------
177 VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier
178 ,1,2,new PolarPlottingPositionHelper());
179 aAxis.setExplicitScaleAndIncrement( m_aScale, m_aIncrement );
180 aAxis.initPlotter(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory, m_aCID );
181 aAxis.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene ) );
182 aAxis.setScales( m_pPosHelper->getScales(), false );
183 aAxis.initAxisLabelProperties(m_aAxisLabelProperties.m_aFontReferenceSize,m_aAxisLabelProperties.m_aMaximumSpaceForLabels);
184 aAxis.createShapes();
188 //.............................................................................
189 } //namespace chart
190 //.............................................................................