Changeset 139


Ignore:
Timestamp:
Dec 15, 2009, 3:40:49 PM (11 years ago)
Author:
ogrimm
Message:
Updates
Location:
Evidence/Edd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Edd/Edd.cc

    r138 r139  
    44
    55Qt-based graphical user interface for the Evidence contron system
     6
     7Edd_Indicator changes its background colour in case it display
     8a DIM status service
    69
    710December 2009, Oliver Grimm
     
    2124
    2225// Constructor
    23 Edd_Indicator::Edd_Indicator(char *DIMService, QWidget *P): QLineEdit(P) {
    24 
    25   ServiceName = new char [strlen(DIMService)+1];
    26   strcpy(ServiceName, DIMService);
     26Edd_Indicator::Edd_Indicator(QString DIMService, QWidget *P): QLineEdit(P) {
     27
     28  ServiceName = qstrdup(DIMService.toAscii().data());
    2729 
    2830  // Widget properties
     
    3133  connect(this, SIGNAL(YEP(QString)), this, SLOT(setText(QString)));
    3234
     35  // Context menu
     36  Menu = new QMenu(this);
     37  Menu->addAction("Copy service", this, SLOT(MenuCopyService()));
     38
    3339  // DIM client
    34   Data = new DimStampedInfo(DIMService, INT_MAX, (char *) NO_LINK, this);
     40  Data = new DimStampedInfo(ServiceName, INT_MAX, (char *) NO_LINK, this);
    3541}
    3642
     
    4450void Edd_Indicator::infoHandler() {
    4551
     52  QPalette Pal = palette(); 
     53  QString S;
     54
    4655  // Check if service available
    47   QPalette Pal = palette(); 
    4856  if (getInfo()->getSize() == strlen(NO_LINK)+1 && strcmp(getInfo()->getString(), NO_LINK) == 0) {
    49         emit(YEP(QString("n/a")));
    50         setStatusTip(QString("%1:  unavailable").arg(ServiceName));
     57    emit(YEP(QString("n/a")));
     58    setStatusTip(QString("%1:  unavailable").arg(ServiceName));
    5159    Pal.setColor(backgroundRole(), Qt::red);
    5260    setPalette(Pal);
    53         return;
     61    return;
    5462  }
    5563  Pal.setColor(backgroundRole(), Qt::white);
    56   setPalette(Pal);
    5764
    5865  // Translate data into ASCII
    5966  char *Text = EvidenceServer::ToString(getInfo());
    60   QString S;
    61 
     67
     68  // If this is a status indicator, adapt background colour
     69  if (getInfo()->getSize() == (int) strlen(Text)+3) {
     70    switch (*((char *) getInfo()->getData() + strlen(Text) + 2)) {
     71      case 0:  Pal.setColor(backgroundRole(), Qt::white); break;
     72      case 1:  Pal.setColor(backgroundRole(), Qt::cyan); break;
     73      case 2:  Pal.setColor(backgroundRole(), Qt::red); break;
     74      case 3:  Pal.setColor(backgroundRole(), Qt::red); break;
     75      default: break;
     76    }
     77  }
     78  setPalette(Pal);
     79 
    6280  if (Text != NULL) {
    6381    QTextStream(&S) << Text;
     
    8199void Edd_Indicator::mouseReleaseEvent(QMouseEvent *Event) {
    82100
    83   if (Event->button()==Qt::LeftButton && contentsRect().contains(Event->pos())) {
    84     Edd_Plot *Graph = new Edd_Plot(ServiceName, NULL);
    85     Graph->show();
    86   }
     101  if (Event->button()!=Qt::LeftButton || !contentsRect().contains(Event->pos())) return;
     102
     103  // Check if last history plot still open, then raise
     104  foreach (QWidget *Widget, QApplication::allWidgets()) {
     105    if (Widget == LastPlot) {
     106      Widget->activateWindow();
     107      Widget->raise();
     108      return;
     109    }
     110  }
     111
     112  // If not, open new plot
     113  LastPlot = new Edd_Plot(ServiceName);
     114  LastPlot->show();
    87115}
    88116
     
    106134}
    107135
     136//
     137// Opening context menu
     138//
     139void Edd_Indicator::contextMenuEvent(QContextMenuEvent *Event) {
     140
     141  Menu->exec(Event->globalPos());
     142}
     143
     144// Copy service name
     145void Edd_Indicator::MenuCopyService() {
     146 
     147  QApplication::clipboard()->setText(QString(ServiceName));
     148}
    108149
    109150//////////////////////////////////
     
    114155// Constructor
    115156//
    116 Edd_Plot::Edd_Plot(char *DIMService, QWidget *P): QwtPlot(P) {
     157Edd_Plot::Edd_Plot(QString DIMService, QWidget *P): QwtPlot(P) {
    117158
    118159  setAcceptDrops(true);
    119 
     160  setAttribute(Qt::WA_DeleteOnClose);
     161 
    120162  // Graph properties
    121163  QwtText XAxisTitle("Time (RJD-55000)");
     
    144186  NormAction = Menu->addAction("Normalize", this, SLOT(UpdatePlot()));
    145187  NormAction->setCheckable(true);
     188  StyleAction = Menu->addAction("Draw dots", this, SLOT(UpdatePlot()));
     189  StyleAction->setCheckable(true);
    146190  Menu->addAction("Zoom out", this, SLOT(MenuZoomOut()));
    147191  Menu->addAction("Single trace", this, SLOT(MenuSingleTrace()));
    148192  Menu->addSeparator();
     193  Menu->addAction("Save as ASCII", this, SLOT(MenuSaveASCII()));
    149194  Menu->addAction("Save plot", this, SLOT(MenuSave()));
    150195  Menu->addAction("Print plot", this, SLOT(MenuPrint()));
     196  Menu->addSeparator();
     197  Menu->addAction("Paste service", this, SLOT(MenuPasteService()));
    151198
    152199  // DIM client
    153   AddService(DIMService);
     200  if (!DIMService.isEmpty()) AddService(DIMService);
    154201}
    155202
     
    161208  for (int i=0; i<Items.size(); i++) {
    162209    delete Items[i].Data;
     210    delete Items[i].LiveData;
    163211    delete Items[i].Signal;
    164212    delete[] Items[i].x;
     
    171219// Add history service to plot
    172220//
    173 void Edd_Plot::AddService(char *DIMService) {
    174 
    175   // Generate name of DIM service
    176   QString Name(DIMService);
    177   Name.append(".hist");
    178 
    179   // Lock this thread (because infoHandler() might be called before list insertion)
     221void Edd_Plot::AddService(QString Name) {
     222
     223  QString HistName = Name+".hist";
     224 
     225  // Lock before accessing Items list
    180226  QMutexLocker Locker(&Mutex);
     227
     228  // Check if already subsribed to service
     229  for (int i=0; i<Items.size(); i++) {
     230    if (HistName == Items[i].Data->getName()) {
     231      QMessageBox::warning(this, "Edd Message",HistName+" already present",QMessageBox::Ok);
     232      return;
     233    }
     234  } 
    181235
    182236  // Generate new curve and subscribe to service
     
    184238  New.Signal = new QwtPlotCurve;
    185239  New.Signal->attach(this);
    186   New.Signal->setTitle(Name);
     240  New.Signal->setTitle(HistName);
    187241  New.Signal->setPen(QColor(LineColors[Items.size()%(sizeof(LineColors)/sizeof(Qt::GlobalColor))]));
    188242  New.x = NULL;
    189243  New.y = NULL;
    190   New.Data = new DimStampedInfo(Name.toAscii(), NO_LINK, this);
     244  New.Count = 0;
     245  New.Data = new DimStampedInfo(HistName.toAscii(), NO_LINK, this);
     246  New.LiveData = new DimStampedInfo(Name.toAscii(), NO_LINK, this);
    191247
    192248  Items.append(New);
     
    204260  }
    205261
    206   // Lock this thread (see AddService())
     262  // Lock before accessing Items list
    207263  QMutexLocker Locker(&Mutex);
    208264
    209265  // Determine which plot item this call belongs to
    210266  int ItemNo;
    211   for (ItemNo=0; ItemNo<Items.size(); ItemNo++) if (Items[ItemNo].Data == getInfo()) break;
    212   if (ItemNo == Items.size()) return;  // safety check
    213  
    214   EvidenceHistoryItem *Curr = (EvidenceHistoryItem *) getInfo()->getData();
    215   int Count=0, DataPoints = getInfo()->getSize()/sizeof(struct EvidenceHistoryItem);
    216 
    217   delete[] Items[ItemNo].x;
    218   delete[] Items[ItemNo].y;
    219   Items[ItemNo].x = new double [DataPoints];
    220   Items[ItemNo].y = new double [DataPoints];
    221 
    222   // Find oldest item
    223   int Oldest;
    224   for (Oldest=1; Oldest<DataPoints; Oldest++) {
    225     if (Curr[Oldest].Seconds < Curr[Oldest-1].Seconds) break;
    226   }
    227 
    228   // Plot data starting with oldest value
    229   for (int i=0; i<DataPoints; i++) {
    230     Items[ItemNo].x[Count] = (double) Curr[(i+Oldest)%DataPoints].Seconds;
    231     Items[ItemNo].y[Count] = Curr[(i+Oldest)%DataPoints].Value;
    232     if (Items[ItemNo].x[Count] != 0) Count++;
    233   }
    234  
    235   // Find smallest and largest item
    236   double Smallest = DBL_MAX, Largest = DBL_MIN;
    237   for (int i=0; i<Count; i++) {
    238     if (Largest < Items[ItemNo].y[i]) Largest = Items[ItemNo].y[i];
    239     if (Smallest > Items[ItemNo].y[i]) Smallest = Items[ItemNo].y[i];
    240   }
    241   Items[ItemNo].Smallest = Smallest;
    242   Items[ItemNo].Largest = Largest;
    243   Items[ItemNo].Count = Count;
    244  
    245   // Update status tip
    246   QDateTime Time = QDateTime::fromTime_t(getInfo()->getTimestamp());
    247   setStatusTip(QString("%1:  Last update %2  Format '%3'").arg(getInfo()->getName(), Time.toString()).arg(getInfo()->getFormat()));
    248 
     267  for (ItemNo=0; ItemNo<Items.size(); ItemNo++) if (Items[ItemNo].Data == getInfo()) {
     268    // This is a history service 
     269    EvidenceHistoryItem *Curr = (EvidenceHistoryItem *) getInfo()->getData();
     270    int Count=0, DataPoints = getInfo()->getSize()/sizeof(struct EvidenceHistoryItem);
     271
     272    delete[] Items[ItemNo].x;
     273    delete[] Items[ItemNo].y;
     274    Items[ItemNo].x = new int [DataPoints];
     275    Items[ItemNo].y = new double [DataPoints];
     276
     277    // Find oldest item
     278    int Oldest;
     279    for (Oldest=1; Oldest<DataPoints; Oldest++) {
     280      if (Curr[Oldest].Seconds < Curr[Oldest-1].Seconds) break;
     281    }
     282
     283    // Plot data starting with oldest value
     284    for (int i=0; i<DataPoints; i++) {
     285      Items[ItemNo].x[Count] = Curr[(i+Oldest)%DataPoints].Seconds;
     286      Items[ItemNo].y[Count] = Curr[(i+Oldest)%DataPoints].Value;
     287      if (Items[ItemNo].x[Count] != 0) Count++;
     288    }
     289
     290    // Find smallest and largest item
     291    double Smallest = DBL_MAX, Largest = DBL_MIN;
     292    for (int i=0; i<Count; i++) {
     293      if (Largest < Items[ItemNo].y[i]) Largest = Items[ItemNo].y[i];
     294      if (Smallest > Items[ItemNo].y[i]) Smallest = Items[ItemNo].y[i];
     295    }
     296    Items[ItemNo].Smallest = Smallest;
     297    Items[ItemNo].Largest = Largest;
     298    Items[ItemNo].Count = Count;
     299
     300    // Clear local history
     301    Items[ItemNo].Live.clear();
     302
     303    // Update status tip
     304    QDateTime Time = QDateTime::fromTime_t(getInfo()->getTimestamp());
     305    setStatusTip(QString("%1:  Last update %2  Format '%3'").arg(getInfo()->getName(), Time.toString()).arg(getInfo()->getFormat()));
     306
     307  } else if (Items[ItemNo].LiveData == getInfo()) {
     308    // This is a live service
     309
     310    // Limit size of list
     311    if (Items[ItemNo].Live.size() > 1000) Items[ItemNo].Live.removeFirst();
     312
     313    // Append data
     314    struct EvidenceHistoryItem Data;
     315    Data.Seconds = getInfo()->getTimestamp();
     316    Data.Value = atof(EvidenceServer::ToString(getInfo()));           
     317    Items[ItemNo].Live.append(Data);
     318   
     319    // Update largest and smallest value   
     320    if (Data.Value > Items[ItemNo].Largest) Items[ItemNo].Largest = Data.Value;
     321    if (Data.Value < Items[ItemNo].Smallest) Items[ItemNo].Smallest = Data.Value;   
     322  }
     323
     324  Locker.unlock();
     325
     326  // Do not call replot() directly from this thread!
    249327  emit(YEP());
    250328}
     
    255333//
    256334void Edd_Plot::UpdatePlot() {
    257 
    258   QMutexLocker Locker(&Mutex);
    259335
    260336  if (!YLogAction->isChecked()) {
     
    263339  else setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
    264340
     341  // Lock before accessing Items list
     342  QMutexLocker Locker(&Mutex);
     343
    265344  for (int ItemNo=0; ItemNo<Items.size(); ItemNo++) {
    266  
    267     double *x = new double [Items[ItemNo].Count];
    268     double *y = new double [Items[ItemNo].Count];
    269 
     345
     346    if (Items[ItemNo].Count == 0) continue;
     347
     348    if (StyleAction->isChecked()) Items[ItemNo].Signal->setStyle(QwtPlotCurve::Dots);
     349    else Items[ItemNo].Signal->setStyle(QwtPlotCurve::Lines);
     350
     351    int DataPoints = Items[ItemNo].Count + Items[ItemNo].Live.size();     
     352    double *x = new double [DataPoints];
     353    double *y = new double [DataPoints];
     354   
    270355    // Adapt time scale and normalize y scale if requested
    271     for (int i=0; i<Items[ItemNo].Count; i++) {
    272       x[i] = Items[ItemNo].x[i]/86400 + 40587.5 - 55000;
    273       y[i] = Items[ItemNo].y[i];
     356    for (int i=0; i<DataPoints; i++) {
     357      if (i < Items[ItemNo].Count) {
     358        x[i] = Items[ItemNo].x[i] / 86400.0 + 40587.5 - 55000;
     359        y[i] = Items[ItemNo].y[i];
     360      }
     361      else {
     362        x[i]= Items[ItemNo].Live[i-Items[ItemNo].Count].Seconds / 86400.0 + 40587.5 - 55000;
     363        y[i] = Items[ItemNo].Live[i-Items[ItemNo].Count].Value;
     364      }
     365
    274366      if (NormAction->isChecked()) {
    275         if (Items[ItemNo].Smallest != Items[ItemNo].Largest) y[i] = (Items[ItemNo].y[i] - Items[ItemNo].Smallest)/(Items[ItemNo].Largest-Items[ItemNo].Smallest);
     367        if (Items[ItemNo].Smallest != Items[ItemNo].Largest) y[i] = (y[i] - Items[ItemNo].Smallest)/(Items[ItemNo].Largest-Items[ItemNo].Smallest);
    276368        else y[i] = 1;
    277369      } 
     
    279371
    280372    // Plot datas
    281     Items[ItemNo].Signal->setData(x, y, Items[ItemNo].Count);
     373    Items[ItemNo].Signal->setData(x, y, DataPoints);
    282374    Items[ItemNo].Signal->show();
    283375    Zoomer->setZoomBase(Items[ItemNo].Signal->boundingRect());
     
    315407   
    316408//
    317 // Context menu and its functions
     409// Opening context menu
    318410//
    319411void Edd_Plot::contextMenuEvent(QContextMenuEvent *Event) {
     
    325417
    326418  Zoomer->zoom(0);
    327   emit YEP();
    328 }
    329 
     419  UpdatePlot();
     420}
     421
     422// Remove all items except last
    330423void Edd_Plot::MenuSingleTrace() {
    331424
     425  // Lock before accessing Items list
    332426  QMutexLocker Locker(&Mutex);
    333427
    334428  while (Items.size() > 1) { 
    335429    delete Items.last().Data;
     430    delete Items.last().LiveData;
    336431    delete Items.last().Signal;
    337432    delete[] Items.last().x;
     
    339434    Items.takeLast();
    340435  }
    341   emit(YEP());
    342 }
    343 
     436 
     437  Locker.unlock();
     438  UpdatePlot();
     439}
     440
     441// Save data of plot as test
     442void Edd_Plot::MenuSaveASCII() {
     443  QString Filename = QFileDialog::getSaveFileName(this,
     444     "Filename", ".", "Text files (*.txt *.ascii *.asc);;All files (*)");
     445  if (Filename.length() <= 0) return;
     446 
     447  QFile File(Filename);
     448  if (!File.open(QFile::WriteOnly | QIODevice::Text | QFile::Truncate)) {
     449    QMessageBox::warning(this, "Edd Message","Could not open file for writing.",QMessageBox::Ok);
     450    return;
     451  }
     452 
     453  // Lock before accessing Items list
     454  QMutexLocker Locker(&Mutex);
     455  QTextStream Stream(&File);
     456
     457   // Write x and y data for all signals to file
     458  for (int ItemNo=0; ItemNo<Items.size(); ItemNo++) {
     459    Stream << QString("# ")+Items[ItemNo].Data->getName() << endl;
     460    for (int i=0; i<Items[ItemNo].Signal->dataSize(); i++) {
     461      Stream << (int) Items[ItemNo].x[i] << " " << Items[ItemNo].Signal->y(i) << endl;
     462    }
     463  }
     464}
     465
     466// Print plot
    344467void Edd_Plot::MenuPrint() {
    345468
     
    354477}
    355478
     479// Save plot as image
    356480void Edd_Plot::MenuSave() {
    357481
     
    361485    QPixmap Pixmap = QPixmap::grabWidget(this);
    362486    if(!Pixmap.save(Filename)) {
    363       QMessageBox::warning(this, "ddd Message","Could not write image file.",QMessageBox::Ok);
     487      QMessageBox::warning(this, "Edd Message","Could not write image file.",QMessageBox::Ok);
    364488      remove(Filename.toAscii().data());
    365489    }
     
    367491}
    368492
    369 //
    370 // Main GUI
     493// Add new service by pasting name
     494void Edd_Plot::MenuPasteService() {
     495
     496  AddService(QApplication::clipboard()->text().toAscii().data());
     497}
     498
     499
     500//
     501// Main GUI (all widgets have ultimately Central as parent)
    371502//
    372503GUI::GUI() {
     504
     505  Edd_Indicator *Value;
     506  Edd_Plot *Graph;
     507  QString Text;
    373508 
    374509  // Set features of main window
    375510  Central = new QWidget(this);
    376511  setCentralWidget(Central);
    377   setStatusBar (new QStatusBar(this));
     512  setStatusBar(new QStatusBar(this));
    378513 
    379514   // TextBox for value
    380   Value = new Edd_Indicator((char *) "SQM/NSB", Central);
    381   Graph = new Edd_Plot((char *) "SQM/NSB", Central);
    382 
    383   Value1 = new Edd_Indicator((char *) "BIAS/VOLT/ID00/00-000", Central);
    384   //Graph1 = new Edd_Plot((char *) "BIAS/VOLT/ID00/00-000", Central);
     515  //Value = new Edd_Indicator((char *) "SQM/NSB", Central);
     516  //Graph = new Edd_Plot((char *) "SQM/NSB", Central);
     517  //Graph->AddService("BIAS/VOLT/ID00/00-000");
     518 
    385519
    386520  // Clock (updated every second)
     
    397531
    398532  MainWidget = new QWidget();
     533  MainLayout = new QGridLayout(MainWidget);
    399534
    400535  // Layout of all widgets
    401   MainLayout = new QGridLayout(MainWidget);
    402   MainLayout->addWidget(Value, 0, 0, 1, 1);
     536  //MainLayout->addWidget(Value, 0, 0, 1, 1);
    403537  //MainLayout->addWidget(Clock, 0, 1, 1, 1);
    404   MainLayout->addWidget(Graph, 1, 0, 1, 2);
     538  //MainLayout->addWidget(Graph, 1, 0, 1, 2);
    405539  //MainLayout->setColumnStretch(1, 10);
    406540 
    407   MainLayout->addWidget(Value1, 0, 1, 1, 1);
    408541  //MainLayout->addWidget(Clock, 0, 1, 1, 1);
    409542  //MainLayout->addWidget(Graph1, 2, 0, 1, 2);
    410543
     544  // Bias voltage page
    411545  BiasWidget = new QWidget();
    412546  BiasLayout = new QGridLayout(BiasWidget);
    413   for (int i=0; i<19; i++) {
    414     char *Item;
    415     if (asprintf(&Item, "BIAS/VOLT/ID00/00-%.3d", i) != -1) {
    416       Value = new Edd_Indicator(Item, NULL);
    417       BiasLayout->addWidget(Value, i%10, 0+i/10, 1, 1);     
    418       free(Item);
    419     }
    420     if (asprintf(&Item, "BIAS/VOLT/ID00/01-%.3d", i) != -1) {
    421       Value = new Edd_Indicator(Item, NULL);
    422       BiasLayout->addWidget(Value, i%10, 2+i/10, 1, 1);     
    423       free(Item);
    424     }
    425   }
    426 
     547  Graph = new Edd_Plot();
     548  for (int i=0; i<18; i++) {
     549    Text = Text.sprintf("BIAS/VOLT/ID00/00-%.3d",i);
     550    Value = new Edd_Indicator(Text);
     551    BiasLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1);
     552    Graph->AddService(Text);
     553
     554    Text = Text.sprintf("BIAS/VOLT/ID00/01-%.3d",i);
     555    Value = new Edd_Indicator(Text);
     556    BiasLayout->addWidget(Value, i%9+1, 2+i/9, 1, 1);
     557    Graph->AddService(Text);
     558  }
     559  BiasLayout->addWidget(Graph, 0, 4, 12, 3);
     560  Value = new Edd_Indicator("BIAS/Status");
     561  Value->setMaximumWidth(200);
     562  BiasLayout->addWidget(Value, 0, 0, 1, 3);     
     563
     564  // Environment page
    427565  EnvironmentWidget = new QWidget();
    428566  EnvironmentLayout = new QGridLayout(EnvironmentWidget);
     567  Value = new Edd_Indicator("ARDUINO/Status");
     568  Value->setMaximumWidth(200);
     569  EnvironmentLayout->addWidget(Value, 0, 0, 1, 3);     
     570
     571  Graph = new Edd_Plot();
    429572  for (int i=0; i<10; i++) {
    430     char *Item;
    431     if (asprintf(&Item, "ARDUINO/VAL%.2d", i) != -1) {
    432       Value = new Edd_Indicator(Item, NULL);
    433       EnvironmentLayout->addWidget(Value, i%5, i/5, 1, 1);     
    434       free(Item);
    435     }
    436   }
     573    Text = Text.sprintf("ARDUINO/VAL%.2d", i);
     574    Value = new Edd_Indicator(Text);
     575    EnvironmentLayout->addWidget(Value, i%5+1, i/5, 1, 1);
     576    Graph->AddService(Text);
     577  }
     578  EnvironmentLayout->addWidget(Graph, 0, 3, 7, 4);     
     579
     580  Value = new Edd_Indicator("SQM/NSB");
     581  EnvironmentLayout->addWidget(Value, 6, 0, 1, 1);     
    437582   
    438583  // Tab widget
     
    444589  // Menu bar
    445590  QMenu* Menu = menuBar()->addMenu("&Menu");
     591  Menu->addAction("New history plot", this, SLOT(MenuNewHistory()));
     592  Menu->addSeparator();
    446593  Menu->addAction("About", this, SLOT(MenuAbout()));
    447594  Menu->addSeparator();
     
    455602
    456603void GUI::MenuAbout() {
     604  QString Rev(SVN_REVISION);
     605  Rev.remove(0,1).chop(1);
     606 
    457607  QMessageBox::about(this, "About Edd","Evidence Data Display\n\n"
    458608    "Written by Oliver Grimm, IPP, ETH Zurich\n"
    459     "EMail: oliver.grimm@phys.ethz.ch\n"
    460     "This version compiled "__DATE__".\n"
    461     "subversion revision "SVN_REVISION".\n\n"
     609    "This version compiled "__DATE__" ("+Rev+")\n\n"
    462610    "Graphical user interface implemented with Qt.\n"
    463     "Evidence control system based on DIM (http://dim.web.cern.ch).");
    464      printf("Revision: $Revision$\n");
     611    "Evidence control system based on DIM (http://dim.web.cern.ch).\n\n"
     612    "Comments to oliver.grimm@phys.ethz.ch.");
     613}
     614
     615// Open request for new history plot
     616void GUI::MenuNewHistory() {
     617
     618  QStringList List;
     619  char *Name, *Format;
     620  int Type;
     621  bool OK;
     622
     623  // Find all services that are not history services and sort
     624  getServices("*");
     625  while ((Type = getNextService(Name, Format)) != 0) {
     626    if (Type==DimSERVICE && strstr(Name, ".hist")==NULL) List.append(Name);
     627  }
     628  List.sort();
     629
     630  // Open dialog and open history window
     631  QString Result = QInputDialog::getItem(this, "Edd Request",
     632    "Enter DIM service name", List, 0, true, &OK);
     633  if (OK && !Result.isEmpty()) {
     634    Result = Result.trimmed();
     635    if (Result.endsWith(".hist")) Result.chop(5);
     636    Edd_Plot *Plot = new Edd_Plot(Result);
     637    Plot->show();
     638  }
    465639}
    466640
     
    483657 
    484658  GUI MainWindow;
    485   MainWindow.setGeometry(100, 100, 800, 500);
     659  MainWindow.setGeometry(100, 100, 800, 650);
    486660  MainWindow.setWindowTitle("Edd - Evidence Data Display");
    487661  MainWindow.show();
  • Evidence/Edd/Edd.h

    r138 r139  
    3232    DimStampedInfo *Data;
    3333
     34    QMenu *Menu;
    3435    QPoint dragStart;
    35        
     36    QwtPlot *LastPlot;
     37       
    3638    void infoHandler();
    3739    void mousePressEvent(QMouseEvent *);
     
    4042       
    4143  public:
    42     Edd_Indicator(char*, QWidget* = NULL);
     44    Edd_Indicator(QString, QWidget * = NULL);
    4345    ~Edd_Indicator();
     46
     47  private slots:
     48    void contextMenuEvent(QContextMenuEvent *);   
     49    void MenuCopyService();
    4450
    4551  signals:
     
    5359    struct PlotItem {
    5460      DimInfo *Data;
     61      DimInfo *LiveData;
    5562      QwtPlotCurve *Signal;
    56       double *x;
     63      int *x;
    5764      double *y;
    5865      int Count;
    5966      double Smallest;
    6067      double Largest;
     68      QList<struct EvidenceHistoryItem> Live;
    6169    };
    6270
     
    6775    QAction *YLogAction;
    6876    QAction *NormAction;
     77    QAction *StyleAction;
    6978   
    7079    QwtPlotPanner *Panner;
     
    7382    QwtLegend *Legend;
    7483   
    75     void AddService(char *);
    7684    void infoHandler();   
    7785    void dragEnterEvent(QDragEnterEvent *);
     
    7987
    8088  public:
    81     Edd_Plot(char *, QWidget * = NULL);
     89    Edd_Plot(QString = QString(), QWidget * = NULL);
    8290    ~Edd_Plot();
     91    void AddService(QString);
    8392
    8493  private slots:
     
    8897    void MenuZoomOut();
    8998    void MenuSingleTrace();       
     99    void MenuSaveASCII();
    90100    void MenuSave();
    91101    void MenuPrint();
    92 
     102    void MenuPasteService();
     103 
    93104 signals:
    94105     void YEP();
     
    97108
    98109// Main window class
    99 class GUI: public QMainWindow {
     110class GUI: public QMainWindow, public DimBrowser {
    100111    Q_OBJECT
    101112
    102     Edd_Indicator *Value, *Value1;
    103     Edd_Plot *Graph, *Graph1;
    104113    QwtAnalogClock *Clock;
    105114       
     
    117126  private slots:
    118127    void MenuAbout();
     128    void MenuNewHistory();
    119129};
    120130
Note: See TracChangeset for help on using the changeset viewer.