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 "VCoordinateSystem.hxx"
27cdf0e10cSrcweir #include "VCartesianCoordinateSystem.hxx"
28cdf0e10cSrcweir #include "VPolarCoordinateSystem.hxx"
29cdf0e10cSrcweir #include "ScaleAutomatism.hxx"
30cdf0e10cSrcweir #include "VSeriesPlotter.hxx"
31cdf0e10cSrcweir #include "ShapeFactory.hxx"
32cdf0e10cSrcweir #include "servicenames_coosystems.hxx"
33cdf0e10cSrcweir #include "macros.hxx"
34cdf0e10cSrcweir #include "AxisIndexDefines.hxx"
35cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
36cdf0e10cSrcweir #include "ExplicitCategoriesProvider.hxx"
37cdf0e10cSrcweir #include "AxisHelper.hxx"
38cdf0e10cSrcweir #include "ContainerHelper.hxx"
39cdf0e10cSrcweir #include "VAxisBase.hxx"
40cdf0e10cSrcweir #include "ViewDefines.hxx"
41cdf0e10cSrcweir #include "DataSeriesHelper.hxx"
42cdf0e10cSrcweir #include "chartview/ExplicitValueProvider.hxx"
43cdf0e10cSrcweir #include <com/sun/star/chart2/AxisType.hpp>
44cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeContainer.hpp>
45cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
46cdf0e10cSrcweir
47cdf0e10cSrcweir // header for define DBG_ASSERT
48cdf0e10cSrcweir #include <tools/debug.hxx>
49cdf0e10cSrcweir #include <rtl/math.hxx>
50cdf0e10cSrcweir
51cdf0e10cSrcweir //.............................................................................
52cdf0e10cSrcweir namespace chart
53cdf0e10cSrcweir {
54cdf0e10cSrcweir //.............................................................................
55cdf0e10cSrcweir using namespace ::com::sun::star;
56cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
57cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
58cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
59cdf0e10cSrcweir
createCoordinateSystem(const Reference<XCoordinateSystem> & xCooSysModel)60cdf0e10cSrcweir VCoordinateSystem* VCoordinateSystem::createCoordinateSystem(
61cdf0e10cSrcweir const Reference< XCoordinateSystem >& xCooSysModel )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir if( !xCooSysModel.is() )
64cdf0e10cSrcweir return 0;
65cdf0e10cSrcweir
66cdf0e10cSrcweir rtl::OUString aViewServiceName = xCooSysModel->getViewServiceName();
67cdf0e10cSrcweir
68cdf0e10cSrcweir //@todo: in future the coordinatesystems should be instanciated via service factory
69cdf0e10cSrcweir VCoordinateSystem* pRet=NULL;
70cdf0e10cSrcweir if( aViewServiceName.equals( CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME ) )
71cdf0e10cSrcweir pRet = new VCartesianCoordinateSystem(xCooSysModel);
72cdf0e10cSrcweir else if( aViewServiceName.equals( CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME ) )
73cdf0e10cSrcweir pRet = new VPolarCoordinateSystem(xCooSysModel);
74cdf0e10cSrcweir if(!pRet)
75cdf0e10cSrcweir pRet = new VCoordinateSystem(xCooSysModel);
76cdf0e10cSrcweir return pRet;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
VCoordinateSystem(const Reference<XCoordinateSystem> & xCooSys)79cdf0e10cSrcweir VCoordinateSystem::VCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
80cdf0e10cSrcweir : m_xCooSysModel(xCooSys)
81cdf0e10cSrcweir , m_xLogicTargetForGrids(0)
82cdf0e10cSrcweir , m_xLogicTargetForAxes(0)
83cdf0e10cSrcweir , m_xFinalTarget(0)
84cdf0e10cSrcweir , m_xShapeFactory(0)
85cdf0e10cSrcweir , m_aMatrixSceneToScreen()
86cdf0e10cSrcweir , m_eLeftWallPos(CuboidPlanePosition_Left)
87cdf0e10cSrcweir , m_eBackWallPos(CuboidPlanePosition_Back)
88cdf0e10cSrcweir , m_eBottomPos(CuboidPlanePosition_Bottom)
89cdf0e10cSrcweir , m_aMergedMinimumAndMaximumSupplier()
90cdf0e10cSrcweir , m_aExplicitScales(3)
91cdf0e10cSrcweir , m_aExplicitIncrements(3)
92cdf0e10cSrcweir , m_apExplicitCategoriesProvider(NULL)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir if( !m_xCooSysModel.is() || m_xCooSysModel->getDimension()<3 )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir m_aExplicitScales[2].Minimum = 1.0;
97cdf0e10cSrcweir m_aExplicitScales[2].Maximum = 2.0;
98cdf0e10cSrcweir m_aExplicitScales[2].Orientation = AxisOrientation_MATHEMATICAL;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir }
~VCoordinateSystem()101cdf0e10cSrcweir VCoordinateSystem::~VCoordinateSystem()
102cdf0e10cSrcweir {
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
initPlottingTargets(const Reference<drawing::XShapes> & xLogicTarget,const Reference<drawing::XShapes> & xFinalTarget,const Reference<lang::XMultiServiceFactory> & xShapeFactory,Reference<drawing::XShapes> & xLogicTargetForSeriesBehindAxis)105cdf0e10cSrcweir void VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes >& xLogicTarget
106cdf0e10cSrcweir , const Reference< drawing::XShapes >& xFinalTarget
107cdf0e10cSrcweir , const Reference< lang::XMultiServiceFactory >& xShapeFactory
108cdf0e10cSrcweir , Reference< drawing::XShapes >& xLogicTargetForSeriesBehindAxis )
109cdf0e10cSrcweir throw (uno::RuntimeException)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir DBG_ASSERT(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters");
112cdf0e10cSrcweir //is only allowed to be called once
113cdf0e10cSrcweir
114cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
115cdf0e10cSrcweir //create group shape for grids first thus axes are always painted above grids
116cdf0e10cSrcweir ShapeFactory aShapeFactory(xShapeFactory);
117cdf0e10cSrcweir if(nDimensionCount==2)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir //create and add to target
120cdf0e10cSrcweir m_xLogicTargetForGrids = aShapeFactory.createGroup2D( xLogicTarget );
121cdf0e10cSrcweir xLogicTargetForSeriesBehindAxis = aShapeFactory.createGroup2D( xLogicTarget );
122cdf0e10cSrcweir m_xLogicTargetForAxes = aShapeFactory.createGroup2D( xLogicTarget );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir else
125cdf0e10cSrcweir {
126cdf0e10cSrcweir //create and added to target
127cdf0e10cSrcweir m_xLogicTargetForGrids = aShapeFactory.createGroup3D( xLogicTarget );
128cdf0e10cSrcweir xLogicTargetForSeriesBehindAxis = aShapeFactory.createGroup3D( xLogicTarget );
129cdf0e10cSrcweir m_xLogicTargetForAxes = aShapeFactory.createGroup3D( xLogicTarget );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir m_xFinalTarget = xFinalTarget;
132cdf0e10cSrcweir m_xShapeFactory = xShapeFactory;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
setParticle(const rtl::OUString & rCooSysParticle)135cdf0e10cSrcweir void VCoordinateSystem::setParticle( const rtl::OUString& rCooSysParticle )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir m_aCooSysParticle = rCooSysParticle;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
setTransformationSceneToScreen(const drawing::HomogenMatrix & rMatrix)140cdf0e10cSrcweir void VCoordinateSystem::setTransformationSceneToScreen(
141cdf0e10cSrcweir const drawing::HomogenMatrix& rMatrix )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir m_aMatrixSceneToScreen = rMatrix;
144cdf0e10cSrcweir
145cdf0e10cSrcweir //correct transformation for axis
146cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
147cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
148cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
151cdf0e10cSrcweir if( pVAxis )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir if(2==pVAxis->getDimensionCount())
154cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
155cdf0e10cSrcweir }
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
getTransformationSceneToScreen()159cdf0e10cSrcweir drawing::HomogenMatrix VCoordinateSystem::getTransformationSceneToScreen()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir return m_aMatrixSceneToScreen;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir //better performance for big data
getCoordinateSystemResolution(const awt::Size & rPageSize,const awt::Size & rPageResolution)165cdf0e10cSrcweir uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution(
166cdf0e10cSrcweir const awt::Size& rPageSize, const awt::Size& rPageResolution )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir uno::Sequence< sal_Int32 > aResolution(2);
169cdf0e10cSrcweir
170cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
171cdf0e10cSrcweir if(nDimensionCount>2)
172cdf0e10cSrcweir aResolution.realloc(nDimensionCount);
173cdf0e10cSrcweir sal_Int32 nN = 0;
174cdf0e10cSrcweir for( nN = 0 ;nN<aResolution.getLength(); nN++ )
175cdf0e10cSrcweir aResolution[nN]=1000;
176cdf0e10cSrcweir
177cdf0e10cSrcweir ::basegfx::B3DTuple aScale( BaseGFXHelper::GetScaleFromMatrix(
178cdf0e10cSrcweir BaseGFXHelper::HomogenMatrixToB3DHomMatrix(
179cdf0e10cSrcweir m_aMatrixSceneToScreen ) ) );
180cdf0e10cSrcweir
181cdf0e10cSrcweir double fCoosysWidth = static_cast< double >( fabs(aScale.getX()*FIXED_SIZE_FOR_3D_CHART_VOLUME));
182cdf0e10cSrcweir double fCoosysHeight = static_cast< double >( fabs(aScale.getY()*FIXED_SIZE_FOR_3D_CHART_VOLUME));
183cdf0e10cSrcweir
184cdf0e10cSrcweir double fPageWidth = rPageSize.Width;
185cdf0e10cSrcweir double fPageHeight = rPageSize.Height;
186cdf0e10cSrcweir
187cdf0e10cSrcweir //factor 2 to avoid rounding problems
188cdf0e10cSrcweir sal_Int32 nXResolution = static_cast<sal_Int32>(2.0*static_cast<double>(rPageResolution.Width)*fCoosysWidth/fPageWidth);
189cdf0e10cSrcweir sal_Int32 nYResolution = static_cast<sal_Int32>(2.0*static_cast<double>(rPageResolution.Height)*fCoosysHeight/fPageHeight);
190cdf0e10cSrcweir
191cdf0e10cSrcweir if( nXResolution < 10 )
192cdf0e10cSrcweir nXResolution = 10;
193cdf0e10cSrcweir if( nYResolution < 10 )
194cdf0e10cSrcweir nYResolution = 10;
195cdf0e10cSrcweir
196cdf0e10cSrcweir if( this->getPropertySwapXAndYAxis() )
197cdf0e10cSrcweir std::swap(nXResolution,nYResolution);
198cdf0e10cSrcweir
199cdf0e10cSrcweir //2D
200cdf0e10cSrcweir if( 2 == aResolution.getLength() )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir aResolution[0]=nXResolution;
203cdf0e10cSrcweir aResolution[1]=nYResolution;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir else
206cdf0e10cSrcweir {
207cdf0e10cSrcweir //this maybe can be optimized further ...
208cdf0e10cSrcweir sal_Int32 nMaxResolution = std::max( nXResolution, nYResolution );
209cdf0e10cSrcweir nMaxResolution*=2;
210cdf0e10cSrcweir for( nN = 0 ;nN<aResolution.getLength(); nN++ )
211cdf0e10cSrcweir aResolution[nN]=nMaxResolution;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir return aResolution;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
getModel() const217cdf0e10cSrcweir Reference< XCoordinateSystem > VCoordinateSystem::getModel() const
218cdf0e10cSrcweir {
219cdf0e10cSrcweir return m_xCooSysModel;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
getAxisByDimension(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex) const222cdf0e10cSrcweir Reference< XAxis > VCoordinateSystem::getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
223cdf0e10cSrcweir {
224cdf0e10cSrcweir if( m_xCooSysModel.is() )
225cdf0e10cSrcweir return m_xCooSysModel->getAxisByDimension( nDimensionIndex, nAxisIndex );
226cdf0e10cSrcweir return 0;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
getGridListFromAxis(const Reference<XAxis> & xAxis)229cdf0e10cSrcweir Sequence< Reference< beans::XPropertySet > > VCoordinateSystem::getGridListFromAxis( const Reference< XAxis >& xAxis )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir std::vector< Reference< beans::XPropertySet > > aRet;
232cdf0e10cSrcweir
233cdf0e10cSrcweir if( xAxis.is() )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir aRet.push_back( xAxis->getGridProperties() );
236cdf0e10cSrcweir std::vector< Reference< beans::XPropertySet > > aSubGrids( ContainerHelper::SequenceToVector( xAxis->getSubGridProperties() ) );
237cdf0e10cSrcweir aRet.insert( aRet.end(), aSubGrids.begin(), aSubGrids.end() );
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir return ContainerHelper::ContainerToSequence( aRet );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
impl_adjustDimension(sal_Int32 & rDimensionIndex) const243cdf0e10cSrcweir void VCoordinateSystem::impl_adjustDimension( sal_Int32& rDimensionIndex ) const
244cdf0e10cSrcweir {
245cdf0e10cSrcweir if( rDimensionIndex<0 )
246cdf0e10cSrcweir rDimensionIndex=0;
247cdf0e10cSrcweir if( rDimensionIndex>2 )
248cdf0e10cSrcweir rDimensionIndex=2;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
impl_adjustDimensionAndIndex(sal_Int32 & rDimensionIndex,sal_Int32 & rAxisIndex) const251cdf0e10cSrcweir void VCoordinateSystem::impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const
252cdf0e10cSrcweir {
253cdf0e10cSrcweir impl_adjustDimension( rDimensionIndex );
254cdf0e10cSrcweir
255cdf0e10cSrcweir if( rAxisIndex < 0 || rAxisIndex > this->getMaximumAxisIndexByDimension(rDimensionIndex) )
256cdf0e10cSrcweir rAxisIndex = 0;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
setExplicitCategoriesProvider(ExplicitCategoriesProvider * pExplicitCategoriesProvider)259cdf0e10cSrcweir void VCoordinateSystem::setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider /*takes ownership*/ )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir m_apExplicitCategoriesProvider = ::std::auto_ptr< ExplicitCategoriesProvider >(pExplicitCategoriesProvider);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
getExplicitCategoriesProvider()264cdf0e10cSrcweir ExplicitCategoriesProvider* VCoordinateSystem::getExplicitCategoriesProvider()
265cdf0e10cSrcweir {
266cdf0e10cSrcweir return m_apExplicitCategoriesProvider.get();
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
getExplicitScales(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex) const269cdf0e10cSrcweir std::vector< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
270cdf0e10cSrcweir {
271cdf0e10cSrcweir std::vector< ExplicitScaleData > aRet(m_aExplicitScales);
272cdf0e10cSrcweir
273cdf0e10cSrcweir impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
274cdf0e10cSrcweir aRet[nDimensionIndex]=this->getExplicitScale( nDimensionIndex, nAxisIndex );
275cdf0e10cSrcweir
276cdf0e10cSrcweir return aRet;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
getExplicitIncrements(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex) const279cdf0e10cSrcweir std::vector< ExplicitIncrementData > VCoordinateSystem::getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
280cdf0e10cSrcweir {
281cdf0e10cSrcweir std::vector< ExplicitIncrementData > aRet(m_aExplicitIncrements);
282cdf0e10cSrcweir
283cdf0e10cSrcweir impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
284cdf0e10cSrcweir aRet[nDimensionIndex]=this->getExplicitIncrement( nDimensionIndex, nAxisIndex );
285cdf0e10cSrcweir
286cdf0e10cSrcweir return aRet;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
getExplicitScale(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex) const289cdf0e10cSrcweir ExplicitScaleData VCoordinateSystem::getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
290cdf0e10cSrcweir {
291cdf0e10cSrcweir ExplicitScaleData aRet;
292cdf0e10cSrcweir
293cdf0e10cSrcweir impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
294cdf0e10cSrcweir
295cdf0e10cSrcweir if( nAxisIndex == 0)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir aRet = m_aExplicitScales[nDimensionIndex];
298cdf0e10cSrcweir }
299cdf0e10cSrcweir else
300cdf0e10cSrcweir {
301cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
302cdf0e10cSrcweir tFullExplicitScaleMap::const_iterator aIt = m_aSecondaryExplicitScales.find( aFullAxisIndex );
303cdf0e10cSrcweir if( aIt != m_aSecondaryExplicitScales.end() )
304cdf0e10cSrcweir aRet = aIt->second;
305cdf0e10cSrcweir else
306cdf0e10cSrcweir aRet = m_aExplicitScales[nDimensionIndex];
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir return aRet;
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
getExplicitIncrement(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex) const312cdf0e10cSrcweir ExplicitIncrementData VCoordinateSystem::getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
313cdf0e10cSrcweir {
314cdf0e10cSrcweir ExplicitIncrementData aRet;
315cdf0e10cSrcweir
316cdf0e10cSrcweir impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
317cdf0e10cSrcweir
318cdf0e10cSrcweir if( nAxisIndex == 0)
319cdf0e10cSrcweir {
320cdf0e10cSrcweir aRet = m_aExplicitIncrements[nDimensionIndex];
321cdf0e10cSrcweir }
322cdf0e10cSrcweir else
323cdf0e10cSrcweir {
324cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
325cdf0e10cSrcweir tFullExplicitIncrementMap::const_iterator aIt = m_aSecondaryExplicitIncrements.find( aFullAxisIndex );
326cdf0e10cSrcweir if( aIt != m_aSecondaryExplicitIncrements.end() )
327cdf0e10cSrcweir aRet = aIt->second;
328cdf0e10cSrcweir else
329cdf0e10cSrcweir aRet = m_aExplicitIncrements[nDimensionIndex];
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
332cdf0e10cSrcweir return aRet;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
createCIDForAxis(const Reference<chart2::XAxis> &,sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex)335cdf0e10cSrcweir rtl::OUString VCoordinateSystem::createCIDForAxis( const Reference< chart2::XAxis >& /* xAxis */, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir rtl::OUString aAxisParticle( ObjectIdentifier::createParticleForAxis( nDimensionIndex, nAxisIndex ) );
338cdf0e10cSrcweir return ObjectIdentifier::createClassifiedIdentifierForParticles( m_aCooSysParticle, aAxisParticle );
339cdf0e10cSrcweir }
createCIDForGrid(const Reference<chart2::XAxis> &,sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex)340cdf0e10cSrcweir rtl::OUString VCoordinateSystem::createCIDForGrid( const Reference< chart2::XAxis >& /* xAxis */, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir rtl::OUString aGridParticle( ObjectIdentifier::createParticleForGrid( nDimensionIndex, nAxisIndex ) );
343cdf0e10cSrcweir return ObjectIdentifier::createClassifiedIdentifierForParticles( m_aCooSysParticle, aGridParticle );
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
getMaximumAxisIndexByDimension(sal_Int32 nDimensionIndex) const346cdf0e10cSrcweir sal_Int32 VCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const
347cdf0e10cSrcweir {
348cdf0e10cSrcweir sal_Int32 nRet = 0;
349cdf0e10cSrcweir tFullExplicitScaleMap::const_iterator aIt = m_aSecondaryExplicitScales.begin();
350cdf0e10cSrcweir tFullExplicitScaleMap::const_iterator aEnd = m_aSecondaryExplicitScales.end();
351cdf0e10cSrcweir for(; aIt!=aEnd; ++aIt)
352cdf0e10cSrcweir {
353cdf0e10cSrcweir if(aIt->first.first==nDimensionIndex)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir sal_Int32 nLocalIdx = aIt->first.second;
356cdf0e10cSrcweir if( nRet < nLocalIdx )
357cdf0e10cSrcweir nRet = nLocalIdx;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir }
360cdf0e10cSrcweir return nRet;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
createVAxisList(const uno::Reference<util::XNumberFormatsSupplier> &,const awt::Size &,const awt::Rectangle &)363cdf0e10cSrcweir void VCoordinateSystem::createVAxisList(
364cdf0e10cSrcweir const uno::Reference< util::XNumberFormatsSupplier > & /* xNumberFormatsSupplier */
365cdf0e10cSrcweir , const awt::Size& /* rFontReferenceSize */
366cdf0e10cSrcweir , const awt::Rectangle& /* rMaximumSpaceForLabels */
367cdf0e10cSrcweir )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir }
370cdf0e10cSrcweir
initVAxisInList()371cdf0e10cSrcweir void VCoordinateSystem::initVAxisInList()
372cdf0e10cSrcweir {
373cdf0e10cSrcweir }
updateScalesAndIncrementsOnAxes()374cdf0e10cSrcweir void VCoordinateSystem::updateScalesAndIncrementsOnAxes()
375cdf0e10cSrcweir {
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
prepareScaleAutomatismForDimensionAndIndex(ScaleAutomatism & rScaleAutomatism,sal_Int32 nDimIndex,sal_Int32 nAxisIndex)378cdf0e10cSrcweir void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::MONTH;
383cdf0e10cSrcweir if( !(rScaleAutomatism.getScale().TimeIncrement.TimeResolution >>= nTimeResolution) )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir nTimeResolution = m_aMergedMinimumAndMaximumSupplier.calculateTimeResolutionOnXAxis();
386cdf0e10cSrcweir rScaleAutomatism.setAutomaticTimeResolution( nTimeResolution );
387cdf0e10cSrcweir }
388cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir
391cdf0e10cSrcweir double fMin = 0.0;
392cdf0e10cSrcweir double fMax = 0.0;
393cdf0e10cSrcweir ::rtl::math::setInf(&fMin, false);
394cdf0e10cSrcweir ::rtl::math::setInf(&fMax, true);
395cdf0e10cSrcweir if( 0 == nDimIndex )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumX();
398cdf0e10cSrcweir fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumX();
399cdf0e10cSrcweir }
400cdf0e10cSrcweir else if( 1 == nDimIndex )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir ExplicitScaleData aScale = getExplicitScale( 0, 0 );
403cdf0e10cSrcweir fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
404cdf0e10cSrcweir fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
405cdf0e10cSrcweir }
406cdf0e10cSrcweir else if( 2 == nDimIndex )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumZ();
409cdf0e10cSrcweir fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumZ();
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir //merge our values with those already contained in rScaleAutomatism
413cdf0e10cSrcweir rScaleAutomatism.expandValueRange( fMin, fMax );
414cdf0e10cSrcweir
415cdf0e10cSrcweir rScaleAutomatism.setAutoScalingOptions(
416cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.isExpandBorderToIncrementRhythm( nDimIndex ),
417cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.isExpandIfValuesCloseToBorder( nDimIndex ),
418cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.isExpandWideValuesToZero( nDimIndex ),
419cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.isExpandNarrowValuesTowardZero( nDimIndex ) );
420cdf0e10cSrcweir
421cdf0e10cSrcweir VAxisBase* pVAxis( this->getVAxis( nDimIndex, nAxisIndex ) );
422cdf0e10cSrcweir if( pVAxis )
423cdf0e10cSrcweir rScaleAutomatism.setMaximumAutoMainIncrementCount( pVAxis->estimateMaximumAutoMainIncrementCount() );
424cdf0e10cSrcweir }
425cdf0e10cSrcweir
getVAxis(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex)426cdf0e10cSrcweir VAxisBase* VCoordinateSystem::getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir VAxisBase* pRet = 0;
429cdf0e10cSrcweir
430cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
431cdf0e10cSrcweir
432cdf0e10cSrcweir tVAxisMap::const_iterator aIt = m_aAxisMap.find( aFullAxisIndex );
433cdf0e10cSrcweir if( aIt != m_aAxisMap.end() )
434cdf0e10cSrcweir pRet = aIt->second.get();
435cdf0e10cSrcweir
436cdf0e10cSrcweir return pRet;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
setExplicitScaleAndIncrement(sal_Int32 nDimensionIndex,sal_Int32 nAxisIndex,const ExplicitScaleData & rExplicitScale,const ExplicitIncrementData & rExplicitIncrement)439cdf0e10cSrcweir void VCoordinateSystem::setExplicitScaleAndIncrement(
440cdf0e10cSrcweir sal_Int32 nDimensionIndex
441cdf0e10cSrcweir , sal_Int32 nAxisIndex
442cdf0e10cSrcweir , const ExplicitScaleData& rExplicitScale
443cdf0e10cSrcweir , const ExplicitIncrementData& rExplicitIncrement )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir impl_adjustDimension( nDimensionIndex );
446cdf0e10cSrcweir
447cdf0e10cSrcweir if( nAxisIndex==0 )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir m_aExplicitScales[nDimensionIndex]=rExplicitScale;
450cdf0e10cSrcweir m_aExplicitIncrements[nDimensionIndex]=rExplicitIncrement;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir else
453cdf0e10cSrcweir {
454cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
455cdf0e10cSrcweir m_aSecondaryExplicitScales[aFullAxisIndex] = rExplicitScale;
456cdf0e10cSrcweir m_aSecondaryExplicitIncrements[aFullAxisIndex] = rExplicitIncrement;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir }
459cdf0e10cSrcweir
set3DWallPositions(CuboidPlanePosition eLeftWallPos,CuboidPlanePosition eBackWallPos,CuboidPlanePosition eBottomPos)460cdf0e10cSrcweir void VCoordinateSystem::set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir m_eLeftWallPos = eLeftWallPos;
463cdf0e10cSrcweir m_eBackWallPos = eBackWallPos;
464cdf0e10cSrcweir m_eBottomPos = eBottomPos;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
createMaximumAxesLabels()467cdf0e10cSrcweir void VCoordinateSystem::createMaximumAxesLabels()
468cdf0e10cSrcweir {
469cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
470cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
471cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
474cdf0e10cSrcweir if( pVAxis )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir if(2==pVAxis->getDimensionCount())
477cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
478cdf0e10cSrcweir pVAxis->createMaximumLabels();
479cdf0e10cSrcweir }
480cdf0e10cSrcweir }
481cdf0e10cSrcweir }
createAxesLabels()482cdf0e10cSrcweir void VCoordinateSystem::createAxesLabels()
483cdf0e10cSrcweir {
484cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
485cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
486cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
489cdf0e10cSrcweir if( pVAxis )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir if(2==pVAxis->getDimensionCount())
492cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
493cdf0e10cSrcweir pVAxis->createLabels();
494cdf0e10cSrcweir }
495cdf0e10cSrcweir }
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
updatePositions()498cdf0e10cSrcweir void VCoordinateSystem::updatePositions()
499cdf0e10cSrcweir {
500cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
501cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
502cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
505cdf0e10cSrcweir if( pVAxis )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir if(2==pVAxis->getDimensionCount())
508cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
509cdf0e10cSrcweir pVAxis->updatePositions();
510cdf0e10cSrcweir }
511cdf0e10cSrcweir }
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
createAxesShapes()514cdf0e10cSrcweir void VCoordinateSystem::createAxesShapes()
515cdf0e10cSrcweir {
516cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
517cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
518cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
521cdf0e10cSrcweir if( pVAxis )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir if(2==pVAxis->getDimensionCount())
524cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
525cdf0e10cSrcweir
526cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex = aIt->first;
527cdf0e10cSrcweir if( aFullAxisIndex.second == 0 )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir if( aFullAxisIndex.first == 0 )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir if( AxisType::CATEGORY!=m_aExplicitScales[1].AxisType )
532cdf0e10cSrcweir pVAxis->setExrtaLinePositionAtOtherAxis(
533cdf0e10cSrcweir m_aExplicitScales[1].Origin );
534cdf0e10cSrcweir }
535cdf0e10cSrcweir else if( aFullAxisIndex.first == 1 )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir if( AxisType::CATEGORY!=m_aExplicitScales[0].AxisType )
538cdf0e10cSrcweir pVAxis->setExrtaLinePositionAtOtherAxis(
539cdf0e10cSrcweir m_aExplicitScales[0].Origin );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir }
542cdf0e10cSrcweir
543cdf0e10cSrcweir pVAxis->createShapes();
544cdf0e10cSrcweir }
545cdf0e10cSrcweir }
546cdf0e10cSrcweir }
createGridShapes()547cdf0e10cSrcweir void VCoordinateSystem::createGridShapes()
548cdf0e10cSrcweir {
549cdf0e10cSrcweir }
addMinimumAndMaximumSupplier(MinimumAndMaximumSupplier * pMinimumAndMaximumSupplier)550cdf0e10cSrcweir void VCoordinateSystem::addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.addMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
553cdf0e10cSrcweir }
554cdf0e10cSrcweir
hasMinimumAndMaximumSupplier(MinimumAndMaximumSupplier * pMinimumAndMaximumSupplier)555cdf0e10cSrcweir bool VCoordinateSystem::hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir return m_aMergedMinimumAndMaximumSupplier.hasMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
558cdf0e10cSrcweir }
559cdf0e10cSrcweir
clearMinimumAndMaximumSupplierList()560cdf0e10cSrcweir void VCoordinateSystem::clearMinimumAndMaximumSupplierList()
561cdf0e10cSrcweir {
562cdf0e10cSrcweir m_aMergedMinimumAndMaximumSupplier.clearMinimumAndMaximumSupplierList();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
getPropertySwapXAndYAxis() const565cdf0e10cSrcweir bool VCoordinateSystem::getPropertySwapXAndYAxis() const
566cdf0e10cSrcweir {
567cdf0e10cSrcweir Reference<beans::XPropertySet> xProp(m_xCooSysModel, uno::UNO_QUERY );
568cdf0e10cSrcweir sal_Bool bSwapXAndY = false;
569cdf0e10cSrcweir if( xProp.is()) try
570cdf0e10cSrcweir {
571cdf0e10cSrcweir xProp->getPropertyValue( C2U( "SwapXAndYAxis" ) ) >>= bSwapXAndY;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir catch( uno::Exception& e )
574cdf0e10cSrcweir {
575cdf0e10cSrcweir ASSERT_EXCEPTION( e );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir return bSwapXAndY;
578cdf0e10cSrcweir }
579cdf0e10cSrcweir
needSeriesNamesForAxis() const580cdf0e10cSrcweir bool VCoordinateSystem::needSeriesNamesForAxis() const
581cdf0e10cSrcweir {
582cdf0e10cSrcweir return ( m_xCooSysModel.is() && m_xCooSysModel->getDimension() == 3 );
583cdf0e10cSrcweir }
setSeriesNamesForAxis(const Sequence<rtl::OUString> & rSeriesNames)584cdf0e10cSrcweir void VCoordinateSystem::setSeriesNamesForAxis( const Sequence< rtl::OUString >& rSeriesNames )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir m_aSeriesNamesForZAxis = rSeriesNames;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir
getNumberFormatKeyForAxis(const Reference<chart2::XAxis> & xAxis,const Reference<util::XNumberFormatsSupplier> & xNumberFormatsSupplier)589cdf0e10cSrcweir sal_Int32 VCoordinateSystem::getNumberFormatKeyForAxis(
590cdf0e10cSrcweir const Reference< chart2::XAxis >& xAxis
591cdf0e10cSrcweir , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
594cdf0e10cSrcweir xAxis, m_xCooSysModel, xNumberFormatsSupplier );
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir //.............................................................................
598cdf0e10cSrcweir } //namespace chart
599cdf0e10cSrcweir //.............................................................................
600