void PlotWidget::refresh () { if (! _plots.size()) return; // load fresh symbol data if (! _cw->count()) return; PluginFactory fac; Plugin *qplug = fac.load(QString("DBSymbol")); if (! qplug) return; DataBase db(g_session); saveMarkers(db); Bars sym = _cw->currentSymbol(); g_symbol->clear(); g_symbol->setSymbol(sym.symbol()); g_symbol->setLength(_cw->length()); g_symbol->setRange(_cw->range()); PluginData pd; pd.command = QString("getBars"); pd.bars = g_symbol; if (! qplug->command(&pd)) return; else emit signalClear(); // refresh dates emit signalSetDates(); QHashIterator<QString, Plot *> it(_plots); while (it.hasNext()) { it.next(); Plot *plot = it.value(); Entity *e = _settings.value(it.key()); if (! e) continue; QVariant *plugin = e->get(QString("plugin")); if (! plugin) continue; Plugin *iplug = fac.load(plugin->toString()); if (! iplug) continue; PluginData tpd; tpd.command = QString("runIndicator"); tpd.settings = e; if (! iplug->command(&tpd)) continue; for (int tpos = 0; tpos < tpd.curves.size(); tpos++) plot->setCurve(tpd.curves.at(tpos)); for (int tpos = 0; tpos < tpd.markers.size(); tpos++) plot->setMarker(tpd.markers.at(tpos)); } loadMarkers(db); emit signalDraw(); setScrollBarSize(); QStringList tl; tl << "OTA" << "-" << sym.symbol() << "(" + sym.name() + ")" << _cw->lengthText() << _cw->rangeText(); emit signalTitle(tl.join(" ")); }
void PlotWidget::refresh () { qDebug() << "PlotWidget::refresh ()"; DataBase db(g_session); bool newData = loadSymbolData(); //Save all markers before clearing the plot saveMarkers(db); emit signalClear(); // refresh dates emit signalSetDates(); Bars sym = _toolbarWidget->currentSymbol(); //Plot all Indicators QHashIterator<QString, Plot *> it(_plots); while (it.hasNext()) { it.next(); Plot *plot = it.value(); Entity *pEntity = _settings.value(it.key()); if (! pEntity) continue; QVariant *plugin = pEntity->get(QString("plugin")); if (! plugin) continue; IIndicatorPlugin *pPlugin = dynamic_cast<IIndicatorPlugin*>(((PluginFactory*)PluginFactory::getPluginFactory())->loadPlugin(plugin->toString())); if (! pPlugin) continue; QList<Curve*> curves = pPlugin->runIndicator(pEntity); if(newData){ pPlugin->newDataLoaded(); } for (int tpos = 0; tpos < curves.size(); tpos++) plot->setCurve(curves.at(tpos)); // for (int tpos = 0; tpos < tpd.markers.size(); tpos++) // plot->setMarker(tpd.markers.at(tpos)); } //relaod all markers after plot have been updated loadMarkers(db); updateScrollBars(); emit signalDraw(); setPanScrollBarSize(); QStringList tl; tl << "QtTrader" << "-" << sym.symbol() << "(" + sym.name() + ")" << _toolbarWidget->lengthText(); emit signalTitle(tl.join(" ")); }