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