Skip to content

Commit

Permalink
Add Up / down arrows listeners on project page. Fix measurement tool
Browse files Browse the repository at this point in the history
  • Loading branch information
dhovart committed Jun 7, 2022
1 parent baf0459 commit 39d3de9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 63 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"multer": "^1.4.2",
"mustache-express": "^1.3.0",
"neuroweblab": "github:neuroanatomy/neuroweblab",
"nwl-components": "^0.0.19",
"nwl-components": "^0.0.20",
"pako": "^1.0.11",
"passport": "^0.4.1",
"passport-github": "^1.1.0",
Expand Down
19 changes: 0 additions & 19 deletions view/atlasmaker/src/atlasmaker-interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ export var AtlasMakerInteraction = {
case 'Measure':
me.User.tool = 'measure';
break;
case 'Adjust':
me.User.tool = 'adjust';
if($('#adjust').length === 0) {
me.loadScript('/lib/atlasmaker-tools/adjust.js');
}
break;
case 'Eyedrop':
me.User.tool = 'eyedrop';
break;
Expand Down Expand Up @@ -916,19 +910,6 @@ export var AtlasMakerInteraction = {
me.paintxy(-1, 'le', x, y, me.User);
},

_adjustToolDown: function (x, y) {
const me = AtlasMakerWidget;
me.User.mouseIsDown = true;
me.info.x = x/me.brainW;
me.info.y = 1-y/me.brainH;
},
_adjustToolMove: function (x, y) {
const me = AtlasMakerWidget;
me.info.x = x/me.brainW;
me.info.y = 1-y/me.brainH;
me.drawImages();
},

/**
* @function eyedrop
* @param {number} x X or horizontal coordinate
Expand Down
43 changes: 0 additions & 43 deletions view/atlasmaker/src/atlasmaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ var me = {
{name: 'erase', func: me._eraseToolDown},
{name: 'measure', func: me._measureToolDownHandler},
{name: 'landmark', func: me._landmarkToolDown},
{name: 'adjust', func: me._adjustToolDown},
{name: 'eyedrop', func: me._eyedropToolDown}
];
for(const tool of arr) {
Expand Down Expand Up @@ -362,52 +361,10 @@ var me = {
me.drawImages();
});

/*
// Init the toolbar
// configure and append tools
let tools;
if(typeof me.useFullTools === 'undefined') {
me.useFullTools = true;
}
if(me.useFullTools) {
tools = toolsFull;
} else {
tools = toolsLight;
}
me.container.insertAdjacentHTML("beforeend", tools);
// event connect: get keyboard events
$(document).keydown(function(e) { me.keyDown(e); });

// event connect: configure annotation tools
me.push($(".push#display-minimize"), function() { me.changeToolbarDisplay("minimize"); });
me.chose($(".chose#penSize"), me.changePenSize);
me.toggle($(".toggle#precise"), me.togglePreciseCursor);
me.toggle($(".toggle#fill"), me.toggleFill);
me.toggle($(".toggle#fullscreen"), me.toggleFullscreen);
me.chose3state($(".chose#text"), me.toggleTextInput);
me.push($(".push#3drender"), me.render3D);
me.push($(".push#link"), me.link);
me.push($(".push#upload"), me.upload);
me.push($(".push#download"), me.download);
me.push($(".push#color"), me.color);
me.push($(".push#undo"), me.sendUndoMessage);
me.push($(".push#save"), me.sendSaveMessage);
me.push($(".push#prev"), me.prevSlice);
me.push($(".push#next"), me.nextSlice);
// event connect: chat message input
$("#msg").keypress((e) => { me.onkey(e); });
$("#tools-minimized").hide();
// load tools
me.loadTools();
// event connect: register click tools
*/

me._registerAllToolsDown();
me._registerAllToolsMove();
me._registerAllToolsUp();
Expand Down
22 changes: 22 additions & 0 deletions view/brainbox/src/pages/project-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ const PageContents = {

window.addEventListener('newMessage', this.handleNewChatMessages);
window.addEventListener('newNotification', this.handleNewNotification);
document.addEventListener('keydown', function(event) {
const selectedTr = document.querySelector('tr.selected');
if (!selectedTr) { return; }
switch(event.key) {
case 'ArrowUp':
if (selectedTr.previousElementSibling) {
selectedTr.previousElementSibling.click();
}
break;
case 'ArrowDown':
if (selectedTr.nextElementSibling) {
selectedTr.nextElementSibling.click();
}
break;
default:
break;
}
});
},

getDefaultAtlas(annotation) {
Expand Down Expand Up @@ -328,6 +346,10 @@ const PageContents = {
AtlasMakerWidget.changeTool(tool);
this.currentTool = tool;
this.displayAdjustSettings = false;
if(tool === 'Measure') {
// remove focus from button
document.activeElement.blur();
}
},

changePenSize(size) {
Expand Down

0 comments on commit 39d3de9

Please sign in to comment.