From e505e6c5f1676108038c165d61fc826a97a1b749 Mon Sep 17 00:00:00 2001
From: Paul Chote
Date: Wed, 27 Feb 2019 00:01:32 +0000
Subject: [PATCH] Add an option to disable the new position.
---
static/findingchart.js | 70 ++++++++++++++++++++++--------------------
templates/input.html | 9 ++++++
2 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/static/findingchart.js b/static/findingchart.js
index 3818360..b120289 100644
--- a/static/findingchart.js
+++ b/static/findingchart.js
@@ -143,39 +143,41 @@ function generateChart(t) {
chartContext.arc(oldX, oldY, json.indicator_size, 0, 2 * Math.PI);
chartContext.stroke();
- // New source position
- var newX = chartImageX + json.observing_pos[0];
- var newY = chartImageY + json.observing_pos[1];
- chartContext.fillStyle = 'rgba(255, 0, 0, 0.5)';
- chartContext.beginPath();
- chartContext.arc(newX, newY, json.indicator_size, 0, 2 * Math.PI);
- chartContext.fill();
-
- // Connecting arrow
- var deltaX = newX - oldX;
- var deltaY = newY - oldY;
- var deltaL = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
- if (deltaL > 2.5 * json.indicator_size) {
- var dirX = deltaX / deltaL;
- var dirY = deltaY / deltaL;
-
- var lineStartX = oldX + json.indicator_size * dirX;
- var lineStartY = oldY + json.indicator_size * dirY;
- var lineEndX = newX - json.indicator_size * dirX;
- var lineEndY = newY - json.indicator_size * dirY;
-
- var arrowAX = lineEndX - json.indicator_size * (dirY + dirX)
- var arrowAY = lineEndY + json.indicator_size * (-dirY + dirX)
- var arrowBX = lineEndX - json.indicator_size * (-dirY + dirX)
- var arrowBY = lineEndY + json.indicator_size * (-dirY - dirX)
-
- chartContext.beginPath();
- chartContext.moveTo(lineStartX, lineStartY);
- chartContext.lineTo(lineEndX, lineEndY);
- chartContext.moveTo(arrowAX, arrowAY);
- chartContext.lineTo(lineEndX, lineEndY);
- chartContext.lineTo(arrowBX, arrowBY);
- chartContext.stroke();
+ if (t.newposition) {
+ // New source position
+ var newX = chartImageX + json.observing_pos[0];
+ var newY = chartImageY + json.observing_pos[1];
+ chartContext.fillStyle = 'rgba(255, 0, 0, 0.5)';
+ chartContext.beginPath();
+ chartContext.arc(newX, newY, json.indicator_size, 0, 2 * Math.PI);
+ chartContext.fill();
+
+ // Connecting arrow
+ var deltaX = newX - oldX;
+ var deltaY = newY - oldY;
+ var deltaL = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+ if (deltaL > 2.5 * json.indicator_size) {
+ var dirX = deltaX / deltaL;
+ var dirY = deltaY / deltaL;
+
+ var lineStartX = oldX + json.indicator_size * dirX;
+ var lineStartY = oldY + json.indicator_size * dirY;
+ var lineEndX = newX - json.indicator_size * dirX;
+ var lineEndY = newY - json.indicator_size * dirY;
+
+ var arrowAX = lineEndX - json.indicator_size * (dirY + dirX)
+ var arrowAY = lineEndY + json.indicator_size * (-dirY + dirX)
+ var arrowBX = lineEndX - json.indicator_size * (-dirY + dirX)
+ var arrowBY = lineEndY + json.indicator_size * (-dirY - dirX)
+
+ chartContext.beginPath();
+ chartContext.moveTo(lineStartX, lineStartY);
+ chartContext.lineTo(lineEndX, lineEndY);
+ chartContext.moveTo(arrowAX, arrowAY);
+ chartContext.lineTo(lineEndX, lineEndY);
+ chartContext.lineTo(arrowBX, arrowBY);
+ chartContext.stroke();
+ }
}
if (t.annotate) {
@@ -222,6 +224,7 @@ function setup() {
var type = $("input[name='type']:checked").val();
var coords = $("textarea[name='coords']").val().split('\n');
+ var newpos = $("input[name='newpos']").prop('checked');
if (parseFloat(size) != size) {
$('#error').html('Unable to parse "' + size + '" as a number');
@@ -345,6 +348,7 @@ function setup() {
'size': size,
'annotate': type == 'annotated',
'outepoch': outepoch,
+ 'newposition': newpos,
});
}
diff --git a/templates/input.html b/templates/input.html
index dccb091..5c41091 100644
--- a/templates/input.html
+++ b/templates/input.html
@@ -73,6 +73,15 @@ Finding chart generator
+