/src/libreoffice/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx
Line | Count | Source |
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 <com/sun/star/drawing/NormalsKind.hpp> |
21 | | #include <basegfx/range/b3drange.hxx> |
22 | | #include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx> |
23 | | #include <primitive3d/sdrdecompositiontools3d.hxx> |
24 | | #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> |
25 | | #include <basegfx/polygon/b3dpolypolygontools.hxx> |
26 | | #include <drawinglayer/attribute/sdrfillattribute.hxx> |
27 | | #include <drawinglayer/attribute/sdrlineattribute.hxx> |
28 | | #include <drawinglayer/attribute/sdrshadowattribute.hxx> |
29 | | #include <utility> |
30 | | |
31 | | |
32 | | using namespace com::sun::star; |
33 | | |
34 | | |
35 | | namespace drawinglayer::primitive3d |
36 | | { |
37 | | Primitive3DContainer SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const |
38 | 0 | { |
39 | 0 | Primitive3DContainer aRetval; |
40 | |
|
41 | 0 | if(getPolyPolygon3D().count()) |
42 | 0 | { |
43 | 0 | std::vector< basegfx::B3DPolyPolygon > aFill { getPolyPolygon3D() }; |
44 | | |
45 | | // get full range |
46 | 0 | const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill)); |
47 | | |
48 | | // #i98295# normal creation |
49 | 0 | if(!getSdrLFSAttribute().getFill().isDefault()) |
50 | 0 | { |
51 | 0 | if(css::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) |
52 | 0 | { |
53 | 0 | applyNormalsKindSphereTo3DGeometry(aFill, aRange); |
54 | 0 | } |
55 | 0 | else if(css::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind()) |
56 | 0 | { |
57 | 0 | applyNormalsKindFlatTo3DGeometry(aFill); |
58 | 0 | } |
59 | |
|
60 | 0 | if(getSdr3DObjectAttribute().getNormalsInvert()) |
61 | 0 | { |
62 | 0 | applyNormalsInvertTo3DGeometry(aFill); |
63 | 0 | } |
64 | 0 | } |
65 | | |
66 | | // #i98314# texture coordinates |
67 | 0 | if(!getSdrLFSAttribute().getFill().isDefault()) |
68 | 0 | { |
69 | 0 | applyTextureTo3DGeometry( |
70 | 0 | getSdr3DObjectAttribute().getTextureProjectionX(), |
71 | 0 | getSdr3DObjectAttribute().getTextureProjectionY(), |
72 | 0 | aFill, |
73 | 0 | aRange, |
74 | 0 | getTextureSize()); |
75 | 0 | } |
76 | |
|
77 | 0 | if(!getSdrLFSAttribute().getFill().isDefault()) |
78 | 0 | { |
79 | | // add fill |
80 | 0 | aRetval = create3DPolyPolygonFillPrimitives( |
81 | 0 | aFill, |
82 | 0 | getTransform(), |
83 | 0 | getTextureSize(), |
84 | 0 | getSdr3DObjectAttribute(), |
85 | 0 | getSdrLFSAttribute().getFill(), |
86 | 0 | getSdrLFSAttribute().getFillFloatTransGradient()); |
87 | 0 | } |
88 | 0 | else |
89 | 0 | { |
90 | | // create simplified 3d hit test geometry |
91 | 0 | aRetval = createHiddenGeometryPrimitives3D( |
92 | 0 | aFill, |
93 | 0 | getTransform(), |
94 | 0 | getTextureSize(), |
95 | 0 | getSdr3DObjectAttribute()); |
96 | 0 | } |
97 | | |
98 | | // add line |
99 | 0 | if(!getSdrLFSAttribute().getLine().isDefault()) |
100 | 0 | { |
101 | 0 | basegfx::B3DPolyPolygon aLine(getPolyPolygon3D()); |
102 | 0 | aLine.clearNormals(); |
103 | 0 | aLine.clearTextureCoordinates(); |
104 | 0 | const Primitive3DContainer aLines(create3DPolyPolygonLinePrimitives( |
105 | 0 | aLine, getTransform(), getSdrLFSAttribute().getLine())); |
106 | 0 | aRetval.append(aLines); |
107 | 0 | } |
108 | | |
109 | | // add shadow |
110 | 0 | if(!getSdrLFSAttribute().getShadow().isDefault() |
111 | 0 | && !aRetval.empty()) |
112 | 0 | { |
113 | 0 | const Primitive3DContainer aShadow(createShadowPrimitive3D( |
114 | 0 | aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); |
115 | 0 | aRetval.append(aShadow); |
116 | 0 | } |
117 | 0 | } |
118 | |
|
119 | 0 | return aRetval; |
120 | 0 | } |
121 | | |
122 | | SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D( |
123 | | basegfx::B3DPolyPolygon aPolyPolygon3D, |
124 | | const basegfx::B3DHomMatrix& rTransform, |
125 | | const basegfx::B2DVector& rTextureSize, |
126 | | const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, |
127 | | const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) |
128 | 0 | : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), |
129 | 0 | maPolyPolygon3D(std::move(aPolyPolygon3D)) |
130 | 0 | { |
131 | 0 | } Unexecuted instantiation: drawinglayer::primitive3d::SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(basegfx::B3DPolyPolygon, basegfx::B3DHomMatrix const&, basegfx::B2DVector const&, drawinglayer::attribute::SdrLineFillShadowAttribute3D const&, drawinglayer::attribute::Sdr3DObjectAttribute const&) Unexecuted instantiation: drawinglayer::primitive3d::SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(basegfx::B3DPolyPolygon, basegfx::B3DHomMatrix const&, basegfx::B2DVector const&, drawinglayer::attribute::SdrLineFillShadowAttribute3D const&, drawinglayer::attribute::Sdr3DObjectAttribute const&) |
132 | | |
133 | | bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
134 | 0 | { |
135 | 0 | if(SdrPrimitive3D::operator==(rPrimitive)) |
136 | 0 | { |
137 | 0 | const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive); |
138 | |
|
139 | 0 | return (getPolyPolygon3D() == rCompare.getPolyPolygon3D()); |
140 | 0 | } |
141 | | |
142 | 0 | return false; |
143 | 0 | } |
144 | | |
145 | | basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const |
146 | 0 | { |
147 | | // added this implementation to make sure that non-visible objects of this |
148 | | // kind will deliver their expansion. If not implemented, it would never deliver |
149 | | // the used space for non-visible objects since the decomposition for that |
150 | | // case will be empty (what is correct). To support chart ATM which relies on |
151 | | // non-visible objects occupying space in 3D, this method was added |
152 | 0 | basegfx::B3DRange aRetval; |
153 | |
|
154 | 0 | if(getPolyPolygon3D().count()) |
155 | 0 | { |
156 | 0 | aRetval = basegfx::utils::getRange(getPolyPolygon3D()); |
157 | 0 | aRetval.transform(getTransform()); |
158 | |
|
159 | 0 | if(!getSdrLFSAttribute().getLine().isDefault()) |
160 | 0 | { |
161 | 0 | const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); |
162 | |
|
163 | 0 | if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) |
164 | 0 | { |
165 | | // expand by half LineWidth as tube radius |
166 | 0 | aRetval.grow(rLine.getWidth() / 2.0); |
167 | 0 | } |
168 | 0 | } |
169 | 0 | } |
170 | |
|
171 | 0 | return aRetval; |
172 | 0 | } |
173 | | |
174 | | // provide unique ID |
175 | | ImplPrimitive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D) |
176 | | |
177 | | } // end of namespace |
178 | | |
179 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |