xref: /AOO41X/main/drawinglayer/source/texture/texture3d.cxx (revision 99bf62e05fc497d5f39a25652dfb5152b08dd171)
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
10cdf0e10cSrcweir  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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/texture/texture3d.hxx>
28cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
29cdf0e10cSrcweir #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace drawinglayer
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 	namespace texture
36cdf0e10cSrcweir 	{
GeoTexSvxMono(const basegfx::BColor & rSingleColor,double fOpacity)37035a2f44SArmin Le Grand 		GeoTexSvxMono::GeoTexSvxMono(
38035a2f44SArmin Le Grand             const basegfx::BColor& rSingleColor,
39035a2f44SArmin Le Grand             double fOpacity)
40cdf0e10cSrcweir 		:	maSingleColor(rSingleColor),
41cdf0e10cSrcweir 			mfOpacity(fOpacity)
42cdf0e10cSrcweir 		{
43cdf0e10cSrcweir 		}
44cdf0e10cSrcweir 
operator ==(const GeoTexSvx & rGeoTexSvx) const45cdf0e10cSrcweir 		bool GeoTexSvxMono::operator==(const GeoTexSvx& rGeoTexSvx) const
46cdf0e10cSrcweir 		{
47cdf0e10cSrcweir 			const GeoTexSvxMono* pCompare = dynamic_cast< const GeoTexSvxMono* >(&rGeoTexSvx);
48035a2f44SArmin Le Grand 
49cdf0e10cSrcweir             return (pCompare
50cdf0e10cSrcweir 				&& maSingleColor == pCompare->maSingleColor
51cdf0e10cSrcweir 				&& mfOpacity == pCompare->mfOpacity);
52cdf0e10cSrcweir 		}
53cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint &,basegfx::BColor & rBColor,double &) const54cdf0e10cSrcweir 		void GeoTexSvxMono::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
55cdf0e10cSrcweir 		{
56cdf0e10cSrcweir 			rBColor = maSingleColor;
57cdf0e10cSrcweir 		}
58cdf0e10cSrcweir 
modifyOpacity(const basegfx::B2DPoint &,double & rfOpacity) const59cdf0e10cSrcweir 		void GeoTexSvxMono::modifyOpacity(const basegfx::B2DPoint& /*rUV*/, double& rfOpacity) const
60cdf0e10cSrcweir 		{
61cdf0e10cSrcweir 			rfOpacity = mfOpacity;
62cdf0e10cSrcweir 		}
63cdf0e10cSrcweir 	} // end of namespace texture
64cdf0e10cSrcweir } // end of namespace drawinglayer
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
67cdf0e10cSrcweir 
68cdf0e10cSrcweir namespace drawinglayer
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	namespace texture
71cdf0e10cSrcweir 	{
GeoTexSvxBitmapEx(const BitmapEx & rBitmapEx,const basegfx::B2DRange & rRange)72035a2f44SArmin Le Grand 		GeoTexSvxBitmapEx::GeoTexSvxBitmapEx(
73035a2f44SArmin Le Grand             const BitmapEx& rBitmapEx,
74035a2f44SArmin Le Grand             const basegfx::B2DRange& rRange)
75035a2f44SArmin Le Grand 		:	maBitmapEx(rBitmapEx),
76035a2f44SArmin Le Grand 			mpReadBitmap(0),
77035a2f44SArmin Le Grand             maTransparence(),
78035a2f44SArmin Le Grand             mpReadTransparence(0),
79035a2f44SArmin Le Grand 			maTopLeft(rRange.getMinimum()),
80035a2f44SArmin Le Grand 			maSize(rRange.getRange()),
81cdf0e10cSrcweir 			mfMulX(0.0),
82035a2f44SArmin Le Grand 			mfMulY(0.0),
83035a2f44SArmin Le Grand             mbIsAlpha(false),
84035a2f44SArmin Le Grand             mbIsTransparent(maBitmapEx.IsTransparent())
85cdf0e10cSrcweir 		{
86035a2f44SArmin Le Grand             // #121194# Todo: use alpha channel, too (for 3d)
87035a2f44SArmin Le Grand 			mpReadBitmap = maBitmapEx.GetBitmap().AcquireReadAccess();
88035a2f44SArmin Le Grand 			OSL_ENSURE(mpReadBitmap, "GeoTexSvxBitmapEx: Got no read access to Bitmap (!)");
89035a2f44SArmin Le Grand 
90035a2f44SArmin Le Grand             if(mbIsTransparent)
91035a2f44SArmin Le Grand             {
92035a2f44SArmin Le Grand                 if(maBitmapEx.IsAlpha())
93035a2f44SArmin Le Grand                 {
94035a2f44SArmin Le Grand                     mbIsAlpha = true;
95035a2f44SArmin Le Grand                     maTransparence = rBitmapEx.GetAlpha().GetBitmap();
96035a2f44SArmin Le Grand                 }
97035a2f44SArmin Le Grand                 else
98035a2f44SArmin Le Grand                 {
99035a2f44SArmin Le Grand                     maTransparence = rBitmapEx.GetMask();
100cdf0e10cSrcweir                 }
101cdf0e10cSrcweir 
102035a2f44SArmin Le Grand                 mpReadTransparence = maTransparence.AcquireReadAccess();
103cdf0e10cSrcweir             }
104cdf0e10cSrcweir 
105035a2f44SArmin Le Grand             mfMulX = (double)mpReadBitmap->Width() / maSize.getX();
106035a2f44SArmin Le Grand 			mfMulY = (double)mpReadBitmap->Height() / maSize.getY();
107035a2f44SArmin Le Grand 
108035a2f44SArmin Le Grand             if(maSize.getX() <= 1.0)
109cdf0e10cSrcweir             {
110035a2f44SArmin Le Grand                 maSize.setX(1.0);
111035a2f44SArmin Le Grand             }
112035a2f44SArmin Le Grand 
113035a2f44SArmin Le Grand             if(maSize.getY() <= 1.0)
114035a2f44SArmin Le Grand             {
115035a2f44SArmin Le Grand                 maSize.setY(1.0);
116035a2f44SArmin Le Grand             }
117035a2f44SArmin Le Grand 		}
118035a2f44SArmin Le Grand 
~GeoTexSvxBitmapEx()119035a2f44SArmin Le Grand 		GeoTexSvxBitmapEx::~GeoTexSvxBitmapEx()
120035a2f44SArmin Le Grand 		{
121035a2f44SArmin Le Grand             delete mpReadTransparence;
122035a2f44SArmin Le Grand 			delete mpReadBitmap;
123035a2f44SArmin Le Grand 		}
124035a2f44SArmin Le Grand 
impGetTransparence(sal_Int32 & rX,sal_Int32 & rY) const125035a2f44SArmin Le Grand         sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32& rX, sal_Int32& rY) const
126035a2f44SArmin Le Grand         {
127035a2f44SArmin Le Grand             switch(maBitmapEx.GetTransparentType())
128035a2f44SArmin Le Grand             {
129035a2f44SArmin Le Grand                 case TRANSPARENT_NONE:
130035a2f44SArmin Le Grand                 {
131035a2f44SArmin Le Grand                     break;
132035a2f44SArmin Le Grand                 }
133035a2f44SArmin Le Grand                 case TRANSPARENT_COLOR:
134035a2f44SArmin Le Grand                 {
1357522ffbeSArmin Le Grand                     const BitmapColor aBitmapColor(mpReadBitmap->GetColor(rY, rX));
136035a2f44SArmin Le Grand 
137*99bf62e0SArmin Le Grand                     if(maBitmapEx.GetTransparentColor() == aBitmapColor.operator Color())
138035a2f44SArmin Le Grand                     {
139035a2f44SArmin Le Grand                         return 255;
140035a2f44SArmin Le Grand                     }
141035a2f44SArmin Le Grand 
142035a2f44SArmin Le Grand                     break;
143035a2f44SArmin Le Grand                 }
144035a2f44SArmin Le Grand                 case TRANSPARENT_BITMAP:
145035a2f44SArmin Le Grand                 {
146035a2f44SArmin Le Grand                     OSL_ENSURE(mpReadTransparence, "OOps, transparence type Bitmap, but no read access created in the constructor (?)");
147035a2f44SArmin Le Grand                     const BitmapColor aBitmapColor(mpReadTransparence->GetPixel(rY, rX));
148035a2f44SArmin Le Grand 
149035a2f44SArmin Le Grand                     if(mbIsAlpha)
150035a2f44SArmin Le Grand                     {
151035a2f44SArmin Le Grand                         return aBitmapColor.GetIndex();
152035a2f44SArmin Le Grand                     }
153035a2f44SArmin Le Grand                     else
154035a2f44SArmin Le Grand                     {
155035a2f44SArmin Le Grand                         if(0x00 != aBitmapColor.GetIndex())
156035a2f44SArmin Le Grand                         {
157035a2f44SArmin Le Grand                             return 255;
158035a2f44SArmin Le Grand                         }
159035a2f44SArmin Le Grand                     }
160035a2f44SArmin Le Grand                     break;
161035a2f44SArmin Le Grand                 }
162035a2f44SArmin Le Grand             }
163035a2f44SArmin Le Grand 
164035a2f44SArmin Le Grand             return 0;
165035a2f44SArmin Le Grand         }
166035a2f44SArmin Le Grand 
impIsValid(const basegfx::B2DPoint & rUV,sal_Int32 & rX,sal_Int32 & rY) const167035a2f44SArmin Le Grand 		bool GeoTexSvxBitmapEx::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const
168035a2f44SArmin Le Grand 		{
169035a2f44SArmin Le Grand 			if(mpReadBitmap)
170cdf0e10cSrcweir 			{
171cdf0e10cSrcweir 				rX = (sal_Int32)((rUV.getX() - maTopLeft.getX()) * mfMulX);
172cdf0e10cSrcweir 
173035a2f44SArmin Le Grand 				if(rX >= 0L && rX < mpReadBitmap->Width())
174cdf0e10cSrcweir 				{
175cdf0e10cSrcweir 					rY = (sal_Int32)((rUV.getY() - maTopLeft.getY()) * mfMulY);
176cdf0e10cSrcweir 
177035a2f44SArmin Le Grand 					return (rY >= 0L && rY < mpReadBitmap->Height());
178cdf0e10cSrcweir 				}
179cdf0e10cSrcweir 			}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 			return false;
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double & rfOpacity) const184035a2f44SArmin Le Grand 		void GeoTexSvxBitmapEx::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
185cdf0e10cSrcweir 		{
186cdf0e10cSrcweir 			sal_Int32 nX, nY;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 			if(impIsValid(rUV, nX, nY))
189cdf0e10cSrcweir 			{
190cdf0e10cSrcweir 				const double fConvertColor(1.0 / 255.0);
191035a2f44SArmin Le Grand 				const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
192cdf0e10cSrcweir 				const basegfx::BColor aBSource(
193cdf0e10cSrcweir 					(double)aBMCol.GetRed() * fConvertColor,
194cdf0e10cSrcweir 					(double)aBMCol.GetGreen() * fConvertColor,
195cdf0e10cSrcweir 					(double)aBMCol.GetBlue() * fConvertColor);
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 				rBColor = aBSource;
198035a2f44SArmin Le Grand 
199035a2f44SArmin Le Grand                 if(mbIsTransparent)
200035a2f44SArmin Le Grand                 {
201035a2f44SArmin Le Grand                     // when we have a transparence, make use of it
202035a2f44SArmin Le Grand                     const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
203035a2f44SArmin Le Grand 
204035a2f44SArmin Le Grand                     rfOpacity = ((double)(0xff - aLuminance) * (1.0 / 255.0));
205035a2f44SArmin Le Grand                 }
206035a2f44SArmin Le Grand                 else
207035a2f44SArmin Le Grand                 {
208035a2f44SArmin Le Grand                     rfOpacity = 1.0;
209035a2f44SArmin Le Grand                 }
210cdf0e10cSrcweir 			}
211cdf0e10cSrcweir 			else
212cdf0e10cSrcweir 			{
213cdf0e10cSrcweir 				rfOpacity = 0.0;
214cdf0e10cSrcweir 			}
215cdf0e10cSrcweir 		}
216cdf0e10cSrcweir 
modifyOpacity(const basegfx::B2DPoint & rUV,double & rfOpacity) const217035a2f44SArmin Le Grand 		void GeoTexSvxBitmapEx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
218cdf0e10cSrcweir 		{
219cdf0e10cSrcweir 			sal_Int32 nX, nY;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 			if(impIsValid(rUV, nX, nY))
222cdf0e10cSrcweir 			{
223035a2f44SArmin Le Grand                 if(mbIsTransparent)
224035a2f44SArmin Le Grand                 {
225035a2f44SArmin Le Grand                     // this texture has an alpha part, use it
226035a2f44SArmin Le Grand                     const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
227035a2f44SArmin Le Grand                     const double fNewOpacity((double)(0xff - aLuminance) * (1.0 / 255.0));
228035a2f44SArmin Le Grand 
229035a2f44SArmin Le Grand                     rfOpacity = 1.0 - ((1.0 - fNewOpacity) * (1.0 - rfOpacity));
230035a2f44SArmin Le Grand                 }
231035a2f44SArmin Le Grand                 else
232035a2f44SArmin Le Grand                 {
233035a2f44SArmin Le Grand                     // this texture is a color bitmap used as transparence map
234035a2f44SArmin Le Grand 				    const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
235cdf0e10cSrcweir 				    const Color aColor(aBMCol.GetRed(), aBMCol.GetGreen(), aBMCol.GetBlue());
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 				    rfOpacity = ((double)(0xff - aColor.GetLuminance()) * (1.0 / 255.0));
238cdf0e10cSrcweir                 }
239035a2f44SArmin Le Grand 			}
240cdf0e10cSrcweir 			else
241cdf0e10cSrcweir 			{
242cdf0e10cSrcweir 				rfOpacity = 0.0;
243cdf0e10cSrcweir 			}
244cdf0e10cSrcweir 		}
245cdf0e10cSrcweir 	} // end of namespace texture
246cdf0e10cSrcweir } // end of namespace drawinglayer
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
249cdf0e10cSrcweir 
250cdf0e10cSrcweir namespace drawinglayer
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	namespace texture
253cdf0e10cSrcweir 	{
impGetCorrected(const basegfx::B2DPoint & rUV) const254035a2f44SArmin Le Grand 		basegfx::B2DPoint GeoTexSvxBitmapExTiled::impGetCorrected(const basegfx::B2DPoint& rUV) const
255cdf0e10cSrcweir 		{
256035a2f44SArmin Le Grand             double fX(rUV.getX() - maTopLeft.getX());
257035a2f44SArmin Le Grand             double fY(rUV.getY() - maTopLeft.getY());
258cdf0e10cSrcweir 
259035a2f44SArmin Le Grand             if(mbUseOffsetX)
260cdf0e10cSrcweir             {
261035a2f44SArmin Le Grand                 const sal_Int32 nCol(static_cast< sal_Int32 >((fY < 0.0 ? maSize.getY() -fY : fY) / maSize.getY()));
262035a2f44SArmin Le Grand 
263035a2f44SArmin Le Grand                 if(nCol % 2)
264cdf0e10cSrcweir                 {
265035a2f44SArmin Le Grand                     fX += mfOffsetX * maSize.getX();
266035a2f44SArmin Le Grand                 }
267035a2f44SArmin Le Grand             }
268035a2f44SArmin Le Grand             else if(mbUseOffsetY)
269035a2f44SArmin Le Grand             {
270035a2f44SArmin Le Grand                 const sal_Int32 nRow(static_cast< sal_Int32 >((fX < 0.0 ? maSize.getX() -fX : fX) / maSize.getX()));
271035a2f44SArmin Le Grand 
272035a2f44SArmin Le Grand                 if(nRow % 2)
273035a2f44SArmin Le Grand                 {
274035a2f44SArmin Le Grand                     fY += mfOffsetY * maSize.getY();
275cdf0e10cSrcweir                 }
276cdf0e10cSrcweir             }
277cdf0e10cSrcweir 
278035a2f44SArmin Le Grand             fX = fmod(fX, maSize.getX());
279035a2f44SArmin Le Grand             fY = fmod(fY, maSize.getY());
280035a2f44SArmin Le Grand 
281035a2f44SArmin Le Grand             if(fX < 0.0)
282cdf0e10cSrcweir             {
283035a2f44SArmin Le Grand                 fX += maSize.getX();
284035a2f44SArmin Le Grand             }
285035a2f44SArmin Le Grand 
286035a2f44SArmin Le Grand             if(fY < 0.0)
287cdf0e10cSrcweir             {
288035a2f44SArmin Le Grand                 fY += maSize.getY();
289035a2f44SArmin Le Grand             }
290035a2f44SArmin Le Grand 
291035a2f44SArmin Le Grand             return basegfx::B2DPoint(fX + maTopLeft.getX(), fY + maTopLeft.getY());
292035a2f44SArmin Le Grand 		}
293035a2f44SArmin Le Grand 
GeoTexSvxBitmapExTiled(const BitmapEx & rBitmapEx,const basegfx::B2DRange & rRange,double fOffsetX,double fOffsetY)294035a2f44SArmin Le Grand         GeoTexSvxBitmapExTiled::GeoTexSvxBitmapExTiled(
295035a2f44SArmin Le Grand             const BitmapEx& rBitmapEx,
296035a2f44SArmin Le Grand             const basegfx::B2DRange& rRange,
297035a2f44SArmin Le Grand             double fOffsetX,
298035a2f44SArmin Le Grand             double fOffsetY)
299035a2f44SArmin Le Grand 		:	GeoTexSvxBitmapEx(rBitmapEx, rRange),
300035a2f44SArmin Le Grand             mfOffsetX(basegfx::clamp(fOffsetX, 0.0, 1.0)),
301035a2f44SArmin Le Grand             mfOffsetY(basegfx::clamp(fOffsetY, 0.0, 1.0)),
302035a2f44SArmin Le Grand             mbUseOffsetX(!basegfx::fTools::equalZero(mfOffsetX)),
303035a2f44SArmin Le Grand             mbUseOffsetY(!mbUseOffsetX && !basegfx::fTools::equalZero(mfOffsetY))
304035a2f44SArmin Le Grand 		{
305035a2f44SArmin Le Grand 		}
306035a2f44SArmin Le Grand 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double & rfOpacity) const307035a2f44SArmin Le Grand 		void GeoTexSvxBitmapExTiled::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
308035a2f44SArmin Le Grand 		{
309035a2f44SArmin Le Grand 			if(mpReadBitmap)
310035a2f44SArmin Le Grand 			{
311035a2f44SArmin Le Grand 				GeoTexSvxBitmapEx::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity);
312035a2f44SArmin Le Grand 			}
313035a2f44SArmin Le Grand 		}
314035a2f44SArmin Le Grand 
modifyOpacity(const basegfx::B2DPoint & rUV,double & rfOpacity) const315035a2f44SArmin Le Grand 		void GeoTexSvxBitmapExTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
316035a2f44SArmin Le Grand 		{
317035a2f44SArmin Le Grand 			if(mpReadBitmap)
318035a2f44SArmin Le Grand 			{
319035a2f44SArmin Le Grand 				GeoTexSvxBitmapEx::modifyOpacity(impGetCorrected(rUV), rfOpacity);
320cdf0e10cSrcweir 			}
321cdf0e10cSrcweir 		}
322cdf0e10cSrcweir 	} // end of namespace texture
323cdf0e10cSrcweir } // end of namespace drawinglayer
324cdf0e10cSrcweir 
325cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
326cdf0e10cSrcweir 
327cdf0e10cSrcweir namespace drawinglayer
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	namespace texture
330cdf0e10cSrcweir 	{
GeoTexSvxMultiHatch(const primitive3d::HatchTexturePrimitive3D & rPrimitive,double fLogicPixelSize)331035a2f44SArmin Le Grand 		GeoTexSvxMultiHatch::GeoTexSvxMultiHatch(
332035a2f44SArmin Le Grand             const primitive3d::HatchTexturePrimitive3D& rPrimitive,
333035a2f44SArmin Le Grand             double fLogicPixelSize)
334cdf0e10cSrcweir 		:	mfLogicPixelSize(fLogicPixelSize),
335cdf0e10cSrcweir 			mp0(0L),
336cdf0e10cSrcweir 			mp1(0L),
337cdf0e10cSrcweir 			mp2(0L)
338cdf0e10cSrcweir 		{
339cdf0e10cSrcweir 			const attribute::FillHatchAttribute& rHatch(rPrimitive.getHatch());
340cdf0e10cSrcweir 			const basegfx::B2DRange aOutlineRange(0.0, 0.0, rPrimitive.getTextureSize().getX(), rPrimitive.getTextureSize().getY());
341cdf0e10cSrcweir 			const double fAngleA(rHatch.getAngle());
342cdf0e10cSrcweir 			maColor = rHatch.getColor();
343cdf0e10cSrcweir 			mbFillBackground = rHatch.isFillBackground();
344cdf0e10cSrcweir 			mp0 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA);
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 			if(attribute::HATCHSTYLE_DOUBLE == rHatch.getStyle() || attribute::HATCHSTYLE_TRIPLE == rHatch.getStyle())
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir 				mp1 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA + F_PI2);
349cdf0e10cSrcweir 			}
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 			if(attribute::HATCHSTYLE_TRIPLE == rHatch.getStyle())
352cdf0e10cSrcweir 			{
353cdf0e10cSrcweir 				mp2 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA + F_PI4);
354cdf0e10cSrcweir 			}
355cdf0e10cSrcweir 		}
356cdf0e10cSrcweir 
~GeoTexSvxMultiHatch()357cdf0e10cSrcweir 		GeoTexSvxMultiHatch::~GeoTexSvxMultiHatch()
358cdf0e10cSrcweir 		{
359cdf0e10cSrcweir 			delete mp0;
360cdf0e10cSrcweir 			delete mp1;
361cdf0e10cSrcweir 			delete mp2;
362cdf0e10cSrcweir 		}
363cdf0e10cSrcweir 
impIsOnHatch(const basegfx::B2DPoint & rUV) const364cdf0e10cSrcweir 		bool GeoTexSvxMultiHatch::impIsOnHatch(const basegfx::B2DPoint& rUV) const
365cdf0e10cSrcweir 		{
366cdf0e10cSrcweir 			if(mp0->getDistanceToHatch(rUV) < mfLogicPixelSize)
367cdf0e10cSrcweir 			{
368cdf0e10cSrcweir 				return true;
369cdf0e10cSrcweir 			}
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 			if(mp1 && mp1->getDistanceToHatch(rUV) < mfLogicPixelSize)
372cdf0e10cSrcweir 			{
373cdf0e10cSrcweir 				return true;
374cdf0e10cSrcweir 			}
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 			if(mp2 && mp2->getDistanceToHatch(rUV) < mfLogicPixelSize)
377cdf0e10cSrcweir 			{
378cdf0e10cSrcweir 				return true;
379cdf0e10cSrcweir 			}
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 			return false;
382cdf0e10cSrcweir 		}
383cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double & rfOpacity) const384cdf0e10cSrcweir 		void GeoTexSvxMultiHatch::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
385cdf0e10cSrcweir 		{
386cdf0e10cSrcweir 			if(impIsOnHatch(rUV))
387cdf0e10cSrcweir 			{
388cdf0e10cSrcweir 				rBColor = maColor;
389cdf0e10cSrcweir 			}
390cdf0e10cSrcweir 			else if(!mbFillBackground)
391cdf0e10cSrcweir 			{
392cdf0e10cSrcweir 				rfOpacity = 0.0;
393cdf0e10cSrcweir 			}
394cdf0e10cSrcweir 		}
395cdf0e10cSrcweir 
modifyOpacity(const basegfx::B2DPoint & rUV,double & rfOpacity) const396cdf0e10cSrcweir 		void GeoTexSvxMultiHatch::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
397cdf0e10cSrcweir 		{
398cdf0e10cSrcweir 			if(mbFillBackground || impIsOnHatch(rUV))
399cdf0e10cSrcweir 			{
400cdf0e10cSrcweir 				rfOpacity = 1.0;
401cdf0e10cSrcweir 			}
402cdf0e10cSrcweir 			else
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				rfOpacity = 0.0;
405cdf0e10cSrcweir 			}
406cdf0e10cSrcweir 		}
407cdf0e10cSrcweir 	} // end of namespace texture
408cdf0e10cSrcweir } // end of namespace drawinglayer
409cdf0e10cSrcweir 
410cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
411cdf0e10cSrcweir // eof
412