Changeset 164 for Evidence/Edd


Ignore:
Timestamp:
02/08/10 15:03:53 (15 years ago)
Author:
ogrimm
Message:
Revision number tracked in server status
Location:
Evidence/Edd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Edd/Edd.cc

    r159 r164  
    2222class GUI *Handler;
    2323
     24
     25// History chooser function (opens plot for numeric data, TextHist for all other)
     26QWidget *OpenHistory(char *Service) {
     27
     28  char *Name, *Format;
     29  DimBrowser Browser;
     30 
     31  //if (Browser.getServices(Service) == 0) return NULL;
     32  Browser.getServices(Service);
     33  if (Browser.getNextService(Name, Format) != DimSERVICE) return NULL;
     34 
     35  if (strlen(Format) == 1 && *Format != 'C') return new Edd_Plot(Service);
     36  else return new Edd_TextHist(Service);
     37}
     38
     39
    2440//////////////////////////////////////////
    2541// Text display for arbitary DIM service//
     
    4157  // Context menu
    4258  Menu = new QMenu(this);
    43   Menu->addAction("Open history", this, SLOT(MenuOpenHistory()));
     59  Menu->addAction("Open new history", this, SLOT(MenuOpenHistory()));
    4460  Menu->addAction("Copy service", this, SLOT(MenuCopyService()));
    4561  Menu->addAction("Copy data", this, SLOT(MenuCopyData()));
     
    135151void Edd_Indicator::MenuOpenHistory() {
    136152 
    137   LastPlot = new Edd_Plot(Data->getName());
    138   LastPlot->show();
     153  LastPlot = OpenHistory(Data->getName());
     154  if (LastPlot != NULL) LastPlot->show();
    139155}
    140156
     
    165181  // Graph properties
    166182  setAutoReplot(false);
    167   QwtText XAxisTitle("Time (RJD-55200)");
    168   XAxisTitle.setFont(QFont("Helvetica", 10));
    169   setAxisTitle(QwtPlot::xBottom, XAxisTitle);
    170183  setCanvasBackground(QColor(Qt::yellow));
     184  setAxisScaleDraw(QwtPlot::xBottom, new TimeScale());
    171185
    172186  Zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,canvas());
     
    347361    else Items[ItemNo].Signal->setSymbol(Sym1);
    348362
    349     int DataPoints = Items[ItemNo].x.size();
    350        
     363    int DataPoints = Items[ItemNo].x.size();   
    351364        if (DataPoints == 0) continue;
    352   
    353     double *x = new double [DataPoints];
     365 
     366    // Normalize y scale if requested
    354367    double *y = new double [DataPoints];
    355  
    356     // Adapt time scale and normalize y scale if requested
    357368    for (int i=0; i<DataPoints; i++) {
    358       x[i] = Items[ItemNo].x[i] / 86400.0 + 40587.5 - 55200;
    359369      y[i] = Items[ItemNo].y[i];
    360370
     
    368378
    369379    // Plot data
    370     Items[ItemNo].Signal->setData(x, y, DataPoints);
     380    Items[ItemNo].Signal->setData(Items[ItemNo].x.data(), y, DataPoints);
    371381    Items[ItemNo].Signal->show();
    372382    Zoomer->setZoomBase(Items[ItemNo].Signal->boundingRect());
    373383
    374     delete[] x;
    375384    delete[] y;
    376385  }
     
    825834    Result = Result.trimmed();
    826835    if (Result.endsWith(".hist")) Result.chop(5);
    827     Edd_Plot *Plot = new Edd_Plot(Result);
    828     Plot->show();
     836    QWidget *Hist = OpenHistory(Result.toAscii().data());
     837    if (Hist != NULL) Hist->show();
    829838  }
    830839}
  • Evidence/Edd/Edd.h

    r159 r164  
    2424
    2525#define SVN_REVISION "$Revision$"
     26
     27QWidget *OpenHistory(char *);
     28
     29// Time scale for axis
     30class TimeScale: public QwtScaleDraw {
     31  public:
     32    TimeScale() { }
     33    virtual QwtText label(double v) const {
     34      QDateTime t = QDateTime::fromTime_t((int) v);
     35      return t.toString("dMMM'\n'h:m:s");
     36    }
     37};
     38
    2639                 
    2740// General indicator for DIM service
     
    3144    QMenu *Menu;
    3245    QPoint dragStart;
    33     QwtPlot *LastPlot;
     46    //QwtPlot *LastPlot;
     47    QWidget *LastPlot;
    3448       
    3549    DimStampedInfo *Data;
Note: See TracChangeset for help on using the changeset viewer.