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