void PlotScene::handleSelection(void) { if (this->selectionLocked > 0) return; QList<QGraphicsItem*> items = this->selectedItems(); /* On n'a sélectionné qu'un élément, ça n'est donc pas une selection * rectangulaire --> on a sélectionné un point */ if (items.count() == 1) { CoordinateItem* coord = qgraphicsitem_cast<CoordinateItem*>(items.first()); if (coord != NULL) { PlotCurve* parent = qgraphicsitem_cast<PlotCurve*>(coord->parentItem()); if (parent != NULL) emit this->pointSelected(coord->index().toFloat(), parent->id()); } } else if (items.count() > 1) { QMap< PlotCurve*, QPair<float, float> > intervalsBounds; foreach (QGraphicsItem* item, items) { CoordinateItem* coord = qgraphicsitem_cast<CoordinateItem*>(item); if (coord != NULL) { PlotCurve* parent = qgraphicsitem_cast<PlotCurve*>(coord->parentItem()); if (parent != NULL) { if (! intervalsBounds.contains(parent)) { intervalsBounds[parent].first = coord->index().toFloat(); intervalsBounds[parent].second = coord->index().toFloat(); } else { if (coord->index().toFloat() < intervalsBounds[parent].first) intervalsBounds[parent].first = coord->index().toFloat(); else if (coord->index().toFloat() > intervalsBounds[parent].second) intervalsBounds[parent].second = coord->index().toFloat(); } } } }
bool PlotScene::removeCurves(const QVariant& idTrack) { PlotCurve* targetCurve; for (int i(0); i < this->curves.count(); ++i) { targetCurve = this->curves.at(i); if(targetCurve->id() == idTrack) { this->curves.removeAt(i); this->removeItem(targetCurve); delete targetCurve; return true; } } return false; }