/src/libreoffice/drawinglayer/source/primitive3d/sdrprimitive3d.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 <drawinglayer/primitive3d/sdrprimitive3d.hxx> |
21 | | #include <basegfx/polygon/b3dpolypolygontools.hxx> |
22 | | #include <basegfx/range/b3drange.hxx> |
23 | | #include <drawinglayer/attribute/sdrlineattribute.hxx> |
24 | | #include <utility> |
25 | | |
26 | | |
27 | | namespace drawinglayer::primitive3d |
28 | | { |
29 | | basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const |
30 | 0 | { |
31 | 0 | basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); |
32 | 0 | aUnitRange.transform(getTransform()); |
33 | |
|
34 | 0 | if(!getSdrLFSAttribute().getLine().isDefault()) |
35 | 0 | { |
36 | 0 | const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); |
37 | |
|
38 | 0 | if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) |
39 | 0 | { |
40 | | // expand by held LineWidth as tube radius |
41 | 0 | aUnitRange.grow(rLine.getWidth() / 2.0); |
42 | 0 | } |
43 | 0 | } |
44 | |
|
45 | 0 | return aUnitRange; |
46 | 0 | } |
47 | | |
48 | | basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const |
49 | 0 | { |
50 | 0 | basegfx::B3DRange aRetval; |
51 | |
|
52 | 0 | if(!rSlices.empty()) |
53 | 0 | { |
54 | 0 | for(const auto & rSlice : rSlices) |
55 | 0 | { |
56 | 0 | aRetval.expand(basegfx::utils::getRange(rSlice.getB3DPolyPolygon())); |
57 | 0 | } |
58 | |
|
59 | 0 | aRetval.transform(getTransform()); |
60 | |
|
61 | 0 | if(!getSdrLFSAttribute().getLine().isDefault()) |
62 | 0 | { |
63 | 0 | const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); |
64 | |
|
65 | 0 | if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) |
66 | 0 | { |
67 | | // expand by half LineWidth as tube radius |
68 | 0 | aRetval.grow(rLine.getWidth() / 2.0); |
69 | 0 | } |
70 | 0 | } |
71 | 0 | } |
72 | |
|
73 | 0 | return aRetval; |
74 | 0 | } |
75 | | |
76 | | SdrPrimitive3D::SdrPrimitive3D( |
77 | | basegfx::B3DHomMatrix aTransform, |
78 | | const basegfx::B2DVector& rTextureSize, |
79 | | attribute::SdrLineFillShadowAttribute3D aSdrLFSAttribute, |
80 | | const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) |
81 | 0 | : maTransform(std::move(aTransform)), |
82 | 0 | maTextureSize(rTextureSize), |
83 | 0 | maSdrLFSAttribute(std::move(aSdrLFSAttribute)), |
84 | 0 | maSdr3DObjectAttribute(rSdr3DObjectAttribute) |
85 | 0 | { |
86 | 0 | } |
87 | | |
88 | | bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
89 | 0 | { |
90 | 0 | if(BufferedDecompositionPrimitive3D::operator==(rPrimitive)) |
91 | 0 | { |
92 | 0 | const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive); |
93 | |
|
94 | 0 | return (getTransform() == rCompare.getTransform() |
95 | 0 | && getTextureSize() == rCompare.getTextureSize() |
96 | 0 | && getSdrLFSAttribute() == rCompare.getSdrLFSAttribute() |
97 | 0 | && getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute()); |
98 | 0 | } |
99 | | |
100 | 0 | return false; |
101 | 0 | } |
102 | | |
103 | | } // end of namespace |
104 | | |
105 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |