1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx>
30 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx>
31 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
32 #include <basegfx/polygon/b3dpolypolygontools.hxx>
33 #include <drawinglayer/attribute/sdrfillattribute.hxx>
34 #include <drawinglayer/attribute/sdrlineattribute.hxx>
35 #include <drawinglayer/attribute/sdrshadowattribute.hxx>
37 //////////////////////////////////////////////////////////////////////////////
39 using namespace com::sun::star
;
41 //////////////////////////////////////////////////////////////////////////////
43 namespace drawinglayer
47 Primitive3DSequence
SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D
& /*rViewInformation*/) const
49 Primitive3DSequence aRetval
;
51 if(getPolyPolygon3D().count())
53 ::std::vector
< basegfx::B3DPolyPolygon
> aFill
;
54 aFill
.push_back(getPolyPolygon3D());
57 const basegfx::B3DRange
aRange(getRangeFrom3DGeometry(aFill
));
59 // #i98295# normal creation
60 if(!getSdrLFSAttribute().getFill().isDefault())
62 if(::com::sun::star::drawing::NormalsKind_SPHERE
== getSdr3DObjectAttribute().getNormalsKind())
64 applyNormalsKindSphereTo3DGeometry(aFill
, aRange
);
66 else if(::com::sun::star::drawing::NormalsKind_FLAT
== getSdr3DObjectAttribute().getNormalsKind())
68 applyNormalsKindFlatTo3DGeometry(aFill
);
71 if(getSdr3DObjectAttribute().getNormalsInvert())
73 applyNormalsInvertTo3DGeometry(aFill
);
77 // #i98314# texture coordinates
78 if(!getSdrLFSAttribute().getFill().isDefault())
80 applyTextureTo3DGeometry(
81 getSdr3DObjectAttribute().getTextureProjectionX(),
82 getSdr3DObjectAttribute().getTextureProjectionY(),
88 if(!getSdrLFSAttribute().getFill().isDefault())
91 aRetval
= create3DPolyPolygonFillPrimitives(
95 getSdr3DObjectAttribute(),
96 getSdrLFSAttribute().getFill(),
97 getSdrLFSAttribute().getFillFloatTransGradient());
101 // create simplified 3d hit test geometry
102 aRetval
= createHiddenGeometryPrimitives3D(
106 getSdr3DObjectAttribute());
110 if(!getSdrLFSAttribute().getLine().isDefault())
112 basegfx::B3DPolyPolygon
aLine(getPolyPolygon3D());
113 aLine
.clearNormals();
114 aLine
.clearTextureCoordinates();
115 const Primitive3DSequence
aLines(create3DPolyPolygonLinePrimitives(
116 aLine
, getTransform(), getSdrLFSAttribute().getLine()));
117 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval
, aLines
);
121 if(!getSdrLFSAttribute().getShadow().isDefault()
122 && aRetval
.hasElements())
124 const Primitive3DSequence
aShadow(createShadowPrimitive3D(
125 aRetval
, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()));
126 appendPrimitive3DSequenceToPrimitive3DSequence(aRetval
, aShadow
);
133 SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(
134 const basegfx::B3DPolyPolygon
& rPolyPolygon3D
,
135 const basegfx::B3DHomMatrix
& rTransform
,
136 const basegfx::B2DVector
& rTextureSize
,
137 const attribute::SdrLineFillShadowAttribute3D
& rSdrLFSAttribute
,
138 const attribute::Sdr3DObjectAttribute
& rSdr3DObjectAttribute
)
139 : SdrPrimitive3D(rTransform
, rTextureSize
, rSdrLFSAttribute
, rSdr3DObjectAttribute
),
140 maPolyPolygon3D(rPolyPolygon3D
)
144 bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
146 if(SdrPrimitive3D::operator==(rPrimitive
))
148 const SdrPolyPolygonPrimitive3D
& rCompare
= static_cast< const SdrPolyPolygonPrimitive3D
& >(rPrimitive
);
150 return (getPolyPolygon3D() == rCompare
.getPolyPolygon3D());
156 basegfx::B3DRange
SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D
& /*rViewInformation*/) const
158 // added this implementation to make sure that non-visible objects of this
159 // kind will deliver their expansion. If not implemented, it would never deliver
160 // the used space for non-visible objects since the decomposition for that
161 // case will be empty (what is correct). To support chart ATM which relies on
162 // non-visible objects occupying space in 3D, this method was added
163 basegfx::B3DRange aRetval
;
165 if(getPolyPolygon3D().count())
167 aRetval
= basegfx::tools::getRange(getPolyPolygon3D());
168 aRetval
.transform(getTransform());
170 if(!getSdrLFSAttribute().getLine().isDefault())
172 const attribute::SdrLineAttribute
& rLine
= getSdrLFSAttribute().getLine();
174 if(!rLine
.isDefault() && !basegfx::fTools::equalZero(rLine
.getWidth()))
176 // expand by half LineWidth as tube radius
177 aRetval
.grow(rLine
.getWidth() / 2.0);
186 ImplPrimitrive3DIDBlock(SdrPolyPolygonPrimitive3D
, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D
)
188 } // end of namespace primitive3d
189 } // end of namespace drawinglayer
191 //////////////////////////////////////////////////////////////////////////////
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */