1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
21 #include <basegfx/polygon/b3dpolygontools.hxx>
22 #include <basegfx/polygon/b3dpolypolygon.hxx>
23 #include <primitive3d/polygontubeprimitive3d.hxx>
24 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
28 using namespace com::sun::star
;
31 namespace drawinglayer::primitive3d
33 PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
34 basegfx::B3DPolygon aPolygon
,
35 const basegfx::BColor
& rBColor
)
36 : maPolygon(std::move(aPolygon
)),
41 bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
43 if(BasePrimitive3D::operator==(rPrimitive
))
45 const PolygonHairlinePrimitive3D
& rCompare
= static_cast<const PolygonHairlinePrimitive3D
&>(rPrimitive
);
47 return (getB3DPolygon() == rCompare
.getB3DPolygon()
48 && getBColor() == rCompare
.getBColor());
54 basegfx::B3DRange
PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D
& /*rViewInformation*/) const
56 return basegfx::utils::getRange(getB3DPolygon());
60 ImplPrimitive3DIDBlock(PolygonHairlinePrimitive3D
, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D
)
64 Primitive3DContainer
PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D
& /*rViewInformation*/) const
66 Primitive3DContainer aRetval
;
68 if(getB3DPolygon().count())
70 basegfx::B3DPolyPolygon aHairLinePolyPolygon
;
72 if(0.0 == getStrokeAttribute().getFullDotDashLen())
74 aHairLinePolyPolygon
= basegfx::B3DPolyPolygon(getB3DPolygon());
79 basegfx::utils::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon
, getStrokeAttribute().getFullDotDashLen());
83 aRetval
.resize(aHairLinePolyPolygon
.count());
85 if(getLineAttribute().getWidth())
87 // create fat line data
88 const double fRadius(getLineAttribute().getWidth() / 2.0);
89 const basegfx::B2DLineJoin
aLineJoin(getLineAttribute().getLineJoin());
90 const css::drawing::LineCap
aLineCap(getLineAttribute().getLineCap());
92 for(sal_uInt32
a(0); a
< aHairLinePolyPolygon
.count(); a
++)
94 // create tube primitives
95 const Primitive3DReference
xRef(
96 new PolygonTubePrimitive3D(
97 aHairLinePolyPolygon
.getB3DPolygon(a
),
98 getLineAttribute().getColor(),
107 // create hair line data for all sub polygons
108 for(sal_uInt32
a(0); a
< aHairLinePolyPolygon
.count(); a
++)
110 const basegfx::B3DPolygon
& aCandidate
= aHairLinePolyPolygon
.getB3DPolygon(a
);
111 const Primitive3DReference
xRef(new PolygonHairlinePrimitive3D(aCandidate
, getLineAttribute().getColor()));
120 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
121 basegfx::B3DPolygon aPolygon
,
122 const attribute::LineAttribute
& rLineAttribute
,
123 attribute::StrokeAttribute aStrokeAttribute
)
124 : maPolygon(std::move(aPolygon
)),
125 maLineAttribute(rLineAttribute
),
126 maStrokeAttribute(std::move(aStrokeAttribute
))
130 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
132 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive
))
134 const PolygonStrokePrimitive3D
& rCompare
= static_cast<const PolygonStrokePrimitive3D
&>(rPrimitive
);
136 return (getB3DPolygon() == rCompare
.getB3DPolygon()
137 && getLineAttribute() == rCompare
.getLineAttribute()
138 && getStrokeAttribute() == rCompare
.getStrokeAttribute());
145 ImplPrimitive3DIDBlock(PolygonStrokePrimitive3D
, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D
)
147 } // end of namespace
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */