X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fcanvas%2Flookup_table.h;h=29452365cdb2db38bd50617042a3949e07cfba55;hb=c4c7598adbc9e5eca5fe04a23bb7e88fc0989f34;hp=d56394ca589aaba482b7023da2dfe6ef677a6cd6;hpb=aaea166135ace01709f7e0be64f40be80f4107ec;p=ardour.git diff --git a/libs/canvas/canvas/lookup_table.h b/libs/canvas/canvas/lookup_table.h index d56394ca58..29452365cd 100644 --- a/libs/canvas/canvas/lookup_table.h +++ b/libs/canvas/canvas/lookup_table.h @@ -1,8 +1,29 @@ +/* + Copyright (C) 2011-2013 Paul Davis + Author: Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + #ifndef __CANVAS_LOOKUP_TABLE_H__ #define __CANVAS_LOOKUP_TABLE_H__ #include #include + +#include "canvas/visibility.h" #include "canvas/types.h" class OptimizingLookupTableTest; @@ -10,55 +31,57 @@ class OptimizingLookupTableTest; namespace ArdourCanvas { class Item; -class Group; -class LookupTable +class LIBCANVAS_API LookupTable { public: - LookupTable (Group const &); - virtual ~LookupTable (); - - virtual std::vector get (Rect const &) = 0; - virtual std::vector items_at_point (Duple) const = 0; + LookupTable (Item const &); + virtual ~LookupTable (); + + virtual std::vector get (Rect const &) = 0; + virtual std::vector items_at_point (Duple const &) const = 0; + virtual bool has_item_at_point (Duple const & point) const = 0; protected: - Group const & _group; + Item const & _item; }; -class DumbLookupTable : public LookupTable +class LIBCANVAS_API DumbLookupTable : public LookupTable { public: - DumbLookupTable (Group const &); - - std::vector get (Rect const &); - std::vector items_at_point (Duple) const; + DumbLookupTable (Item const &); + + std::vector get (Rect const &); + std::vector items_at_point (Duple const &) const; + bool has_item_at_point (Duple const & point) const; }; -class OptimizingLookupTable : public LookupTable +class LIBCANVAS_API OptimizingLookupTable : public LookupTable { public: - OptimizingLookupTable (Group const &, int); - ~OptimizingLookupTable (); - std::vector get (Rect const &); - std::vector items_at_point (Duple) const; - - static int default_items_per_cell; - -private: - - void area_to_indices (Rect const &, int &, int &, int &, int &) const; - void point_to_indices (Duple, int &, int &) const; - - friend class ::OptimizingLookupTableTest; - - typedef std::vector Cell; - int _items_per_cell; - int _dimension; - Duple _cell_size; - Duple _offset; - Cell** _cells; - bool _added; + OptimizingLookupTable (Item const &, int); + ~OptimizingLookupTable (); + std::vector get (Rect const &); + std::vector items_at_point (Duple const &) const; + bool has_item_at_point (Duple const & point) const; + + static int default_items_per_cell; + + private: + + void area_to_indices (Rect const &, int &, int &, int &, int &) const; + void point_to_indices (Duple, int &, int &) const; + + friend class ::OptimizingLookupTableTest; + + typedef std::vector Cell; + int _items_per_cell; + int _dimension; + Duple _cell_size; + Duple _offset; + Cell** _cells; + bool _added; }; }