LCOV - code coverage report
Current view: top level - chart2/source/view/axes - VPolarCoordinateSystem.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 44 94 46.8 %
Date: 2014-11-03 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10