Sfoglia il codice sorgente

Current time indicator in graph. Fixes #98

Neal Wilson 11 anni fa
parent
commit
b49a2c3e8b
2 ha cambiato i file con 40 aggiunte e 0 eliminazioni
  1. 2
    0
      config/Windows/productionroaster.xml
  2. 38
    0
      src/typica.w

+ 2
- 0
config/Windows/productionroaster.xml Vedi File

@@ -592,6 +592,7 @@
592 592
 			}
593 593
 			stop.enabled = true;
594 594
 			window.windowModified = true;
595
+			graph.setTimeIndicatorEnabled(true);
595 596
         });
596 597
 		for(var i = 0; i < annotationButtons.length; i++) {
597 598
 			if(channels.length > 0)
@@ -650,6 +651,7 @@
650 651
 			}
651 652
 			start.enabled = true;
652 653
 			window.windowModified = false;
654
+			graph.setTimeIndicatorEnabled(false);
653 655
         });
654 656
 		stop.annotation.connect(function(note, tcol, ncol) {
655 657
 			for(var i = tcol; i < ncol; i++) {

+ 38
- 0
src/typica.w Vedi File

@@ -7664,6 +7664,8 @@ class GraphView : public QGraphicsView@/
7664 7664
 	QList<QGraphicsItem *> *gridLinesC;
7665 7665
 	QList<QGraphicsItem *> *relativeGridLines;
7666 7666
 	bool relativeEnabled;
7667
+	bool timeIndicatorEnabled;
7668
+	QGraphicsLineItem *timeLine;
7667 7669
 	LinearSplineInterpolator *relativeAdjuster;@/
7668 7670
 	public:@/
7669 7671
 		GraphView(QWidget *parent = NULL);
@@ -7673,6 +7675,7 @@ class GraphView : public QGraphicsView@/
7673 7675
 	@t\4@>public slots@t\kern-3pt@>:@/
7674 7676
 		void newMeasurement(Measurement measure, int tempcolumn);
7675 7677
 		void setSeriesTranslation(int column, double offset);
7678
+		void setTimeIndicatorEnabled(bool enabled);
7676 7679
 		void clear();
7677 7680
 		void showF();
7678 7681
 		void showC();@t\2@>@/
@@ -7709,12 +7712,20 @@ GraphView::GraphView(QWidget *parent) : QGraphicsView(parent),
7709 7712
 	gridLinesC(new QList<QGraphicsItem *>),
7710 7713
 	relativeGridLines(new QList<QGraphicsItem *>),
7711 7714
 	relativeEnabled(false),
7715
+	timeIndicatorEnabled(false),
7716
+	timeLine(new QGraphicsLineItem),
7712 7717
 	relativeAdjuster(new LinearSplineInterpolator)@/
7713 7718
 {
7714 7719
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7715 7720
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7716 7721
 	setScene(theScene);
7717 7722
 	setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
7723
+	QPen timePen;
7724
+	timePen.setColor(QColor(160, 160, 164, 127)); //gray, half opacity
7725
+	timeLine->setPen(timePen);
7726
+	timeLine->setLine(0, 0, 0, -500);
7727
+	timeLine->hide();
7728
+	theScene->addItem(timeLine);
7718 7729
 	@<Draw temperature axis and grid lines@>;
7719 7730
 	@<Draw secondary axes@>@;
7720 7731
 	@<Draw time axis and ticks@>;
@@ -7947,6 +7958,10 @@ In the case of the first measurement,
7947 7958
 @<Handle the first measurement@>=
7948 7959
 int x = FULLTIMETOINT(measure.time())/1000;
7949 7960
 prevPoints->insert(tempcolumn, QPointF(x, measure.temperature()));
7961
+if(timeIndicatorEnabled)
7962
+{
7963
+	timeLine->setLine(x, 0, x, -500);
7964
+}
7950 7965
 
7951 7966
 @ When at least one measurement already exists, we need to handle drawing the
7952 7967
 line between the new measurement and the previous measurement.
@@ -7968,6 +7983,10 @@ static QColor p[12] = {Qt::yellow, Qt::blue, Qt::cyan, Qt::red, Qt::magenta,
7968 7983
 segment->setPen(p[tempcolumn % 12]);
7969 7984
 theScene->addItem(segment);
7970 7985
 prevPoints->insert(tempcolumn, nextPoint);
7986
+if(timeIndicatorEnabled)
7987
+{
7988
+	timeLine->setLine(nextPoint.x() + offset, 0, nextPoint.x() + offset, -500);
7989
+}
7971 7990
 
7972 7991
 @ In addition to adding data to the view, we also sometimes want to clear the
7973 7992
 view of data.
@@ -8027,6 +8046,25 @@ void GraphView::setSeriesTranslation(int column, double offset)
8027 8046
 	}
8028 8047
 }
8029 8048
 
8049
+@ Starting in \pn{} 1.6 it is possible to add a vertical line indicating the
8050
+time position of the most recent measurement. This should be hidden for loading
8051
+target roast profiles and shown depending on preference. A new method controls
8052
+this.
8053
+
8054
+@<GraphView Implementation@>=
8055
+void GraphView::setTimeIndicatorEnabled(bool enabled)
8056
+{
8057
+	timeIndicatorEnabled = enabled;
8058
+	if(enabled)
8059
+	{
8060
+		timeLine->show();
8061
+	}
8062
+	else
8063
+	{
8064
+		timeLine->hide();
8065
+	}
8066
+}
8067
+
8030 8068
 @ These functions are required to create a |GraphView| object from a script.
8031 8069
 
8032 8070
 @<Function prototypes for scripting@>=

Loading…
Annulla
Salva