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