1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx> 32*cdf0e10cSrcweir #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> 33*cdf0e10cSrcweir #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> 34*cdf0e10cSrcweir #include <basegfx/polygon/b3dpolypolygontools.hxx> 35*cdf0e10cSrcweir #include <drawinglayer/attribute/sdrfillattribute.hxx> 36*cdf0e10cSrcweir #include <drawinglayer/attribute/sdrlineattribute.hxx> 37*cdf0e10cSrcweir #include <drawinglayer/attribute/sdrshadowattribute.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir using namespace com::sun::star; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir namespace drawinglayer 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir namespace primitive3d 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir Primitive3DSequence SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir Primitive3DSequence aRetval; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir if(getPolyPolygon3D().count()) 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir ::std::vector< basegfx::B3DPolyPolygon > aFill; 56*cdf0e10cSrcweir aFill.push_back(getPolyPolygon3D()); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // get full range 59*cdf0e10cSrcweir const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill)); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir // #i98295# normal creation 62*cdf0e10cSrcweir if(!getSdrLFSAttribute().getFill().isDefault()) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir applyNormalsKindSphereTo3DGeometry(aFill, aRange); 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind()) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir applyNormalsKindFlatTo3DGeometry(aFill); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir if(getSdr3DObjectAttribute().getNormalsInvert()) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir applyNormalsInvertTo3DGeometry(aFill); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // #i98314# texture coordinates 80*cdf0e10cSrcweir if(!getSdrLFSAttribute().getFill().isDefault()) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir applyTextureTo3DGeometry( 83*cdf0e10cSrcweir getSdr3DObjectAttribute().getTextureProjectionX(), 84*cdf0e10cSrcweir getSdr3DObjectAttribute().getTextureProjectionY(), 85*cdf0e10cSrcweir aFill, 86*cdf0e10cSrcweir aRange, 87*cdf0e10cSrcweir getTextureSize()); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir if(!getSdrLFSAttribute().getFill().isDefault()) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir // add fill 93*cdf0e10cSrcweir aRetval = create3DPolyPolygonFillPrimitives( 94*cdf0e10cSrcweir aFill, 95*cdf0e10cSrcweir getTransform(), 96*cdf0e10cSrcweir getTextureSize(), 97*cdf0e10cSrcweir getSdr3DObjectAttribute(), 98*cdf0e10cSrcweir getSdrLFSAttribute().getFill(), 99*cdf0e10cSrcweir getSdrLFSAttribute().getFillFloatTransGradient()); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir else 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir // create simplified 3d hit test geometry 104*cdf0e10cSrcweir aRetval = createHiddenGeometryPrimitives3D( 105*cdf0e10cSrcweir aFill, 106*cdf0e10cSrcweir getTransform(), 107*cdf0e10cSrcweir getTextureSize(), 108*cdf0e10cSrcweir getSdr3DObjectAttribute()); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // add line 112*cdf0e10cSrcweir if(!getSdrLFSAttribute().getLine().isDefault()) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir basegfx::B3DPolyPolygon aLine(getPolyPolygon3D()); 115*cdf0e10cSrcweir aLine.clearNormals(); 116*cdf0e10cSrcweir aLine.clearTextureCoordinates(); 117*cdf0e10cSrcweir const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives( 118*cdf0e10cSrcweir aLine, getTransform(), getSdrLFSAttribute().getLine())); 119*cdf0e10cSrcweir appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir // add shadow 123*cdf0e10cSrcweir if(!getSdrLFSAttribute().getShadow().isDefault() 124*cdf0e10cSrcweir && aRetval.hasElements()) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir const Primitive3DSequence aShadow(createShadowPrimitive3D( 127*cdf0e10cSrcweir aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); 128*cdf0e10cSrcweir appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir return aRetval; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D( 136*cdf0e10cSrcweir const basegfx::B3DPolyPolygon& rPolyPolygon3D, 137*cdf0e10cSrcweir const basegfx::B3DHomMatrix& rTransform, 138*cdf0e10cSrcweir const basegfx::B2DVector& rTextureSize, 139*cdf0e10cSrcweir const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, 140*cdf0e10cSrcweir const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) 141*cdf0e10cSrcweir : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), 142*cdf0e10cSrcweir maPolyPolygon3D(rPolyPolygon3D) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir if(SdrPrimitive3D::operator==(rPrimitive)) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir return (getPolyPolygon3D() == rCompare.getPolyPolygon3D()); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir return false; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir // added this implementation to make sure that non-visible objects of this 161*cdf0e10cSrcweir // kind will deliver their expansion. If not implemented, it would never deliver 162*cdf0e10cSrcweir // the used space for non-visible objects since the decomposition for that 163*cdf0e10cSrcweir // case will be empty (what is correct). To support chart ATM which relies on 164*cdf0e10cSrcweir // non-visible objects occupying space in 3D, this method was added 165*cdf0e10cSrcweir basegfx::B3DRange aRetval; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if(getPolyPolygon3D().count()) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir aRetval = basegfx::tools::getRange(getPolyPolygon3D()); 170*cdf0e10cSrcweir aRetval.transform(getTransform()); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if(!getSdrLFSAttribute().getLine().isDefault()) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir // expand by half LineWidth as tube radius 179*cdf0e10cSrcweir aRetval.grow(rLine.getWidth() / 2.0); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir return aRetval; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir // provide unique ID 188*cdf0e10cSrcweir ImplPrimitrive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D) 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir } // end of namespace primitive3d 191*cdf0e10cSrcweir } // end of namespace drawinglayer 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 194*cdf0e10cSrcweir // eof 195