Skip to content

Commit

Permalink
TVB-2359 Fix sphere rendering non-selected channel
Browse files Browse the repository at this point in the history
Fix not requesting energy data while updating channel selection
  • Loading branch information
kimonoki committed Aug 31, 2018
1 parent 6484a31 commit 18a38f1
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
24 changes: 18 additions & 6 deletions tvb/interfaces/web/static/js/tvbviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,17 @@ tv.plot = {
f.render();
}; // end function f()

f.update_energy=function(){
var all_slice = f.current_slice();
all_slice[0].di = f.shape()[1];
all_slice[0].hi = f.shape()[0];
all_slice[0].lo = 0;
tv.util.get_time_selection_energy(f.baseURL(), all_slice, f.energy_callback, f.channels(), f.mode(), f.state_var(), timeselection_interval_length);

};

f.channel_lasttime=null;

f.energy_callback = function (data) {
timeselection_energy = data;
if (isInternalSensorView) {
Expand Down Expand Up @@ -630,7 +641,6 @@ tv.plot = {
f.prepare_data();
f.status_line.text("rendering data...");
f.render_focus();

if (!f.we_are_setup) {
f.render_contexts();
f.add_brushes();
Expand Down Expand Up @@ -1219,8 +1229,6 @@ tv.plot = {


f.br_fcs_startfn = function () {
// we will use the left upper of the brush to do a tooltip

//select a channel
var event_selection_y = [];
event_selection_y[1] = d3.event.selection[0][1];
Expand Down Expand Up @@ -1313,18 +1321,20 @@ tv.plot = {

if (triggered_by_timeselection) {
var timeselection_lasttime=timeselection_interval_length;

timeselection_interval = timeselection[1] - timeselection[0];
timeselection_interval_length = parseInt(timeselection_interval / f.dt()) - 1;

//retrieve energy for the whole timeline rather than a slice
var all_slice = f.current_slice();
all_slice[0].di = f.shape()[1];
all_slice[0].hi = f.shape()[0];
all_slice[0].lo = 0;

//call the energy computation method and block until get the enery data
if(timeselection_lasttime!=timeselection_interval_length){
//call the energy computation method and block until get the enery data if channel or time range is changed
if(timeselection_lasttime!=timeselection_interval_length||f.channel_lasttime!==f.channels()){
showBlockerOverlay(50000);
tv.util.get_time_selection_energy(f.baseURL(), all_slice, f.energy_callback, f.channels(), f.mode(), f.state_var(), timeselection_interval_length);
f.update_energy();
}
else if(timeselection_lasttime===timeselection_interval_length&&timeselection_interval_length!=0){
if (isInternalSensorView) {
Expand All @@ -1334,6 +1344,8 @@ tv.plot = {
changeSphereMeasurePoints_energy();
}
}
f.channel_lasttime=f.channels();

//update the time in the input tag
var time_index = parseInt((timeselection[0] - f.t0()) / f.dt());
triggered_by_changeinput = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@ function _VSI_bufferAtPoint(p, idx) {
}

function VSI_change_energySphericalMeasurePoints() {
for (let i = 0; i < VS_selectedRegions.length; i++) {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], timeselection_energy[i][currentTimeValue], 12, 12);
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
const vertexRegionBuffer = VSI_createColorBufferForSphere(i, bufferVertices.numItems * 3);
measurePointsBuffers[i] = [bufferVertices, bufferNormals, bufferTriangles, vertexRegionBuffer];
let energyIndex = 0;
for (let i = 0; i < NO_OF_MEASURE_POINTS; i++) {
if (tsView.channels().includes(i)) {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], timeselection_energy[energyIndex][currentTimeValue], 12, 12);
energyIndex++;
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
const vertexRegionBuffer = VSI_createColorBufferForSphere(i, bufferVertices.numItems * 3);
measurePointsBuffers[i] = [bufferVertices, bufferNormals, bufferTriangles, vertexRegionBuffer];
}
else {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], 3, 12, 12);
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
const vertexRegionBuffer = VSI_createColorBufferForSphere(i, bufferVertices.numItems * 3);
measurePointsBuffers[i] = [bufferVertices, bufferNormals, bufferTriangles, vertexRegionBuffer];
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function _VS_init_cubicalMeasurePoints() {

function _VS_init_sphereMeasurePoints() {
for (let i = 0; i < NO_OF_MEASURE_POINTS; i++) {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], 1);//3 for the default radius value now, we will modify it later
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], 2);//2 for the default radius value now, we will modify it later
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
Expand Down Expand Up @@ -1428,13 +1428,25 @@ function readFileData(fileUrl, async, callIdentifier) {
/////////////////////////////////////// ~~~~~~~~~~ START ENERGY RELATED METHOD ~~~~~~~~~~~~~ //////////////////////////////////
//init spheres with energy controlling the radius
function changeSphereMeasurePoints_energy() {
for (let i = 0; i < NO_OF_MEASURE_POINTS; i++) {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], timeselection_energy[i][currentTimeValue]);//3 for the default radius value now, we will modify it later
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
const bufferColor = createColorBufferForCube(false);
measurePointsBuffers[i] = [bufferVertices, bufferNormals, bufferTriangles, bufferColor];
let energyIndex = 0;
for (let i = 0; i < NO_OF_MEASURE_POINTS; i++) {
if (tsView.channels().includes(i)) {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], timeselection_energy[energyIndex][currentTimeValue]);
energyIndex++;
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
const bufferColor = createColorBufferForCube(false);
measurePointsBuffers[i] = [bufferVertices, bufferNormals, bufferTriangles, bufferColor];
}
else {
const result = HLPR_sphereBufferAtPoint(gl, measurePoints[i], 2);
const bufferVertices = result[0];
const bufferNormals = result[1];
const bufferTriangles = result[2];
const bufferColor = createColorBufferForCube(false);
measurePointsBuffers[i] = [bufferVertices, bufferNormals, bufferTriangles, bufferColor];
}
}
}

Expand Down

0 comments on commit 18a38f1

Please sign in to comment.