1464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5464702f4SAndrew Rist  * distributed with this work for additional information
6464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10464702f4SAndrew Rist  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12464702f4SAndrew Rist  *
13464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14464702f4SAndrew Rist  * software distributed under the License is distributed on an
15464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17464702f4SAndrew Rist  * specific language governing permissions and limitations
18464702f4SAndrew Rist  * under the License.
19464702f4SAndrew Rist  *
20464702f4SAndrew Rist  *************************************************************/
21464702f4SAndrew Rist 
22464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
28cdf0e10cSrcweir #include <basegfx/polygon/b3dpolygontools.hxx>
29cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
30cdf0e10cSrcweir #include <basegfx/polygon/b3dpolypolygontools.hxx>
31cdf0e10cSrcweir #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
32cdf0e10cSrcweir #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace com::sun::star;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace drawinglayer
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	namespace primitive3d
43cdf0e10cSrcweir 	{
PolygonHairlinePrimitive3D(const basegfx::B3DPolygon & rPolygon,const basegfx::BColor & rBColor)44cdf0e10cSrcweir 		PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
45cdf0e10cSrcweir 			const basegfx::B3DPolygon& rPolygon,
46cdf0e10cSrcweir 			const basegfx::BColor& rBColor)
47cdf0e10cSrcweir 		:	BasePrimitive3D(),
48cdf0e10cSrcweir 			maPolygon(rPolygon),
49cdf0e10cSrcweir 			maBColor(rBColor)
50cdf0e10cSrcweir 		{
51cdf0e10cSrcweir 		}
52cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const53cdf0e10cSrcweir 		bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
54cdf0e10cSrcweir 		{
55cdf0e10cSrcweir 			if(BasePrimitive3D::operator==(rPrimitive))
56cdf0e10cSrcweir 			{
57cdf0e10cSrcweir 				const PolygonHairlinePrimitive3D& rCompare = (PolygonHairlinePrimitive3D&)rPrimitive;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 				return (getB3DPolygon() == rCompare.getB3DPolygon()
60cdf0e10cSrcweir 					&& getBColor() == rCompare.getBColor());
61cdf0e10cSrcweir 			}
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 			return false;
64cdf0e10cSrcweir 		}
65cdf0e10cSrcweir 
getB3DRange(const geometry::ViewInformation3D &) const66cdf0e10cSrcweir 		basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
67cdf0e10cSrcweir 		{
68cdf0e10cSrcweir 			return basegfx::tools::getRange(getB3DPolygon());
69cdf0e10cSrcweir 		}
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 		// provide unique ID
72cdf0e10cSrcweir 		ImplPrimitrive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D)
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	} // end of namespace primitive3d
75cdf0e10cSrcweir } // end of namespace drawinglayer
76cdf0e10cSrcweir 
77cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
78cdf0e10cSrcweir 
79cdf0e10cSrcweir namespace drawinglayer
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	namespace primitive3d
82cdf0e10cSrcweir 	{
create3DDecomposition(const geometry::ViewInformation3D &) const83cdf0e10cSrcweir 		Primitive3DSequence PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
84cdf0e10cSrcweir 		{
85cdf0e10cSrcweir 			Primitive3DSequence aRetval;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 			if(getB3DPolygon().count())
88cdf0e10cSrcweir 			{
89cdf0e10cSrcweir 				basegfx::B3DPolyPolygon aHairLinePolyPolygon;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 				if(0.0 == getStrokeAttribute().getFullDotDashLen())
92cdf0e10cSrcweir 				{
93cdf0e10cSrcweir 					aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
94cdf0e10cSrcweir 				}
95cdf0e10cSrcweir 				else
96cdf0e10cSrcweir 				{
97cdf0e10cSrcweir 					// apply LineStyle
98cdf0e10cSrcweir 					basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, 0, getStrokeAttribute().getFullDotDashLen());
99cdf0e10cSrcweir 				}
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 				// prepare result
102cdf0e10cSrcweir 				aRetval.realloc(aHairLinePolyPolygon.count());
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 				if(getLineAttribute().getWidth())
105cdf0e10cSrcweir 				{
106cdf0e10cSrcweir 					// create fat line data
107cdf0e10cSrcweir 					const double fRadius(getLineAttribute().getWidth() / 2.0);
108cdf0e10cSrcweir 					const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin());
109*5aaf853bSArmin Le Grand                     const com::sun::star::drawing::LineCap aLineCap(getLineAttribute().getLineCap());
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 					for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
112cdf0e10cSrcweir 					{
113cdf0e10cSrcweir 						// create tube primitives
114*5aaf853bSArmin Le Grand 						const Primitive3DReference xRef(
115*5aaf853bSArmin Le Grand                             new PolygonTubePrimitive3D(
116*5aaf853bSArmin Le Grand                                 aHairLinePolyPolygon.getB3DPolygon(a),
117*5aaf853bSArmin Le Grand                                 getLineAttribute().getColor(),
118*5aaf853bSArmin Le Grand                                 fRadius,
119*5aaf853bSArmin Le Grand                                 aLineJoin,
120*5aaf853bSArmin Le Grand                                 aLineCap));
121cdf0e10cSrcweir 						aRetval[a] = xRef;
122cdf0e10cSrcweir 					}
123cdf0e10cSrcweir 				}
124cdf0e10cSrcweir 				else
125cdf0e10cSrcweir 				{
126cdf0e10cSrcweir 					// create hair line data for all sub polygons
127cdf0e10cSrcweir 					for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
128cdf0e10cSrcweir 					{
129cdf0e10cSrcweir 						const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
130cdf0e10cSrcweir 						const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
131cdf0e10cSrcweir 						aRetval[a] = xRef;
132cdf0e10cSrcweir 					}
133cdf0e10cSrcweir 				}
134cdf0e10cSrcweir 			}
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 			return aRetval;
137cdf0e10cSrcweir 		}
138cdf0e10cSrcweir 
PolygonStrokePrimitive3D(const basegfx::B3DPolygon & rPolygon,const attribute::LineAttribute & rLineAttribute,const attribute::StrokeAttribute & rStrokeAttribute)139cdf0e10cSrcweir 		PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
140cdf0e10cSrcweir 			const basegfx::B3DPolygon& rPolygon,
141cdf0e10cSrcweir             const attribute::LineAttribute& rLineAttribute,
142cdf0e10cSrcweir 			const attribute::StrokeAttribute& rStrokeAttribute)
143cdf0e10cSrcweir 		:	BufferedDecompositionPrimitive3D(),
144cdf0e10cSrcweir 			maPolygon(rPolygon),
145cdf0e10cSrcweir             maLineAttribute(rLineAttribute),
146cdf0e10cSrcweir 			maStrokeAttribute(rStrokeAttribute)
147cdf0e10cSrcweir 		{
148cdf0e10cSrcweir 		}
149cdf0e10cSrcweir 
PolygonStrokePrimitive3D(const basegfx::B3DPolygon & rPolygon,const attribute::LineAttribute & rLineAttribute)150cdf0e10cSrcweir 		PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
151cdf0e10cSrcweir 			const basegfx::B3DPolygon& rPolygon,
152cdf0e10cSrcweir             const attribute::LineAttribute& rLineAttribute)
153cdf0e10cSrcweir 		:	BufferedDecompositionPrimitive3D(),
154cdf0e10cSrcweir 			maPolygon(rPolygon),
155cdf0e10cSrcweir             maLineAttribute(rLineAttribute),
156cdf0e10cSrcweir 			maStrokeAttribute()
157cdf0e10cSrcweir 		{
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const160cdf0e10cSrcweir 		bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
161cdf0e10cSrcweir 		{
162cdf0e10cSrcweir 			if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
163cdf0e10cSrcweir 			{
164cdf0e10cSrcweir 				const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 				return (getB3DPolygon() == rCompare.getB3DPolygon()
167cdf0e10cSrcweir 					&& getLineAttribute() == rCompare.getLineAttribute()
168cdf0e10cSrcweir 					&& getStrokeAttribute() == rCompare.getStrokeAttribute());
169cdf0e10cSrcweir 			}
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 			return false;
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		// provide unique ID
175cdf0e10cSrcweir 		ImplPrimitrive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D)
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	} // end of namespace primitive3d
178cdf0e10cSrcweir } // end of namespace drawinglayer
179cdf0e10cSrcweir 
180cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
181cdf0e10cSrcweir // eof
182