From 808767ff74047f91519524fd512fa1c52ac6b700 Mon Sep 17 00:00:00 2001 From: Gary Keeble Date: Sat, 23 Apr 2016 20:35:07 +0100 Subject: [PATCH] Add marker to graph as a custom event Marker is now shown on the graph as a red event. Adjusted width of chart to allow more toolbar area. Moved the update of the current time text box into the main routine for tidiness. --- css/main.css | 2 +- js/flightlog_fielddefs.js | 3 ++- js/grapher.js | 24 +++++++++++++++++------- js/main.js | 16 ++++++++++++---- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/css/main.css b/css/main.css index 656deafb..795c3754 100644 --- a/css/main.css +++ b/css/main.css @@ -9,7 +9,7 @@ html, body { /* Add an extended wide size to the page container for large monitors */ @media (min-width: 1400px) { .container.main-pane { - width:1280px; + width:1320px; } } diff --git a/js/flightlog_fielddefs.js b/js/flightlog_fielddefs.js index c63b925a..82dc8fad 100644 --- a/js/flightlog_fielddefs.js +++ b/js/flightlog_fielddefs.js @@ -23,9 +23,10 @@ var GTUNE_CYCLE_RESULT: 20, FLIGHT_MODE: 30, // New Event type + CUSTOM : 250, // Virtual Event Code - Never part of Log File. LOG_END: 255 }), - + FLIGHT_LOG_FLIGHT_MODE_NAME = makeReadOnly([ "ANGLE_MODE", "HORIZON_MODE", diff --git a/js/grapher.js b/js/grapher.js index c6052093..83420bfb 100755 --- a/js/grapher.js +++ b/js/grapher.js @@ -438,12 +438,6 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options) frameLabelTextWidthFrameTime = canvasContext.measureText("00:00.000").width; canvasContext.fillText(formatTime(timeMsec, true), canvas.width - frameLabelTextWidthFrameTime - 8, canvas.height - 8 - drawingParams.fontSizeFrameLabel - 8); - // update time field on toolbar -// $(".graph-time").val(formatTime(timeMsec, true)); -// if(hasMarker) { -// $(".graph-time-marker").val(formatTime(timeMsec-markerTime, true)); -// } - } @@ -641,6 +635,9 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options) case FlightLogEvent.FLIGHT_MODE: drawEventLine(x, labelY, "Flight Mode Change" + eventToFriendly(event.data.newFlags, event.data.lastFlags), "rgba(0,0,255,0.75)", 3); break; + case FlightLogEvent.CUSTOM: // Virtual Events shown in RED + drawEventLine(x, labelY, (event.label)?event.label:'EVENT', "rgba(255,0,0,0.75)", 3); + break; default: drawEventLine(x); } @@ -677,6 +674,19 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options) } } } + + // Add custom markers + + // Draw Marker Event Line + var markerEvent = blackboxLogViewer.getMarker(); + if(markerEvent!=null) { + if(markerEvent.state) drawEvent( + { + event:FlightLogEvent.CUSTOM, + time:markerEvent.time, + label:'Marker:' +formatTime((markerEvent.time-flightLog.getMinTime())/1000, true) + }, sequenceNum++); + } } /** @@ -838,7 +848,7 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options) // Draw events drawEvents(chunks); - + // Draw details at the current time var centerFrame = flightLog.getSmoothedFrameAtTime(windowCenterTime); diff --git a/js/main.js b/js/main.js index b561f94b..8a362741 100644 --- a/js/main.js +++ b/js/main.js @@ -195,7 +195,7 @@ function BlackboxLogViewer() { table.append(rows.join("")); // update time field on toolbar - $(".graph-time").val(formatTime(currentBlackboxTime/1000, true)); + $(".graph-time").val(formatTime((currentBlackboxTime-flightLog.getMinTime())/1000, true)); if(hasMarker) { $(".graph-time-marker").val(formatTime((currentBlackboxTime-markerTime)/1000, true)); } @@ -604,11 +604,18 @@ function BlackboxLogViewer() { updateCanvasSize(); } - function markerSet(state) { // update marker field + function setMarker(state) { // update marker field hasMarker = state; (state)?$("html").addClass("has-marker"):$("html").removeClass("has-marker"); } - + + this.getMarker = function() { // get marker field + return { + state:hasMarker, + time:markerTime + }; + } + prefs.get('videoConfig', function(item) { if (item) { videoConfig = item; @@ -906,7 +913,8 @@ function BlackboxLogViewer() { if (!(shifted)) { markerTime = currentBlackboxTime; $(".graph-time-marker").val(formatTime(0)); - markerSet(!hasMarker); + setMarker(!hasMarker); + invalidateGraph(); } e.preventDefault(); break;