1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "VPolarCoordinateSystem.hxx"
27cdf0e10cSrcweir #include "VPolarGrid.hxx"
28cdf0e10cSrcweir #include "VPolarAxis.hxx"
29cdf0e10cSrcweir #include "AxisIndexDefines.hxx"
30cdf0e10cSrcweir #include "AxisHelper.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir //.............................................................................
33cdf0e10cSrcweir namespace chart
34cdf0e10cSrcweir {
35cdf0e10cSrcweir //.............................................................................
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
38cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
39cdf0e10cSrcweir
VPolarCoordinateSystem(const Reference<XCoordinateSystem> & xCooSys)40cdf0e10cSrcweir VPolarCoordinateSystem::VPolarCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
41cdf0e10cSrcweir : VCoordinateSystem(xCooSys)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir
~VPolarCoordinateSystem()45cdf0e10cSrcweir VPolarCoordinateSystem::~VPolarCoordinateSystem()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir }
48cdf0e10cSrcweir
49cdf0e10cSrcweir //better performance for big data
getCoordinateSystemResolution(const awt::Size & rPageSize,const awt::Size & rPageResolution)50cdf0e10cSrcweir uno::Sequence< sal_Int32 > VPolarCoordinateSystem::getCoordinateSystemResolution(
51cdf0e10cSrcweir const awt::Size& rPageSize, const awt::Size& rPageResolution )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir uno::Sequence< sal_Int32 > aResolution( VCoordinateSystem::getCoordinateSystemResolution( rPageSize, rPageResolution) );
54cdf0e10cSrcweir
55cdf0e10cSrcweir if( aResolution.getLength() >= 2 )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir if( this->getPropertySwapXAndYAxis() )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir aResolution[0]/=2;//radius
60cdf0e10cSrcweir aResolution[1]*=4;//outer circle resolution
61cdf0e10cSrcweir }
62cdf0e10cSrcweir else
63cdf0e10cSrcweir {
64cdf0e10cSrcweir aResolution[0]*=4;//outer circle resolution
65cdf0e10cSrcweir aResolution[1]/=2;//radius
66cdf0e10cSrcweir }
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
69cdf0e10cSrcweir return aResolution;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
createVAxisList(const uno::Reference<util::XNumberFormatsSupplier> & xNumberFormatsSupplier,const awt::Size & rFontReferenceSize,const awt::Rectangle & rMaximumSpaceForLabels)72cdf0e10cSrcweir void VPolarCoordinateSystem::createVAxisList(
73cdf0e10cSrcweir const uno::Reference< util::XNumberFormatsSupplier > & xNumberFormatsSupplier
74cdf0e10cSrcweir , const awt::Size& rFontReferenceSize
75cdf0e10cSrcweir , const awt::Rectangle& rMaximumSpaceForLabels
76cdf0e10cSrcweir )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir m_aAxisMap.clear();
79cdf0e10cSrcweir
80cdf0e10cSrcweir //if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
81cdf0e10cSrcweir // return;
82cdf0e10cSrcweir
83cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
84cdf0e10cSrcweir // bool bSwapXAndY = this->getPropertySwapXAndYAxis();
85cdf0e10cSrcweir
86cdf0e10cSrcweir sal_Int32 nDimensionIndex = 0;
87cdf0e10cSrcweir
88cdf0e10cSrcweir //create angle axis (dimension index 0)
89cdf0e10cSrcweir for( nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir sal_Int32 nMaxAxisIndex = m_xCooSysModel->getMaximumAxisIndexByDimension(nDimensionIndex);
92cdf0e10cSrcweir for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir Reference< XAxis > xAxis( this->getAxisByDimension(nDimensionIndex,nAxisIndex) );
95cdf0e10cSrcweir if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
96cdf0e10cSrcweir continue;
97cdf0e10cSrcweir AxisProperties aAxisProperties(xAxis,this->getExplicitCategoriesProvider());
98cdf0e10cSrcweir aAxisProperties.init();
99cdf0e10cSrcweir if(aAxisProperties.m_bDisplayLabels)
100cdf0e10cSrcweir aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier );
101cdf0e10cSrcweir //-------------------
102cdf0e10cSrcweir ::boost::shared_ptr< VAxisBase > apVAxis( VPolarAxis::createAxis( aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
103cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
104cdf0e10cSrcweir m_aAxisMap[aFullAxisIndex] = apVAxis;
105cdf0e10cSrcweir
106cdf0e10cSrcweir apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
107cdf0e10cSrcweir }
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
initVAxisInList()111cdf0e10cSrcweir void VPolarCoordinateSystem::initVAxisInList()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
114cdf0e10cSrcweir return;
115cdf0e10cSrcweir
116cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
117cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
118cdf0e10cSrcweir
119cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
120cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
121cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
124cdf0e10cSrcweir if( pVAxis )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir sal_Int32 nDimensionIndex = aIt->first.first;
127cdf0e10cSrcweir sal_Int32 nAxisIndex = aIt->first.second;
128cdf0e10cSrcweir pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) );
129cdf0e10cSrcweir pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory
130cdf0e10cSrcweir , this->createCIDForAxis( getAxisByDimension( nDimensionIndex, nAxisIndex ), nDimensionIndex, nAxisIndex ) );
131cdf0e10cSrcweir VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis );
132cdf0e10cSrcweir if( pVPolarAxis )
133cdf0e10cSrcweir pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
134cdf0e10cSrcweir if(2==nDimensionCount)
135cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
136cdf0e10cSrcweir pVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
137cdf0e10cSrcweir }
138cdf0e10cSrcweir }
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
updateScalesAndIncrementsOnAxes()141cdf0e10cSrcweir void VPolarCoordinateSystem::updateScalesAndIncrementsOnAxes()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
144cdf0e10cSrcweir return;
145cdf0e10cSrcweir
146cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
147cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
148cdf0e10cSrcweir
149cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
150cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
151cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
154cdf0e10cSrcweir if( pVAxis )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir sal_Int32 nDimensionIndex = aIt->first.first;
157cdf0e10cSrcweir sal_Int32 nAxisIndex = aIt->first.second;
158cdf0e10cSrcweir pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) );
159cdf0e10cSrcweir VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis );
160cdf0e10cSrcweir if( pVPolarAxis )
161cdf0e10cSrcweir pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
162cdf0e10cSrcweir if(2==nDimensionCount)
163cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
164cdf0e10cSrcweir pVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
createGridShapes()169cdf0e10cSrcweir void VPolarCoordinateSystem::createGridShapes()
170cdf0e10cSrcweir {
171cdf0e10cSrcweir if(!m_xLogicTargetForGrids.is() || !m_xFinalTarget.is() )
172cdf0e10cSrcweir return;
173cdf0e10cSrcweir
174cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
175cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
176cdf0e10cSrcweir
177cdf0e10cSrcweir for( sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir sal_Int32 nAxisIndex = MAIN_AXIS_INDEX;
180cdf0e10cSrcweir
181cdf0e10cSrcweir Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, m_xCooSysModel ) );
182cdf0e10cSrcweir if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
183cdf0e10cSrcweir continue;
184cdf0e10cSrcweir
185cdf0e10cSrcweir VPolarGrid aGrid(nDimensionIndex,nDimensionCount,this->getGridListFromAxis( xAxis ));
186cdf0e10cSrcweir aGrid.setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
187cdf0e10cSrcweir aGrid.initPlotter(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory
188cdf0e10cSrcweir , this->createCIDForGrid( xAxis, nDimensionIndex, nAxisIndex ) );
189cdf0e10cSrcweir if(2==nDimensionCount)
190cdf0e10cSrcweir aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
191cdf0e10cSrcweir aGrid.setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex), bSwapXAndY );
192cdf0e10cSrcweir aGrid.createShapes();
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir //.............................................................................
197cdf0e10cSrcweir } //namespace chart
198cdf0e10cSrcweir //.............................................................................
199