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