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