LCOV - code coverage report
Current view: top level - chart2/source/view/axes - VPolarGrid.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 88 0.0 %
Date: 2014-04-14 Functions: 0 8 0.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 "VPolarGrid.hxx"
      21             : #include "VCartesianGrid.hxx"
      22             : #include "Tickmarks.hxx"
      23             : #include "PlottingPositionHelper.hxx"
      24             : #include "ShapeFactory.hxx"
      25             : #include "ObjectIdentifier.hxx"
      26             : #include "macros.hxx"
      27             : #include "CommonConverters.hxx"
      28             : #include "Tickmarks_Equidistant.hxx"
      29             : #include <com/sun/star/drawing/LineStyle.hpp>
      30             : 
      31             : #include <vector>
      32             : 
      33             : namespace chart
      34             : {
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::chart2;
      37             : using ::com::sun::star::uno::Reference;
      38             : 
      39           0 : VPolarGrid::VPolarGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
      40             :                        , const uno::Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList )
      41             :             : VAxisOrGridBase( nDimensionIndex, nDimensionCount )
      42             :             , m_aGridPropertiesList( rGridPropertiesList )
      43           0 :             , m_pPosHelper( new PolarPlottingPositionHelper() )
      44           0 :             , m_aIncrements()
      45             : {
      46           0 :     PlotterBase::m_pPosHelper = m_pPosHelper;
      47           0 : }
      48             : 
      49           0 : VPolarGrid::~VPolarGrid()
      50             : {
      51           0 :     delete m_pPosHelper;
      52           0 :     m_pPosHelper = NULL;
      53           0 : }
      54             : 
      55           0 : void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements )
      56             : {
      57           0 :     m_aIncrements = rIncrements;
      58           0 : }
      59             : 
      60           0 : void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
      61             : {
      62             :     TickFactory aTickFactory(
      63           0 :             m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] );
      64           0 :     aTickFactory.getAllTicks( rAllTickInfos );
      65           0 : }
      66             : 
      67           0 : void VPolarGrid::createLinePointSequence_ForAngleAxis(
      68             :         drawing::PointSequenceSequence& rPoints
      69             :         , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos
      70             :         , const ExplicitIncrementData& rIncrement
      71             :         , const ExplicitScaleData& rScale
      72             :         , PolarPlottingPositionHelper* pPosHelper
      73             :         , double fLogicRadius, double fLogicZ )
      74             : {
      75           0 :     Reference< XScaling > xInverseScaling( NULL );
      76           0 :     if( rScale.Scaling.is() )
      77           0 :         xInverseScaling = rScale.Scaling->getInverseScaling();
      78             : 
      79           0 :     sal_Int32 nTick = 0;
      80           0 :     EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
      81           0 :     for( TickInfo* pTickInfo = aIter.firstInfo()
      82             :         ; pTickInfo
      83             :         ; pTickInfo = aIter.nextInfo(), nTick++ )
      84             :     {
      85           0 :         if(nTick>=rPoints[0].getLength())
      86           0 :             rPoints[0].realloc(rPoints[0].getLength()+30);
      87             : 
      88             :         //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
      89           0 :         double fLogicAngle = pTickInfo->getUnscaledTickValue();
      90             : 
      91           0 :         drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) );
      92           0 :         rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX);
      93           0 :         rPoints[0][nTick].Y = static_cast<sal_Int32>(aScenePosition3D.PositionY);
      94             :     }
      95           0 :     if(rPoints[0].getLength()>1)
      96             :     {
      97           0 :         rPoints[0].realloc(nTick+1);
      98           0 :         rPoints[0][nTick].X = rPoints[0][0].X;
      99           0 :         rPoints[0][nTick].Y = rPoints[0][0].Y;
     100             :     }
     101             :     else
     102           0 :         rPoints[0].realloc(0);
     103           0 : }
     104             : #ifdef NOTYET
     105             : void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicTarget
     106             :         , ::std::vector< ::std::vector< TickInfo > >& /* rRadiusTickInfos */
     107             :         , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos
     108             :         , const ::std::vector<VLineProperties>& rLinePropertiesList )
     109             : {
     110             :     Reference< drawing::XShapes > xMainTarget(
     111             :         this->createGroupShape( xLogicTarget, m_aCID ) );
     112             : 
     113             :     const ExplicitScaleData&     rAngleScale = m_pPosHelper->getScales()[0];
     114             :     Reference< XScaling > xInverseScaling( NULL );
     115             :     if( rAngleScale.Scaling.is() )
     116             :         xInverseScaling = rAngleScale.Scaling->getInverseScaling();
     117             : 
     118             :     double fLogicInnerRadius = m_pPosHelper->getInnerLogicRadius();
     119             :     double fLogicOuterRadius = m_pPosHelper->getOuterLogicRadius();
     120             : 
     121             :     sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
     122             :     ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter             = rAngleTickInfos.begin();
     123             :     if(nLinePropertiesCount)
     124             :     {
     125             :         double fLogicZ      = 1.0;//as defined
     126             :         sal_Int32 nDepth=0;
     127             :         //create axis main lines
     128             :         drawing::PointSequenceSequence aAllPoints;
     129             :         ::std::vector< TickInfo >::iterator             aTickIter = (*aDepthIter).begin();
     130             :         const ::std::vector< TickInfo >::const_iterator aTickEnd  = (*aDepthIter).end();
     131             :         for( ; aTickIter != aTickEnd; ++aTickIter )
     132             :         {
     133             :             TickInfo& rTickInfo = *aTickIter;
     134             :             if( !rTickInfo.bPaintIt )
     135             :                 continue;
     136             : 
     137             :             //xxxxx rTickInfo.updateUnscaledValue( xInverseScaling );
     138             :             double fLogicAngle = rTickInfo.getUnscaledTickValue();
     139             : 
     140             :             drawing::PointSequenceSequence aPoints(1);
     141             :             aPoints[0].realloc(2);
     142             :             drawing::Position3D aScenePositionStart( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicInnerRadius, fLogicZ ) );
     143             :             drawing::Position3D aScenePositionEnd(   m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicOuterRadius, fLogicZ ) );
     144             :             aPoints[0][0].X = static_cast<sal_Int32>(aScenePositionStart.PositionX);
     145             :             aPoints[0][0].Y = static_cast<sal_Int32>(aScenePositionStart.PositionY);
     146             :             aPoints[0][1].X = static_cast<sal_Int32>(aScenePositionEnd.PositionX);
     147             :             aPoints[0][1].Y = static_cast<sal_Int32>(aScenePositionEnd.PositionY);
     148             :             appendPointSequence( aAllPoints, aPoints );
     149             :         }
     150             : 
     151             :         Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
     152             :                 xMainTarget, aAllPoints, &rLinePropertiesList[nDepth] );
     153             :         //because of this name this line will be used for marking
     154             :         m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
     155             :     }
     156             : }
     157             : #endif
     158             : 
     159           0 : void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogicTarget
     160             :         , ::std::vector< ::std::vector< TickInfo > >& rRadiusTickInfos
     161             :         , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos
     162             :         , const ::std::vector<VLineProperties>& rLinePropertiesList )
     163             : {
     164             :     Reference< drawing::XShapes > xMainTarget(
     165           0 :         this->createGroupShape( xLogicTarget, m_aCID ) );
     166             : 
     167           0 :     const ExplicitScaleData&     rRadiusScale = m_pPosHelper->getScales()[1];
     168           0 :     const ExplicitScaleData&     rAngleScale = m_pPosHelper->getScales()[0];
     169           0 :     const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
     170           0 :     Reference< XScaling > xInverseRadiusScaling( NULL );
     171           0 :     if( rRadiusScale.Scaling.is() )
     172           0 :         xInverseRadiusScaling = rRadiusScale.Scaling->getInverseScaling();
     173             : 
     174           0 :     sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
     175           0 :     ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter             = rRadiusTickInfos.begin();
     176           0 :     const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd  = rRadiusTickInfos.end();
     177           0 :     for( sal_Int32 nDepth=0
     178           0 :         ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
     179             :         ; ++aDepthIter, nDepth++ )
     180             :     {
     181           0 :         if( !rLinePropertiesList[nDepth].isLineVisible() )
     182           0 :             continue;
     183             : 
     184           0 :         Reference< drawing::XShapes > xTarget( xMainTarget );
     185           0 :         if( nDepth > 0 )
     186             :         {
     187             :             xTarget.set( this->createGroupShape( xLogicTarget
     188             :                 , ObjectIdentifier::addChildParticle( m_aCID, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_SUBGRID, nDepth-1 ) )
     189           0 :                 ) );
     190           0 :             if(!xTarget.is())
     191           0 :                 xTarget.set( xMainTarget );
     192             :         }
     193             : 
     194             :         //create axis main lines
     195           0 :         drawing::PointSequenceSequence aAllPoints;
     196           0 :         ::std::vector< TickInfo >::iterator             aTickIter = (*aDepthIter).begin();
     197           0 :         const ::std::vector< TickInfo >::const_iterator aTickEnd  = (*aDepthIter).end();
     198           0 :         for( ; aTickIter != aTickEnd; ++aTickIter )
     199             :         {
     200           0 :             TickInfo& rTickInfo = *aTickIter;
     201           0 :             if( !rTickInfo.bPaintIt )
     202           0 :                 continue;
     203             : 
     204             :             //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling );
     205           0 :             double fLogicRadius = rTickInfo.getUnscaledTickValue();
     206           0 :             double fLogicZ      = 1.0;//as defined
     207             : 
     208           0 :             drawing::PointSequenceSequence aPoints(1);
     209             :             VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos
     210           0 :                 , rAngleIncrement, rAngleScale, m_pPosHelper, fLogicRadius, fLogicZ );
     211           0 :             if(aPoints[0].getLength())
     212           0 :                 appendPointSequence( aAllPoints, aPoints );
     213           0 :         }
     214             : 
     215             :         Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
     216           0 :                 xTarget, aAllPoints, &rLinePropertiesList[nDepth] );
     217             :         //because of this name this line will be used for marking
     218           0 :         m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
     219           0 :     }
     220           0 : }
     221             : 
     222           0 : void VPolarGrid::createShapes()
     223             : {
     224             :     OSL_PRECOND(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized");
     225           0 :     if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
     226           0 :         return;
     227           0 :     if(!m_aGridPropertiesList.getLength())
     228           0 :         return;
     229             : 
     230             :     //create all scaled tickmark values
     231           0 :     ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos;
     232           0 :     ::std::vector< ::std::vector< TickInfo > > aRadiusTickInfos;
     233           0 :     getAllTickInfos( 0, aAngleTickInfos );
     234           0 :     getAllTickInfos( 1, aRadiusTickInfos );
     235             : 
     236           0 :     ::std::vector<VLineProperties> aLinePropertiesList;
     237           0 :     VCartesianGrid::fillLinePropertiesFromGridModel( aLinePropertiesList, m_aGridPropertiesList );
     238             : 
     239             :     //create tick mark line shapes
     240           0 :     if(2==m_nDimension)
     241             :     {
     242           0 :         if(m_nDimensionIndex==1)
     243           0 :             this->create2DRadiusGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
     244             :         //else //no Angle Grid so far as this equals exactly the y axis positions
     245             :         //    this->create2DAngleGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
     246           0 :     }
     247             : }
     248             : 
     249             : } //namespace chart
     250             : 
     251             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10