1*4f506f19SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*4f506f19SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*4f506f19SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*4f506f19SAndrew Rist  * distributed with this work for additional information
6*4f506f19SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*4f506f19SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*4f506f19SAndrew Rist  * "License"); you may not use this file except in compliance
9*4f506f19SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*4f506f19SAndrew Rist  *
11*4f506f19SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*4f506f19SAndrew Rist  *
13*4f506f19SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*4f506f19SAndrew Rist  * software distributed under the License is distributed on an
15*4f506f19SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*4f506f19SAndrew Rist  * KIND, either express or implied.  See the License for the
17*4f506f19SAndrew Rist  * specific language governing permissions and limitations
18*4f506f19SAndrew Rist  * under the License.
19*4f506f19SAndrew Rist  *
20*4f506f19SAndrew Rist  *************************************************************/
21*4f506f19SAndrew Rist 
22*4f506f19SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
25cdf0e10cSrcweir #define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
26cdf0e10cSrcweir 
27090f0eb8SEike Rathke #include <drawinglayer/drawinglayerdllapi.h>
28cdf0e10cSrcweir #include <drawinglayer/processor2d/baseprocessor2d.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
31cdf0e10cSrcweir // predeclarations
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace basegfx { class B2DPolygon; }
34cdf0e10cSrcweir namespace basegfx { class B2DPolyPolygon; }
35cdf0e10cSrcweir namespace drawinglayer { namespace primitive2d { class ScenePrimitive2D; }}
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace drawinglayer
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	namespace processor2d
42cdf0e10cSrcweir 	{
43cdf0e10cSrcweir         /** HitTestProcessor2D class
44cdf0e10cSrcweir 
45cdf0e10cSrcweir             This processor implements a HitTest with the feeded primitives,
46cdf0e10cSrcweir             given tolerance and extras
47cdf0e10cSrcweir          */
48090f0eb8SEike Rathke 		class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D : public BaseProcessor2D
49cdf0e10cSrcweir 		{
50cdf0e10cSrcweir 		private:
51cdf0e10cSrcweir 			/// discrete HitTest position
52cdf0e10cSrcweir 			basegfx::B2DPoint			maDiscreteHitPosition;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 			/// discrete HitTolerance
55cdf0e10cSrcweir 			double						mfDiscreteHitTolerance;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 			/// bitfield
58cdf0e10cSrcweir 			unsigned					mbHit : 1;
59cdf0e10cSrcweir 			unsigned					mbHitToleranceUsed : 1;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 			/*  this flag decides if primitives which are embedded to an
62cdf0e10cSrcweir                 UnifiedTransparencePrimitive2D and are invisible will be taken into account for
63cdf0e10cSrcweir                 HitTesting or not. Those primitives are created for objects which are else
64cdf0e10cSrcweir                 completely invisible and normally their content exists of hairline
65cdf0e10cSrcweir                 primitives describing the object's contour
66cdf0e10cSrcweir              */
67cdf0e10cSrcweir 			unsigned					mbUseInvisiblePrimitiveContent : 1;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir             /// flag to concentraze on text hits only
70cdf0e10cSrcweir             unsigned                    mbHitTextOnly : 1;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 			/// tooling methods
73cdf0e10cSrcweir 			void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
74cdf0e10cSrcweir 			bool checkHairlineHitWithTolerance(
75cdf0e10cSrcweir 				const basegfx::B2DPolygon& rPolygon,
76cdf0e10cSrcweir 				double fDiscreteHitTolerance);
77cdf0e10cSrcweir 			bool checkFillHitWithTolerance(
78cdf0e10cSrcweir 				const basegfx::B2DPolyPolygon& rPolyPolygon,
79cdf0e10cSrcweir 				double fDiscreteHitTolerance);
80cdf0e10cSrcweir 			void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 		public:
83cdf0e10cSrcweir 			HitTestProcessor2D(
84cdf0e10cSrcweir 				const geometry::ViewInformation2D& rViewInformation,
85cdf0e10cSrcweir 				const basegfx::B2DPoint& rLogicHitPosition,
86cdf0e10cSrcweir 				double fLogicHitTolerance,
87cdf0e10cSrcweir                 bool bHitTextOnly);
88cdf0e10cSrcweir 			virtual ~HitTestProcessor2D();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 			/// data write access
setUseInvisiblePrimitiveContent(bool bNew)91cdf0e10cSrcweir 			void setUseInvisiblePrimitiveContent(bool bNew)
92cdf0e10cSrcweir 			{
93cdf0e10cSrcweir 				if((bool)mbUseInvisiblePrimitiveContent != bNew) mbUseInvisiblePrimitiveContent = bNew;
94cdf0e10cSrcweir 			}
95cdf0e10cSrcweir 
96cdf0e10cSrcweir             /// data read access
getDiscreteHitPosition() const97cdf0e10cSrcweir 			const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; }
getDiscreteHitTolerance() const98cdf0e10cSrcweir 			double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; }
getHit() const99cdf0e10cSrcweir 			bool getHit() const { return mbHit; }
getHitToleranceUsed() const100cdf0e10cSrcweir 			bool getHitToleranceUsed() const { return mbHitToleranceUsed; }
getUseInvisiblePrimitiveContent() const101cdf0e10cSrcweir 			bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;}
getHitTextOnly() const102cdf0e10cSrcweir             bool getHitTextOnly() const { return mbHitTextOnly; }
103cdf0e10cSrcweir 		};
104cdf0e10cSrcweir 	} // end of namespace processor2d
105cdf0e10cSrcweir } // end of namespace drawinglayer
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
108cdf0e10cSrcweir 
109cdf0e10cSrcweir #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // eof
112