Skip to content

Commit e7f5566

Browse files
author
Gary Keeble
committed
Add measure feature
Press M to mark a point on the graph, as you scroll time from mark is then shown on toolbar, press M again to clear marker.
1 parent acca016 commit e7f5566

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

css/main.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ html.has-log .log-seek-bar {
313313
display:block;
314314
}
315315

316+
html .graph-time-marker-group > .graph-time-marker {
317+
display:none;
318+
}
319+
html.has-marker .graph-time-marker-group > .graph-time-marker {
320+
display:inline-block;
321+
}
322+
316323
.log-metadata, .log-field-values {
317324
display:none;
318325
}

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ <h4>Time</h4>
206206
<div class="form-group">
207207
<input type="text" class="form-control graph-time" value="1.0" size="8">
208208
</div>
209+
<div class="form-group graph-time-marker-group">
210+
<input type="text" class="form-control graph-time-marker" value="0" size="8">
211+
</div>
209212
</div>
210213
</li>
211214
<li class="log-sync-panel">

js/grapher.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,12 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
439439

440440
canvasContext.fillText(formatTime(timeMsec, true), canvas.width - frameLabelTextWidthFrameTime - 8, canvas.height - 8 - drawingParams.fontSizeFrameLabel - 8);
441441
// update time field on toolbar
442-
$(".graph-time").val(formatTime(timeMsec, true));
442+
// $(".graph-time").val(formatTime(timeMsec, true));
443+
// if(hasMarker) {
444+
// $(".graph-time-marker").val(formatTime(timeMsec-markerTime, true));
445+
// }
446+
447+
443448
}
444449

445450
/**

js/main.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function BlackboxLogViewer() {
9393
graphLegend = null,
9494
fieldPresenter = FlightLogFieldPresenter,
9595

96-
hasVideo = false, hasLog = false,
96+
hasVideo = false, hasLog = false, hasMarker = false, // add measure feature
9797
video = $(".log-graph video")[0],
9898
canvas = $("#graphCanvas")[0],
9999
craftCanvas = $("#craftCanvas")[0],
@@ -102,6 +102,8 @@ function BlackboxLogViewer() {
102102

103103
videoExportInTime = false,
104104
videoExportOutTime = false,
105+
106+
markerTime = 0, // New marker time
105107

106108
graphRendersCount = 0,
107109

@@ -191,6 +193,12 @@ function BlackboxLogViewer() {
191193
}
192194

193195
table.append(rows.join(""));
196+
197+
// update time field on toolbar
198+
$(".graph-time").val(formatTime(currentBlackboxTime/1000, true));
199+
if(hasMarker) {
200+
$(".graph-time-marker").val(formatTime((currentBlackboxTime-markerTime)/1000, true));
201+
}
194202
}
195203
}
196204

@@ -595,7 +603,12 @@ function BlackboxLogViewer() {
595603
function onLegendSelectionChange() {
596604
updateCanvasSize();
597605
}
598-
606+
607+
function markerSet(state) { // update marker field
608+
hasMarker = state;
609+
(state)?$("html").addClass("has-marker"):$("html").removeClass("has-marker");
610+
}
611+
599612
prefs.get('videoConfig', function(item) {
600613
if (item) {
601614
videoConfig = item;
@@ -888,6 +901,15 @@ function BlackboxLogViewer() {
888901
}
889902
}
890903
e.preventDefault();
904+
break;
905+
case "M".charCodeAt(0):
906+
if (!(shifted)) {
907+
markerTime = currentBlackboxTime;
908+
$(".graph-time-marker").val(formatTime(0));
909+
markerSet(!hasMarker);
910+
}
911+
e.preventDefault();
912+
break;
891913
// Add my shortcuts
892914
case " ".charCodeAt(0): // start/stop playback
893915
logPlayPause();

js/tools.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,23 @@ function leftPad(string, pad, minLength) {
168168
}
169169

170170
function formatTime(msec, displayMsec) {
171+
// modify function to allow negative times.
171172
var
172-
secs, mins, hours;
173+
ms, secs, mins, hours;
173174

174-
msec = Math.round(msec);
175+
ms = Math.round(Math.abs(msec));
175176

176-
secs = Math.floor(msec / 1000);
177-
msec %= 1000;
177+
secs = Math.floor(ms / 1000);
178+
ms %= 1000;
178179

179180
mins = Math.floor(secs / 60);
180181
secs %= 60;
181182

182183
hours = Math.floor(mins / 60);
183184
mins %= 60;
184185

185-
return (hours ? leftPad(hours, "0", 2) + ":" : "") + leftPad(mins, "0", 2) + ":" + leftPad(secs, "0", 2)
186-
+ (displayMsec ? "." + leftPad(msec, "0", 3) : "");
186+
return ((msec<0)?'-':'') + (hours ? leftPad(hours, "0", 2) + ":" : "") + leftPad(mins, "0", 2) + ":" + leftPad(secs, "0", 2)
187+
+ (displayMsec ? "." + leftPad(ms, "0", 3) : "");
187188
}
188189

189190
function stringTimetoMsec(input) {

0 commit comments

Comments
 (0)