update dev300-m58
[ooovba.git] / drawinglayer / source / primitive3d / sdrpolypolygonprimitive3d.cxx
blob38d9ad54e15a7aec37e95f4f9cf5b9cea2d6fbb9
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: sdrpolypolygonprimitive3d.cxx,v $
7 * $Revision: 1.7 $
9 * last change: $Author: aw $ $Date: 2008-06-10 09:29:33 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx>
40 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx>
41 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
42 #include <basegfx/polygon/b3dpolypolygontools.hxx>
43 #include <drawinglayer/attribute/sdrattribute.hxx>
44 #include <drawinglayer/primitive3d/hittestprimitive3d.hxx>
46 //////////////////////////////////////////////////////////////////////////////
48 using namespace com::sun::star;
50 //////////////////////////////////////////////////////////////////////////////
52 namespace drawinglayer
54 namespace primitive3d
56 Primitive3DSequence SdrPolyPolygonPrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
58 Primitive3DSequence aRetval;
60 if(getPolyPolygon3D().count())
62 ::std::vector< basegfx::B3DPolyPolygon > aFill;
63 aFill.push_back(getPolyPolygon3D());
65 // get full range
66 const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
68 // #i98295# normal creation
69 if(getSdrLFSAttribute().getFill())
71 if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
73 applyNormalsKindSphereTo3DGeometry(aFill, aRange);
75 else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
77 applyNormalsKindFlatTo3DGeometry(aFill);
80 if(getSdr3DObjectAttribute().getNormalsInvert())
82 applyNormalsInvertTo3DGeometry(aFill);
86 // #i98314# texture coordinates
87 if(getSdrLFSAttribute().getFill())
89 applyTextureTo3DGeometry(
90 getSdr3DObjectAttribute().getTextureProjectionX(),
91 getSdr3DObjectAttribute().getTextureProjectionY(),
92 aFill,
93 aRange,
94 getTextureSize());
97 if(getSdrLFSAttribute().getFill())
99 // add fill
100 aRetval = create3DPolyPolygonFillPrimitives(
101 aFill,
102 getTransform(),
103 getTextureSize(),
104 getSdr3DObjectAttribute(),
105 *getSdrLFSAttribute().getFill(),
106 getSdrLFSAttribute().getFillFloatTransGradient());
108 else
110 // create simplified 3d hit test geometry
111 const attribute::SdrFillAttribute aSimplifiedFillAttribute(0.0, basegfx::BColor(), 0, 0, 0);
113 aRetval = create3DPolyPolygonFillPrimitives(
114 aFill,
115 getTransform(),
116 getTextureSize(),
117 getSdr3DObjectAttribute(),
118 aSimplifiedFillAttribute,
121 // encapsulate in HitTestPrimitive3D and add
122 const Primitive3DReference xRef(new HitTestPrimitive3D(aRetval));
123 aRetval = Primitive3DSequence(&xRef, 1L);
126 // add line
127 if(getSdrLFSAttribute().getLine())
129 basegfx::B3DPolyPolygon aLine(getPolyPolygon3D());
130 aLine.clearNormals();
131 aLine.clearTextureCoordinates();
132 const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(aLine, getTransform(), *getSdrLFSAttribute().getLine()));
133 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines);
136 // add shadow
137 if(getSdrLFSAttribute().getShadow() && aRetval.hasElements())
139 const Primitive3DSequence aShadow(createShadowPrimitive3D(aRetval, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()));
140 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow);
144 return aRetval;
147 SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(
148 const basegfx::B3DPolyPolygon& rPolyPolygon3D,
149 const basegfx::B3DHomMatrix& rTransform,
150 const basegfx::B2DVector& rTextureSize,
151 const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute,
152 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
153 : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute),
154 maPolyPolygon3D(rPolyPolygon3D)
158 bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
160 if(SdrPrimitive3D::operator==(rPrimitive))
162 const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive);
164 return (getPolyPolygon3D() == rCompare.getPolyPolygon3D());
167 return false;
170 basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
172 // added this implementation to make sure that non-visible objects of this
173 // kind will deliver their expansion. If not implemented, it would never deliver
174 // the used space for non-visible objects since the decomposition for that
175 // case will be empty (what is correct). To support chart ATM which relies on
176 // non-visible objects occupying space in 3D, this method was added
177 basegfx::B3DRange aRetval;
179 if(getPolyPolygon3D().count())
181 aRetval = basegfx::tools::getRange(getPolyPolygon3D());
182 aRetval.transform(getTransform());
184 if(getSdrLFSAttribute().getLine())
186 const attribute::SdrLineAttribute& rLine = *getSdrLFSAttribute().getLine();
188 if(rLine.isVisible() && !basegfx::fTools::equalZero(rLine.getWidth()))
190 // expand by half LineWidth as tube radius
191 aRetval.grow(rLine.getWidth() / 2.0);
196 return aRetval;
199 // provide unique ID
200 ImplPrimitrive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D)
202 } // end of namespace primitive3d
203 } // end of namespace drawinglayer
205 //////////////////////////////////////////////////////////////////////////////
206 // eof