MuseScore/libmscore/spannermap.h

54 lines
1.9 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __SPANNERMAP_H__
#define __SPANNERMAP_H__
2013-07-05 11:23:52 +02:00
#include "thirdparty/intervaltree/IntervalTree.h"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class Spanner;
//---------------------------------------------------------
// SpannerMap
//---------------------------------------------------------
2013-07-05 11:23:52 +02:00
class SpannerMap : std::multimap<int, Spanner*> {
mutable bool dirty;
mutable IntervalTree<Spanner*> tree;
std::vector< ::Interval<Spanner*> > results;
2012-05-26 14:26:10 +02:00
public:
2013-07-05 11:23:52 +02:00
SpannerMap();
const std::vector< ::Interval<Spanner*> >& findContained(int start, int stop);
const std::vector< ::Interval<Spanner*> >& findOverlapping(int start, int stop);
const std::multimap<int, Spanner*>& map() const { return *this; }
std::multimap<int,Spanner*>::const_reverse_iterator crbegin() const { return std::multimap<int, Spanner*>::crbegin(); }
std::multimap<int,Spanner*>::const_reverse_iterator crend() const { return std::multimap<int, Spanner*>::crend(); }
std::multimap<int,Spanner*>::const_iterator cbegin() const { return std::multimap<int, Spanner*>::cbegin(); }
std::multimap<int,Spanner*>::const_iterator cend() const { return std::multimap<int, Spanner*>::cend(); }
void addSpanner(Spanner* s);
bool removeSpanner(Spanner* s);
void update() const;
void setDirty() const { dirty = true; } // must be called if a spanner changes start/length
2016-04-11 15:28:32 +02:00
#ifndef NDEBUG
void dump() const;
#endif
2012-05-26 14:26:10 +02:00
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2013-07-05 11:23:52 +02:00
2012-05-26 14:26:10 +02:00
#endif