LibreOffice Module drawinglayer (master) 1
sdrpolypolygonprimitive3d.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
27#include <utility>
28
29
30using namespace com::sun::star;
31
32
34{
36 {
38
40 {
41 std::vector< basegfx::B3DPolyPolygon > aFill { getPolyPolygon3D() };
42
43 // get full range
44 const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
45
46 // #i98295# normal creation
47 if(!getSdrLFSAttribute().getFill().isDefault())
48 {
49 if(css::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
50 {
52 }
53 else if(css::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
54 {
56 }
57
58 if(getSdr3DObjectAttribute().getNormalsInvert())
59 {
61 }
62 }
63
64 // #i98314# texture coordinates
65 if(!getSdrLFSAttribute().getFill().isDefault())
66 {
68 getSdr3DObjectAttribute().getTextureProjectionX(),
69 getSdr3DObjectAttribute().getTextureProjectionY(),
70 aFill,
71 aRange,
73 }
74
75 if(!getSdrLFSAttribute().getFill().isDefault())
76 {
77 // add fill
79 aFill,
83 getSdrLFSAttribute().getFill(),
84 getSdrLFSAttribute().getFillFloatTransGradient());
85 }
86 else
87 {
88 // create simplified 3d hit test geometry
90 aFill,
94 }
95
96 // add line
97 if(!getSdrLFSAttribute().getLine().isDefault())
98 {
100 aLine.clearNormals();
103 aLine, getTransform(), getSdrLFSAttribute().getLine()));
104 aRetval.append(aLines);
105 }
106
107 // add shadow
108 if(!getSdrLFSAttribute().getShadow().isDefault()
109 && !aRetval.empty())
110 {
112 aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()));
113 aRetval.append(aShadow);
114 }
115 }
116
117 return aRetval;
118 }
119
121 basegfx::B3DPolyPolygon aPolyPolygon3D,
122 const basegfx::B3DHomMatrix& rTransform,
123 const basegfx::B2DVector& rTextureSize,
124 const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
125 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
126 : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute),
127 maPolyPolygon3D(std::move(aPolyPolygon3D))
128 {
129 }
130
132 {
133 if(SdrPrimitive3D::operator==(rPrimitive))
134 {
135 const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive);
136
137 return (getPolyPolygon3D() == rCompare.getPolyPolygon3D());
138 }
139
140 return false;
141 }
142
144 {
145 // added this implementation to make sure that non-visible objects of this
146 // kind will deliver their expansion. If not implemented, it would never deliver
147 // the used space for non-visible objects since the decomposition for that
148 // case will be empty (what is correct). To support chart ATM which relies on
149 // non-visible objects occupying space in 3D, this method was added
150 basegfx::B3DRange aRetval;
151
152 if(getPolyPolygon3D().count())
153 {
155 aRetval.transform(getTransform());
156
157 if(!getSdrLFSAttribute().getLine().isDefault())
158 {
160
161 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
162 {
163 // expand by half LineWidth as tube radius
164 aRetval.grow(rLine.getWidth() / 2.0);
165 }
166 }
167 }
168
169 return aRetval;
170 }
171
172 // provide unique ID
174
175} // end of namespace
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix &rMatrix)
void grow(double fValue)
void append(const Primitive3DContainer &rSource)
virtual Primitive3DContainer create3DDecomposition(const geometry::ViewInformation3D &rViewInformation) const override
local decomposition.
virtual bool operator==(const BasePrimitive3D &rPrimitive) const override
compare operator
virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D &rViewInformation) const override
get range
const basegfx::B3DPolyPolygon & getPolyPolygon3D() const
data access
SdrPolyPolygonPrimitive3D(basegfx::B3DPolyPolygon aPolyPolygon3D, const basegfx::B3DHomMatrix &rTransform, const basegfx::B2DVector &rTextureSize, const attribute::SdrLineFillShadowAttribute3D &rSdrLFSAttribute, const attribute::Sdr3DObjectAttribute &rSdr3DObjectAttribute)
constructor
const basegfx::B3DHomMatrix & getTransform() const
data read access
const basegfx::B2DVector & getTextureSize() const
const attribute::Sdr3DObjectAttribute & getSdr3DObjectAttribute() const
const attribute::SdrLineFillShadowAttribute3D & getSdrLFSAttribute() const
#define PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D
bool equalZero(const T &rfVal)
B2DRange getRange(const B2DPolygon &rCandidate)
SdrPrimitive3D class.
void applyNormalsInvertTo3DGeometry(std::vector< basegfx::B3DPolyPolygon > &rFill)
ImplPrimitive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D) Primitive3DContainer PolygonStrokePrimitive3D
Primitive3DContainer create3DPolyPolygonFillPrimitives(const std::vector< basegfx::B3DPolyPolygon > &r3DPolyPolygonVector, const basegfx::B3DHomMatrix &rObjectTransform, const basegfx::B2DVector &rTextureSize, const attribute::Sdr3DObjectAttribute &aSdr3DObjectAttribute, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)
Primitive3DContainer createHiddenGeometryPrimitives3D(const std::vector< basegfx::B3DPolyPolygon > &r3DPolyPolygonVector, const basegfx::B3DHomMatrix &rObjectTransform, const basegfx::B2DVector &rTextureSize, const attribute::Sdr3DObjectAttribute &aSdr3DObjectAttribute)
void applyNormalsKindSphereTo3DGeometry(std::vector< basegfx::B3DPolyPolygon > &rFill, const basegfx::B3DRange &rRange)
basegfx::B3DRange getRangeFrom3DGeometry(std::vector< basegfx::B3DPolyPolygon > &rFill)
void applyTextureTo3DGeometry(css::drawing::TextureProjectionMode eModeX, css::drawing::TextureProjectionMode eModeY, std::vector< basegfx::B3DPolyPolygon > &rFill, const basegfx::B3DRange &rRange, const basegfx::B2DVector &rTextureSize)
void applyNormalsKindFlatTo3DGeometry(std::vector< basegfx::B3DPolyPolygon > &rFill)
Primitive3DContainer createShadowPrimitive3D(const Primitive3DContainer &rSource, const attribute::SdrShadowAttribute &rShadow, bool bShadow3D)
Primitive3DContainer create3DPolyPolygonLinePrimitives(const basegfx::B3DPolyPolygon &rUnitPolyPolygon, const basegfx::B3DHomMatrix &rObjectTransform, const attribute::SdrLineAttribute &rLine)