LibreOffice Module drawinglayer (master) 1
polygonprimitive3d.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
25#include <utility>
26
27
28using namespace com::sun::star;
29
30
32{
34 basegfx::B3DPolygon aPolygon,
35 const basegfx::BColor& rBColor)
36 : maPolygon(std::move(aPolygon)),
37 maBColor(rBColor)
38 {
39 }
40
42 {
43 if(BasePrimitive3D::operator==(rPrimitive))
44 {
45 const PolygonHairlinePrimitive3D& rCompare = static_cast<const PolygonHairlinePrimitive3D&>(rPrimitive);
46
47 return (getB3DPolygon() == rCompare.getB3DPolygon()
48 && getBColor() == rCompare.getBColor());
49 }
50
51 return false;
52 }
53
55 {
57 }
58
59 // provide unique ID
61
62
63
65 {
67
68 if(getB3DPolygon().count())
69 {
70 basegfx::B3DPolyPolygon aHairLinePolyPolygon;
71
72 if(0.0 == getStrokeAttribute().getFullDotDashLen())
73 {
74 aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
75 }
76 else
77 {
78 // apply LineStyle
79 basegfx::utils::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, getStrokeAttribute().getFullDotDashLen());
80 }
81
82 // prepare result
83 aRetval.resize(aHairLinePolyPolygon.count());
84
85 if(getLineAttribute().getWidth())
86 {
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());
91
92 for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++)
93 {
94 // create tube primitives
95 const Primitive3DReference xRef(
97 aHairLinePolyPolygon.getB3DPolygon(a),
98 getLineAttribute().getColor(),
99 fRadius,
100 aLineJoin,
101 aLineCap));
102 aRetval[a] = xRef;
103 }
104 }
105 else
106 {
107 // create hair line data for all sub polygons
108 for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++)
109 {
110 const basegfx::B3DPolygon& aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
111 const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
112 aRetval[a] = xRef;
113 }
114 }
115 }
116
117 return aRetval;
118 }
119
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))
127 {
128 }
129
130 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
131 {
132 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
133 {
134 const PolygonStrokePrimitive3D& rCompare = static_cast<const PolygonStrokePrimitive3D&>(rPrimitive);
135
136 return (getB3DPolygon() == rCompare.getB3DPolygon()
137 && getLineAttribute() == rCompare.getLineAttribute()
138 && getStrokeAttribute() == rCompare.getStrokeAttribute());
139 }
140
141 return false;
142 }
143
144 // provide unique ID
146
147} // end of namespace
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
B2DPolygon maPolygon
#define ImplPrimitive3DIDBlock(TheClass, TheID)
sal_uInt32 count() const
B3DPolygon const & getB3DPolygon(sal_uInt32 nIndex) const
PolygonHairlinePrimitive3D(basegfx::B3DPolygon aPolygon, const basegfx::BColor &rBColor)
constructor
virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D &rViewInformation) const override
get range
const basegfx::B3DPolygon & getB3DPolygon() const
data read access
virtual bool operator==(const BasePrimitive3D &rPrimitive) const override
compare operator
const attribute::StrokeAttribute & getStrokeAttribute() const
PolygonStrokePrimitive3D(basegfx::B3DPolygon aPolygon, const attribute::LineAttribute &rLineAttribute, attribute::StrokeAttribute aStrokeAttribute)
constructor
const basegfx::B3DPolygon & getB3DPolygon() const
data read access
virtual Primitive3DContainer create3DDecomposition(const geometry::ViewInformation3D &rViewInformation) const override
local decomposition.
const attribute::LineAttribute & getLineAttribute() const
#define PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D
#define PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D
uno_Any a
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
B2DRange getRange(const B2DPolygon &rCandidate)
SdrPrimitive3D class.
css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference
ImplPrimitive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D) Primitive3DContainer PolygonStrokePrimitive3D