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/tools/canvastools.hxx>
23 #include <basegfx/polygon/b3dpolypolygontools.hxx>
24 #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
25 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
27 //////////////////////////////////////////////////////////////////////////////
29 using namespace com::sun::star
;
31 //////////////////////////////////////////////////////////////////////////////
33 namespace drawinglayer
37 PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
38 const basegfx::B3DPolygon
& rPolygon
,
39 const basegfx::BColor
& rBColor
)
46 bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
48 if(BasePrimitive3D::operator==(rPrimitive
))
50 const PolygonHairlinePrimitive3D
& rCompare
= (PolygonHairlinePrimitive3D
&)rPrimitive
;
52 return (getB3DPolygon() == rCompare
.getB3DPolygon()
53 && getBColor() == rCompare
.getBColor());
59 basegfx::B3DRange
PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D
& /*rViewInformation*/) const
61 return basegfx::tools::getRange(getB3DPolygon());
65 ImplPrimitive3DIDBlock(PolygonHairlinePrimitive3D
, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D
)
67 } // end of namespace primitive3d
68 } // end of namespace drawinglayer
70 //////////////////////////////////////////////////////////////////////////////
72 namespace drawinglayer
76 Primitive3DSequence
PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D
& /*rViewInformation*/) const
78 Primitive3DSequence aRetval
;
80 if(getB3DPolygon().count())
82 basegfx::B3DPolyPolygon aHairLinePolyPolygon
;
84 if(0.0 == getStrokeAttribute().getFullDotDashLen())
86 aHairLinePolyPolygon
= basegfx::B3DPolyPolygon(getB3DPolygon());
91 basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon
, 0, getStrokeAttribute().getFullDotDashLen());
95 aRetval
.realloc(aHairLinePolyPolygon
.count());
97 if(getLineAttribute().getWidth())
99 // create fat line data
100 const double fRadius(getLineAttribute().getWidth() / 2.0);
101 const basegfx::B2DLineJoin
aLineJoin(getLineAttribute().getLineJoin());
102 const com::sun::star::drawing::LineCap
aLineCap(getLineAttribute().getLineCap());
104 for(sal_uInt32
a(0L); a
< aHairLinePolyPolygon
.count(); a
++)
106 // create tube primitives
107 const Primitive3DReference
xRef(
108 new PolygonTubePrimitive3D(
109 aHairLinePolyPolygon
.getB3DPolygon(a
),
110 getLineAttribute().getColor(),
119 // create hair line data for all sub polygons
120 for(sal_uInt32
a(0L); a
< aHairLinePolyPolygon
.count(); a
++)
122 const basegfx::B3DPolygon aCandidate
= aHairLinePolyPolygon
.getB3DPolygon(a
);
123 const Primitive3DReference
xRef(new PolygonHairlinePrimitive3D(aCandidate
, getLineAttribute().getColor()));
132 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
133 const basegfx::B3DPolygon
& rPolygon
,
134 const attribute::LineAttribute
& rLineAttribute
,
135 const attribute::StrokeAttribute
& rStrokeAttribute
)
136 : BufferedDecompositionPrimitive3D(),
138 maLineAttribute(rLineAttribute
),
139 maStrokeAttribute(rStrokeAttribute
)
143 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
145 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive
))
147 const PolygonStrokePrimitive3D
& rCompare
= (PolygonStrokePrimitive3D
&)rPrimitive
;
149 return (getB3DPolygon() == rCompare
.getB3DPolygon()
150 && getLineAttribute() == rCompare
.getLineAttribute()
151 && getStrokeAttribute() == rCompare
.getStrokeAttribute());
158 ImplPrimitive3DIDBlock(PolygonStrokePrimitive3D
, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D
)
160 } // end of namespace primitive3d
161 } // end of namespace drawinglayer
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */