From 7a8157df578aa11457a478ec52e1e055fd0828d4 Mon Sep 17 00:00:00 2001 From: cesine Date: Sun, 19 Oct 2014 12:54:12 -0400 Subject: [PATCH] fixes #24 user can click and it will collect nearst vertex, shape and model file as well as point of intersection with the surface --- client/js/controllers/MainCtrl.js | 15 ++++++++++++++- client/js/directives/brainbrowser.js | 17 +++++++++++------ client/partials/base.html | 7 +++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/client/js/controllers/MainCtrl.js b/client/js/controllers/MainCtrl.js index ce776d6..18d4c50 100644 --- a/client/js/controllers/MainCtrl.js +++ b/client/js/controllers/MainCtrl.js @@ -113,7 +113,7 @@ angular.module('app') } } return data; - } + }; $scope.scatterplot1 = { options: { chart: { @@ -565,6 +565,19 @@ angular.module('app') vector: [] }]; + $scope.addPointToCurrentMouseMask = function(pick_info) { + $scope.mouseMasks[$scope.mouseMasks.length - 1].vector.push({ + modelID: pick_info.object.model_name, + shapeID: pick_info.object.name, + nearestVertex: pick_info.index, + point: pick_info.point + }); + console.log("last mask is ", $scope.mouseMasks[$scope.mouseMasks.length - 1]); + if (!$scope.$$phase) { + $scope.$digest(); //$digest or $apply + } + }; + $scope.runScript = function(scriptname) { console.warn("security hole, this should not permit execution of unknown scripts."); scriptname = scriptname.trim().replace(/[\/\\]+/g, ""); diff --git a/client/js/directives/brainbrowser.js b/client/js/directives/brainbrowser.js index f6b0969..e2eda8e 100644 --- a/client/js/directives/brainbrowser.js +++ b/client/js/directives/brainbrowser.js @@ -1,5 +1,5 @@ +/* globals angular, console, BrainBrowser, window, document, $, Image, THREE */ "use strict"; -/* globals FieldDB */ /** @@ -12,8 +12,8 @@ angular.module("app").directive("brainbrowser", function() { var controller = function($scope, $timeout) { console.log("Loading brain browser"); - + }; controller.$inject = ["$scope", "$location", "$timeout"]; @@ -32,7 +32,7 @@ angular.module("app").directive("brainbrowser", function() { /// UI niceties from examples/surface-viewer-demo.js - + var atlas_labels = {}; // Request variables used to cancel the current request @@ -46,7 +46,7 @@ angular.module("app").directive("brainbrowser", function() { } function hideLoading() { - scope.loading = false; + scope.loading = false; } // Make sure WebGL is available. @@ -515,16 +515,21 @@ angular.module("app").directive("brainbrowser", function() { viewer.clearScreen(); current_request = 0; current_request_name = ""; - loading_div.hide(); + // loading_div.hide(); }); - $("#brainbrowser").click(function(event) { + scope.element.addEventListener("click", function(event) { if (!event.shiftKey && !event.ctrlKey) return; if (viewer.model.children.length === 0) return; var annotation_display = $("#annotation-display"); var media = $("#annotation-media"); var pick_info = viewer.pick(); + //keep this click into the masks... + // + console.log("Adding a mouse pick ", pick_info); + scope.addPointToCurrentMouseMask(pick_info); + var model_data; var annotation_info; var value, label, text; diff --git a/client/partials/base.html b/client/partials/base.html index 72bd4b9..d0d96f6 100644 --- a/client/partials/base.html +++ b/client/partials/base.html @@ -9,6 +9,13 @@ + +