Ardour  8.7-15-gadf511264b
lookup_table.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2013-2015 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __CANVAS_LOOKUP_TABLE_H__
21 #define __CANVAS_LOOKUP_TABLE_H__
22 
23 #include <vector>
24 #include <boost/multi_array.hpp>
25 
26 #include "canvas/visibility.h"
27 #include "canvas/types.h"
28 
30 
31 namespace ArdourCanvas {
32 
33 class Item;
34 
36 {
37 public:
38  LookupTable (Item const &);
39  virtual ~LookupTable ();
40 
41  virtual std::vector<Item*> get (Rect const &) = 0;
42  virtual std::vector<Item*> items_at_point (Duple const &) const = 0;
43  virtual bool has_item_at_point (Duple const & point) const = 0;
44 
45 protected:
46 
47  Item const & _item;
48 };
49 
51 {
52 public:
53  DumbLookupTable (Item const &);
54 
55  std::vector<Item*> get (Rect const &);
56  std::vector<Item*> items_at_point (Duple const &) const;
57  bool has_item_at_point (Duple const & point) const;
58 };
59 
61 {
62 public:
63  OptimizingLookupTable (Item const &, int);
65  std::vector<Item*> get (Rect const &);
66  std::vector<Item*> items_at_point (Duple const &) const;
67  bool has_item_at_point (Duple const & point) const;
68 
70 
71  private:
72 
73  void area_to_indices (Rect const &, int &, int &, int &, int &) const;
74  void point_to_indices (Duple, int &, int &) const;
75 
76  friend class ::OptimizingLookupTableTest;
77 
78  typedef std::vector<Item*> Cell;
84  bool _added;
85 };
86 
87 }
88 
89 #endif
#define LIBCANVAS_API
bool has_item_at_point(Duple const &point) const
std::vector< Item * > get(Rect const &)
std::vector< Item * > items_at_point(Duple const &) const
virtual std::vector< Item * > get(Rect const &)=0
virtual bool has_item_at_point(Duple const &point) const =0
virtual std::vector< Item * > items_at_point(Duple const &) const =0
void area_to_indices(Rect const &, int &, int &, int &, int &) const
void point_to_indices(Duple, int &, int &) const
std::vector< Item * > items_at_point(Duple const &) const
std::vector< Item * > get(Rect const &)
bool has_item_at_point(Duple const &point) const
OptimizingLookupTable(Item const &, int)