LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive3d - sdrpolypolygonprimitive3d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 52 56 92.9 %
Date: 2014-11-03 Functions: 5 5 100.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 <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         305 :         Primitive3DSequence SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
      39             :         {
      40         305 :             Primitive3DSequence aRetval;
      41             : 
      42         305 :             if(getPolyPolygon3D().count())
      43             :             {
      44         305 :                 ::std::vector< basegfx::B3DPolyPolygon > aFill;
      45         305 :                 aFill.push_back(getPolyPolygon3D());
      46             : 
      47             :                 // get full range
      48         305 :                 const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
      49             : 
      50             :                 // #i98295# normal creation
      51         305 :                 if(!getSdrLFSAttribute().getFill().isDefault())
      52             :                 {
      53         243 :                     if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
      54             :                     {
      55           0 :                         applyNormalsKindSphereTo3DGeometry(aFill, aRange);
      56             :                     }
      57         243 :                     else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
      58             :                     {
      59         243 :                         applyNormalsKindFlatTo3DGeometry(aFill);
      60             :                     }
      61             : 
      62         243 :                     if(getSdr3DObjectAttribute().getNormalsInvert())
      63             :                     {
      64           0 :                         applyNormalsInvertTo3DGeometry(aFill);
      65             :                     }
      66             :                 }
      67             : 
      68             :                 // #i98314# texture coordinates
      69         305 :                 if(!getSdrLFSAttribute().getFill().isDefault())
      70             :                 {
      71             :                     applyTextureTo3DGeometry(
      72             :                         getSdr3DObjectAttribute().getTextureProjectionX(),
      73             :                         getSdr3DObjectAttribute().getTextureProjectionY(),
      74             :                         aFill,
      75             :                         aRange,
      76         243 :                         getTextureSize());
      77             :                 }
      78             : 
      79         305 :                 if(!getSdrLFSAttribute().getFill().isDefault())
      80             :                 {
      81             :                     // add fill
      82         729 :                     aRetval = create3DPolyPolygonFillPrimitives(
      83             :                         aFill,
      84         243 :                         getTransform(),
      85         243 :                         getTextureSize(),
      86             :                         getSdr3DObjectAttribute(),
      87         243 :                         getSdrLFSAttribute().getFill(),
      88         486 :                         getSdrLFSAttribute().getFillFloatTransGradient());
      89             :                 }
      90             :                 else
      91             :                 {
      92             :                     // create simplified 3d hit test geometry
      93         186 :                     aRetval = createHiddenGeometryPrimitives3D(
      94             :                         aFill,
      95          62 :                         getTransform(),
      96          62 :                         getTextureSize(),
      97          62 :                         getSdr3DObjectAttribute());
      98             :                 }
      99             : 
     100             :                 // add line
     101         305 :                 if(!getSdrLFSAttribute().getLine().isDefault())
     102             :                 {
     103         280 :                     basegfx::B3DPolyPolygon aLine(getPolyPolygon3D());
     104         280 :                     aLine.clearNormals();
     105         280 :                     aLine.clearTextureCoordinates();
     106             :                     const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(
     107         560 :                         aLine, getTransform(), getSdrLFSAttribute().getLine()));
     108         560 :                     appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines);
     109             :                 }
     110             : 
     111             :                 // add shadow
     112         610 :                 if(!getSdrLFSAttribute().getShadow().isDefault()
     113         305 :                     && aRetval.hasElements())
     114             :                 {
     115             :                     const Primitive3DSequence aShadow(createShadowPrimitive3D(
     116           0 :                         aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()));
     117           0 :                     appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow);
     118         305 :                 }
     119             :             }
     120             : 
     121         305 :             return aRetval;
     122             :         }
     123             : 
     124        3564 :         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        3564 :             maPolyPolygon3D(rPolyPolygon3D)
     132             :         {
     133        3564 :         }
     134             : 
     135        5200 :         bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
     136             :         {
     137        5200 :             if(SdrPrimitive3D::operator==(rPrimitive))
     138             :             {
     139        5097 :                 const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive);
     140             : 
     141        5097 :                 return (getPolyPolygon3D() == rCompare.getPolyPolygon3D());
     142             :             }
     143             : 
     144         103 :             return false;
     145             :         }
     146             : 
     147        3869 :         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        3869 :             basegfx::B3DRange aRetval;
     155             : 
     156        3869 :             if(getPolyPolygon3D().count())
     157             :             {
     158        3688 :                 aRetval = basegfx::tools::getRange(getPolyPolygon3D());
     159        3688 :                 aRetval.transform(getTransform());
     160             : 
     161        3688 :                 if(!getSdrLFSAttribute().getLine().isDefault())
     162             :                 {
     163        2634 :                     const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
     164             : 
     165        2634 :                     if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
     166             :                     {
     167             :                         // expand by half LineWidth as tube radius
     168        1084 :                         aRetval.grow(rLine.getWidth() / 2.0);
     169             :                     }
     170             :                 }
     171             :             }
     172             : 
     173        3869 :             return aRetval;
     174             :         }
     175             : 
     176             :         // provide unique ID
     177       11002 :         ImplPrimitive3DIDBlock(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