1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX 29 #define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX 30 31 #include <drawinglayer/drawinglayerdllapi.h> 32 #include <drawinglayer/processor2d/baseprocessor2d.hxx> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 // predeclarations 36 37 namespace basegfx { class B2DPolygon; } 38 namespace basegfx { class B2DPolyPolygon; } 39 namespace drawinglayer { namespace primitive2d { class ScenePrimitive2D; }} 40 41 ////////////////////////////////////////////////////////////////////////////// 42 43 namespace drawinglayer 44 { 45 namespace processor2d 46 { 47 /** HitTestProcessor2D class 48 49 This processor implements a HitTest with the feeded primitives, 50 given tolerance and extras 51 */ 52 class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D : public BaseProcessor2D 53 { 54 private: 55 /// discrete HitTest position 56 basegfx::B2DPoint maDiscreteHitPosition; 57 58 /// discrete HitTolerance 59 double mfDiscreteHitTolerance; 60 61 /// bitfield 62 unsigned mbHit : 1; 63 unsigned mbHitToleranceUsed : 1; 64 65 /* this flag decides if primitives which are embedded to an 66 UnifiedTransparencePrimitive2D and are invisible will be taken into account for 67 HitTesting or not. Those primitives are created for objects which are else 68 completely invisible and normally their content exists of hairline 69 primitives describing the object's contour 70 */ 71 unsigned mbUseInvisiblePrimitiveContent : 1; 72 73 /// flag to concentraze on text hits only 74 unsigned mbHitTextOnly : 1; 75 76 /// tooling methods 77 void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); 78 bool checkHairlineHitWithTolerance( 79 const basegfx::B2DPolygon& rPolygon, 80 double fDiscreteHitTolerance); 81 bool checkFillHitWithTolerance( 82 const basegfx::B2DPolyPolygon& rPolyPolygon, 83 double fDiscreteHitTolerance); 84 void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate); 85 86 public: 87 HitTestProcessor2D( 88 const geometry::ViewInformation2D& rViewInformation, 89 const basegfx::B2DPoint& rLogicHitPosition, 90 double fLogicHitTolerance, 91 bool bHitTextOnly); 92 virtual ~HitTestProcessor2D(); 93 94 /// data write access 95 void setUseInvisiblePrimitiveContent(bool bNew) 96 { 97 if((bool)mbUseInvisiblePrimitiveContent != bNew) mbUseInvisiblePrimitiveContent = bNew; 98 } 99 100 /// data read access 101 const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; } 102 double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; } 103 bool getHit() const { return mbHit; } 104 bool getHitToleranceUsed() const { return mbHitToleranceUsed; } 105 bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;} 106 bool getHitTextOnly() const { return mbHitTextOnly; } 107 }; 108 } // end of namespace processor2d 109 } // end of namespace drawinglayer 110 111 ////////////////////////////////////////////////////////////////////////////// 112 113 #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX 114 115 // eof 116