1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_drawinglayer.hxx" 30 31 #include <drawinglayer/primitive3d/sdrprimitive3d.hxx> 32 #include <basegfx/polygon/b3dpolypolygontools.hxx> 33 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> 34 #include <drawinglayer/attribute/sdrlineattribute.hxx> 35 36 ////////////////////////////////////////////////////////////////////////////// 37 38 using namespace com::sun::star; 39 40 ////////////////////////////////////////////////////////////////////////////// 41 42 namespace drawinglayer 43 { 44 namespace primitive3d 45 { 46 basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const 47 { 48 basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); 49 aUnitRange.transform(getTransform()); 50 51 if(!getSdrLFSAttribute().getLine().isDefault()) 52 { 53 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 54 55 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 56 { 57 // expand by hald LineWidth as tube radius 58 aUnitRange.grow(rLine.getWidth() / 2.0); 59 } 60 } 61 62 return aUnitRange; 63 } 64 65 basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const 66 { 67 basegfx::B3DRange aRetval; 68 69 if(rSlices.size()) 70 { 71 for(sal_uInt32 a(0L); a < rSlices.size(); a++) 72 { 73 aRetval.expand(basegfx::tools::getRange(rSlices[a].getB3DPolyPolygon())); 74 } 75 76 aRetval.transform(getTransform()); 77 78 if(!getSdrLFSAttribute().getLine().isDefault()) 79 { 80 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 81 82 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 83 { 84 // expand by half LineWidth as tube radius 85 aRetval.grow(rLine.getWidth() / 2.0); 86 } 87 } 88 } 89 90 return aRetval; 91 } 92 93 SdrPrimitive3D::SdrPrimitive3D( 94 const basegfx::B3DHomMatrix& rTransform, 95 const basegfx::B2DVector& rTextureSize, 96 const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, 97 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) 98 : BufferedDecompositionPrimitive3D(), 99 maTransform(rTransform), 100 maTextureSize(rTextureSize), 101 maSdrLFSAttribute(rSdrLFSAttribute), 102 maSdr3DObjectAttribute(rSdr3DObjectAttribute) 103 { 104 } 105 106 bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 107 { 108 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive)) 109 { 110 const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive); 111 112 return (getTransform() == rCompare.getTransform() 113 && getTextureSize() == rCompare.getTextureSize() 114 && getSdrLFSAttribute() == rCompare.getSdrLFSAttribute() 115 && getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute()); 116 } 117 118 return false; 119 } 120 121 } // end of namespace primitive3d 122 } // end of namespace drawinglayer 123 124 ////////////////////////////////////////////////////////////////////////////// 125 // eof 126