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

Generated by: LCOV version 1.11