1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_drawinglayer.hxx" 26 27 #include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx> 28 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> 29 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> 30 #include <basegfx/polygon/b3dpolypolygontools.hxx> 31 #include <drawinglayer/attribute/sdrfillattribute.hxx> 32 #include <drawinglayer/attribute/sdrlineattribute.hxx> 33 #include <drawinglayer/attribute/sdrshadowattribute.hxx> 34 35 ////////////////////////////////////////////////////////////////////////////// 36 37 using namespace com::sun::star; 38 39 ////////////////////////////////////////////////////////////////////////////// 40 41 namespace drawinglayer 42 { 43 namespace primitive3d 44 { create3DDecomposition(const geometry::ViewInformation3D &) const45 Primitive3DSequence SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const 46 { 47 Primitive3DSequence aRetval; 48 49 if(getPolyPolygon3D().count()) 50 { 51 ::std::vector< basegfx::B3DPolyPolygon > aFill; 52 aFill.push_back(getPolyPolygon3D()); 53 54 // get full range 55 const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill)); 56 57 // #i98295# normal creation 58 if(!getSdrLFSAttribute().getFill().isDefault()) 59 { 60 if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) 61 { 62 applyNormalsKindSphereTo3DGeometry(aFill, aRange); 63 } 64 else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind()) 65 { 66 applyNormalsKindFlatTo3DGeometry(aFill); 67 } 68 69 if(getSdr3DObjectAttribute().getNormalsInvert()) 70 { 71 applyNormalsInvertTo3DGeometry(aFill); 72 } 73 } 74 75 // #i98314# texture coordinates 76 if(!getSdrLFSAttribute().getFill().isDefault()) 77 { 78 applyTextureTo3DGeometry( 79 getSdr3DObjectAttribute().getTextureProjectionX(), 80 getSdr3DObjectAttribute().getTextureProjectionY(), 81 aFill, 82 aRange, 83 getTextureSize()); 84 } 85 86 if(!getSdrLFSAttribute().getFill().isDefault()) 87 { 88 // add fill 89 aRetval = create3DPolyPolygonFillPrimitives( 90 aFill, 91 getTransform(), 92 getTextureSize(), 93 getSdr3DObjectAttribute(), 94 getSdrLFSAttribute().getFill(), 95 getSdrLFSAttribute().getFillFloatTransGradient()); 96 } 97 else 98 { 99 // create simplified 3d hit test geometry 100 aRetval = createHiddenGeometryPrimitives3D( 101 aFill, 102 getTransform(), 103 getTextureSize(), 104 getSdr3DObjectAttribute()); 105 } 106 107 // add line 108 if(!getSdrLFSAttribute().getLine().isDefault()) 109 { 110 basegfx::B3DPolyPolygon aLine(getPolyPolygon3D()); 111 aLine.clearNormals(); 112 aLine.clearTextureCoordinates(); 113 const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives( 114 aLine, getTransform(), getSdrLFSAttribute().getLine())); 115 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); 116 } 117 118 // add shadow 119 if(!getSdrLFSAttribute().getShadow().isDefault() 120 && aRetval.hasElements()) 121 { 122 const Primitive3DSequence aShadow(createShadowPrimitive3D( 123 aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); 124 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); 125 } 126 } 127 128 return aRetval; 129 } 130 SdrPolyPolygonPrimitive3D(const basegfx::B3DPolyPolygon & rPolyPolygon3D,const basegfx::B3DHomMatrix & rTransform,const basegfx::B2DVector & rTextureSize,const attribute::SdrLineFillShadowAttribute3D & rSdrLFSAttribute,const attribute::Sdr3DObjectAttribute & rSdr3DObjectAttribute)131 SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D( 132 const basegfx::B3DPolyPolygon& rPolyPolygon3D, 133 const basegfx::B3DHomMatrix& rTransform, 134 const basegfx::B2DVector& rTextureSize, 135 const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, 136 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) 137 : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), 138 maPolyPolygon3D(rPolyPolygon3D) 139 { 140 } 141 operator ==(const BasePrimitive3D & rPrimitive) const142 bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 143 { 144 if(SdrPrimitive3D::operator==(rPrimitive)) 145 { 146 const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive); 147 148 return (getPolyPolygon3D() == rCompare.getPolyPolygon3D()); 149 } 150 151 return false; 152 } 153 getB3DRange(const geometry::ViewInformation3D &) const154 basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const 155 { 156 // added this implementation to make sure that non-visible objects of this 157 // kind will deliver their expansion. If not implemented, it would never deliver 158 // the used space for non-visible objects since the decomposition for that 159 // case will be empty (what is correct). To support chart ATM which relies on 160 // non-visible objects occupying space in 3D, this method was added 161 basegfx::B3DRange aRetval; 162 163 if(getPolyPolygon3D().count()) 164 { 165 aRetval = basegfx::tools::getRange(getPolyPolygon3D()); 166 aRetval.transform(getTransform()); 167 168 if(!getSdrLFSAttribute().getLine().isDefault()) 169 { 170 const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine(); 171 172 if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth())) 173 { 174 // expand by half LineWidth as tube radius 175 aRetval.grow(rLine.getWidth() / 2.0); 176 } 177 } 178 } 179 180 return aRetval; 181 } 182 183 // provide unique ID 184 ImplPrimitrive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D) 185 186 } // end of namespace primitive3d 187 } // end of namespace drawinglayer 188 189 ////////////////////////////////////////////////////////////////////////////// 190 // eof 191