Branch libreoffice-5-0-4
[LibreOffice.git] / include / drawinglayer / processor2d / hittestprocessor2d.hxx
blob2b6419d74b2fa41e4d0842c2a114f79df596fbcb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
33 namespace processor2d
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
42 private:
43 /// discrete HitTest position
44 basegfx::B2DPoint maDiscreteHitPosition;
46 /// discrete HitTolerance
47 double mfDiscreteHitTolerance;
49 /// bitfield
50 bool mbHit : 1;
51 bool mbHitToleranceUsed : 1;
53 /* this flag decides if primitives which are embedded to an
54 UnifiedTransparencePrimitive2D and are invisible will be taken into account for
55 HitTesting or not. Those primitives are created for objects which are else
56 completely invisible and normally their content exists of hairline
57 primitives describing the object's contour
59 bool mbUseInvisiblePrimitiveContent : 1;
61 /// flag to concentraze on text hits only
62 bool mbHitTextOnly : 1;
64 /// If we are tiled rendering.
65 bool mbTiledRendering;
67 /// tooling methods
68 void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) SAL_OVERRIDE;
69 bool checkHairlineHitWithTolerance(
70 const basegfx::B2DPolygon& rPolygon,
71 double fDiscreteHitTolerance);
72 bool checkFillHitWithTolerance(
73 const basegfx::B2DPolyPolygon& rPolyPolygon,
74 double fDiscreteHitTolerance);
75 void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate);
77 public:
78 HitTestProcessor2D(
79 const geometry::ViewInformation2D& rViewInformation,
80 const basegfx::B2DPoint& rLogicHitPosition,
81 double fLogicHitTolerance,
82 bool bHitTextOnly,
83 bool bTiledRendering);
84 virtual ~HitTestProcessor2D();
86 /// data write access
87 void setUseInvisiblePrimitiveContent(bool bNew)
89 if((bool)mbUseInvisiblePrimitiveContent != bNew) mbUseInvisiblePrimitiveContent = bNew;
92 /// data read access
93 const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; }
94 double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; }
95 bool getHit() const { return mbHit; }
96 bool getHitToleranceUsed() const { return mbHitToleranceUsed; }
97 bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;}
98 bool getHitTextOnly() const { return mbHitTextOnly; }
100 } // end of namespace processor2d
101 } // end of namespace drawinglayer
103 #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */