1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
27 namespace basegfx
{ class B2DPolygon
; }
28 namespace basegfx
{ class B2DPolyPolygon
; }
29 namespace drawinglayer
{ namespace primitive2d
{ class ScenePrimitive2D
; }}
31 namespace drawinglayer
35 /** HitTestProcessor2D class
37 This processor implements a HitTest with the feeded primitives,
38 given tolerance and extras
40 class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D
: public BaseProcessor2D
43 /// discrete HitTest position
44 basegfx::B2DPoint maDiscreteHitPosition
;
46 /// discrete HitTolerance
47 double mfDiscreteHitTolerance
;
49 /// stack of HitPrimitives, taken care of during HitTest run
50 primitive2d::Primitive2DContainer maHitStack
;
52 /// flag if HitStack shall be collected as part of the result, default is false
53 bool mbCollectHitStack
: 1;
55 /// Boolean to flag if a hit was found. If yes, fast exit is taken
58 /// flag to concentrate on text hits only
59 bool mbHitTextOnly
: 1;
62 void processBasePrimitive2D(const primitive2d::BasePrimitive2D
& rCandidate
) override
;
63 bool checkHairlineHitWithTolerance(
64 const basegfx::B2DPolygon
& rPolygon
,
65 double fDiscreteHitTolerance
) const;
66 bool checkFillHitWithTolerance(
67 const basegfx::B2DPolyPolygon
& rPolyPolygon
,
68 double fDiscreteHitTolerance
) const;
69 void check3DHit(const primitive2d::ScenePrimitive2D
& rCandidate
);
73 const geometry::ViewInformation2D
& rViewInformation
,
74 const basegfx::B2DPoint
& rLogicHitPosition
,
75 double fLogicHitTolerance
,
77 virtual ~HitTestProcessor2D() override
;
79 /// switch on collecting primitives for a found hit on maHitStack, default is off
80 void collectHitStack(bool bCollect
) { mbCollectHitStack
= bCollect
; }
82 /// get HitStack of primitives, first is the one that created the hit, last is the
84 const primitive2d::Primitive2DContainer
& getHitStack() const { return maHitStack
; }
87 const basegfx::B2DPoint
& getDiscreteHitPosition() const { return maDiscreteHitPosition
; }
88 double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance
; }
89 bool getCollectHitStack() const { return mbCollectHitStack
; }
90 bool getHit() const { return mbHit
; }
91 bool getHitTextOnly() const { return mbHitTextOnly
; }
93 } // end of namespace processor2d
94 } // end of namespace drawinglayer
96 #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */