Browse Source

Current time indicator in graph. Fixes #98

Neal Wilson 11 years ago
parent
commit
b49a2c3e8b
2 changed files with 40 additions and 0 deletions
  1. 2
    0
      config/Windows/productionroaster.xml
  2. 38
    0
      src/typica.w

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

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

+ 38
- 0
src/typica.w View File

7664
 	QList<QGraphicsItem *> *gridLinesC;
7664
 	QList<QGraphicsItem *> *gridLinesC;
7665
 	QList<QGraphicsItem *> *relativeGridLines;
7665
 	QList<QGraphicsItem *> *relativeGridLines;
7666
 	bool relativeEnabled;
7666
 	bool relativeEnabled;
7667
+	bool timeIndicatorEnabled;
7668
+	QGraphicsLineItem *timeLine;
7667
 	LinearSplineInterpolator *relativeAdjuster;@/
7669
 	LinearSplineInterpolator *relativeAdjuster;@/
7668
 	public:@/
7670
 	public:@/
7669
 		GraphView(QWidget *parent = NULL);
7671
 		GraphView(QWidget *parent = NULL);
7673
 	@t\4@>public slots@t\kern-3pt@>:@/
7675
 	@t\4@>public slots@t\kern-3pt@>:@/
7674
 		void newMeasurement(Measurement measure, int tempcolumn);
7676
 		void newMeasurement(Measurement measure, int tempcolumn);
7675
 		void setSeriesTranslation(int column, double offset);
7677
 		void setSeriesTranslation(int column, double offset);
7678
+		void setTimeIndicatorEnabled(bool enabled);
7676
 		void clear();
7679
 		void clear();
7677
 		void showF();
7680
 		void showF();
7678
 		void showC();@t\2@>@/
7681
 		void showC();@t\2@>@/
7709
 	gridLinesC(new QList<QGraphicsItem *>),
7712
 	gridLinesC(new QList<QGraphicsItem *>),
7710
 	relativeGridLines(new QList<QGraphicsItem *>),
7713
 	relativeGridLines(new QList<QGraphicsItem *>),
7711
 	relativeEnabled(false),
7714
 	relativeEnabled(false),
7715
+	timeIndicatorEnabled(false),
7716
+	timeLine(new QGraphicsLineItem),
7712
 	relativeAdjuster(new LinearSplineInterpolator)@/
7717
 	relativeAdjuster(new LinearSplineInterpolator)@/
7713
 {
7718
 {
7714
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7719
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7715
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7720
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7716
 	setScene(theScene);
7721
 	setScene(theScene);
7717
 	setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
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
 	@<Draw temperature axis and grid lines@>;
7729
 	@<Draw temperature axis and grid lines@>;
7719
 	@<Draw secondary axes@>@;
7730
 	@<Draw secondary axes@>@;
7720
 	@<Draw time axis and ticks@>;
7731
 	@<Draw time axis and ticks@>;
7947
 @<Handle the first measurement@>=
7958
 @<Handle the first measurement@>=
7948
 int x = FULLTIMETOINT(measure.time())/1000;
7959
 int x = FULLTIMETOINT(measure.time())/1000;
7949
 prevPoints->insert(tempcolumn, QPointF(x, measure.temperature()));
7960
 prevPoints->insert(tempcolumn, QPointF(x, measure.temperature()));
7961
+if(timeIndicatorEnabled)
7962
+{
7963
+	timeLine->setLine(x, 0, x, -500);
7964
+}
7950
 
7965
 
7951
 @ When at least one measurement already exists, we need to handle drawing the
7966
 @ When at least one measurement already exists, we need to handle drawing the
7952
 line between the new measurement and the previous measurement.
7967
 line between the new measurement and the previous measurement.
7968
 segment->setPen(p[tempcolumn % 12]);
7983
 segment->setPen(p[tempcolumn % 12]);
7969
 theScene->addItem(segment);
7984
 theScene->addItem(segment);
7970
 prevPoints->insert(tempcolumn, nextPoint);
7985
 prevPoints->insert(tempcolumn, nextPoint);
7986
+if(timeIndicatorEnabled)
7987
+{
7988
+	timeLine->setLine(nextPoint.x() + offset, 0, nextPoint.x() + offset, -500);
7989
+}
7971
 
7990
 
7972
 @ In addition to adding data to the view, we also sometimes want to clear the
7991
 @ In addition to adding data to the view, we also sometimes want to clear the
7973
 view of data.
7992
 view of data.
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
 @ These functions are required to create a |GraphView| object from a script.
8068
 @ These functions are required to create a |GraphView| object from a script.
8031
 
8069
 
8032
 @<Function prototypes for scripting@>=
8070
 @<Function prototypes for scripting@>=

Loading…
Cancel
Save