MuseScore  3.4
Music composition and notation
spannermap.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __SPANNERMAP_H__
14 #define __SPANNERMAP_H__
15 
16 
17 #include "thirdparty/intervaltree/IntervalTree.h"
18 
19 namespace Ms {
20 
21 class Spanner;
22 
23 //---------------------------------------------------------
24 // SpannerMap
25 //---------------------------------------------------------
26 
27 class SpannerMap : std::multimap<int, Spanner*> {
28  mutable bool dirty;
29  mutable IntervalTree<Spanner*> tree;
30  std::vector< ::Interval<Spanner*> > results;
31 
32  public:
33  SpannerMap();
34  const std::vector< ::Interval<Spanner*> >& findContained(int start, int stop);
35  const std::vector< ::Interval<Spanner*> >& findOverlapping(int start, int stop);
36  const std::multimap<int, Spanner*>& map() const { return *this; }
37  std::multimap<int,Spanner*>::const_reverse_iterator crbegin() const { return std::multimap<int, Spanner*>::crbegin(); }
38  std::multimap<int,Spanner*>::const_reverse_iterator crend() const { return std::multimap<int, Spanner*>::crend(); }
39  std::multimap<int,Spanner*>::const_iterator cbegin() const { return std::multimap<int, Spanner*>::cbegin(); }
40  std::multimap<int,Spanner*>::const_iterator cend() const { return std::multimap<int, Spanner*>::cend(); }
41  void addSpanner(Spanner* s);
42  bool removeSpanner(Spanner* s);
43  void clear() { std::multimap<int, Spanner*>::clear(); dirty = true; }
44  void update() const;
45  void setDirty() const { dirty = true; } // must be called if a spanner changes start/length
46 #ifndef NDEBUG
47  void dump() const;
48 #endif
49  };
50 
51 } // namespace Ms
52 
53 #endif
54 
void setDirty() const
Definition: spannermap.h:45
Virtual base class for slurs, ties, lines etc.
Definition: spanner.h:136
const std::vector< ::Interval< Spanner * > > & findContained(int start, int stop)
Definition: spannermap.cpp:46
std::multimap< int, Spanner * >::const_reverse_iterator crend() const
Definition: spannermap.h:38
bool dirty
Definition: spannermap.h:28
void clear()
Definition: spannermap.h:43
bool removeSpanner(Spanner *s)
Definition: spannermap.cpp:92
SpannerMap()
Definition: spannermap.cpp:22
const std::vector< ::Interval< Spanner * > > & findOverlapping(int start, int stop)
Definition: spannermap.cpp:59
const std::multimap< int, Spanner * > & map() const
Definition: spannermap.h:36
std::multimap< int, Spanner * >::const_iterator cend() const
Definition: spannermap.h:40
void addSpanner(Spanner *s)
Definition: spannermap.cpp:72
std::multimap< int, Spanner * >::const_reverse_iterator crbegin() const
Definition: spannermap.h:37
void dump() const
Definition: spannermap.cpp:110
IntervalTree< Spanner * > tree
Definition: spannermap.h:29
void update() const
Definition: spannermap.cpp:33
Definition: aeolus.cpp:26
Definition: spannermap.h:27
std::multimap< int, Spanner * >::const_iterator cbegin() const
Definition: spannermap.h:39
std::vector< ::Interval< Spanner * > > results
Definition: spannermap.h:30