use insert function instead of for loop
[LibreOffice.git] / include / drawinglayer / processor2d / hittestprocessor2d.hxx
blob0f1f6d232d85d5a0dc9f56439bf082a358ce0fb0
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>
24 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
25 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
27 namespace basegfx { class B2DPolygon; }
28 namespace basegfx { class B2DPolyPolygon; }
29 namespace drawinglayer::primitive2d { class ScenePrimitive2D; }
30 class BitmapEx;
32 namespace drawinglayer::processor2d
34 /** HitTestProcessor2D class
36 This processor implements a HitTest with the fed primitives,
37 given tolerance and extras
39 class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D final : public BaseProcessor2D
41 private:
42 /// discrete HitTest position
43 basegfx::B2DPoint maDiscreteHitPosition;
45 /// discrete HitTolerance
46 basegfx::B2DVector maDiscreteHitTolerancePerAxis;
48 /// stack of HitPrimitives, taken care of during HitTest run
49 primitive2d::Primitive2DContainer maHitStack;
51 /// flag if HitStack shall be collected as part of the result, default is false
52 bool mbCollectHitStack : 1;
54 /// Boolean to flag if a hit was found. If yes, fast exit is taken
55 bool mbHit : 1;
57 /// flag to concentrate on text hits only
58 bool mbHitTextOnly : 1;
60 /// tooling methods
61 void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
62 bool checkHairlineHitWithTolerance(
63 const basegfx::B2DPolygon& rPolygon,
64 const basegfx::B2DVector& rDiscreteHitTolerancePerAxis) const;
65 bool checkFillHitWithTolerance(
66 const basegfx::B2DPolyPolygon& rPolyPolygon,
67 const basegfx::B2DVector& rDiscreteHitTolerancePerAxis) const;
68 void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate);
69 void checkBitmapHit(basegfx::B2DRange aRange, const BitmapEx& rBitmapEx, const basegfx::B2DHomMatrix& rTransform);
71 public:
72 HitTestProcessor2D(
73 const geometry::ViewInformation2D& rViewInformation,
74 const basegfx::B2DPoint& rLogicHitPosition,
75 const basegfx::B2DVector& rLogicHitTolerancePerAxis,
76 bool bHitTextOnly);
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
83 /// top-most
84 const primitive2d::Primitive2DContainer& getHitStack() const { return maHitStack; }
86 /// data read access
87 const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; }
88 const basegfx::B2DVector& getDiscreteHitTolerance() const { return maDiscreteHitTolerancePerAxis; }
89 bool getCollectHitStack() const { return mbCollectHitStack; }
90 bool getHit() const { return mbHit; }
91 bool getHitTextOnly() const { return mbHitTextOnly; }
94 } // end of namespace drawinglayer::processor2d
96 #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */