From ef1356c2c7c1d6d0310fc7f0f6fa02e309f6c84c Mon Sep 17 00:00:00 2001
From: Oliver Bock <oliver.bock@aei.mpg.de>
Date: Wed, 4 Feb 2009 17:02:15 +0100
Subject: [PATCH] Improved curve/marker updates

* Removed workaround code (now normalized values: [0,1])
* Pending: marker sync issue (see previous commit)
---
 src/pulsescopewidget.cpp | 18 +++++-------------
 src/pulsescopewidget.h   |  2 +-
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/pulsescopewidget.cpp b/src/pulsescopewidget.cpp
index 836bb82..8f2f1c2 100644
--- a/src/pulsescopewidget.cpp
+++ b/src/pulsescopewidget.cpp
@@ -42,8 +42,8 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent),
 		qWarning("Sorry, no multisampling support for pulse scope...");
 	}
 
-	m_scopeSizeH = 360;
-	m_scopeSizeV = 1;
+	m_scopeSizeH = 360.0f;
+	m_scopeSizeV = 1.0f;
 
 	m_path = NULL;
 	m_marker = m_scene.addLine(0.0f, 0.0f, 0.0f, m_scopeSizeV, QPen(Qt::red));
@@ -71,14 +71,9 @@ void PulseScopeWidget::drawCurve(const QVector<float>& vector)
 {
 	m_data = vector;
 
-	// FIXME: to be removed later because amplitude should be normalized to 1!
-	QVector<float> test(vector);
-	qSort(test.begin(), test.end());
-	if(test.last() > 1) m_scopeSizeV = 1-test.last();
-
-	QPainterPath pulsePath(QPoint(0.0f, 1.0f));
+	QPainterPath pulsePath(QPoint(0.0f, m_scopeSizeV));
 	for(int i = 0; i < m_scopeSizeH; ++i) {
-		pulsePath.lineTo(i, 1-m_data.at(i));
+		pulsePath.lineTo(i, m_scopeSizeV - m_data.at(i));
 	}
 	if(m_path == NULL) {
 		m_path = m_scene.addPath(pulsePath, QPen(Qt::yellow));
@@ -86,8 +81,6 @@ void PulseScopeWidget::drawCurve(const QVector<float>& vector)
 	else {
 		m_path->setPath(pulsePath);
 	}
-
-	fitInView(m_scene.itemsBoundingRect(), Qt::IgnoreAspectRatio);
 }
 
 void PulseScopeWidget::markerStep(float stepSize) {
@@ -98,8 +91,7 @@ void PulseScopeWidget::markerStep(float stepSize) {
 		m_marker->setLine(x, 0.0f, x, m_scopeSizeV);
 	}
 	else {
-		x = 0.0f;
-		markerReset();
+		x -= m_scopeSizeH;
 	}
 }
 
diff --git a/src/pulsescopewidget.h b/src/pulsescopewidget.h
index 9a3bb43..27537c7 100644
--- a/src/pulsescopewidget.h
+++ b/src/pulsescopewidget.h
@@ -51,7 +51,7 @@ private:
 	QGraphicsPathItem *m_path;
 	QGraphicsLineItem *m_marker;
 
-	int m_scopeSizeH;
+	float m_scopeSizeH;
 	float m_scopeSizeV;
 };
 
-- 
GitLab