LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive3d - sdrpolypolygonprimitive3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 48 54 88.9 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 70 146 47.9 %

           Branch data     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 <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx>
      21                 :            : #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx>
      22                 :            : #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
      23                 :            : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      24                 :            : #include <drawinglayer/attribute/sdrfillattribute.hxx>
      25                 :            : #include <drawinglayer/attribute/sdrlineattribute.hxx>
      26                 :            : #include <drawinglayer/attribute/sdrshadowattribute.hxx>
      27                 :            : 
      28                 :            : //////////////////////////////////////////////////////////////////////////////
      29                 :            : 
      30                 :            : using namespace com::sun::star;
      31                 :            : 
      32                 :            : //////////////////////////////////////////////////////////////////////////////
      33                 :            : 
      34                 :            : namespace drawinglayer
      35                 :            : {
      36                 :            :     namespace primitive3d
      37                 :            :     {
      38                 :        279 :         Primitive3DSequence SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
      39                 :            :         {
      40                 :        279 :             Primitive3DSequence aRetval;
      41                 :            : 
      42 [ +  - ][ +  - ]:        279 :             if(getPolyPolygon3D().count())
      43                 :            :             {
      44         [ +  - ]:        279 :                 ::std::vector< basegfx::B3DPolyPolygon > aFill;
      45         [ +  - ]:        279 :                 aFill.push_back(getPolyPolygon3D());
      46                 :            : 
      47                 :            :                 // get full range
      48         [ +  - ]:        279 :                 const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
      49                 :            : 
      50                 :            :                 // #i98295# normal creation
      51 [ +  - ][ +  + ]:        279 :                 if(!getSdrLFSAttribute().getFill().isDefault())
      52                 :            :                 {
      53 [ +  - ][ +  - ]:        265 :                     if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
         [ +  - ][ -  + ]
      54                 :            :                     {
      55         [ #  # ]:          0 :                         applyNormalsKindSphereTo3DGeometry(aFill, aRange);
      56                 :            :                     }
      57 [ +  - ][ +  - ]:        265 :                     else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
         [ +  - ][ +  - ]
      58                 :            :                     {
      59         [ +  - ]:        265 :                         applyNormalsKindFlatTo3DGeometry(aFill);
      60                 :            :                     }
      61                 :            : 
      62 [ +  - ][ +  - ]:        265 :                     if(getSdr3DObjectAttribute().getNormalsInvert())
         [ +  - ][ -  + ]
      63                 :            :                     {
      64         [ #  # ]:          0 :                         applyNormalsInvertTo3DGeometry(aFill);
      65                 :            :                     }
      66                 :            :                 }
      67                 :            : 
      68                 :            :                 // #i98314# texture coordinates
      69 [ +  - ][ +  + ]:        279 :                 if(!getSdrLFSAttribute().getFill().isDefault())
      70                 :            :                 {
      71                 :            :                     applyTextureTo3DGeometry(
      72                 :            :                         getSdr3DObjectAttribute().getTextureProjectionX(),
      73                 :            :                         getSdr3DObjectAttribute().getTextureProjectionY(),
      74                 :            :                         aFill,
      75                 :            :                         aRange,
      76 [ +  - ][ +  - ]:        265 :                         getTextureSize());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      77                 :            :                 }
      78                 :            : 
      79 [ +  - ][ +  + ]:        279 :                 if(!getSdrLFSAttribute().getFill().isDefault())
      80                 :            :                 {
      81                 :            :                     // add fill
      82                 :            :                     aRetval = create3DPolyPolygonFillPrimitives(
      83                 :            :                         aFill,
      84                 :        265 :                         getTransform(),
      85                 :        265 :                         getTextureSize(),
      86                 :            :                         getSdr3DObjectAttribute(),
      87                 :        265 :                         getSdrLFSAttribute().getFill(),
      88   [ +  -  +  - ]:        795 :                         getSdrLFSAttribute().getFillFloatTransGradient());
         [ +  - ][ +  - ]
                 [ +  - ]
      89                 :            :                 }
      90                 :            :                 else
      91                 :            :                 {
      92                 :            :                     // create simplified 3d hit test geometry
      93                 :            :                     aRetval = createHiddenGeometryPrimitives3D(
      94                 :            :                         aFill,
      95                 :         14 :                         getTransform(),
      96                 :         14 :                         getTextureSize(),
      97   [ +  -  +  - ]:         28 :                         getSdr3DObjectAttribute());
         [ +  - ][ +  - ]
                 [ +  - ]
      98                 :            :                 }
      99                 :            : 
     100                 :            :                 // add line
     101 [ +  - ][ +  + ]:        279 :                 if(!getSdrLFSAttribute().getLine().isDefault())
     102                 :            :                 {
     103         [ +  - ]:         18 :                     basegfx::B3DPolyPolygon aLine(getPolyPolygon3D());
     104         [ +  - ]:         18 :                     aLine.clearNormals();
     105         [ +  - ]:         18 :                     aLine.clearTextureCoordinates();
     106                 :            :                     const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(
     107         [ +  - ]:         18 :                         aLine, getTransform(), getSdrLFSAttribute().getLine()));
     108 [ +  - ][ +  - ]:         18 :                     appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines);
                 [ +  - ]
     109                 :            :                 }
     110                 :            : 
     111                 :            :                 // add shadow
     112         [ +  - ]:        279 :                 if(!getSdrLFSAttribute().getShadow().isDefault()
           [ -  +  #  # ]
                 [ -  + ]
     113                 :          0 :                     && aRetval.hasElements())
     114                 :            :                 {
     115                 :            :                     const Primitive3DSequence aShadow(createShadowPrimitive3D(
     116 [ #  # ][ #  # ]:          0 :                         aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()));
         [ #  # ][ #  # ]
     117 [ #  # ][ #  # ]:          0 :                     appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow);
     118                 :        279 :                 }
     119                 :            :             }
     120                 :            : 
     121                 :        279 :             return aRetval;
     122                 :            :         }
     123                 :            : 
     124                 :      10134 :         SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(
     125                 :            :             const basegfx::B3DPolyPolygon& rPolyPolygon3D,
     126                 :            :             const basegfx::B3DHomMatrix& rTransform,
     127                 :            :             const basegfx::B2DVector& rTextureSize,
     128                 :            :             const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
     129                 :            :             const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
     130                 :            :         :   SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute),
     131         [ +  - ]:      10134 :             maPolyPolygon3D(rPolyPolygon3D)
     132                 :            :         {
     133                 :      10134 :         }
     134                 :            : 
     135                 :       9696 :         bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
     136                 :            :         {
     137         [ +  + ]:       9696 :             if(SdrPrimitive3D::operator==(rPrimitive))
     138                 :            :             {
     139                 :       9262 :                 const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive);
     140                 :            : 
     141                 :       9262 :                 return (getPolyPolygon3D() == rCompare.getPolyPolygon3D());
     142                 :            :             }
     143                 :            : 
     144                 :       9696 :             return false;
     145                 :            :         }
     146                 :            : 
     147                 :      10647 :         basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
     148                 :            :         {
     149                 :            :             // added this implementation to make sure that non-visible objects of this
     150                 :            :             // kind will deliver their expansion. If not implemented, it would never deliver
     151                 :            :             // the used space for non-visible objects since the decomposition for that
     152                 :            :             // case will be empty (what is correct). To support chart ATM which relies on
     153                 :            :             // non-visible objects occupying space in 3D, this method was added
     154                 :      10647 :             basegfx::B3DRange aRetval;
     155                 :            : 
     156         [ +  + ]:      10647 :             if(getPolyPolygon3D().count())
     157                 :            :             {
     158                 :       9782 :                 aRetval = basegfx::tools::getRange(getPolyPolygon3D());
     159                 :       9782 :                 aRetval.transform(getTransform());
     160                 :            : 
     161         [ +  + ]:       9782 :                 if(!getSdrLFSAttribute().getLine().isDefault())
     162                 :            :                 {
     163                 :       1310 :                     const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
     164                 :            : 
     165 [ +  - ][ +  - ]:       1310 :                     if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
         [ -  + ][ +  - ]
           [ -  +  #  # ]
                 [ +  - ]
     166                 :            :                     {
     167                 :            :                         // expand by half LineWidth as tube radius
     168                 :          0 :                         aRetval.grow(rLine.getWidth() / 2.0);
     169                 :            :                     }
     170                 :            :                 }
     171                 :            :             }
     172                 :            : 
     173                 :      10647 :             return aRetval;
     174                 :            :         }
     175                 :            : 
     176                 :            :         // provide unique ID
     177                 :      20418 :         ImplPrimitrive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D)
     178                 :            : 
     179                 :            :     } // end of namespace primitive3d
     180                 :            : } // end of namespace drawinglayer
     181                 :            : 
     182                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10