summaryrefslogtreecommitdiffhomepage
path: root/QFunctionConfigurator
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2012-09-21 07:21:02 +0000
committerStanislaw Halik <sthalik@misaki.pl>2012-09-21 07:21:02 +0000
commit9b75369b820c4d3a93739dbcb664df329b183e09 (patch)
treecfd72be603bd4c2f48291a62a00a965e53cba88b /QFunctionConfigurator
parent5da3b245b35cdd2bb4b1490aae81f8d0ff0bde82 (diff)
Fix function-config and Accela after recent refactoring.
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@149 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'QFunctionConfigurator')
-rw-r--r--QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp42
-rw-r--r--QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h2
2 files changed, 29 insertions, 15 deletions
diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp
index b2fb9655..58bf69ac 100644
--- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp
+++ b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp
@@ -86,8 +86,8 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent)
range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output);
setMouseTracking(true);
- moving = 0; // Pointer to the curve-point, that's being moved
- movingPoint = 0; // Index of that same point
+ moving = NULL; // Pointer to the curve-point, that's being moved
+ movingPoint = 1; // Index of that same point
//
// Add a Reset-button
@@ -262,6 +262,8 @@ QRect scale;
//
void QFunctionConfigurator::drawFunction(const QRectF &fullRect)
{
+ if (!_config)
+ return;
int i;
QPointF prevPoint;
QPointF currentPoint;
@@ -290,12 +292,15 @@ QPointF currentPoint;
QPen pen(colBezier, 2, Qt::SolidLine);
prevPoint = graphicalizePoint( QPointF(0,0), "drawFunction lines" ); // Start at the Axis
- for (i = 0; i < _draw_points.size(); i++) {
- currentPoint = _draw_points[i];
- drawLine(&painter, prevPoint, currentPoint, pen);
- prevPoint = currentPoint;
+ double max = maxInputEGU();
+ QPointF prev = graphicalizePoint(QPointF(0, 0));
+ double step = 1 / (double) pixPerEGU_Input();
+ for (double i = 0; i < max; i += step) {
+ double val = _config->getValue(i);
+ QPointF cur = graphicalizePoint(QPointF(i, val));
+ drawLine(&painter, prev, cur, pen);
+ prev = cur;
}
-
painter.restore();
}
@@ -451,7 +456,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e)
if (withinRect(e->pos(), range)) {
_config->addPoint(normalizePoint(e->pos()));
setConfig(_config, strSettingsFile);
- moving = 0;
+ moving = NULL;
emit CurveChanged( true );
}
}
@@ -467,7 +472,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e)
//
// Check to see if the cursor is touching one of the points.
//
- moving = 0;
+ moving = NULL;
movingPoint = -1;
WaitForSingleObject(_mutex, INFINITE);
if (_config) {
@@ -541,7 +546,7 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e)
}
}
-void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *)
+void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e)
{
//qDebug()<<"releasing";
if (moving > 0) {
@@ -552,14 +557,14 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *)
//
WaitForSingleObject(_mutex, INFINITE);
if (_config) {
- _config->movePoint(movingPoint, _points[movingPoint]);
+ _config->movePoint(movingPoint, normalizePoint(e->pos()));
setConfig(_config, strSettingsFile);
}
ReleaseMutex(_mutex);
}
setCursor(Qt::ArrowCursor);
- moving = 0;
+ moving = NULL;
movingPoint = 0;
}
@@ -588,10 +593,19 @@ bool QFunctionConfigurator::withinRect( const QPointF &coord, const QRectF &rect
//
QPointF QFunctionConfigurator::normalizePoint(QPointF point) const
{
-QPointF norm;
+ QPointF norm;
norm.setX( (point.x() - range.left()) / pPerEGU_Input );
- norm.setY( (range.bottom() - point.y()) / pPerEGU_Output );
+ norm.setY( (range.bottom() - point.y()) / pPerEGU_Output );
+
+ if (norm.x() > maxInputEGU())
+ norm.setX(maxInputEGU());
+ else if (norm.x() < 0)
+ norm.setX(0);
+ if (norm.y() > maxOutputEGU())
+ norm.setY(maxOutputEGU());
+ else if (norm.y() < 0)
+ norm.setY(0);
return norm;
}
diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h
index 48b816ca..c467bc92 100644
--- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h
+++ b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h
@@ -168,7 +168,7 @@ private:
QRectF range; // The actual rectangle for the Bezier-curve
QPointF lastPoint; // The right-most point of the Function
QPointF normalizePoint (QPointF point) const; // Convert the graphical Point to a real-life Point
- QPointF graphicalizePoint (QPointF point, QString source) const; // Convert the Point to a graphical Point
+ QPointF graphicalizePoint (QPointF point, QString source = "") const; // Convert the Point to a graphical Point
QPointF *moving;
int movingPoint;