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 using namespace com::sun::star; 27 28 29 namespace drawinglayer 30 { 31 namespace primitive3d 32 { getStandard3DRange() const33 basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const 34 { 35 basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); 36 aUnitRange.transform(getTransform()); 37 38 if(!getSdrLFSAttribute().getLine().isDefault()) 39 { 40 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 41 42 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 43 { 44 // expand by held LineWidth as tube radius 45 aUnitRange.grow(rLine.getWidth() / 2.0); 46 } 47 } 48 49 return aUnitRange; 50 } 51 get3DRangeFromSlices(const Slice3DVector & rSlices) const52 basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const 53 { 54 basegfx::B3DRange aRetval; 55 56 if(!rSlices.empty()) 57 { 58 for(const auto & rSlice : rSlices) 59 { 60 aRetval.expand(basegfx::utils::getRange(rSlice.getB3DPolyPolygon())); 61 } 62 63 aRetval.transform(getTransform()); 64 65 if(!getSdrLFSAttribute().getLine().isDefault()) 66 { 67 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 68 69 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 70 { 71 // expand by half LineWidth as tube radius 72 aRetval.grow(rLine.getWidth() / 2.0); 73 } 74 } 75 } 76 77 return aRetval; 78 } 79 SdrPrimitive3D(const basegfx::B3DHomMatrix & rTransform,const basegfx::B2DVector & rTextureSize,const attribute::SdrLineFillShadowAttribute3D & rSdrLFSAttribute,const attribute::Sdr3DObjectAttribute & rSdr3DObjectAttribute)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) 90 { 91 } 92 operator ==(const BasePrimitive3D & rPrimitive) const93 bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 94 { 95 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive)) 96 { 97 const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive); 98 99 return (getTransform() == rCompare.getTransform() 100 && getTextureSize() == rCompare.getTextureSize() 101 && getSdrLFSAttribute() == rCompare.getSdrLFSAttribute() 102 && getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute()); 103 } 104 105 return false; 106 } 107 108 } // end of namespace primitive3d 109 } // end of namespace drawinglayer 110 111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 112