1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VPolarCoordinateSystem.cxx,v $
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"
33 #include "VPolarCoordinateSystem.hxx"
34 #include "VPolarGrid.hxx"
35 #include "VPolarAxis.hxx"
36 #include "AxisIndexDefines.hxx"
37 #include "AxisHelper.hxx"
39 //.............................................................................
42 //.............................................................................
43 using namespace ::com::sun::star
;
44 using namespace ::com::sun::star::chart2
;
45 using ::com::sun::star::uno::Reference
;
47 VPolarCoordinateSystem::VPolarCoordinateSystem( const Reference
< XCoordinateSystem
>& xCooSys
)
48 : VCoordinateSystem(xCooSys
)
52 VPolarCoordinateSystem::~VPolarCoordinateSystem()
56 //better performance for big data
57 uno::Sequence
< sal_Int32
> VPolarCoordinateSystem::getCoordinateSystemResolution(
58 const awt::Size
& rPageSize
, const awt::Size
& rPageResolution
)
60 uno::Sequence
< sal_Int32
> aResolution( VCoordinateSystem::getCoordinateSystemResolution( rPageSize
, rPageResolution
) );
62 if( aResolution
.getLength() >= 2 )
64 if( this->getPropertySwapXAndYAxis() )
66 aResolution
[0]/=2;//radius
67 aResolution
[1]*=4;//outer circle resolution
71 aResolution
[0]*=4;//outer circle resolution
72 aResolution
[1]/=2;//radius
79 void VPolarCoordinateSystem::createVAxisList(
80 const uno::Reference
< util::XNumberFormatsSupplier
> & xNumberFormatsSupplier
81 , const awt::Size
& rFontReferenceSize
82 , const awt::Rectangle
& rMaximumSpaceForLabels
87 //if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
90 sal_Int32 nDimensionCount
= m_xCooSysModel
->getDimension();
91 // bool bSwapXAndY = this->getPropertySwapXAndYAxis();
93 sal_Int32 nDimensionIndex
= 0;
95 //create angle axis (dimension index 0)
96 for( nDimensionIndex
= 0; nDimensionIndex
< nDimensionCount
; nDimensionIndex
++ )
98 sal_Int32 nMaxAxisIndex
= m_xCooSysModel
->getMaximumAxisIndexByDimension(nDimensionIndex
);
99 for( sal_Int32 nAxisIndex
= 0; nAxisIndex
<= nMaxAxisIndex
; nAxisIndex
++ )
101 Reference
< XAxis
> xAxis( this->getAxisByDimension(nDimensionIndex
,nAxisIndex
) );
102 if(!xAxis
.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis
, m_xCooSysModel
))
104 AxisProperties
aAxisProperties(xAxis
,this->getExplicitCategoriesProvider());
105 aAxisProperties
.init();
106 if(aAxisProperties
.m_bDisplayLabels
)
107 aAxisProperties
.m_nNumberFormatKey
= this->getNumberFormatKeyForAxis( xAxis
, xNumberFormatsSupplier
);
108 //-------------------
109 ::boost::shared_ptr
< VAxisBase
> apVAxis( VPolarAxis::createAxis( aAxisProperties
,xNumberFormatsSupplier
,nDimensionIndex
,nDimensionCount
) );
110 tFullAxisIndex
aFullAxisIndex( nDimensionIndex
, nAxisIndex
);
111 m_aAxisMap
[aFullAxisIndex
] = apVAxis
;
113 //apVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) );
114 //apVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory
115 // , this->createCIDForAxis( xAxis, nDimensionIndex, nAxisIndex ) );
116 //VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( apVAxis.get() );
118 // pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
119 //if(2==nDimensionCount)
120 // apVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
121 //apVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
122 apVAxis
->initAxisLabelProperties(rFontReferenceSize
,rMaximumSpaceForLabels
);
127 void VPolarCoordinateSystem::initVAxisInList()
129 if(!m_xLogicTargetForAxes
.is() || !m_xFinalTarget
.is() || !m_xCooSysModel
.is() )
132 sal_Int32 nDimensionCount
= m_xCooSysModel
->getDimension();
133 bool bSwapXAndY
= this->getPropertySwapXAndYAxis();
135 tVAxisMap::iterator
aIt( m_aAxisMap
.begin() );
136 tVAxisMap::const_iterator
aEnd( m_aAxisMap
.end() );
137 for( ; aIt
!= aEnd
; ++aIt
)
139 VAxisBase
* pVAxis
= aIt
->second
.get();
142 sal_Int32 nDimensionIndex
= aIt
->first
.first
;
143 sal_Int32 nAxisIndex
= aIt
->first
.second
;
144 pVAxis
->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex
, nAxisIndex
), this->getExplicitIncrement(nDimensionIndex
, nAxisIndex
) );
145 pVAxis
->initPlotter(m_xLogicTargetForAxes
,m_xFinalTarget
,m_xShapeFactory
146 , this->createCIDForAxis( getAxisByDimension( nDimensionIndex
, nAxisIndex
), nDimensionIndex
, nAxisIndex
) );
147 VPolarAxis
* pVPolarAxis
= dynamic_cast< VPolarAxis
* >( pVAxis
);
149 pVPolarAxis
->setIncrements( this->getExplicitIncrements( nDimensionIndex
, nAxisIndex
) );
150 if(2==nDimensionCount
)
151 pVAxis
->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
152 pVAxis
->setScales( this->getExplicitScales( nDimensionIndex
, nAxisIndex
), bSwapXAndY
);
157 void VPolarCoordinateSystem::updateScalesAndIncrementsOnAxes()
159 if(!m_xLogicTargetForAxes
.is() || !m_xFinalTarget
.is() || !m_xCooSysModel
.is() )
162 sal_Int32 nDimensionCount
= m_xCooSysModel
->getDimension();
163 bool bSwapXAndY
= this->getPropertySwapXAndYAxis();
165 tVAxisMap::iterator
aIt( m_aAxisMap
.begin() );
166 tVAxisMap::const_iterator
aEnd( m_aAxisMap
.end() );
167 for( ; aIt
!= aEnd
; ++aIt
)
169 VAxisBase
* pVAxis
= aIt
->second
.get();
172 sal_Int32 nDimensionIndex
= aIt
->first
.first
;
173 sal_Int32 nAxisIndex
= aIt
->first
.second
;
174 pVAxis
->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex
, nAxisIndex
), this->getExplicitIncrement(nDimensionIndex
, nAxisIndex
) );
175 VPolarAxis
* pVPolarAxis
= dynamic_cast< VPolarAxis
* >( pVAxis
);
177 pVPolarAxis
->setIncrements( this->getExplicitIncrements( nDimensionIndex
, nAxisIndex
) );
178 if(2==nDimensionCount
)
179 pVAxis
->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
180 pVAxis
->setScales( this->getExplicitScales( nDimensionIndex
, nAxisIndex
), bSwapXAndY
);
185 void VPolarCoordinateSystem::createGridShapes()
187 if(!m_xLogicTargetForGrids
.is() || !m_xFinalTarget
.is() )
190 sal_Int32 nDimensionCount
= m_xCooSysModel
->getDimension();
191 bool bSwapXAndY
= this->getPropertySwapXAndYAxis();
193 for( sal_Int32 nDimensionIndex
=0; nDimensionIndex
<3; nDimensionIndex
++)
195 sal_Int32 nAxisIndex
= MAIN_AXIS_INDEX
;
197 Reference
< XAxis
> xAxis( AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, m_xCooSysModel
) );
198 if(!xAxis
.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis
, m_xCooSysModel
))
201 VPolarGrid
aGrid(nDimensionIndex
,nDimensionCount
,this->getGridListFromAxis( xAxis
));
202 aGrid
.setIncrements( this->getExplicitIncrements( nDimensionIndex
, nAxisIndex
) );
203 aGrid
.initPlotter(m_xLogicTargetForGrids
,m_xFinalTarget
,m_xShapeFactory
204 , this->createCIDForGrid( xAxis
, nDimensionIndex
, nAxisIndex
) );
205 if(2==nDimensionCount
)
206 aGrid
.setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
207 aGrid
.setScales( this->getExplicitScales( nDimensionIndex
, nAxisIndex
), bSwapXAndY
);
208 aGrid
.createShapes();
212 //.............................................................................
214 //.............................................................................