Skip to content

Commit

Permalink
Finished testing offset changes
Browse files Browse the repository at this point in the history
- Also fixed another bug encountered when dragging annotations - that caused them to prematurely save. Result was skipping behaviour while dragging. Bug was bad boolean value (for signaling 'finished' events) in selected event handler for drawabox
- Fixed null ref bug when accessing spectrogram window property off media element
- Fixed routing bug triggered by unecessary forward slash in `listen` ngRoute configuration
- Removed random testing of property deletion for unitConverter specs (consistently test all props now)
  • Loading branch information
atruskie committed Dec 9, 2013
1 parent 450576f commit 42515df
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/app/annotationViewer/annotationViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ avModule.controller('AnnotationViewerCtrl', ['$scope', '$element', '$attrs', '$t
};

$scope.positionLabel = function (audioEvent) {
return $scope.model.converters.secondsToPixels(audioEvent.startTimeSeconds);
return $scope.model.converters.toLeft(audioEvent.startTimeSeconds);
};

$scope.positionLine = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/baw.configuration.tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ angular.module('bawApp.configuration', ['url'])
},
// routes used by angular
ngRoutes: {
listen: "/listen/{recordingId}/"
listen: "/listen/{recordingId}"
},
// general links for use in <a />'s
links: {
Expand Down
21 changes: 10 additions & 11 deletions src/components/directives/bawAnnotationViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ bawds.directive('bawAnnotationViewer',
'Tag',
function (paths, unitConverter, AudioEvent, Tag) {


/**
* Create an watcher for an audio event model.
* The purpose is to allow for binding from model -> drawabox || model -> server
Expand Down Expand Up @@ -61,7 +60,7 @@ bawds.directive('bawAnnotationViewer',

scope.model.converters = unitConverter.getConversions({
sampleRate: scope.model.media.sampleRate,
spectrogramWindowSize: scope.model.media.spectrogram.window,
spectrogramWindowSize: scope.model.media.spectrogram ? scope.model.media.spectrogram.window : null,
endOffset: scope.model.media.endOffset,
startOffset: scope.model.media.startOffset,
imageElement: scope.$image[0]
Expand Down Expand Up @@ -144,10 +143,10 @@ bawds.directive('bawAnnotationViewer',
}
else {
// resize / move
annotation.highFrequencyHertz = unitConverter.toHigh(box.top);
annotation.startTimeSeconds = unitConverter.toStart(box.left);
annotation.endTimeSeconds = unitConverter.toEnd(box.left, box.width);
annotation.lowFrequencyHertz = unitConverter.toLow(box.top, box.height);
annotation.highFrequencyHertz = scope.model.converters.toHigh(box.top);
annotation.startTimeSeconds = scope.model.converters.toStart(box.left);
annotation.endTimeSeconds = scope.model.converters.toEnd(box.left, box.width);
annotation.lowFrequencyHertz = scope.model.converters.toLow(box.top, box.height);

if (!annotation.$intermediateEvent) {
// funny bug. resized does not trigger a model updated... although moved does.
Expand Down Expand Up @@ -185,10 +184,10 @@ bawds.directive('bawAnnotationViewer',
console.debug("AnnotationEditor:modelUpdatesDrawabox:", annotation.__localId__);

var drawaboxInstance = scope.$drawaboxElement,
top = unitConverter.toTop(annotation.highFrequencyHertz),
left = unitConverter.toLeft(annotation.startTimeSeconds),
width = unitConverter.toWidth(annotation.endTimeSeconds, annotation.startTimeSeconds),
height = unitConverter.toHeight(annotation.highFrequencyHertz, annotation.lowFrequencyHertz);
top = scope.model.converters.toTop(annotation.highFrequencyHertz),
left = scope.model.converters.toLeft(annotation.startTimeSeconds),
width = scope.model.converters.toWidth(annotation.endTimeSeconds, annotation.startTimeSeconds),
height = scope.model.converters.toHeight(annotation.highFrequencyHertz, annotation.lowFrequencyHertz);

drawaboxInstance.drawabox('setBox', annotation.__localId__, top, left, height, width,
annotation.selected);
Expand Down Expand Up @@ -491,7 +490,7 @@ bawds.directive('bawAnnotationViewer',
console.log("boxSelected", selectedBox);
drawaboxUpdatesModel(scope, scope.model.audioEvents[element[0].annotationViewerIndex],
selectedBox,
DRAWABOX_ACTION_SELECT, false);
DRAWABOX_ACTION_SELECT, true);
},
"boxResizing": function (element, box) {
console.log("boxResizing");
Expand Down
28 changes: 18 additions & 10 deletions src/components/services/unitConverters.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
describe("The unitConverter service", function () {

var unitConverter;
var inputArgs;
var inputArgs = {
sampleRate: null,
spectrogramWindowSize: null,
endOffset: null,
startOffset: null,
imageElement: null
};

beforeEach(module('bawApp.services.unitConverter'));

Expand Down Expand Up @@ -34,17 +40,19 @@ describe("The unitConverter service", function () {
expect(c).toBeObject();
});

it("fails iff the input object is missing properties", function () {
var keys = Object.keys(inputArgs);
var rand = Math.randomInt(0, keys.length);
var obj = angular.copy(inputArgs);
delete obj[keys[rand - 1]];

var f = function () {
unitConverter.getConversions(obj);
};
Object.keys(inputArgs).forEach(function (key) {
it("fails iff the input object is missing the " + key + " property", function () {
var obj = angular.copy(inputArgs);
delete obj[key];

var f = function () {
unitConverter.getConversions(obj);
};

expect(f).toThrowError("Missing property: " + key);
});

expect(f).toThrowError("Missing property: " + keys[rand]);
});

describe("has the getConversions method:", function () {
Expand Down

0 comments on commit 42515df

Please sign in to comment.