Changeset 17039 for fact/Evidence


Ignore:
Timestamp:
08/26/13 16:11:27 (11 years ago)
Author:
ogrimm
Message:
Changed curve highlighting to single clicks
Location:
fact/Evidence
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/Evidence/GUI.cc

    r17037 r17039  
    339339  // Horizontal time scale
    340340  setAxisScaleDraw(QwtPlot::xBottom, new EddDateScale());
    341   connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SLOT(ScaleUpdate()));
    342 
     341 
    343342  // Additonal context menu items
    344343  QAction* Action = Menu->addAction("Paste service", this, SLOT(MenuPasteService()));
     
    424423        NewData = true;
    425424  }
    426 }
    427 
    428 // Add text indicating time range to plot
    429 void EddPlot::ScaleUpdate() {
    430 
    431   QwtText Text;
    432   QFont Font;
    433  
    434   // Set footer
    435   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");
    436 
    437   Font.setPointSize(6);
    438   Text.setFont(Font);
    439   setFooter(Text);
    440425}
    441426
     
    702687  else setCanvasBackground(EddPlotBackgroundColor);
    703688
     689  // Set footer
     690  QwtText Text;
     691  QFont Font;
     692 
     693  Text = QDateTime::fromMSecsSinceEpoch(axisScaleDiv(QwtPlot::xBottom).lowerBound()).toString("d-MMM-yyyy hh:mm:ss") + " to " +
     694        QDateTime::fromMSecsSinceEpoch(axisScaleDiv(QwtPlot::xBottom).upperBound()).toString("d-MMM-yyyy hh:mm:ss") +
     695        (StripAction->isChecked() ? " (Stripchart)" : "");
     696
     697  Font.setPointSize(6);
     698  Text.setFont(Font);
     699  setFooter(Text); // For EddScope (not a history plot, no time scale) this action is removed
     700 
     701  // Recalculate statistics
    704702  ReDoStats();
    705703}
     
    836834}
    837835
    838 // Double clicking hightlights curve
    839 void EddBasePlot::mouseDoubleClickEvent (QMouseEvent *Event) {
    840        
     836// Mouse events: Release click highlights curve if mouse did not move (which is zoom)
     837void EddBasePlot::mousePressEvent(QMouseEvent *) {
     838
     839  MouseMoved = false;
     840}
     841
     842void EddBasePlot::mouseMoveEvent(QMouseEvent *) {
     843
     844  MouseMoved = true;
     845}
     846
     847void EddBasePlot::mouseReleaseEvent(QMouseEvent *Event) {
     848 
    841849  double Dist, MinDistance = std::numeric_limits<double>::infinity();
    842850  int Index = -1;
    843851
     852  if (Event->button() != Qt::LeftButton || MouseMoved) return;
     853
    844854  // Check which curve is closest
    845855  for (int i=0; i<Items.size(); i++) {
    846         if (Items[i].Signal->closestPoint(Event->pos(), &Dist) != -1 && Dist < MinDistance) {
     856        if (Items[i].Signal->closestPoint(canvas()->mapFromGlobal(QCursor::pos()), &Dist) != -1 && Dist < MinDistance) {
    847857          MinDistance = Dist;
    848858          Index = i;
     
    943953    "Pan\tShift and left mouse button\n\n"
    944954        "ESC cancels selection\n"
    945         "Double-clicking highlights nearest curve\n"
     955        "Clicking near a curve or on legend highlights\n"
    946956    "Cursor keys move mouse\n\n"
    947957        "Statistics are calculated over the current x axis extend\n\n"
     
    10081018}
    10091019
    1010 // Handling of mouse release event: Open history
     1020// Handling of mouse release event: Mark line
    10111021void EddLegendLabel::mouseReleaseEvent(QMouseEvent *Event) {
    10121022
    10131023  if (Event->button() != Qt::LeftButton) return;
    10141024 
    1015   QString D(text().text());
    1016   D.replace(':',' ');
    1017   QStringList A = D.split(" ");
    1018  
    1019   OpenHistory(A[0].toAscii().data(), A[1].toInt());
    1020 }
     1025  ThickLineAction->toggle();
     1026 }
    10211027
    10221028// Menu: Open history plot
  • fact/Evidence/GUI.h

    r17037 r17039  
    7878        QwtPlotMarker *Stats;
    7979        class EddLegend *Legend;
    80        
     80        bool MouseMoved;
     81
    8182  public:
    8283    EddBasePlot(QWidget * = NULL);
     
    9899    void HandleZoom(const QRectF &);
    99100        void MouseSelection(const QPolygon &);
    100         void mouseDoubleClickEvent(QMouseEvent *);
     101        void mousePressEvent(QMouseEvent *);
     102        void mouseReleaseEvent(QMouseEvent *);
     103        void mouseMoveEvent(QMouseEvent *);
    101104        void contextMenuEvent(QContextMenuEvent *);
    102105    void MenuSetUpdateRate();       
     
    166169
    167170  private:
    168     //EddDateScale *Scale;
    169171        QwtLegend *Legend;
    170172        QTimer *SingleShot;
     
    185187   
    186188  private slots:
    187     void ScaleUpdate();
    188189    void MenuPasteService();
    189190        void MenuShowLastHour();
Note: See TracChangeset for help on using the changeset viewer.