void GraphView::loadGraph(const Graph &graph, PathItem *path, int id) { if (graph.size() < 2) return; GraphItem *gi = new GraphItem(graph); gi->setGraphType(_graphType); gi->setId(id); gi->setColor(_palette.nextColor()); gi->setWidth(_width); connect(this, SIGNAL(sliderPositionChanged(qreal)), gi, SLOT(emitSliderPositionChanged(qreal))); connect(gi, SIGNAL(sliderPositionChanged(qreal)), path, SLOT(moveMarker(qreal))); connect(path, SIGNAL(selected(bool)), gi, SLOT(selected(bool))); _graphs.append(gi); if (!_hide.contains(id)) { _visible.append(gi); _scene->addItem(gi); _bounds |= gi->bounds(); setXUnits(); } }
void GraphView::showGraph(bool show, int id) { if (show) _hide.remove(id); else _hide.insert(id); _visible.clear(); _bounds = QRectF(); for (int i = 0; i < _graphs.count(); i++) { GraphItem* gi = _graphs.at(i); if (_hide.contains(gi->id())) removeItem(gi); else { addItem(gi); _visible.append(gi); _bounds |= gi->bounds(); } } }