LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/drawinglayer/source/primitive2d - polypolygonprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 96 186 51.6 %
Date: 2013-07-09 Functions: 25 39 64.1 %
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/primitive2d/polypolygonprimitive2d.hxx>
      21             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      22             : #include <basegfx/tools/canvastools.hxx>
      23             : #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
      24             : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
      25             : #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
      26             : #include <basegfx/matrix/b2dhommatrix.hxx>
      27             : #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
      28             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      29             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      30             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      31             : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
      32             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      33             : #include <vcl/graph.hxx>
      34             : 
      35             : //////////////////////////////////////////////////////////////////////////////
      36             : 
      37             : using namespace com::sun::star;
      38             : 
      39             : //////////////////////////////////////////////////////////////////////////////
      40             : 
      41             : namespace drawinglayer
      42             : {
      43             :     namespace primitive2d
      44             :     {
      45        8122 :         Primitive2DSequence PolyPolygonHairlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      46             :         {
      47        8122 :             const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
      48        8122 :             const sal_uInt32 nCount(aPolyPolygon.count());
      49             : 
      50        8122 :             if(nCount)
      51             :             {
      52        8122 :                 Primitive2DSequence aRetval(nCount);
      53             : 
      54       28069 :                 for(sal_uInt32 a(0L); a < nCount; a++)
      55             :                 {
      56       19947 :                     aRetval[a] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolyPolygon.getB2DPolygon(a), getBColor()));
      57             :                 }
      58             : 
      59        8122 :                 return aRetval;
      60             :             }
      61             :             else
      62             :             {
      63           0 :                 return Primitive2DSequence();
      64        8122 :             }
      65             :         }
      66             : 
      67       17842 :         PolyPolygonHairlinePrimitive2D::PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor)
      68             :         :   BufferedDecompositionPrimitive2D(),
      69             :             maPolyPolygon(rPolyPolygon),
      70       17842 :             maBColor(rBColor)
      71             :         {
      72       17842 :         }
      73             : 
      74          56 :         bool PolyPolygonHairlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      75             :         {
      76          56 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
      77             :             {
      78          56 :                 const PolyPolygonHairlinePrimitive2D& rCompare = (PolyPolygonHairlinePrimitive2D&)rPrimitive;
      79             : 
      80          56 :                 return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
      81          56 :                     && getBColor() == rCompare.getBColor());
      82             :             }
      83             : 
      84           0 :             return false;
      85             :         }
      86             : 
      87       74356 :         basegfx::B2DRange PolyPolygonHairlinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
      88             :         {
      89             :             // return range
      90       74356 :             return basegfx::tools::getRange(getB2DPolyPolygon());
      91             :         }
      92             : 
      93             :         // provide unique ID
      94        9795 :         ImplPrimitive2DIDBlock(PolyPolygonHairlinePrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D)
      95             : 
      96             :     } // end of namespace primitive2d
      97             : } // end of namespace drawinglayer
      98             : 
      99             : //////////////////////////////////////////////////////////////////////////////
     100             : 
     101             : namespace drawinglayer
     102             : {
     103             :     namespace primitive2d
     104             :     {
     105           0 :         Primitive2DSequence PolyPolygonMarkerPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
     106             :         {
     107           0 :             const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
     108           0 :             const sal_uInt32 nCount(aPolyPolygon.count());
     109             : 
     110           0 :             if(nCount)
     111             :             {
     112           0 :                 Primitive2DSequence aRetval(nCount);
     113             : 
     114           0 :                 for(sal_uInt32 a(0L); a < nCount; a++)
     115             :                 {
     116           0 :                     aRetval[a] = Primitive2DReference(
     117             :                         new PolygonMarkerPrimitive2D(
     118             :                             aPolyPolygon.getB2DPolygon(a),
     119             :                             getRGBColorA(),
     120             :                             getRGBColorB(),
     121           0 :                             getDiscreteDashLength()));
     122             :                 }
     123             : 
     124           0 :                 return aRetval;
     125             :             }
     126             :             else
     127             :             {
     128           0 :                 return Primitive2DSequence();
     129           0 :             }
     130             :         }
     131             : 
     132           0 :         PolyPolygonMarkerPrimitive2D::PolyPolygonMarkerPrimitive2D(
     133             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     134             :             const basegfx::BColor& rRGBColorA,
     135             :             const basegfx::BColor& rRGBColorB,
     136             :             double fDiscreteDashLength)
     137             :         :   BufferedDecompositionPrimitive2D(),
     138             :             maPolyPolygon(rPolyPolygon),
     139             :             maRGBColorA(rRGBColorA),
     140             :             maRGBColorB(rRGBColorB),
     141           0 :             mfDiscreteDashLength(fDiscreteDashLength)
     142             :         {
     143           0 :         }
     144             : 
     145           0 :         bool PolyPolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     146             :         {
     147           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     148             :             {
     149           0 :                 const PolyPolygonMarkerPrimitive2D& rCompare = (PolyPolygonMarkerPrimitive2D&)rPrimitive;
     150             : 
     151           0 :                 return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
     152           0 :                     && getRGBColorA() == rCompare.getRGBColorA()
     153           0 :                     && getRGBColorB() == rCompare.getRGBColorB()
     154           0 :                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
     155             :             }
     156             : 
     157           0 :             return false;
     158             :         }
     159             : 
     160           0 :         basegfx::B2DRange PolyPolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
     161             :         {
     162             :             // return range
     163           0 :             return basegfx::tools::getRange(getB2DPolyPolygon());
     164             :         }
     165             : 
     166             :         // provide unique ID
     167           0 :         ImplPrimitive2DIDBlock(PolyPolygonMarkerPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D)
     168             : 
     169             :     } // end of namespace primitive2d
     170             : } // end of namespace drawinglayer
     171             : 
     172             : //////////////////////////////////////////////////////////////////////////////
     173             : 
     174             : namespace drawinglayer
     175             : {
     176             :     namespace primitive2d
     177             :     {
     178         231 :         Primitive2DSequence PolyPolygonStrokePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
     179             :         {
     180         231 :             const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
     181         231 :             const sal_uInt32 nCount(aPolyPolygon.count());
     182             : 
     183         231 :             if(nCount)
     184             :             {
     185         231 :                 Primitive2DSequence aRetval(nCount);
     186             : 
     187         503 :                 for(sal_uInt32 a(0L); a < nCount; a++)
     188             :                 {
     189         544 :                     aRetval[a] = Primitive2DReference(
     190             :                         new PolygonStrokePrimitive2D(
     191         816 :                             aPolyPolygon.getB2DPolygon(a), getLineAttribute(), getStrokeAttribute()));
     192             :                 }
     193             : 
     194         231 :                 return aRetval;
     195             :             }
     196             :             else
     197             :             {
     198           0 :                 return Primitive2DSequence();
     199         231 :             }
     200             :         }
     201             : 
     202          36 :         PolyPolygonStrokePrimitive2D::PolyPolygonStrokePrimitive2D(
     203             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     204             :               const attribute::LineAttribute& rLineAttribute,
     205             :             const attribute::StrokeAttribute& rStrokeAttribute)
     206             :         :   BufferedDecompositionPrimitive2D(),
     207             :             maPolyPolygon(rPolyPolygon),
     208             :             maLineAttribute(rLineAttribute),
     209          36 :             maStrokeAttribute(rStrokeAttribute)
     210             :         {
     211          36 :         }
     212             : 
     213         195 :         PolyPolygonStrokePrimitive2D::PolyPolygonStrokePrimitive2D(
     214             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     215             :               const attribute::LineAttribute& rLineAttribute)
     216             :         :   BufferedDecompositionPrimitive2D(),
     217             :             maPolyPolygon(rPolyPolygon),
     218             :             maLineAttribute(rLineAttribute),
     219         195 :             maStrokeAttribute()
     220             :         {
     221         195 :         }
     222             : 
     223           0 :         bool PolyPolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     224             :         {
     225           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     226             :             {
     227           0 :                 const PolyPolygonStrokePrimitive2D& rCompare = (PolyPolygonStrokePrimitive2D&)rPrimitive;
     228             : 
     229           0 :                 return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
     230           0 :                     && getLineAttribute() == rCompare.getLineAttribute()
     231           0 :                     && getStrokeAttribute() == rCompare.getStrokeAttribute());
     232             :             }
     233             : 
     234           0 :             return false;
     235             :         }
     236             : 
     237         381 :         basegfx::B2DRange PolyPolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
     238             :         {
     239             :             // get range of it (subdivided)
     240         381 :             basegfx::B2DRange aRetval(basegfx::tools::getRange(getB2DPolyPolygon()));
     241             : 
     242             :             // if width, grow by line width
     243         381 :             if(getLineAttribute().getWidth())
     244             :             {
     245         381 :                 aRetval.grow(getLineAttribute().getWidth() / 2.0);
     246             :             }
     247             : 
     248         381 :             return aRetval;
     249             :         }
     250             : 
     251             :         // provide unique ID
     252         457 :         ImplPrimitive2DIDBlock(PolyPolygonStrokePrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D)
     253             : 
     254             :     } // end of namespace primitive2d
     255             : } // end of namespace drawinglayer
     256             : 
     257             : //////////////////////////////////////////////////////////////////////////////
     258             : 
     259             : namespace drawinglayer
     260             : {
     261             :     namespace primitive2d
     262             :     {
     263      119275 :         PolyPolygonColorPrimitive2D::PolyPolygonColorPrimitive2D(
     264             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     265             :             const basegfx::BColor& rBColor)
     266             :         :   BasePrimitive2D(),
     267             :             maPolyPolygon(rPolyPolygon),
     268      119275 :             maBColor(rBColor)
     269             :         {
     270      119275 :         }
     271             : 
     272         993 :         bool PolyPolygonColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     273             :         {
     274         993 :             if(BasePrimitive2D::operator==(rPrimitive))
     275             :             {
     276         993 :                 const PolyPolygonColorPrimitive2D& rCompare = (PolyPolygonColorPrimitive2D&)rPrimitive;
     277             : 
     278         993 :                 return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
     279         993 :                     && getBColor() == rCompare.getBColor());
     280             :             }
     281             : 
     282           0 :             return false;
     283             :         }
     284             : 
     285      108202 :         basegfx::B2DRange PolyPolygonColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
     286             :         {
     287             :             // return range
     288      108202 :             return basegfx::tools::getRange(getB2DPolyPolygon());
     289             :         }
     290             : 
     291             :         // provide unique ID
     292      126499 :         ImplPrimitive2DIDBlock(PolyPolygonColorPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D)
     293             : 
     294             :     } // end of namespace primitive2d
     295             : } // end of namespace drawinglayer
     296             : 
     297             : //////////////////////////////////////////////////////////////////////////////
     298             : 
     299             : namespace drawinglayer
     300             : {
     301             :     namespace primitive2d
     302             :     {
     303          94 :         Primitive2DSequence PolyPolygonGradientPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
     304             :         {
     305          94 :             if(!getFillGradient().isDefault())
     306             :             {
     307             :                 // create SubSequence with FillGradientPrimitive2D
     308          94 :                 const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
     309          94 :                 FillGradientPrimitive2D* pNewGradient = new FillGradientPrimitive2D(aPolyPolygonRange, getFillGradient());
     310          94 :                 const Primitive2DReference xSubRef(pNewGradient);
     311         188 :                 const Primitive2DSequence aSubSequence(&xSubRef, 1L);
     312             : 
     313             :                 // create mask primitive
     314          94 :                 MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence);
     315         188 :                 const Primitive2DReference xRef(pNewMask);
     316             : 
     317         188 :                 return Primitive2DSequence(&xRef, 1);
     318             :             }
     319             :             else
     320             :             {
     321           0 :                 return Primitive2DSequence();
     322             :             }
     323             :         }
     324             : 
     325          94 :         PolyPolygonGradientPrimitive2D::PolyPolygonGradientPrimitive2D(
     326             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     327             :             const attribute::FillGradientAttribute& rFillGradient)
     328             :         :   BufferedDecompositionPrimitive2D(),
     329             :             maPolyPolygon(rPolyPolygon),
     330          94 :             maFillGradient(rFillGradient)
     331             :         {
     332          94 :         }
     333             : 
     334           0 :         bool PolyPolygonGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     335             :         {
     336           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     337             :             {
     338           0 :                 const PolyPolygonGradientPrimitive2D& rCompare = (PolyPolygonGradientPrimitive2D&)rPrimitive;
     339             : 
     340           0 :                 return (getFillGradient() == rCompare.getFillGradient());
     341             :             }
     342             : 
     343           0 :             return false;
     344             :         }
     345             : 
     346             :         // provide unique ID
     347         175 :         ImplPrimitive2DIDBlock(PolyPolygonGradientPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D)
     348             : 
     349             :     } // end of namespace primitive2d
     350             : } // end of namespace drawinglayer
     351             : 
     352             : //////////////////////////////////////////////////////////////////////////////
     353             : 
     354             : namespace drawinglayer
     355             : {
     356             :     namespace primitive2d
     357             :     {
     358         572 :         Primitive2DSequence PolyPolygonHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
     359             :         {
     360         572 :             if(!getFillHatch().isDefault())
     361             :             {
     362             :                 // create SubSequence with FillHatchPrimitive2D
     363         572 :                 const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
     364         572 :                 FillHatchPrimitive2D* pNewHatch = new FillHatchPrimitive2D(aPolyPolygonRange, getBackgroundColor(), getFillHatch());
     365         572 :                 const Primitive2DReference xSubRef(pNewHatch);
     366        1144 :                 const Primitive2DSequence aSubSequence(&xSubRef, 1L);
     367             : 
     368             :                 // create mask primitive
     369         572 :                 MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence);
     370        1144 :                 const Primitive2DReference xRef(pNewMask);
     371             : 
     372        1144 :                 return Primitive2DSequence(&xRef, 1);
     373             :             }
     374             :             else
     375             :             {
     376           0 :                 return Primitive2DSequence();
     377             :             }
     378             :         }
     379             : 
     380         572 :         PolyPolygonHatchPrimitive2D::PolyPolygonHatchPrimitive2D(
     381             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     382             :             const basegfx::BColor& rBackgroundColor,
     383             :             const attribute::FillHatchAttribute& rFillHatch)
     384             :         :   BufferedDecompositionPrimitive2D(),
     385             :             maPolyPolygon(rPolyPolygon),
     386             :             maBackgroundColor(rBackgroundColor),
     387         572 :             maFillHatch(rFillHatch)
     388             :         {
     389         572 :         }
     390             : 
     391           0 :         bool PolyPolygonHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     392             :         {
     393           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     394             :             {
     395           0 :                 const PolyPolygonHatchPrimitive2D& rCompare = (PolyPolygonHatchPrimitive2D&)rPrimitive;
     396             : 
     397           0 :                 return (getBackgroundColor() == rCompare.getBackgroundColor()
     398           0 :                     && getFillHatch() == rCompare.getFillHatch());
     399             :             }
     400             : 
     401           0 :             return false;
     402             :         }
     403             : 
     404             :         // provide unique ID
     405         343 :         ImplPrimitive2DIDBlock(PolyPolygonHatchPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D)
     406             : 
     407             :     } // end of namespace primitive2d
     408             : } // end of namespace drawinglayer
     409             : 
     410             : //////////////////////////////////////////////////////////////////////////////
     411             : 
     412             : namespace drawinglayer
     413             : {
     414             :     namespace primitive2d
     415             :     {
     416         120 :         Primitive2DSequence PolyPolygonGraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
     417             :         {
     418         120 :             if(!getFillGraphic().isDefault())
     419             :             {
     420         120 :                 const Graphic& rGraphic = getFillGraphic().getGraphic();
     421         120 :                 const GraphicType aType(rGraphic.GetType());
     422             : 
     423             :                 // is there a bitmap or a metafile (do we have content)?
     424         120 :                 if(GRAPHIC_BITMAP == aType || GRAPHIC_GDIMETAFILE == aType)
     425             :                 {
     426         120 :                     const Size aPrefSize(rGraphic.GetPrefSize());
     427             : 
     428             :                     // does content have a size?
     429         120 :                     if(aPrefSize.Width() && aPrefSize.Height())
     430             :                     {
     431             :                         // create SubSequence with FillGraphicPrimitive2D based on polygon range
     432         120 :                         const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
     433             :                         const basegfx::B2DHomMatrix aNewObjectTransform(
     434             :                             basegfx::tools::createScaleTranslateB2DHomMatrix(
     435             :                                 aPolyPolygonRange.getRange(),
     436         120 :                                 aPolyPolygonRange.getMinimum()));
     437             :                         const Primitive2DReference xSubRef(
     438             :                             new FillGraphicPrimitive2D(
     439             :                                 aNewObjectTransform,
     440         240 :                                 getFillGraphic()));
     441             : 
     442             :                         // embed to mask primitive
     443             :                         const Primitive2DReference xRef(
     444             :                             new MaskPrimitive2D(
     445             :                                 getB2DPolyPolygon(),
     446         240 :                                 Primitive2DSequence(&xSubRef, 1)));
     447             : 
     448         240 :                         return Primitive2DSequence(&xRef, 1);
     449             :                     }
     450             :                 }
     451             :             }
     452             : 
     453           0 :             return Primitive2DSequence();
     454             :         }
     455             : 
     456         120 :         PolyPolygonGraphicPrimitive2D::PolyPolygonGraphicPrimitive2D(
     457             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     458             :             const attribute::FillGraphicAttribute& rFillGraphic)
     459             :         :   BufferedDecompositionPrimitive2D(),
     460             :             maPolyPolygon(rPolyPolygon),
     461         120 :             maFillGraphic(rFillGraphic)
     462             :         {
     463         120 :         }
     464             : 
     465           0 :         bool PolyPolygonGraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     466             :         {
     467           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     468             :             {
     469           0 :                 const PolyPolygonGraphicPrimitive2D& rCompare = (PolyPolygonGraphicPrimitive2D&)rPrimitive;
     470             : 
     471           0 :                 return (getFillGraphic() == rCompare.getFillGraphic());
     472             :             }
     473             : 
     474           0 :             return false;
     475             :         }
     476             : 
     477             :         // provide unique ID
     478         123 :         ImplPrimitive2DIDBlock(PolyPolygonGraphicPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D)
     479             : 
     480             :     } // end of namespace primitive2d
     481             : } // end of namespace drawinglayer
     482             : 
     483             : //////////////////////////////////////////////////////////////////////////////
     484             : 
     485             : namespace drawinglayer
     486             : {
     487             :     namespace primitive2d
     488             :     {
     489           0 :         Primitive2DSequence PolyPolygonSelectionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
     490             :         {
     491           0 :             Primitive2DSequence aRetval;
     492             : 
     493           0 :             if(getTransparence() < 1.0 && getB2DPolyPolygon().count())
     494             :             {
     495           0 :                 if(getFill() && getB2DPolyPolygon().isClosed())
     496             :                 {
     497             :                     // create fill primitive
     498             :                     const Primitive2DReference aFill(
     499             :                         new PolyPolygonColorPrimitive2D(
     500             :                             getB2DPolyPolygon(),
     501           0 :                             getColor()));
     502             : 
     503           0 :                     aRetval = Primitive2DSequence(&aFill, 1);
     504             :                 }
     505             : 
     506           0 :                 if(getDiscreteGrow() > 0.0)
     507             :                 {
     508             :                     const attribute::LineAttribute aLineAttribute(
     509           0 :                         getColor(),
     510           0 :                         getDiscreteGrow() * getDiscreteUnit() * 2.0);
     511             :                     const Primitive2DReference aFatLine(
     512             :                         new PolyPolygonStrokePrimitive2D(
     513             :                             getB2DPolyPolygon(),
     514           0 :                             aLineAttribute));
     515             : 
     516           0 :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aFatLine);
     517             :                 }
     518             : 
     519             :                 // embed filled to transparency (if used)
     520           0 :                 if(aRetval.getLength() && getTransparence() > 0.0)
     521             :                 {
     522             :                     const Primitive2DReference aTrans(
     523             :                         new UnifiedTransparencePrimitive2D(
     524             :                             aRetval,
     525           0 :                             getTransparence()));
     526             : 
     527           0 :                     aRetval = Primitive2DSequence(&aTrans, 1);
     528             :                 }
     529             :             }
     530             : 
     531           0 :             return aRetval;
     532             :         }
     533             : 
     534           0 :         PolyPolygonSelectionPrimitive2D::PolyPolygonSelectionPrimitive2D(
     535             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
     536             :             const basegfx::BColor& rColor,
     537             :             double fTransparence,
     538             :             double fDiscreteGrow,
     539             :             bool bFill)
     540             :         :   DiscreteMetricDependentPrimitive2D(),
     541             :             maPolyPolygon(rPolyPolygon),
     542             :             maColor(rColor),
     543             :             mfTransparence(fTransparence),
     544           0 :             mfDiscreteGrow(fabs(fDiscreteGrow)),
     545           0 :             mbFill(bFill)
     546             :         {
     547           0 :         }
     548             : 
     549           0 :         bool PolyPolygonSelectionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     550             :         {
     551           0 :             if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
     552             :             {
     553           0 :                 const PolyPolygonSelectionPrimitive2D& rCompare = (PolyPolygonSelectionPrimitive2D&)rPrimitive;
     554             : 
     555           0 :                 return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
     556           0 :                     && getColor() == rCompare.getColor()
     557           0 :                     && getTransparence() == rCompare.getTransparence()
     558           0 :                     && getDiscreteGrow() == rCompare.getDiscreteGrow()
     559           0 :                     && getFill() == rCompare.getFill());
     560             :             }
     561             : 
     562           0 :             return false;
     563             :         }
     564             : 
     565           0 :         basegfx::B2DRange PolyPolygonSelectionPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
     566             :         {
     567           0 :             basegfx::B2DRange aRetval(basegfx::tools::getRange(getB2DPolyPolygon()));
     568             : 
     569           0 :             if(getDiscreteGrow() > 0.0)
     570             :             {
     571             :                 // get the current DiscreteUnit (not sure if getDiscreteUnit() is updated here, better go safe way)
     572           0 :                 const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
     573             : 
     574           0 :                 aRetval.grow(fDiscreteUnit * getDiscreteGrow());
     575             :             }
     576             : 
     577           0 :             return aRetval;
     578             :         }
     579             : 
     580             :         // provide unique ID
     581           0 :         ImplPrimitive2DIDBlock(PolyPolygonSelectionPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D)
     582             : 
     583             :     } // end of namespace primitive2d
     584         408 : } // end of namespace drawinglayer
     585             : 
     586             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10