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/sdrpolypolygonprimitive3d.hxx> 32 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> 33 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> 34 #include <basegfx/polygon/b3dpolypolygontools.hxx> 35 #include <drawinglayer/attribute/sdrfillattribute.hxx> 36 #include <drawinglayer/attribute/sdrlineattribute.hxx> 37 #include <drawinglayer/attribute/sdrshadowattribute.hxx> 38 39 ////////////////////////////////////////////////////////////////////////////// 40 41 using namespace com::sun::star; 42 43 ////////////////////////////////////////////////////////////////////////////// 44 45 namespace drawinglayer 46 { 47 namespace primitive3d 48 { 49 Primitive3DSequence SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const 50 { 51 Primitive3DSequence aRetval; 52 53 if(getPolyPolygon3D().count()) 54 { 55 ::std::vector< basegfx::B3DPolyPolygon > aFill; 56 aFill.push_back(getPolyPolygon3D()); 57 58 // get full range 59 const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill)); 60 61 // #i98295# normal creation 62 if(!getSdrLFSAttribute().getFill().isDefault()) 63 { 64 if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) 65 { 66 applyNormalsKindSphereTo3DGeometry(aFill, aRange); 67 } 68 else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind()) 69 { 70 applyNormalsKindFlatTo3DGeometry(aFill); 71 } 72 73 if(getSdr3DObjectAttribute().getNormalsInvert()) 74 { 75 applyNormalsInvertTo3DGeometry(aFill); 76 } 77 } 78 79 // #i98314# texture coordinates 80 if(!getSdrLFSAttribute().getFill().isDefault()) 81 { 82 applyTextureTo3DGeometry( 83 getSdr3DObjectAttribute().getTextureProjectionX(), 84 getSdr3DObjectAttribute().getTextureProjectionY(), 85 aFill, 86 aRange, 87 getTextureSize()); 88 } 89 90 if(!getSdrLFSAttribute().getFill().isDefault()) 91 { 92 // add fill 93 aRetval = create3DPolyPolygonFillPrimitives( 94 aFill, 95 getTransform(), 96 getTextureSize(), 97 getSdr3DObjectAttribute(), 98 getSdrLFSAttribute().getFill(), 99 getSdrLFSAttribute().getFillFloatTransGradient()); 100 } 101 else 102 { 103 // create simplified 3d hit test geometry 104 aRetval = createHiddenGeometryPrimitives3D( 105 aFill, 106 getTransform(), 107 getTextureSize(), 108 getSdr3DObjectAttribute()); 109 } 110 111 // add line 112 if(!getSdrLFSAttribute().getLine().isDefault()) 113 { 114 basegfx::B3DPolyPolygon aLine(getPolyPolygon3D()); 115 aLine.clearNormals(); 116 aLine.clearTextureCoordinates(); 117 const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives( 118 aLine, getTransform(), getSdrLFSAttribute().getLine())); 119 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); 120 } 121 122 // add shadow 123 if(!getSdrLFSAttribute().getShadow().isDefault() 124 && aRetval.hasElements()) 125 { 126 const Primitive3DSequence aShadow(createShadowPrimitive3D( 127 aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); 128 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); 129 } 130 } 131 132 return aRetval; 133 } 134 135 SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D( 136 const basegfx::B3DPolyPolygon& rPolyPolygon3D, 137 const basegfx::B3DHomMatrix& rTransform, 138 const basegfx::B2DVector& rTextureSize, 139 const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, 140 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) 141 : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), 142 maPolyPolygon3D(rPolyPolygon3D) 143 { 144 } 145 146 bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 147 { 148 if(SdrPrimitive3D::operator==(rPrimitive)) 149 { 150 const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive); 151 152 return (getPolyPolygon3D() == rCompare.getPolyPolygon3D()); 153 } 154 155 return false; 156 } 157 158 basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const 159 { 160 // added this implementation to make sure that non-visible objects of this 161 // kind will deliver their expansion. If not implemented, it would never deliver 162 // the used space for non-visible objects since the decomposition for that 163 // case will be empty (what is correct). To support chart ATM which relies on 164 // non-visible objects occupying space in 3D, this method was added 165 basegfx::B3DRange aRetval; 166 167 if(getPolyPolygon3D().count()) 168 { 169 aRetval = basegfx::tools::getRange(getPolyPolygon3D()); 170 aRetval.transform(getTransform()); 171 172 if(!getSdrLFSAttribute().getLine().isDefault()) 173 { 174 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 175 176 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 177 { 178 // expand by half LineWidth as tube radius 179 aRetval.grow(rLine.getWidth() / 2.0); 180 } 181 } 182 } 183 184 return aRetval; 185 } 186 187 // provide unique ID 188 ImplPrimitrive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D) 189 190 } // end of namespace primitive3d 191 } // end of namespace drawinglayer 192 193 ////////////////////////////////////////////////////////////////////////////// 194 // eof 195