Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / drawinglayer / source / primitive3d / sdrprimitive3d.cxx
blob8547da5a89bf03c148b125894abcdd70dab4beb7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
21 #include <basegfx/polygon/b3dpolypolygontools.hxx>
22 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx>
23 #include <drawinglayer/attribute/sdrlineattribute.hxx>
26 using namespace com::sun::star;
29 namespace drawinglayer
31 namespace primitive3d
33 basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const
35 basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
36 aUnitRange.transform(getTransform());
38 if(!getSdrLFSAttribute().getLine().isDefault())
40 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
42 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
44 // expand by held LineWidth as tube radius
45 aUnitRange.grow(rLine.getWidth() / 2.0);
49 return aUnitRange;
52 basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const
54 basegfx::B3DRange aRetval;
56 if(!rSlices.empty())
58 for(const auto & rSlice : rSlices)
60 aRetval.expand(basegfx::utils::getRange(rSlice.getB3DPolyPolygon()));
63 aRetval.transform(getTransform());
65 if(!getSdrLFSAttribute().getLine().isDefault())
67 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
69 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
71 // expand by half LineWidth as tube radius
72 aRetval.grow(rLine.getWidth() / 2.0);
77 return aRetval;
80 SdrPrimitive3D::SdrPrimitive3D(
81 const basegfx::B3DHomMatrix& rTransform,
82 const basegfx::B2DVector& rTextureSize,
83 const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
84 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
85 : BufferedDecompositionPrimitive3D(),
86 maTransform(rTransform),
87 maTextureSize(rTextureSize),
88 maSdrLFSAttribute(rSdrLFSAttribute),
89 maSdr3DObjectAttribute(rSdr3DObjectAttribute)
93 bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
95 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
97 const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive);
99 return (getTransform() == rCompare.getTransform()
100 && getTextureSize() == rCompare.getTextureSize()
101 && getSdrLFSAttribute() == rCompare.getSdrLFSAttribute()
102 && getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute());
105 return false;
108 } // end of namespace primitive3d
109 } // end of namespace drawinglayer
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */