Index: /fact/Evidence/GUI.cc
===================================================================
--- /fact/Evidence/GUI.cc	(revision 17036)
+++ /fact/Evidence/GUI.cc	(revision 17037)
@@ -50,5 +50,5 @@
 	// If service is array and no index given, try to find out how many indices exist and add all
 	if (FromIndex == -1 && Format.size() == 1) {
-	  DimCurrentInfo X(Service, NULL, 0);
+	  DimCurrentInfo X(Service, (char *) NULL, 0);
 	  
 	  FromIndex = 0;
@@ -336,8 +336,8 @@
   // Widget properties
   setAcceptDrops(true);
-  setAxisScaleDraw(QwtPlot::xBottom, new EddTimeScale);
-
-  // Update time range on plot when axis change	(update() results in paintEvent())
-  connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SLOT(update()));
+
+  // Horizontal time scale
+  setAxisScaleDraw(QwtPlot::xBottom, new EddDateScale());
+  connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SLOT(ScaleUpdate()));
 
   // Additonal context menu items
@@ -354,5 +354,5 @@
   Menu->insertAction(Menu->actions().value(10), Action); 
    
-  // Set timer to regularly update plot if new data available
+  // Set timer update plot after new data added
   SingleShot = new QTimer(this);
   connect(SingleShot, SIGNAL(timeout()), this, SLOT(UpdatePlot()));
@@ -390,12 +390,4 @@
   List.append(N);
 
-  // Use custom legend widget
-  EddLegend *Legend = new EddLegend(N.Curve, this);
-  legend()->remove(N.Curve);
-  legend()->insert(N.Curve, (QWidget *) Legend);
-
-  // Context menu might delete curve and legend -> seg fault if using direct connection, as legend item deleted
-  connect(Legend, SIGNAL(DeleteCurve(QwtPlotCurve *)), this, SLOT(RemoveService(QwtPlotCurve *)), Qt::QueuedConnection);
-
   // Get history
   struct EddDim::HistItem Hist = Handler->GetHistory(Name);
@@ -403,91 +395,12 @@
   for (int i=0; i<Hist.DataText.size(); i++) {
     if (Hist.DataText[i].second.size() > N.Index) {
-	  AddPoint(List.size()-1, Hist.DataText[i].first, Hist.DataText[i].second.at(N.Index).toFloat());
+	  AddPoint(List.size()-1, double(Hist.DataText[i].first)*1000, Hist.DataText[i].second.at(N.Index).toFloat());
 	}
   }
-
+ 
   // Subscribe to service and start updating plot after 100 ms (to allow addition of other curves)
   Handler->Subscribe(Name, this, Index);
   SingleShot->start(100);
 }
-
-// Update widget (must happen in GUI thread)
-void EddPlot::Update(const QString &Name, int Time, const QByteArray &, const QString &Format, const QString &Text, int Index) {
-
-  for (int ItemNo=0; ItemNo<List.size(); ItemNo++) if (List[ItemNo].Name==Name && List[ItemNo].Index==Index) {
-
- 	// Append data if service available
-	if (SetStatus(this, Name, Time, Format)) AddPoint(ItemNo, Time, atof(Text.toAscii().data()));
-	NewData = true;
-  }
-}
-
-// Add text indicating time range to plot
-void EddPlot::paintEvent(QPaintEvent *) {
-
-  QString Text;
-  QFont Font;
-  QPainter Painter(this);
-  
-  Text = QDateTime::fromTime_t((int) axisScaleDiv(QwtPlot::xBottom)->lowerBound()).toString("d-MMM-yyyy hh:mm:ss") + " to " + QDateTime::fromTime_t((int) axisScaleDiv(QwtPlot::xBottom)->upperBound()).toString("d-MMM-yyyy hh:mm:ss");
-
-  Font.setPointSize(6);  
-  Painter.setFont(Font);
-  Painter.drawText(0, height(), Text);
-}
-
-// Drag and drop methods
-void EddPlot::dragEnterEvent(QDragEnterEvent *Event) {
-    
-  if (Event->mimeData()->hasFormat("Edd/Service")) Event->acceptProposedAction();
-}
-
-void EddPlot::dropEvent(QDropEvent *Event) {
-
-  QByteArray D(Event->mimeData()->data("Edd/Service"));
-  AddService(D.left(D.lastIndexOf(' ')), D.right(D.size()-D.lastIndexOf(' ')).toInt());
-}
-
-// Add new service by pasting name
-void EddPlot::MenuPasteService() {
-
-  const QMimeData *D = QApplication::clipboard()->mimeData();
-  if (!D->hasFormat("Edd/Service")) return;
-  
-  QByteArray E(D->data("Edd/Service"));
-  AddService(E.left(E.lastIndexOf(' ')), E.right(E.size()-E.lastIndexOf(' ')).toInt());
-}
-
-// Show last hour/last day
-void EddPlot::MenuShowLastHour() {
-
-  setAxisScale(QwtPlot::xBottom, time(NULL)-60*60, time(NULL)+60);
-  replot();
-}
-
-void EddPlot::MenuShowLastDay() {
-
-  setAxisScale(QwtPlot::xBottom, time(NULL)-24*3600, time(NULL)+3600);
-  replot();
-}
-
-void EddPlot::MenuAllAsText() {
-
-  QMainWindow *M = new QMainWindow;
-  M->setCentralWidget(new QWidget(M));
-  M->setStatusBar(new QStatusBar(M));
-  M->setAttribute(Qt::WA_DeleteOnClose);
-  M->setWindowTitle("Edd Services");
-
-  QGridLayout *Layout = new QGridLayout(M->centralWidget());
-
-  for (int i=0; i<List.size(); i++) {
-      Layout->addWidget(new EddLineDisplay(List[i].Name, List[i].Index), i/10, i%10);
-  }
-
-  M->resize(400,450);
-  M->show();
-}
-
 
 // Remove subscription
@@ -502,4 +415,96 @@
 }
 
+// Update widget (must happen in GUI thread)
+void EddPlot::Update(const QString &Name, int Time, const QByteArray &, const QString &Format, const QString &Text, int Index) {
+
+  for (int ItemNo=0; ItemNo<List.size(); ItemNo++) if (List[ItemNo].Name==Name && List[ItemNo].Index==Index) {
+
+ 	// Append data if service available
+	if (SetStatus(this, Name, Time, Format)) AddPoint(ItemNo, (double) Time*1000, atof(Text.toAscii().data()));
+	NewData = true;
+  }
+}
+
+// Add text indicating time range to plot
+void EddPlot::ScaleUpdate() {
+
+  QwtText Text;
+  QFont Font;
+  
+  // Set footer
+  Text = QDateTime::fromMSecsSinceEpoch(axisScaleDiv(QwtPlot::xBottom).lowerBound()).toString("d-MMM-yyyy hh:mm:ss") + " to " + QDateTime::fromMSecsSinceEpoch(axisScaleDiv(QwtPlot::xBottom).upperBound()).toString("d-MMM-yyyy hh:mm:ss");
+
+  Font.setPointSize(6);
+  Text.setFont(Font);
+  setFooter(Text);
+}
+
+// Drag and drop methods
+void EddPlot::dragEnterEvent(QDragEnterEvent *Event) {
+    
+  if (Event->mimeData()->hasFormat("Edd/Service")) Event->acceptProposedAction();
+}
+
+void EddPlot::dropEvent(QDropEvent *Event) {
+
+  QByteArray D(Event->mimeData()->data("Edd/Service"));
+  AddService(D.left(D.lastIndexOf(' ')), D.right(D.size()-D.lastIndexOf(' ')).toInt());
+}
+
+// Add new service by pasting name
+void EddPlot::MenuPasteService() {
+
+  const QMimeData *D = QApplication::clipboard()->mimeData();
+  if (!D->hasFormat("Edd/Service")) return;
+  
+  QByteArray E(D->data("Edd/Service"));
+  AddService(E.left(E.lastIndexOf(' ')), E.right(E.size()-E.lastIndexOf(' ')).toInt());
+}
+
+// Show last hour/last day
+void EddPlot::MenuShowLastHour() {
+
+  setAxisScale(QwtPlot::xBottom, (time(NULL)-60*60)*1000, (time(NULL)+60)*1000);
+  replot();
+}
+
+void EddPlot::MenuShowLastDay() {
+
+  setAxisScale(QwtPlot::xBottom, (time(NULL)-24*3600)*1000, (time(NULL)+3600)*1000);
+  replot();
+}
+
+void EddPlot::MenuAllAsText() {
+
+  QMainWindow *M = new QMainWindow;
+  M->setCentralWidget(new QWidget(M));
+  M->setStatusBar(new QStatusBar(M));
+  M->setAttribute(Qt::WA_DeleteOnClose);
+  M->setWindowTitle("Edd Services");
+
+  QGridLayout *Layout = new QGridLayout(M->centralWidget());
+
+  for (int i=0; i<List.size(); i++) {
+      Layout->addWidget(new EddLineDisplay(List[i].Name, List[i].Index), i/10, i%10);
+  }
+
+  M->resize(400,450);
+  M->show();
+}
+
+//
+// Reimplementation of QwtDateScaleDraw::label()
+//
+QwtText EddDateScale::label(double Value) const {
+
+  QString Format;
+   
+  if (scaleDiv().range() > 30*24*60*60*1000.0) Format = "d-MMM\n yyyy";
+  else if (scaleDiv().range() > 1*24*60*60*1000.0) Format = "  h 'h'\nd-MMM";
+  else if (scaleDiv().range() > 60*60*1000.0) Format = "hh:mm";
+  else Format = "hh:mm:ss";  
+
+  return QwtDate::toString(toDateTime(Value), Format, QwtDate::FirstThursday);
+}
 
 //////////////////
@@ -514,14 +519,14 @@
   setAutoReplot(false);
   setCanvasBackground(EddPlotBackgroundColor);
-  setMargin(15);
   NewData = false;
 
   // Plot navigation
   Zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,canvas());
-  connect(Zoomer, SIGNAL(zoomed(const QwtDoubleRect &)), this, SLOT(HandleZoom(const QwtDoubleRect &)));
-  connect(Zoomer, SIGNAL(zoomed(const QwtDoubleRect &)), this, SLOT(ReDoStats()));
+  Zoomer->setTrackerMode(QwtPicker::AlwaysOff);
+  connect(Zoomer, SIGNAL(zoomed(const QRectF &)), this, SLOT(HandleZoom(const QRectF &)));
+  connect(Zoomer, SIGNAL(zoomed(const QRectF &)), this, SLOT(ReDoStats()));
 
   Magnifier = new QwtPlotMagnifier(canvas());
-  Magnifier->setMouseButton(Qt::NoButton,Qt::NoButton);
+  Magnifier->setMouseButton(Qt::NoButton, Qt::NoModifier);
   Magnifier->setZoomInKey(Qt::Key_M, Qt::NoModifier);
   Magnifier->setZoomOutKey(Qt::Key_M, Qt::ShiftModifier);
@@ -531,13 +536,15 @@
   connect(Panner, SIGNAL(panned(int, int)), this, SLOT(ReDoStats()));
 
-  Picker = new QwtPicker(QwtPicker::CornerToCorner|QwtPicker::RectSelection, QwtPicker::RectRubberBand, QwtPicker::AlwaysOff, this);
-  connect(Picker, SIGNAL(selected(const QwtPolygon &)), SLOT(MouseSelection(const QwtPolygon &)));
+  Picker = new QwtPicker(QwtPicker::RectRubberBand, QwtPicker::AlwaysOff, this);
+  Picker->setStateMachine(new QwtPickerDragRectMachine);
+  connect(Picker, SIGNAL(selected(const QPolygon &)), SLOT(MouseSelection(const QPolygon &)));
 
   // Grid and legend
   Grid = new QwtPlotGrid;
-  Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
+  Grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
   Grid->attach(this);
   
-  insertLegend(new QwtLegend(), QwtPlot::TopLegend, 0.3);
+  Legend = new EddLegend();
+  insertLegend(Legend, QwtPlot::TopLegend, 0.3);
 
   // Marker for statistics text
@@ -599,5 +606,5 @@
     // Calculate mean and sigma for data points currently visible	
 	for (int j=0; j<Items[i].y.size(); j++) {
-	  if (!axisScaleDiv(QwtPlot::xBottom)->contains(Items[i].x[j])) continue;
+	  if (!axisScaleDiv(QwtPlot::xBottom).contains(Items[i].x[j])) continue;
 	  Mean += Items[i].y[j];
 	  Sigma += Items[i].y[j]*Items[i].y[j];
@@ -620,5 +627,5 @@
   QwtText text(Text);
   text.setFont(QFont("Helvetica", 8));
-  Stats->setValue(axisScaleDiv(QwtPlot::xBottom)->upperBound(), axisScaleDiv(QwtPlot::yLeft)->upperBound());
+  Stats->setValue(axisScaleDiv(QwtPlot::xBottom).upperBound(), axisScaleDiv(QwtPlot::yLeft).upperBound());
   Stats->setLabel(text);
 
@@ -630,10 +637,7 @@
 void EddBasePlot::UpdatePlot() {
 
-  double Lower = axisScaleDiv(QwtPlot::xBottom)->lowerBound();
-  double Upper = axisScaleDiv(QwtPlot::xBottom)->upperBound();
+  double Lower = axisScaleDiv(QwtPlot::xBottom).lowerBound();
+  double Upper = axisScaleDiv(QwtPlot::xBottom).upperBound();
   double MaxTime = DBL_MIN;
-  static QwtSymbol Symbol, Sym1;
-  Symbol.setStyle(QwtSymbol::Ellipse);
-  Symbol.setSize(4);
 
   // Only update if called by timer if new data is available
@@ -645,5 +649,5 @@
     setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
   }
-  else setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
+  else setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine);
 
   for (int ItemNo=0; ItemNo<Items.size(); ItemNo++) {
@@ -654,6 +658,11 @@
 
 	// Set symbol if requested
-    if (StyleAction->isChecked()) Items[ItemNo].Signal->setSymbol(Symbol);
-    else Items[ItemNo].Signal->setSymbol(Sym1);
+    if (StyleAction->isChecked()) {
+	  QwtSymbol *Symbol = new QwtSymbol();
+	  Symbol->setStyle(QwtSymbol::Ellipse);
+	  Symbol->setSize(4);
+	  Items[ItemNo].Signal->setSymbol(Symbol);
+	}
+    else Items[ItemNo].Signal->setSymbol(new QwtSymbol);
 
 	// Determine number of data points
@@ -675,5 +684,5 @@
 
     // Plot data
-    Items[ItemNo].Signal->setData(Items[ItemNo].x.data(), y, DataPoints);
+    Items[ItemNo].Signal->setSamples(Items[ItemNo].x.data(), y, DataPoints);
     Items[ItemNo].Signal->show();
 	delete[] y;
@@ -704,7 +713,6 @@
   struct PlotItem N;
 
-  N.Signal = new QwtPlotCurve;
+  N.Signal = new QwtPlotCurve(Title);
   N.Signal->attach(this);
-  N.Signal->setTitle(Title);
   N.Signal->setPen(QColor(LineColors[Items.size() % (sizeof(LineColors)/sizeof(Qt::GlobalColor))]));
   N.Largest = DBL_MIN;
@@ -712,5 +720,22 @@
   Items.append(N);
   
+  QVariant ItemInfo	= itemToInfo(N.Signal);
+  ((EddLegendLabel *) Legend->legendWidget(ItemInfo))->Curve = N.Signal;
+ 
+  // Context menu might delete curve and legend -> seg fault if using direct connection, as legend item deleted
+  connect(((EddLegendLabel *) Legend->legendWidget(ItemInfo)), SIGNAL(DeleteCurve(QwtPlotCurve *)), SLOT(RemoveService(QwtPlotCurve *)), Qt::QueuedConnection);
+
   return N.Signal;
+}
+
+// Remove item
+void EddBasePlot::DeleteCurve(QwtPlotCurve *Curve) {
+
+  for (int i=0; i<Items.size(); i++) if (Items[i].Signal == Curve) {
+	delete Curve;
+	Items.takeAt(i);
+	break;
+  }
+  UpdatePlot();
 }
 
@@ -737,19 +762,20 @@
 
 // Rescale plot in case selection has been made outside the canvas
-void EddBasePlot::MouseSelection(const QPolygon &P) {
+void EddBasePlot::MouseSelection(const QPolygon &P_integer) {
  
-  QwtDoubleInterval xPlot, xMouse, yPlot, yMouse; 
-
+  QwtInterval xPlot, xMouse, yPlot, yMouse; 
+  QPolygonF P(P_integer);
+  
   // Shift selected rectangle so that upper left corner is 0/0 on canvas
-  QRect R = P.boundingRect().translated(-plotLayout()->canvasRect().topLeft());
+  QRectF R = P.boundingRect().translated(-plotLayout()->canvasRect().topLeft());
 
   // Current axis intervals
-  xPlot = axisScaleDiv(QwtPlot::xBottom)->interval();
-  yPlot = axisScaleDiv(QwtPlot::yLeft)->interval();
+  xPlot = axisScaleDiv(QwtPlot::xBottom).interval();
+  yPlot = axisScaleDiv(QwtPlot::yLeft).interval();
   
   // Selected axis intervals
-  xMouse = QwtDoubleInterval(invTransform(QwtPlot::xBottom, R.left()),
+  xMouse = QwtInterval(invTransform(QwtPlot::xBottom, R.left()),
   		invTransform(QwtPlot::xBottom, R.right()));
-  yMouse = QwtDoubleInterval(invTransform(QwtPlot::yLeft, R.bottom()),
+  yMouse = QwtInterval(invTransform(QwtPlot::yLeft, R.bottom()),
 		invTransform(QwtPlot::yLeft, R.top()));
 
@@ -773,8 +799,8 @@
   // Rescale y axis (increase range if selected rectangle larger than axis area)
   if (R.right() < 0) {
-	if (yMouse.maxValue() > axisScaleDiv(QwtPlot::yLeft)->upperBound()) {
+	if (yMouse.maxValue() > axisScaleDiv(QwtPlot::yLeft).upperBound()) {
 	  yMouse.setMaxValue(yMouse.maxValue() + yPlot.width());
 	}
-	if (yMouse.minValue() < axisScaleDiv(QwtPlot::yLeft)->lowerBound()) {
+	if (yMouse.minValue() < axisScaleDiv(QwtPlot::yLeft).lowerBound()) {
 	  yMouse.setMinValue(yMouse.minValue() - yPlot.width());
 	}
@@ -785,8 +811,8 @@
   // Rescale x axis (increase range if selected rectangle larger than axis area)
   if (R.top() > plotLayout()->canvasRect().height()) {
-	if (xMouse.maxValue() > axisScaleDiv(QwtPlot::xBottom)->upperBound()) {
+	if (xMouse.maxValue() > axisScaleDiv(QwtPlot::xBottom).upperBound()) {
 	  xMouse.setMaxValue(xMouse.maxValue() + xPlot.width());
 	}
-	if (xMouse.minValue() < axisScaleDiv(QwtPlot::xBottom)->lowerBound()) {
+	if (xMouse.minValue() < axisScaleDiv(QwtPlot::xBottom).lowerBound()) {
 	  xMouse.setMinValue(xMouse.minValue() - xPlot.width());
 	}
@@ -800,5 +826,5 @@
 
 // Reset graph axes to autoscale when fully unzoomed
-void EddBasePlot::HandleZoom(const QwtDoubleRect &) {
+void EddBasePlot::HandleZoom(const QRectF &) {
 
   if(Zoomer->zoomRectIndex() == 0) {
@@ -809,4 +835,24 @@
   UpdatePlot();
 }
+
+// Double clicking hightlights curve
+void EddBasePlot::mouseDoubleClickEvent (QMouseEvent *Event) {
+	
+  double Dist, MinDistance = std::numeric_limits<double>::infinity();
+  int Index = -1;
+
+  // Check which curve is closest
+  for (int i=0; i<Items.size(); i++) {
+	if (Items[i].Signal->closestPoint(Event->pos(), &Dist) != -1 && Dist < MinDistance) {
+	  MinDistance = Dist;
+	  Index = i;
+	}
+  }
+
+  // Toggle 'thick line' action
+  if (Index != -1) {
+	((EddLegendLabel *) Legend->legendWidget(itemToInfo(Items[Index].Signal)))->ThickLineAction->toggle();
+  }
+} 
     
 // Opening context menu
@@ -820,16 +866,4 @@
 
   Zoomer->zoom(0);
-  UpdatePlot();
-}
-
-
-// Remove item
-void EddBasePlot::DeleteCurve(QwtPlotCurve *Curve) {
-
-  for (int i=0; i<Items.size(); i++) if (Items[i].Signal == Curve) {
-	delete Curve;
-	Items.takeAt(i);
-	break;
-  }
   UpdatePlot();
 }
@@ -863,6 +897,7 @@
   for (int ItemNo=0; ItemNo<Items.size(); ItemNo++) {
     Stream << QString("# ") + Items[ItemNo].Signal->title().text() + ".hist" << endl;
-    for (int i=0; i<Items[ItemNo].Signal->dataSize(); i++) {
-      Stream << Items[ItemNo].x.at(i) << " " << Items[ItemNo].Signal->y(i) << endl;
+    for (unsigned int i=0; i<Items[ItemNo].Signal->dataSize(); i++) {
+      //Stream << Items[ItemNo].x.at(i) << " " << Items[ItemNo].Signal->y(i) << endl;
+      Stream << Items[ItemNo].x.at(i) << " " << Items[ItemNo].Signal->sample(i).y() << endl;
     }
   }
@@ -908,4 +943,5 @@
     "Pan\tShift and left mouse button\n\n"
 	"ESC cancels selection\n"
+	"Double-clicking highlights nearest curve\n"
     "Cursor keys move mouse\n\n"
 	"Statistics are calculated over the current x axis extend\n\n"
@@ -915,9 +951,16 @@
 
 
-////////////////
-// Edd Legend //
-////////////////
-
-EddLegend::EddLegend(QwtPlotCurve *Curve, EddPlot *Plot): Curve(Curve), Plot(Plot) {
+////////////////////////////////
+// Edd Legend and LegendLabel //
+////////////////////////////////
+
+// Reimplementation to return EddLegendLabel widget
+QWidget *EddLegend::createWidget(const QwtLegendData &) const {
+
+  return new EddLegendLabel();
+}
+	
+// Constructor for EddLegendLabel class
+EddLegendLabel::EddLegendLabel() {
 
   // Context menu
@@ -925,13 +968,17 @@
   Menu->addAction("Open in new history", this, SLOT(MenuOpenHistory()));
   Menu->addAction("Copy service", this, SLOT(MenuCopyService()));
-  Menu->addAction("Normal line", this, SLOT(MenuNormalLine()));
-  Menu->addAction("Thick line", this, SLOT(MenuThickLine()));
+
+  ThickLineAction = new QAction("Thick line", this);
+  ThickLineAction->setCheckable(true);
+  connect(ThickLineAction, SIGNAL(toggled(bool)), SLOT(MenuThickLine(bool)));
+  Menu->addAction(ThickLineAction);
+
   Menu->addAction("Remove curve", this, SLOT(MenuRemove()));
-}
-
-//
+
+  Curve = NULL;
+}
+
 // Opening context menu
-//
-void EddLegend::contextMenuEvent(QContextMenuEvent *Event) {
+void EddLegendLabel::contextMenuEvent(QContextMenuEvent *Event) {
  
   Menu->exec(Event->globalPos());
@@ -939,5 +986,5 @@
 
 // Handling of mouse press event: Register start position for drag
-void EddLegend::mousePressEvent(QMouseEvent *Event) {
+void EddLegendLabel::mousePressEvent(QMouseEvent *Event) {
 
   if (Event->button() == Qt::LeftButton) dragStart = Event->pos();
@@ -945,5 +992,5 @@
 
 // Handling of dragging (Drag and MimeData will be deleted by Qt)
-void EddLegend::mouseMoveEvent(QMouseEvent *Event) {
+void EddLegendLabel::mouseMoveEvent(QMouseEvent *Event) {
 
   if ((Event->buttons() & Qt::LeftButton) == 0) return;
@@ -962,5 +1009,5 @@
 
 // Handling of mouse release event: Open history
-void EddLegend::mouseReleaseEvent(QMouseEvent *Event) {
+void EddLegendLabel::mouseReleaseEvent(QMouseEvent *Event) {
 
   if (Event->button() != Qt::LeftButton) return;
@@ -974,5 +1021,5 @@
 
 // Menu: Open history plot
-void EddLegend::MenuOpenHistory() {
+void EddLegendLabel::MenuOpenHistory() {
 
   QString D(text().text());
@@ -984,5 +1031,5 @@
 
 // Menu: Copy service name
-void EddLegend::MenuCopyService() {
+void EddLegendLabel::MenuCopyService() {
 
   QString D(text().text());
@@ -995,24 +1042,26 @@
 }
 
-// Menu: Normal line width
-void EddLegend::MenuNormalLine() {
-
+// Menu: Thick line width
+void EddLegendLabel::MenuThickLine(bool State) {
+
+  if (Curve == NULL) {
+	printf("Warning: No QwtPlotCurve set in EddLegendLabel::MenuThickLine(), programming error\n");
+	return;
+  }
+
+  // Set pxel width of curve
   QPen Pen = Curve->pen();
-  Pen.setWidth(1);
+  Pen.setWidth(State ? 4:1);
   Curve->setPen(Pen);
   Curve->plot()->replot();
+  
+  // Highlight legend entry
+  QFont Font = font();
+  Font.setWeight(State ? QFont::Bold:QFont::Normal);
+  setFont(Font);
 }
 
 // Menu: Normal line width
-void EddLegend::MenuThickLine() {
-
-  QPen Pen = Curve->pen();
-  Pen.setWidth(4);
-  Curve->setPen(Pen);
-  Curve->plot()->replot();
-}
-
-// Menu: Normal line width
-void EddLegend::MenuRemove() {
+void EddLegendLabel::MenuRemove() {
 
   emit(DeleteCurve(Curve));
@@ -1031,5 +1080,4 @@
   setAttribute(Qt::WA_DeleteOnClose);
   setAutoFillBackground(true);
-  //setText("connecting...");
   document()->setMaximumBlockCount(1000);
   Accumulate = true;
Index: /fact/Evidence/GUI.h
===================================================================
--- /fact/Evidence/GUI.h	(revision 17036)
+++ /fact/Evidence/GUI.h	(revision 17037)
@@ -17,9 +17,9 @@
 #include <qwt_plot_layout.h>
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
 #include <qwt_symbol.h>
 #include <qwt_plot_marker.h>
-#include <qwt_data.h>
 #include <qwt_color_map.h>
+#include <qwt_date_scale_draw.h>
 
 #include <limits>
@@ -44,5 +44,6 @@
 
 // Base class for Edd plot
-// DeleteCurve() is pure virtual and needs to be implemented iin the application class
+// RemoveService() is pure virtual and needs to be implemented in the application class,
+// it will be called through signal by context menu of legend entries 
 class EddBasePlot: public QwtPlot {
   Q_OBJECT
@@ -74,7 +75,8 @@
 	QwtPlotMagnifier *Magnifier;
     QwtPicker *Picker;
-	QwtDoubleRect BBox;
+	QRectF BBox;
 	QwtPlotMarker *Stats;
-	 	
+	class EddLegend *Legend;
+ 	
   public:
     EddBasePlot(QWidget * = NULL);
@@ -84,4 +86,5 @@
 	bool NewData;
 	QwtPlotCurve *NewCurve(QwtText);
+	virtual void RemoveService(QwtPlotCurve *) = 0;
 	void DeleteCurve(QwtPlotCurve *);
 	void ClearCurve(unsigned int);
@@ -93,6 +96,7 @@
   private slots:
 	void ReDoStats();
-    void HandleZoom(const QwtDoubleRect &);
-	void MouseSelection(const QwtPolygon &);
+    void HandleZoom(const QRectF &);
+	void MouseSelection(const QPolygon &);
+	void mouseDoubleClickEvent(QMouseEvent *); 
 	void contextMenuEvent(QContextMenuEvent *);
     void MenuSetUpdateRate();        
@@ -154,28 +158,4 @@
     Q_OBJECT
 
-	// Time scale for axis
-	class EddTimeScale: public QwtScaleDraw {
-
-	  public:
-		EddTimeScale() {}
-
-		virtual QwtText label(double v) const {
-		  // Adapt text format to time span 
-		  QString Format;
-		  if (scaleDiv().range() < 60*60) Format = "hh' h\n'mm:ss";
-		  else if (scaleDiv().range() < 24*60*60) Format = "hh:mm";
-		  else if (scaleDiv().range() < 30*24*60*60) Format = "h' h\n'd-MMM";
-		  else Format = "d-MMM'\n'yyyy";
-
-		  // Generate text
-		  QwtText Text = QDateTime::fromTime_t((int) v).toString(Format);
-		  QFont Font = Text.font();
-		  Font.setPointSize(7);
-		  Text.setFont(Font);
-
-    	  return Text;
-		}
-	};
-
     struct ItemDetails {
       QString Name;
@@ -186,4 +166,5 @@
 
   private:
+    //EddDateScale *Scale;
 	QwtLegend *Legend;
 	QTimer *SingleShot;
@@ -192,5 +173,4 @@
     void dragEnterEvent(QDragEnterEvent *);
     void dropEvent(QDropEvent *);
-	void paintEvent(QPaintEvent *);
 	 	
   public:
@@ -202,6 +182,8 @@
   public slots:
 	void RemoveService(QwtPlotCurve *);
-
-  private slots:
+    void borderPath(QRect) {}; //Dummy method for qwtPicker, prevents QMetaObject::invokeMethod: No such method EddPlot::borderPath(QRect)
+   
+  private slots:
+    void ScaleUpdate();
     void MenuPasteService();
 	void MenuShowLastHour();
@@ -210,16 +192,26 @@
 };
 
-
-// Legend
-class EddLegend: public QwtLegendItem {
+// Scale showing date and time
+class EddDateScale: public QwtDateScaleDraw {
+
+  public:
+	QwtText label(double) const;
+};
+
+// Legend and legend label with protected methods implemented
+class EddLegend: public QwtLegend {
+
+  protected:
+	QWidget *createWidget(const QwtLegendData &) const;
+};
+
+class EddLegendLabel: public QwtLegendLabel {
     Q_OBJECT
 
     QMenu *Menu;
     QPoint dragStart;
-	QwtPlotCurve *Curve;
-	EddPlot *Plot;
-
-  public:
-	EddLegend(QwtPlotCurve *, EddPlot *);
+	
+  public:
+	EddLegendLabel();
 
 	void contextMenuEvent(QContextMenuEvent *);
@@ -228,9 +220,11 @@
     void mouseMoveEvent(QMouseEvent *);
 	
+	QwtPlotCurve *Curve;
+	QAction *ThickLineAction;
+
   private slots:
 	void MenuOpenHistory();
 	void MenuCopyService();
-	void MenuNormalLine();
-	void MenuThickLine();
+	void MenuThickLine(bool);
 	void MenuRemove();
 	
Index: /fact/tools/Edd/Edd.cc
===================================================================
--- /fact/tools/Edd/Edd.cc	(revision 17036)
+++ /fact/tools/Edd/Edd.cc	(revision 17037)
@@ -85,5 +85,5 @@
   N.Channel = Channel;
   N.Trigger = new QwtPlotMarker();
-  N.Trigger->setSymbol(QwtSymbol(QwtSymbol::Diamond, QBrush(N.Curve->pen().color()), N.Curve->pen(), QSize(10,10)));
+  N.Trigger->setSymbol(new QwtSymbol(QwtSymbol::Diamond, QBrush(N.Curve->pen().color()), N.Curve->pen(), QSize(10,10)));
   N.Trigger->attach(this);
 
@@ -778,5 +778,5 @@
 
   for (int i=0; i<Data.size(); i++) {
-	Pixel[i]->setPalette(QPalette(Map.color(QwtDoubleInterval(300, 400), Data[i])));
+	Pixel[i]->setPalette(QPalette(Map.color(QwtInterval(300, 400), Data[i])));
   }
 }
@@ -1053,4 +1053,8 @@
   static bool AlarmServerWarned = false;
 
+
+  // Removed 19 August 2013
+  return;
+
   // === Check service Alarm/MasterAlarm ===
   DimCurrentInfo MasterAlarm("Alarm/MasterAlarm", -1);
Index: /fact/tools/Edd/Edd.h
===================================================================
--- /fact/tools/Edd/Edd.h	(revision 17036)
+++ /fact/tools/Edd/Edd.h	(revision 17037)
@@ -49,5 +49,6 @@
   public slots:
 	void OpenRawFile(QString=QString());
-	
+	void RemoveService(QwtPlotCurve *) {};
+		
   signals:
 	void PixelData(QVector<double>);
Index: /fact/tools/Scripts/Logon
===================================================================
--- /fact/tools/Scripts/Logon	(revision 17036)
+++ /fact/tools/Scripts/Logon	(revision 17037)
@@ -7,7 +7,6 @@
 if [ -z "$DIMDIR" ]; then export DIMDIR=/usr/local/dim/; fi
 if [ -z "$QWTDIR" ]; then export QWTDIR=/usr/local/qwt/; fi
-if [ -z "$QTDIR" ]; then export QTDIR=/usr/local/Trolltech/Qt-4.6.2; fi
 
 #Set paths
 export LD_LIBRARY_PATH=$QWTDIR/lib:$DIMDIR/linux:$LD_LIBRARY_PATH
-export PATH=.:$DIMDIR/linux:$QTDIR/bin:$PATH
+export PATH=.:$DIMDIR/linux:$PATH
