1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
30 #include <basegfx/polygon/b3dpolygontools.hxx>
31 #include <basegfx/tools/canvastools.hxx>
32 #include <basegfx/polygon/b3dpolypolygontools.hxx>
33 #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
34 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
36 //////////////////////////////////////////////////////////////////////////////
38 using namespace com::sun::star
;
40 //////////////////////////////////////////////////////////////////////////////
42 namespace drawinglayer
46 PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
47 const basegfx::B3DPolygon
& rPolygon
,
48 const basegfx::BColor
& rBColor
)
55 bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
57 if(BasePrimitive3D::operator==(rPrimitive
))
59 const PolygonHairlinePrimitive3D
& rCompare
= (PolygonHairlinePrimitive3D
&)rPrimitive
;
61 return (getB3DPolygon() == rCompare
.getB3DPolygon()
62 && getBColor() == rCompare
.getBColor());
68 basegfx::B3DRange
PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D
& /*rViewInformation*/) const
70 return basegfx::tools::getRange(getB3DPolygon());
74 ImplPrimitrive3DIDBlock(PolygonHairlinePrimitive3D
, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D
)
76 } // end of namespace primitive3d
77 } // end of namespace drawinglayer
79 //////////////////////////////////////////////////////////////////////////////
81 namespace drawinglayer
85 Primitive3DSequence
PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D
& /*rViewInformation*/) const
87 Primitive3DSequence aRetval
;
89 if(getB3DPolygon().count())
91 basegfx::B3DPolyPolygon aHairLinePolyPolygon
;
93 if(0.0 == getStrokeAttribute().getFullDotDashLen())
95 aHairLinePolyPolygon
= basegfx::B3DPolyPolygon(getB3DPolygon());
100 basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon
, 0, getStrokeAttribute().getFullDotDashLen());
104 aRetval
.realloc(aHairLinePolyPolygon
.count());
106 if(getLineAttribute().getWidth())
108 // create fat line data
109 const double fRadius(getLineAttribute().getWidth() / 2.0);
110 const basegfx::B2DLineJoin
aLineJoin(getLineAttribute().getLineJoin());
112 for(sal_uInt32
a(0L); a
< aHairLinePolyPolygon
.count(); a
++)
114 // create tube primitives
115 const Primitive3DReference
xRef(new PolygonTubePrimitive3D(aHairLinePolyPolygon
.getB3DPolygon(a
), getLineAttribute().getColor(), fRadius
, aLineJoin
));
121 // create hair line data for all sub polygons
122 for(sal_uInt32
a(0L); a
< aHairLinePolyPolygon
.count(); a
++)
124 const basegfx::B3DPolygon aCandidate
= aHairLinePolyPolygon
.getB3DPolygon(a
);
125 const Primitive3DReference
xRef(new PolygonHairlinePrimitive3D(aCandidate
, getLineAttribute().getColor()));
134 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
135 const basegfx::B3DPolygon
& rPolygon
,
136 const attribute::LineAttribute
& rLineAttribute
,
137 const attribute::StrokeAttribute
& rStrokeAttribute
)
138 : BufferedDecompositionPrimitive3D(),
140 maLineAttribute(rLineAttribute
),
141 maStrokeAttribute(rStrokeAttribute
)
145 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
147 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive
))
149 const PolygonStrokePrimitive3D
& rCompare
= (PolygonStrokePrimitive3D
&)rPrimitive
;
151 return (getB3DPolygon() == rCompare
.getB3DPolygon()
152 && getLineAttribute() == rCompare
.getLineAttribute()
153 && getStrokeAttribute() == rCompare
.getStrokeAttribute());
160 ImplPrimitrive3DIDBlock(PolygonStrokePrimitive3D
, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D
)
162 } // end of namespace primitive3d
163 } // end of namespace drawinglayer
165 //////////////////////////////////////////////////////////////////////////////
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */