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

Generated by: LCOV version 1.10