LibreOffice Module drawinglayer (master) 1
PolyPolygonSelectionPrimitive2D.cxx
Go to the documentation of this file.
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
21
28#include <utility>
29
30using namespace com::sun::star;
31
33{
35 Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
36{
37 if (getTransparence() >= 1.0 || !getB2DPolyPolygon().count())
38 return;
39
41
42 if (getFill() && getB2DPolyPolygon().isClosed())
43 {
44 // create fill primitive
45 const Primitive2DReference aFill(
47
48 aRetval = Primitive2DContainer{ aFill };
49 }
50
51 if (getDiscreteGrow() > 0.0)
52 {
53 const attribute::LineAttribute aLineAttribute(getColor(),
55 const Primitive2DReference aFatLine(
56 new PolyPolygonStrokePrimitive2D(getB2DPolyPolygon(), aLineAttribute));
57
58 aRetval.push_back(aFatLine);
59 }
60
61 // embed filled to transparency (if used)
62 if (!aRetval.empty() && getTransparence() > 0.0)
63 {
64 const Primitive2DReference aTrans(
65 new UnifiedTransparencePrimitive2D(std::move(aRetval), getTransparence()));
66
67 aRetval = Primitive2DContainer{ aTrans };
68 }
69
70 rContainer.append(std::move(aRetval));
71}
72
74 basegfx::B2DPolyPolygon aPolyPolygon, const basegfx::BColor& rColor, double fTransparence,
75 double fDiscreteGrow, bool bFill)
76 : maPolyPolygon(std::move(aPolyPolygon))
77 , maColor(rColor)
78 , mfTransparence(fTransparence)
79 , mfDiscreteGrow(fabs(fDiscreteGrow))
80 , mbFill(bFill)
81{
82}
83
85{
86 if (DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
87 {
89 = static_cast<const PolyPolygonSelectionPrimitive2D&>(rPrimitive);
90
91 return (
92 getB2DPolyPolygon() == rCompare.getB2DPolyPolygon() && getColor() == rCompare.getColor()
93 && getTransparence() == rCompare.getTransparence()
94 && getDiscreteGrow() == rCompare.getDiscreteGrow() && getFill() == rCompare.getFill());
95 }
96
97 return false;
98}
99
101 const geometry::ViewInformation2D& rViewInformation) const
102{
104
105 if (getDiscreteGrow() > 0.0)
106 {
107 // get the current DiscreteUnit (not sure if getDiscreteUnit() is updated here, better go safe way)
108 const double fDiscreteUnit(
109 (rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0))
110 .getLength());
111
112 aRetval.grow(fDiscreteUnit * getDiscreteGrow());
113 }
114
115 return aRetval;
116}
117
118// provide unique ID
120{
122}
123
124} // end drawinglayer::primitive2d namespace
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::BColor maColor
void grow(TYPE fValue)
const basegfx::B2DHomMatrix & getInverseObjectToViewTransformation() const
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
compare operator
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
data read access
PolyPolygonSelectionPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, const basegfx::BColor &rColor, double fTransparence, double fDiscreteGrow, bool bFill)
constructor
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &rViewInformation) const override
local decomposition.
virtual sal_uInt32 getPrimitive2DID() const override
provide unique ID
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &rViewInformation) const override
get range
#define PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D
B2DRange getRange(const B2DPolygon &rCandidate)
basegfx::B2DPolyPolygon maPolyPolygon