Example #1
0
void Plot::markerDialog ()
{
  if (! _plotSettings.selected)
    return;

  Entity *e = _plotSettings.selected->settings();
  if (! e)
    return;

  QVariant *plugin = e->get(QString("plugin"));
  if (! plugin)
    return;
  
  PluginFactory fac;
  Plugin *plug = fac.load(plugin->toString());
  if (! plug)
    return;

  PluginData pd;
  pd.command = QString("dialog");
  pd.dialogParent = this;
  pd.settings = e;
  if (! plug->command(&pd))
    return;

  connect(pd.dialog, SIGNAL(accepted()), this, SLOT(markerDialog2()));
  pd.dialog->show();
}
Example #2
0
void
PlotWidget::editIndicator2 (QString name)
{
  Entity *e = _settings.value(name);
  if (! e)
    return;

  QVariant *plugin = e->get(QString("plugin"));
  if (! plugin)
    return;
  
  PluginFactory fac;
  Plugin *plug = fac.load(plugin->toString());
  if (! plug)
    return;

  PluginData pd;
  pd.command = QString("dialog");
  pd.dialogParent = this;
  pd.settings = e;
  if (! plug->command(&pd))
    return;
  
  connect(pd.dialog, SIGNAL(accepted()), this, SLOT(refresh()));
  pd.dialog->show();
}
Example #3
0
void
PlotWidget::addPlot (QString plugin, int row, QString name)
{
  PluginFactory fac;
  Plugin *plug = fac.load(plugin);
  if (! plug)
    return;

  PluginData pd;
  pd.command = QString("settings");
  if (! plug->command(&pd))
    return;
  
  Entity *settings = pd.settings;
  settings->setName(name);
  
  _settings.insert(name, settings);
  
  addPlotSettings(settings);

  QVariant *tset = settings->get(QString("row"));
  if (tset)
    tset->setValue(row);

  Plot *plot = new Plot(name, 0);
  plot->setMinimumHeight(30);
  _plots.insert(name, plot);
  
  _csplitter->insertWidget(row, plot);

  plot->setStartIndex(_cw->scrollBarValue());
  
  // connect all we need here
  connect(plot, SIGNAL(signalResizeScrollBar(Plot *)), _cw, SLOT(resizeScrollBar(Plot *)));
  connect(this, SIGNAL(signalClear()), plot, SLOT(clear()));
  connect(this, SIGNAL(signalDraw()), plot, SLOT(updatePlot()));
  connect(this, SIGNAL(signalSetDates()), plot, SLOT(setDates()));
  connect(this, SIGNAL(signalBarLength(int)), plot, SLOT(setBarLength(int)));
  connect(this, SIGNAL(signalIndex(int)), plot, SLOT(setStartIndex(int)));
  connect(plot, SIGNAL(signalMessage(QString)), this, SIGNAL(signalMessage(QString)));
  connect(plot, SIGNAL(signalDeleteMarkers(QStringList)), this, SLOT(deleteMarkers(QStringList)));
}
Example #4
0
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(" "));
}