LCOV - code coverage report
Current view: top level - chart2/source/view/main - Stripe.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 115 201 57.2 %
Date: 2014-11-03 Functions: 7 9 77.8 %
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 "Stripe.hxx"
      21             : #include "CommonConverters.hxx"
      22             : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
      23             : #include <com/sun/star/drawing/DoubleSequence.hpp>
      24             : #include <basegfx/polygon/b3dpolygon.hxx>
      25             : #include <basegfx/polygon/b3dpolygontools.hxx>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : 
      29             : namespace chart
      30             : {
      31             : 
      32         111 : Stripe::Stripe( const drawing::Position3D& rPoint1
      33             :         , const drawing::Direction3D& rDirectionToPoint2
      34             :         , const drawing::Direction3D& rDirectionToPoint4 )
      35             :             : m_aPoint1(rPoint1)
      36             :             , m_aPoint2(rPoint1+rDirectionToPoint2)
      37         111 :             , m_aPoint3(m_aPoint2+rDirectionToPoint4)
      38             :             , m_aPoint4(rPoint1+rDirectionToPoint4)
      39             :             , m_bInvertNormal(false)
      40         222 :             , m_bManualNormalSet(false)
      41             : {
      42         111 : }
      43             : 
      44        1224 : Stripe::Stripe( const drawing::Position3D& rPoint1
      45             :         , const drawing::Position3D& rPoint2
      46             :         , double fDepth )
      47             :         : m_aPoint1(rPoint1)
      48             :         , m_aPoint2(rPoint2)
      49             :         , m_aPoint3(rPoint2)
      50             :         , m_aPoint4(rPoint1)
      51             :         , m_bInvertNormal(false)
      52        1224 :         , m_bManualNormalSet(false)
      53             : {
      54        1224 :     m_aPoint3.PositionZ += fDepth;
      55        1224 :     m_aPoint4.PositionZ += fDepth;
      56        1224 : }
      57             : 
      58           0 : Stripe::Stripe( const drawing::Position3D& rPoint1
      59             :           , const drawing::Position3D& rPoint2
      60             :           , const drawing::Position3D& rPoint3
      61             :           , const drawing::Position3D& rPoint4 )
      62             :             : m_aPoint1(rPoint1)
      63             :             , m_aPoint2(rPoint2)
      64             :             , m_aPoint3(rPoint3)
      65             :             , m_aPoint4(rPoint4)
      66             :             , m_bInvertNormal(false)
      67           0 :             , m_bManualNormalSet(false)
      68             : {
      69           0 : }
      70             : 
      71           0 : void Stripe::SetManualNormal( const drawing::Direction3D& rNormal )
      72             : {
      73           0 :     m_aManualNormal = rNormal;
      74           0 :     m_bManualNormalSet = true;
      75           0 : }
      76             : 
      77         111 : void Stripe::InvertNormal( bool bInvertNormal )
      78             : {
      79         111 :     m_bInvertNormal = bInvertNormal;
      80         111 : }
      81             : 
      82         723 : uno::Any Stripe::getPolyPolygonShape3D() const
      83             : {
      84         723 :     drawing::PolyPolygonShape3D aPP;
      85             : 
      86         723 :     aPP.SequenceX.realloc(1);
      87         723 :     aPP.SequenceY.realloc(1);
      88         723 :     aPP.SequenceZ.realloc(1);
      89             : 
      90         723 :     drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
      91         723 :     drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
      92         723 :     drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
      93             : 
      94         723 :     pOuterSequenceX->realloc(4);
      95         723 :     pOuterSequenceY->realloc(4);
      96         723 :     pOuterSequenceZ->realloc(4);
      97             : 
      98         723 :     double* pInnerSequenceX = pOuterSequenceX->getArray();
      99         723 :     double* pInnerSequenceY = pOuterSequenceY->getArray();
     100         723 :     double* pInnerSequenceZ = pOuterSequenceZ->getArray();
     101             : 
     102         723 :     *pInnerSequenceX++ = m_aPoint1.PositionX;
     103         723 :     *pInnerSequenceY++ = m_aPoint1.PositionY;
     104         723 :     *pInnerSequenceZ++ = m_aPoint1.PositionZ;
     105             : 
     106         723 :     *pInnerSequenceX++ = m_aPoint2.PositionX;
     107         723 :     *pInnerSequenceY++ = m_aPoint2.PositionY;
     108         723 :     *pInnerSequenceZ++ = m_aPoint2.PositionZ;
     109             : 
     110         723 :     *pInnerSequenceX++ = m_aPoint3.PositionX;
     111         723 :     *pInnerSequenceY++ = m_aPoint3.PositionY;
     112         723 :     *pInnerSequenceZ++ = m_aPoint3.PositionZ;
     113             : 
     114         723 :     *pInnerSequenceX++ = m_aPoint4.PositionX;
     115         723 :     *pInnerSequenceY++ = m_aPoint4.PositionY;
     116         723 :     *pInnerSequenceZ++ = m_aPoint4.PositionZ;
     117             : 
     118         723 :     return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get());
     119             : }
     120             : 
     121         723 : drawing::Direction3D Stripe::getNormal() const
     122             : {
     123         723 :     drawing::Direction3D aRet(1.0,0.0,0.0);
     124             : 
     125         723 :     if( m_bManualNormalSet )
     126           0 :         aRet = m_aManualNormal;
     127             :     else
     128             :     {
     129         723 :         ::basegfx::B3DPolygon aPolygon3D;
     130         723 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 ));
     131         723 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 ));
     132         723 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 ));
     133         723 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint4 ));
     134        1446 :         ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D));
     135        1446 :         aRet = B3DVectorToDirection3D(aNormal);
     136             :     }
     137             : 
     138         723 :     if( m_bInvertNormal )
     139             :     {
     140         111 :         aRet.DirectionX *= -1.0;
     141         111 :         aRet.DirectionY *= -1.0;
     142         111 :         aRet.DirectionZ *= -1.0;
     143             :     }
     144         723 :     return aRet;
     145             : }
     146             : 
     147         723 : uno::Any Stripe::getNormalsPolygon() const
     148             : {
     149         723 :     drawing::PolyPolygonShape3D aPP;
     150             : 
     151         723 :     aPP.SequenceX.realloc(1);
     152         723 :     aPP.SequenceY.realloc(1);
     153         723 :     aPP.SequenceZ.realloc(1);
     154             : 
     155         723 :     drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
     156         723 :     drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
     157         723 :     drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
     158             : 
     159         723 :     pOuterSequenceX->realloc(4);
     160         723 :     pOuterSequenceY->realloc(4);
     161         723 :     pOuterSequenceZ->realloc(4);
     162             : 
     163         723 :     double* pInnerSequenceX = pOuterSequenceX->getArray();
     164         723 :     double* pInnerSequenceY = pOuterSequenceY->getArray();
     165         723 :     double* pInnerSequenceZ = pOuterSequenceZ->getArray();
     166             : 
     167         723 :     drawing::Direction3D aNormal( getNormal() );
     168             : 
     169        3615 :     for(sal_Int32 nN=4; --nN; )
     170             :     {
     171        2169 :         *pInnerSequenceX++ = aNormal.DirectionX;
     172        2169 :         *pInnerSequenceY++ = aNormal.DirectionY;
     173        2169 :         *pInnerSequenceZ++ = aNormal.DirectionZ;
     174             :     }
     175         723 :     return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get());
     176             : }
     177             : 
     178         723 : uno::Any Stripe::getTexturePolygon( short nRotatedTexture ) const
     179             : {
     180         723 :     drawing::PolyPolygonShape3D aPP;
     181             : 
     182         723 :     aPP.SequenceX.realloc(1);
     183         723 :     aPP.SequenceY.realloc(1);
     184         723 :     aPP.SequenceZ.realloc(1);
     185             : 
     186         723 :     drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
     187         723 :     drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
     188         723 :     drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
     189             : 
     190         723 :     pOuterSequenceX->realloc(4);
     191         723 :     pOuterSequenceY->realloc(4);
     192         723 :     pOuterSequenceZ->realloc(4);
     193             : 
     194         723 :     double* pInnerSequenceX = pOuterSequenceX->getArray();
     195         723 :     double* pInnerSequenceY = pOuterSequenceY->getArray();
     196         723 :     double* pInnerSequenceZ = pOuterSequenceZ->getArray();
     197             : 
     198         723 :     if( nRotatedTexture==0 )
     199             :     {
     200          74 :         *pInnerSequenceX++ = 0.0;
     201          74 :         *pInnerSequenceY++ = 0.0;
     202          74 :         *pInnerSequenceZ++ = 0.0;
     203             : 
     204          74 :         *pInnerSequenceX++ = 0.0;
     205          74 :         *pInnerSequenceY++ = 1.0;
     206          74 :         *pInnerSequenceZ++ = 0.0;
     207             : 
     208          74 :         *pInnerSequenceX++ = 1.0;
     209          74 :         *pInnerSequenceY++ = 1.0;
     210          74 :         *pInnerSequenceZ++ = 0.0;
     211             : 
     212          74 :         *pInnerSequenceX++ = 1.0;
     213          74 :         *pInnerSequenceY++ = 0.0;
     214          74 :         *pInnerSequenceZ++ = 0.0;
     215             :     }
     216         649 :     else if( nRotatedTexture==1 )
     217             :     {
     218         649 :         *pInnerSequenceX++ = 1.0;
     219         649 :         *pInnerSequenceY++ = 0.0;
     220         649 :         *pInnerSequenceZ++ = 0.0;
     221             : 
     222         649 :         *pInnerSequenceX++ = 0.0;
     223         649 :         *pInnerSequenceY++ = 0.0;
     224         649 :         *pInnerSequenceZ++ = 0.0;
     225             : 
     226         649 :         *pInnerSequenceX++ = 0.0;
     227         649 :         *pInnerSequenceY++ = 1.0;
     228         649 :         *pInnerSequenceZ++ = 0.0;
     229             : 
     230         649 :         *pInnerSequenceX++ = 1.0;
     231         649 :         *pInnerSequenceY++ = 1.0;
     232         649 :         *pInnerSequenceZ++ = 0.0;
     233             :     }
     234           0 :     else if( nRotatedTexture==2 )
     235             :     {
     236           0 :         *pInnerSequenceX++ = 1.0;
     237           0 :         *pInnerSequenceY++ = 1.0;
     238           0 :         *pInnerSequenceZ++ = 0.0;
     239             : 
     240           0 :         *pInnerSequenceX++ = 1.0;
     241           0 :         *pInnerSequenceY++ = 0.0;
     242           0 :         *pInnerSequenceZ++ = 0.0;
     243             : 
     244           0 :         *pInnerSequenceX++ = 0.0;
     245           0 :         *pInnerSequenceY++ = 0.0;
     246           0 :         *pInnerSequenceZ++ = 0.0;
     247             : 
     248           0 :         *pInnerSequenceX++ = 0.0;
     249           0 :         *pInnerSequenceY++ = 1.0;
     250           0 :         *pInnerSequenceZ++ = 0.0;
     251             :     }
     252           0 :     else if( nRotatedTexture==3 )
     253             :     {
     254           0 :         *pInnerSequenceX++ = 0.0;
     255           0 :         *pInnerSequenceY++ = 1.0;
     256           0 :         *pInnerSequenceZ++ = 0.0;
     257             : 
     258           0 :         *pInnerSequenceX++ = 1.0;
     259           0 :         *pInnerSequenceY++ = 1.0;
     260           0 :         *pInnerSequenceZ++ = 0.0;
     261             : 
     262           0 :         *pInnerSequenceX++ = 1.0;
     263           0 :         *pInnerSequenceY++ = 0.0;
     264           0 :         *pInnerSequenceZ++ = 0.0;
     265             : 
     266           0 :         *pInnerSequenceX++ = 0.0;
     267           0 :         *pInnerSequenceY++ = 0.0;
     268           0 :         *pInnerSequenceZ++ = 0.0;
     269             :     }
     270           0 :     else if( nRotatedTexture==4 )
     271             :     {
     272           0 :         *pInnerSequenceX++ = 1.0;
     273           0 :         *pInnerSequenceY++ = 0.0;
     274           0 :         *pInnerSequenceZ++ = 0.0;
     275             : 
     276           0 :         *pInnerSequenceX++ = 1.0;
     277           0 :         *pInnerSequenceY++ = 1.0;
     278           0 :         *pInnerSequenceZ++ = 0.0;
     279             : 
     280           0 :         *pInnerSequenceX++ = 0.0;
     281           0 :         *pInnerSequenceY++ = 1.0;
     282           0 :         *pInnerSequenceZ++ = 0.0;
     283             : 
     284           0 :         *pInnerSequenceX++ = 0.0;
     285           0 :         *pInnerSequenceY++ = 0.0;
     286           0 :         *pInnerSequenceZ++ = 0.0;
     287             :     }
     288           0 :     else if( nRotatedTexture==5 )
     289             :     {
     290           0 :         *pInnerSequenceX++ = 0.0;
     291           0 :         *pInnerSequenceY++ = 0.0;
     292           0 :         *pInnerSequenceZ++ = 0.0;
     293             : 
     294           0 :         *pInnerSequenceX++ = 1.0;
     295           0 :         *pInnerSequenceY++ = 0.0;
     296           0 :         *pInnerSequenceZ++ = 0.0;
     297             : 
     298           0 :         *pInnerSequenceX++ = 1.0;
     299           0 :         *pInnerSequenceY++ = 1.0;
     300           0 :         *pInnerSequenceZ++ = 0.0;
     301             : 
     302           0 :         *pInnerSequenceX++ = 0.0;
     303           0 :         *pInnerSequenceY++ = 1.0;
     304           0 :         *pInnerSequenceZ++ = 0.0;
     305             :     }
     306           0 :     else if( nRotatedTexture==6 )
     307             :     {
     308           0 :         *pInnerSequenceX++ = 0.0;
     309           0 :         *pInnerSequenceY++ = 1.0;
     310           0 :         *pInnerSequenceZ++ = 0.0;
     311             : 
     312           0 :         *pInnerSequenceX++ = 0.0;
     313           0 :         *pInnerSequenceY++ = 0.0;
     314           0 :         *pInnerSequenceZ++ = 0.0;
     315             : 
     316           0 :         *pInnerSequenceX++ = 1.0;
     317           0 :         *pInnerSequenceY++ = 0.0;
     318           0 :         *pInnerSequenceZ++ = 0.0;
     319             : 
     320           0 :         *pInnerSequenceX++ = 1.0;
     321           0 :         *pInnerSequenceY++ = 1.0;
     322           0 :         *pInnerSequenceZ++ = 0.0;
     323             :     }
     324           0 :     else if( nRotatedTexture==7 )
     325             :     {
     326           0 :         *pInnerSequenceX++ = 1.0;
     327           0 :         *pInnerSequenceY++ = 1.0;
     328           0 :         *pInnerSequenceZ++ = 0.0;
     329             : 
     330           0 :         *pInnerSequenceX++ = 0.0;
     331           0 :         *pInnerSequenceY++ = 1.0;
     332           0 :         *pInnerSequenceZ++ = 0.0;
     333             : 
     334           0 :         *pInnerSequenceX++ = 0.0;
     335           0 :         *pInnerSequenceY++ = 0.0;
     336           0 :         *pInnerSequenceZ++ = 0.0;
     337             : 
     338           0 :         *pInnerSequenceX++ = 1.0;
     339           0 :         *pInnerSequenceY++ = 0.0;
     340           0 :         *pInnerSequenceZ++ = 0.0;
     341             :     }
     342             : 
     343         723 :     return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get());
     344             : }
     345             : 
     346             : } //namespace chart
     347             : 
     348             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10