Example #1
0
void Graph::saveData(DataFileParser *file)
{
    // background color
    file->writeBlockIdentifier("graphWBgColor");
    file->writeString(getBgColor().name());

    // markers
    file->writeBlockIdentifier("graphWMarkersX");
    saveMarkers(file, QwtPlot::xBottom);

    file->writeBlockIdentifier("graphWMarkersY");
    saveMarkers(file, QwtPlot::yLeft);

    file->writeBlockIdentifier("graphWMarkersYRight");
    saveMarkers(file, QwtPlot::yRight);

    // axes
    file->writeBlockIdentifier("graphWAxisRangeV2");
    *file << (quint32)QwtPlot::axisCnt;
    for(size_t i = 0; i < QwtPlot::axisCnt; ++i)
    {
        const QwtScaleDiv div = axisScaleDiv(i);
        *file << div.lowerBound();
        *file << div.upperBound();
    }
}
Example #2
0
int
main(int argc, char **argv) {

    FILE * ofP;
    struct cmdlineInfo cmdline;
    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;
    struct sourceManager * sourceManagerP;

    pnm_init(&argc, argv);

    parseCommandLine(argc, argv, &cmdline);

    if (cmdline.exif_filespec && streq(cmdline.exif_filespec, "-"))
        /* He's got exif going to stdout, so there can be no image output */
        ofP = NULL;
    else
        ofP = stdout;

    displayComments = cmdline.comments;

    /* Initialize the JPEG decompression object with default error handling. */
    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_decompress(&cinfo);

    if (cmdline.trace_level == 0 && cmdline.verbose) 
        cinfo.err->trace_level = 1;
    else 
        cinfo.err->trace_level = cmdline.trace_level;
    
    saveMarkers(&cinfo);

    sourceManagerP = dsCreateSource(cmdline.input_filespec);

    cinfo.src = dsJpegSourceMgr(sourceManagerP);

    convertImages(ofP, cmdline, &cinfo, sourceManagerP);

    jpeg_destroy_decompress(&cinfo);

    if (ofP) {
        int rc;
        rc = fclose(ofP);
        if (rc == EOF) 
            pm_error("Error writing output file.  Errno = %s (%d).",
                     strerror(errno), errno);
    }

    dsDestroySource(sourceManagerP);

    free(cmdline.input_filespec);
  
    exit(jerr.num_warnings > 0 ? EXIT_WARNING : EXIT_SUCCESS);
}
Example #3
0
void
PlotWidget::saveSettings ()
{
  DataBase db(g_session);
  db.transaction();

  // save controlWidget settings
  _cw->saveSettings(&db);

  // save this settings
  Entity *e = settings();
  db.set(e);
  delete e;
  
  QHashIterator<QString, Entity *> it(_settings);
  while (it.hasNext())
  {
    it.next();
    Entity *e = it.value();
    
    Plot *p = _plots.value(it.key());
    if (! p)
      continue;
    
    QVariant *tset = e->get(QString("date"));
    if (tset)
      tset->setValue(p->date());

    tset = e->get(QString("grid"));
    if (tset)
      tset->setValue(p->grid());

    tset = e->get(QString("info"));
    if (tset)
      tset->setValue(p->info());
    
    // save indicator settings
    db.set(e);
  }

  // save markers
  saveMarkers(db);
  
  db.commit();
}
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(" "));
}
Example #5
0
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(" "));
}