LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive3d - polygonprimitive3d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 47 66.0 %
Date: 2014-11-03 Functions: 5 8 62.5 %
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/polygonprimitive3d.hxx>
      21             : #include <basegfx/polygon/b3dpolygontools.hxx>
      22             : #include <basegfx/tools/canvastools.hxx>
      23             : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      24             : #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
      25             : #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
      26             : 
      27             : 
      28             : 
      29             : using namespace com::sun::star;
      30             : 
      31             : 
      32             : 
      33             : namespace drawinglayer
      34             : {
      35             :     namespace primitive3d
      36             :     {
      37        1484 :         PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
      38             :             const basegfx::B3DPolygon& rPolygon,
      39             :             const basegfx::BColor& rBColor)
      40             :         :   BasePrimitive3D(),
      41             :             maPolygon(rPolygon),
      42        1484 :             maBColor(rBColor)
      43             :         {
      44        1484 :         }
      45             : 
      46           0 :         bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
      47             :         {
      48           0 :             if(BasePrimitive3D::operator==(rPrimitive))
      49             :             {
      50           0 :                 const PolygonHairlinePrimitive3D& rCompare = static_cast<const PolygonHairlinePrimitive3D&>(rPrimitive);
      51             : 
      52           0 :                 return (getB3DPolygon() == rCompare.getB3DPolygon()
      53           0 :                     && getBColor() == rCompare.getBColor());
      54             :             }
      55             : 
      56           0 :             return false;
      57             :         }
      58             : 
      59           0 :         basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
      60             :         {
      61           0 :             return basegfx::tools::getRange(getB3DPolygon());
      62             :         }
      63             : 
      64             :         // provide unique ID
      65         804 :         ImplPrimitive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D)
      66             : 
      67             :     } // end of namespace primitive3d
      68             : } // end of namespace drawinglayer
      69             : 
      70             : 
      71             : 
      72             : namespace drawinglayer
      73             : {
      74             :     namespace primitive3d
      75             :     {
      76        1812 :         Primitive3DSequence PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
      77             :         {
      78        1812 :             Primitive3DSequence aRetval;
      79             : 
      80        1812 :             if(getB3DPolygon().count())
      81             :             {
      82        1116 :                 basegfx::B3DPolyPolygon aHairLinePolyPolygon;
      83             : 
      84        1116 :                 if(0.0 == getStrokeAttribute().getFullDotDashLen())
      85             :                 {
      86        1116 :                     aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
      87             :                 }
      88             :                 else
      89             :                 {
      90             :                     // apply LineStyle
      91           0 :                     basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, 0, getStrokeAttribute().getFullDotDashLen());
      92             :                 }
      93             : 
      94             :                 // prepare result
      95        1116 :                 aRetval.realloc(aHairLinePolyPolygon.count());
      96             : 
      97        1116 :                 if(getLineAttribute().getWidth())
      98             :                 {
      99             :                     // create fat line data
     100         898 :                     const double fRadius(getLineAttribute().getWidth() / 2.0);
     101         898 :                     const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin());
     102         898 :                     const com::sun::star::drawing::LineCap aLineCap(getLineAttribute().getLineCap());
     103             : 
     104        1796 :                     for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
     105             :                     {
     106             :                         // create tube primitives
     107             :                         const Primitive3DReference xRef(
     108             :                             new PolygonTubePrimitive3D(
     109             :                                 aHairLinePolyPolygon.getB3DPolygon(a),
     110         898 :                                 getLineAttribute().getColor(),
     111             :                                 fRadius,
     112             :                                 aLineJoin,
     113        1796 :                                 aLineCap));
     114         898 :                         aRetval[a] = xRef;
     115         898 :                     }
     116             :                 }
     117             :                 else
     118             :                 {
     119             :                     // create hair line data for all sub polygons
     120         436 :                     for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
     121             :                     {
     122         218 :                         const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
     123         436 :                         const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
     124         218 :                         aRetval[a] = xRef;
     125         218 :                     }
     126        1116 :                 }
     127             :             }
     128             : 
     129        1812 :             return aRetval;
     130             :         }
     131             : 
     132        1484 :         PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
     133             :             const basegfx::B3DPolygon& rPolygon,
     134             :             const attribute::LineAttribute& rLineAttribute,
     135             :             const attribute::StrokeAttribute& rStrokeAttribute)
     136             :         :   BufferedDecompositionPrimitive3D(),
     137             :             maPolygon(rPolygon),
     138             :             maLineAttribute(rLineAttribute),
     139        1484 :             maStrokeAttribute(rStrokeAttribute)
     140             :         {
     141        1484 :         }
     142             : 
     143           0 :         bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
     144             :         {
     145           0 :             if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
     146             :             {
     147           0 :                 const PolygonStrokePrimitive3D& rCompare = static_cast<const PolygonStrokePrimitive3D&>(rPrimitive);
     148             : 
     149           0 :                 return (getB3DPolygon() == rCompare.getB3DPolygon()
     150           0 :                     && getLineAttribute() == rCompare.getLineAttribute()
     151           0 :                     && getStrokeAttribute() == rCompare.getStrokeAttribute());
     152             :             }
     153             : 
     154           0 :             return false;
     155             :         }
     156             : 
     157             :         // provide unique ID
     158        2230 :         ImplPrimitive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D)
     159             : 
     160             :     } // end of namespace primitive3d
     161             : } // end of namespace drawinglayer
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10