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/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>
26 :
27 : //////////////////////////////////////////////////////////////////////////////
28 :
29 : using namespace com::sun::star;
30 :
31 : //////////////////////////////////////////////////////////////////////////////
32 :
33 : namespace drawinglayer
34 : {
35 : namespace primitive3d
36 : {
37 0 : PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
38 : const basegfx::B3DPolygon& rPolygon,
39 : const basegfx::BColor& rBColor)
40 : : BasePrimitive3D(),
41 : maPolygon(rPolygon),
42 0 : maBColor(rBColor)
43 : {
44 0 : }
45 :
46 0 : bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
47 : {
48 0 : if(BasePrimitive3D::operator==(rPrimitive))
49 : {
50 0 : const PolygonHairlinePrimitive3D& rCompare = (PolygonHairlinePrimitive3D&)rPrimitive;
51 :
52 0 : return (getB3DPolygon() == rCompare.getB3DPolygon()
53 0 : && getBColor() == rCompare.getBColor());
54 : }
55 :
56 0 : return false;
57 : }
58 :
59 0 : basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
60 : {
61 0 : return basegfx::tools::getRange(getB3DPolygon());
62 : }
63 :
64 : // provide unique ID
65 0 : ImplPrimitrive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D)
66 :
67 : } // end of namespace primitive3d
68 : } // end of namespace drawinglayer
69 :
70 : //////////////////////////////////////////////////////////////////////////////
71 :
72 : namespace drawinglayer
73 : {
74 : namespace primitive3d
75 : {
76 0 : Primitive3DSequence PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
77 : {
78 0 : Primitive3DSequence aRetval;
79 :
80 0 : if(getB3DPolygon().count())
81 : {
82 0 : basegfx::B3DPolyPolygon aHairLinePolyPolygon;
83 :
84 0 : if(0.0 == getStrokeAttribute().getFullDotDashLen())
85 : {
86 0 : aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
87 : }
88 : else
89 : {
90 : // apply LineStyle
91 0 : basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, 0, getStrokeAttribute().getFullDotDashLen());
92 : }
93 :
94 : // prepare result
95 0 : aRetval.realloc(aHairLinePolyPolygon.count());
96 :
97 0 : if(getLineAttribute().getWidth())
98 : {
99 : // create fat line data
100 0 : const double fRadius(getLineAttribute().getWidth() / 2.0);
101 0 : const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin());
102 0 : const com::sun::star::drawing::LineCap aLineCap(getLineAttribute().getLineCap());
103 :
104 0 : for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
105 : {
106 : // create tube primitives
107 : const Primitive3DReference xRef(
108 : new PolygonTubePrimitive3D(
109 : aHairLinePolyPolygon.getB3DPolygon(a),
110 0 : getLineAttribute().getColor(),
111 : fRadius,
112 : aLineJoin,
113 0 : aLineCap));
114 0 : aRetval[a] = xRef;
115 0 : }
116 : }
117 : else
118 : {
119 : // create hair line data for all sub polygons
120 0 : for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
121 : {
122 0 : const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
123 0 : const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
124 0 : aRetval[a] = xRef;
125 0 : }
126 0 : }
127 : }
128 :
129 0 : return aRetval;
130 : }
131 :
132 0 : PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
133 : const basegfx::B3DPolygon& rPolygon,
134 : const attribute::LineAttribute& rLineAttribute,
135 : const attribute::StrokeAttribute& rStrokeAttribute)
136 : : BufferedDecompositionPrimitive3D(),
137 : maPolygon(rPolygon),
138 : maLineAttribute(rLineAttribute),
139 0 : maStrokeAttribute(rStrokeAttribute)
140 : {
141 0 : }
142 :
143 0 : bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
144 : {
145 0 : if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
146 : {
147 0 : const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive;
148 :
149 0 : return (getB3DPolygon() == rCompare.getB3DPolygon()
150 0 : && getLineAttribute() == rCompare.getLineAttribute()
151 0 : && getStrokeAttribute() == rCompare.getStrokeAttribute());
152 : }
153 :
154 0 : return false;
155 : }
156 :
157 : // provide unique ID
158 0 : ImplPrimitrive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D)
159 :
160 : } // end of namespace primitive3d
161 : } // end of namespace drawinglayer
162 :
163 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|