Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
21 : #define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
22 :
23 : #include <drawinglayer/drawinglayerdllapi.h>
24 :
25 : #include <drawinglayer/processor2d/baseprocessor2d.hxx>
26 :
27 :
28 : // predeclarations
29 :
30 : namespace basegfx { class B2DPolygon; }
31 : namespace basegfx { class B2DPolyPolygon; }
32 : namespace drawinglayer { namespace primitive2d { class ScenePrimitive2D; }}
33 :
34 :
35 :
36 : namespace drawinglayer
37 : {
38 : namespace processor2d
39 : {
40 : /** HitTestProcessor2D class
41 :
42 : This processor implements a HitTest with the feeded primitives,
43 : given tolerance and extras
44 : */
45 : class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D : public BaseProcessor2D
46 : {
47 : private:
48 : /// discrete HitTest position
49 : basegfx::B2DPoint maDiscreteHitPosition;
50 :
51 : /// discrete HitTolerance
52 : double mfDiscreteHitTolerance;
53 :
54 : /// bitfield
55 : bool mbHit : 1;
56 : bool mbHitToleranceUsed : 1;
57 :
58 : /* this flag decides if primitives which are embedded to an
59 : UnifiedTransparencePrimitive2D and are invisible will be taken into account for
60 : HitTesting or not. Those primitives are created for objects which are else
61 : completely invisible and normally their content exists of hairline
62 : primitives describing the object's contour
63 : */
64 : bool mbUseInvisiblePrimitiveContent : 1;
65 :
66 : /// flag to concentraze on text hits only
67 : bool mbHitTextOnly : 1;
68 :
69 : /// tooling methods
70 : void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) SAL_OVERRIDE;
71 : bool checkHairlineHitWithTolerance(
72 : const basegfx::B2DPolygon& rPolygon,
73 : double fDiscreteHitTolerance);
74 : bool checkFillHitWithTolerance(
75 : const basegfx::B2DPolyPolygon& rPolyPolygon,
76 : double fDiscreteHitTolerance);
77 : void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate);
78 :
79 : public:
80 : HitTestProcessor2D(
81 : const geometry::ViewInformation2D& rViewInformation,
82 : const basegfx::B2DPoint& rLogicHitPosition,
83 : double fLogicHitTolerance,
84 : bool bHitTextOnly);
85 : virtual ~HitTestProcessor2D();
86 :
87 : /// data write access
88 : void setUseInvisiblePrimitiveContent(bool bNew)
89 : {
90 : if((bool)mbUseInvisiblePrimitiveContent != bNew) mbUseInvisiblePrimitiveContent = bNew;
91 : }
92 :
93 : /// data read access
94 0 : const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; }
95 0 : double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; }
96 0 : bool getHit() const { return mbHit; }
97 : bool getHitToleranceUsed() const { return mbHitToleranceUsed; }
98 0 : bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;}
99 0 : bool getHitTextOnly() const { return mbHitTextOnly; }
100 : };
101 : } // end of namespace processor2d
102 : } // end of namespace drawinglayer
103 :
104 :
105 :
106 : #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|