LCOV - code coverage report
Current view: top level - chart2/source/view/main - Stripe.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 201 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "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           0 : 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           0 :             , m_aPoint3(m_aPoint2+rDirectionToPoint4)
      38             :             , m_aPoint4(rPoint1+rDirectionToPoint4)
      39             :             , m_bInvertNormal(false)
      40           0 :             , m_bManualNormalSet(false)
      41             : {
      42           0 : }
      43             : 
      44           0 : 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           0 :         , m_bManualNormalSet(false)
      53             : {
      54           0 :     m_aPoint3.PositionZ += fDepth;
      55           0 :     m_aPoint4.PositionZ += fDepth;
      56           0 : }
      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           0 : void Stripe::InvertNormal( bool bInvertNormal )
      78             : {
      79           0 :     m_bInvertNormal = bInvertNormal;
      80           0 : }
      81             : 
      82           0 : uno::Any Stripe::getPolyPolygonShape3D() const
      83             : {
      84           0 :     drawing::PolyPolygonShape3D aPP;
      85             : 
      86           0 :     aPP.SequenceX.realloc(1);
      87           0 :     aPP.SequenceY.realloc(1);
      88           0 :     aPP.SequenceZ.realloc(1);
      89             : 
      90           0 :     drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
      91           0 :     drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
      92           0 :     drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
      93             : 
      94           0 :     pOuterSequenceX->realloc(4);
      95           0 :     pOuterSequenceY->realloc(4);
      96           0 :     pOuterSequenceZ->realloc(4);
      97             : 
      98           0 :     double* pInnerSequenceX = pOuterSequenceX->getArray();
      99           0 :     double* pInnerSequenceY = pOuterSequenceY->getArray();
     100           0 :     double* pInnerSequenceZ = pOuterSequenceZ->getArray();
     101             : 
     102           0 :     *pInnerSequenceX++ = m_aPoint1.PositionX;
     103           0 :     *pInnerSequenceY++ = m_aPoint1.PositionY;
     104           0 :     *pInnerSequenceZ++ = m_aPoint1.PositionZ;
     105             : 
     106           0 :     *pInnerSequenceX++ = m_aPoint2.PositionX;
     107           0 :     *pInnerSequenceY++ = m_aPoint2.PositionY;
     108           0 :     *pInnerSequenceZ++ = m_aPoint2.PositionZ;
     109             : 
     110           0 :     *pInnerSequenceX++ = m_aPoint3.PositionX;
     111           0 :     *pInnerSequenceY++ = m_aPoint3.PositionY;
     112           0 :     *pInnerSequenceZ++ = m_aPoint3.PositionZ;
     113             : 
     114           0 :     *pInnerSequenceX++ = m_aPoint4.PositionX;
     115           0 :     *pInnerSequenceY++ = m_aPoint4.PositionY;
     116           0 :     *pInnerSequenceZ++ = m_aPoint4.PositionZ;
     117             : 
     118           0 :     return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
     119             : }
     120             : 
     121           0 : drawing::Direction3D Stripe::getNormal() const
     122             : {
     123           0 :     drawing::Direction3D aRet(1.0,0.0,0.0);
     124             : 
     125           0 :     if( m_bManualNormalSet )
     126           0 :         aRet = m_aManualNormal;
     127             :     else
     128             :     {
     129           0 :         ::basegfx::B3DPolygon aPolygon3D;
     130           0 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 ));
     131           0 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 ));
     132           0 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 ));
     133           0 :         aPolygon3D.append(Position3DToB3DPoint( m_aPoint4 ));
     134           0 :         ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D));
     135           0 :         aRet = B3DVectorToDirection3D(aNormal);
     136             :     }
     137             : 
     138           0 :     if( m_bInvertNormal )
     139             :     {
     140           0 :         aRet.DirectionX *= -1.0;
     141           0 :         aRet.DirectionY *= -1.0;
     142           0 :         aRet.DirectionZ *= -1.0;
     143             :     }
     144           0 :     return aRet;
     145             : }
     146             : 
     147           0 : uno::Any Stripe::getNormalsPolygon() const
     148             : {
     149           0 :     drawing::PolyPolygonShape3D aPP;
     150             : 
     151           0 :     aPP.SequenceX.realloc(1);
     152           0 :     aPP.SequenceY.realloc(1);
     153           0 :     aPP.SequenceZ.realloc(1);
     154             : 
     155           0 :     drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
     156           0 :     drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
     157           0 :     drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
     158             : 
     159           0 :     pOuterSequenceX->realloc(4);
     160           0 :     pOuterSequenceY->realloc(4);
     161           0 :     pOuterSequenceZ->realloc(4);
     162             : 
     163           0 :     double* pInnerSequenceX = pOuterSequenceX->getArray();
     164           0 :     double* pInnerSequenceY = pOuterSequenceY->getArray();
     165           0 :     double* pInnerSequenceZ = pOuterSequenceZ->getArray();
     166             : 
     167           0 :     drawing::Direction3D aNormal( getNormal() );
     168             : 
     169           0 :     for(sal_Int32 nN=4; --nN; )
     170             :     {
     171           0 :         *pInnerSequenceX++ = aNormal.DirectionX;
     172           0 :         *pInnerSequenceY++ = aNormal.DirectionY;
     173           0 :         *pInnerSequenceZ++ = aNormal.DirectionZ;
     174             :     }
     175           0 :     return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
     176             : }
     177             : 
     178           0 : uno::Any Stripe::getTexturePolygon( short nRotatedTexture ) const
     179             : {
     180           0 :     drawing::PolyPolygonShape3D aPP;
     181             : 
     182           0 :     aPP.SequenceX.realloc(1);
     183           0 :     aPP.SequenceY.realloc(1);
     184           0 :     aPP.SequenceZ.realloc(1);
     185             : 
     186           0 :     drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
     187           0 :     drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
     188           0 :     drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
     189             : 
     190           0 :     pOuterSequenceX->realloc(4);
     191           0 :     pOuterSequenceY->realloc(4);
     192           0 :     pOuterSequenceZ->realloc(4);
     193             : 
     194           0 :     double* pInnerSequenceX = pOuterSequenceX->getArray();
     195           0 :     double* pInnerSequenceY = pOuterSequenceY->getArray();
     196           0 :     double* pInnerSequenceZ = pOuterSequenceZ->getArray();
     197             : 
     198           0 :     if( nRotatedTexture==0 )
     199             :     {
     200           0 :         *pInnerSequenceX++ = 0.0;
     201           0 :         *pInnerSequenceY++ = 0.0;
     202           0 :         *pInnerSequenceZ++ = 0.0;
     203             : 
     204           0 :         *pInnerSequenceX++ = 0.0;
     205           0 :         *pInnerSequenceY++ = 1.0;
     206           0 :         *pInnerSequenceZ++ = 0.0;
     207             : 
     208           0 :         *pInnerSequenceX++ = 1.0;
     209           0 :         *pInnerSequenceY++ = 1.0;
     210           0 :         *pInnerSequenceZ++ = 0.0;
     211             : 
     212           0 :         *pInnerSequenceX++ = 1.0;
     213           0 :         *pInnerSequenceY++ = 0.0;
     214           0 :         *pInnerSequenceZ++ = 0.0;
     215             :     }
     216           0 :     else if( nRotatedTexture==1 )
     217             :     {
     218           0 :         *pInnerSequenceX++ = 1.0;
     219           0 :         *pInnerSequenceY++ = 0.0;
     220           0 :         *pInnerSequenceZ++ = 0.0;
     221             : 
     222           0 :         *pInnerSequenceX++ = 0.0;
     223           0 :         *pInnerSequenceY++ = 0.0;
     224           0 :         *pInnerSequenceZ++ = 0.0;
     225             : 
     226           0 :         *pInnerSequenceX++ = 0.0;
     227           0 :         *pInnerSequenceY++ = 1.0;
     228           0 :         *pInnerSequenceZ++ = 0.0;
     229             : 
     230           0 :         *pInnerSequenceX++ = 1.0;
     231           0 :         *pInnerSequenceY++ = 1.0;
     232           0 :         *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           0 :     return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
     344             : }
     345             : 
     346             : } //namespace chart
     347             : 
     348             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10