46 QList<T>
findInRange(
double x,
double y,
double w=0,
double h=0);
56 void clear(
bool autoDelete=
true);
84 _mapX.insertMulti(elt->xPos(), elt);
88 _mapXW.insertMulti(elt->xPos()+elt->width(), elt);
91 _mapXW.insertMulti(std::numeric_limits<double>::max(), elt);
94 if (elt->yPos() + elt->height() > _maxY) {
95 _maxY = elt->yPos() + elt->height();
106 for (
typename QMultiMap<double, T>::const_iterator it=_mapX.constBegin(); it!=_mapX.constEnd(); it++) {
125 T rightMostElt = _mapX.lowerBound(x+w).value();
126 for (
typename QMultiMap<double, T>::const_iterator it=_mapXW.upperBound(x); (it!=_mapXW.end()) && (it.value()!=rightMostElt); it++) {
128 (it.value()->yPos() <= y+h) &&
129 (it.value()->yPos() + it.value()->height() >= y)) ||
131 (it.value()->width() == 0) &&
132 (it.value()->yPos() <= y+h) &&
133 (it.value()->yPos() + it.value()->height() >= y)) ||
135 (it.value()->height() == 0))
151 return findInRange(rect.x(), rect.y(), rect.width(), rect.height());
164 if (_mapX.size()==0) {
168 typename QMultiMap<double, T>::const_iterator it = _mapX.lowerBound(x);
169 while (it!=_mapX.constBegin() && (it==_mapX.constEnd() || it.value()->xPos()>=x)) {
173 if (it.value()->xPos()>=x) {
181 (!context || it.value()->drawableContext() == context) &&
186 (!it.value()->musElement()->isPlayable() &&
187 it.value()->musElement()->context() == voice->
staff())
190 (it.value()->musElement()->isPlayable() &&
195 return static_cast<T
>(it.value());
197 }
while ((it--)!=_mapX.constBegin());
213 typename QMultiMap<double, T>::const_iterator it = _mapX.upperBound(x);
215 for (; it!=_mapX.constEnd(); it++) {
218 (!context || it.value()->drawableContext() == context) &&
223 (!it.value()->musElement()->isPlayable() &&
224 it.value()->musElement()->context() == voice->
staff())
227 (it.value()->musElement()->isPlayable() &&
232 return static_cast<T
>(it.value());
254 for (
typename QMultiMap<double, T>::const_iterator it=_mapX.constBegin(); it!=_mapX.constEnd(); it++) {
255 if ( ((!elt) || ((it.value()->yPos() + it.value()->height()) > (elt->yPos() + elt->height())))
256 && ((it.value()->yPos()+ it.value()->height()) < y) ) {
278 for (
typename QMultiMap<double, T>::const_iterator it=_mapX.constBegin(); it!=_mapX.constEnd(); it++) {
279 if ( ((!elt) || (it.value()->yPos() < elt->yPos())) && (it.value()->yPos() > y) ) {
293 if(_mapXW.constEnd() == _mapXW.constBegin())
295 for (
typename QMultiMap<double, T>::const_iterator it=(--_mapXW.constEnd());
296 it!=_mapXW.constBegin();
298 if (it.key()!=std::numeric_limits<double>::max()) {
323 for (
typename QMultiMap<double, T>::iterator it=_mapX.begin(); it!=_mapX.end(); it++) {
324 if (it.value()->yPos()+it.value()->height() > _maxY) {
325 _maxY = it.value()->yPos()+it.value()->height();
Definition: drawablecontext.h:18
Space partitioning structure for fast access to drawable elements on canvas.
Definition: kdtree.h:39
void addElement(T elt)
Definition: kdtree.h:83
T findNearestDown(double y)
Definition: kdtree.h:273
double getMaxX()
Definition: kdtree.h:292
T findNearestUp(double y)
Definition: kdtree.h:249
T removeElement(double x, double y)
CAKDTree()
Definition: kdtree.h:75
QList< T > list()
Definition: kdtree.h:58
int size()
Definition: kdtree.h:57
QList< T > findInRange(QRect &area)
Definition: kdtree.h:150
double _maxY
Definition: kdtree.h:66
T findNearestRight(double x, bool timeBased=false, CADrawableContext *context=0, CAVoice *voice=0)
Definition: kdtree.h:212
T findNearestLeft(double x, bool timeBased=false, CADrawableContext *context=0, CAVoice *voice=0)
Definition: kdtree.h:163
double getMaxY()
Definition: kdtree.h:311
QMultiMap< double, T > _mapXW
Definition: kdtree.h:65
QList< T > findInRange(double x, double y, double w=0, double h=0)
Definition: kdtree.h:122
QMultiMap< double, T > _mapX
Definition: kdtree.h:64
void clear(bool autoDelete=true)
Definition: kdtree.h:104
void calculateMaxY()
Definition: kdtree.h:321
Playable instances of music elements.
Definition: playable.h:18
CAVoice * voice()
Definition: playable.h:31
Class which represents a voice in the staff.
Definition: voice.h:23
CAStaff * staff()
Definition: voice.h:29