Skip to content

Commit

Permalink
Merge pull request #483 from Kitware/fix-local-remote-switch
Browse files Browse the repository at this point in the history
Fix local remote switch
  • Loading branch information
scottwittenburg authored Aug 22, 2018
2 parents fb43200 + 030fb4f commit c7849d6
Show file tree
Hide file tree
Showing 24 changed files with 6,705 additions and 7,788 deletions.
14,274 changes: 6,610 additions & 7,664 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"plotly.js": "1.38.1",
"vtk.js": "7.5.2",
"vtk.js": "7.6.1",
"wslink": "0.1.7",
"monologue.js": "0.3.5",
"mout": "1.1.0",
Expand All @@ -33,7 +33,7 @@
"gl-matrix": "2.6.1",
"hammerjs": "2.0.8",
"font-awesome": "4.7.0",
"kw-web-suite": "6.1.0",
"kw-web-suite": "6.2.0",
"kw-doc": "1.2.0",
"babel-plugin-istanbul": "4.1.6",
"karma": "2.0.2",
Expand All @@ -58,7 +58,7 @@
"doc:www": "kw-doc -c ./documentation/config.js -s",
"predoc:publish": "./tools/install-data/install-sample-data-cli.js",
"doc:publish": "kw-doc -c ./documentation/config.js -p",
"build": "webpack --progress --colors --mode development",
"build": "webpack --progress --colors --mode development --devtool source-map",
"build:release": "webpack --progress --colors --mode production",
"test": "karma start karma.conf.js",
"test:travis": "karma start karma.conf.js --browsers ChromeHeadlessNoSandbox --single-run",
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Core/LookupTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default class LookupTable {
return this.colorNaN;
}
const idxValue = Math.floor(
this.colorTableSize * (scalar - this.scalarRange[0]) / this.delta
(this.colorTableSize * (scalar - this.scalarRange[0])) / this.delta
);
if (idxValue < 0) {
return this.colorTable[0];
Expand Down
6 changes: 3 additions & 3 deletions src/Common/Misc/TimeProbeManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class TimeProbeManager {
} else {
const width = this.lastSize ? this.lastSize[0] : 200;
const height = this.lastSize ? this.lastSize[1] : 200;
const extent = [width / 4, 3 * width / 4, height / 4, 3 * height / 4];
const extent = [width / 4, (3 * width) / 4, height / 4, (3 * height) / 4];
this.addProbe(
new TimeProbe(`Probe ${this.probes.length + 1}`, 'mean', extent)
);
Expand Down Expand Up @@ -281,10 +281,10 @@ export class TimeProbeManager {
drag(event) {
const { activeArea, relative } = event;
const x = Math.round(
(relative.x - activeArea[0]) / activeArea[2] * this.lastSize[0]
((relative.x - activeArea[0]) / activeArea[2]) * this.lastSize[0]
);
const y = Math.round(
(relative.y - activeArea[1]) / activeArea[3] * this.lastSize[1]
((relative.y - activeArea[1]) / activeArea[3]) * this.lastSize[1]
);
const scale = this.lastSize[0] / activeArea[2];

Expand Down
2 changes: 1 addition & 1 deletion src/Common/Misc/UUID/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function generateUUID() {
d += window.performance.now(); // use high-precision timer if available
}
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = ((d + Math.random() * 16) % 16) | 0;
const r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
});
Expand Down
4 changes: 3 additions & 1 deletion src/IO/WebSocket/WslinkImageStream/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ function wslinkImageStream(publicAPI, model) {

publicAPI.viewChanged = (data) => {
const msg = data[0];
if (!msg || !msg.image || msg.id !== model.view_id) return;
/* eslint-disable eqeqeq */
if (!msg || !msg.image || msg.id != model.view_id) return;
/* eslint-enable eqeqeq */
const imgBlob = new Blob([msg.image], {
type: model.mimeType,
});
Expand Down
19 changes: 7 additions & 12 deletions src/InfoViz/Native/FieldSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function fieldSelector(publicAPI, model) {

if (el) {
d3.select(model.container).html(template);
d3
.select(model.container)
d3.select(model.container)
.select('.fieldSelector')
.classed(style.fieldSelector, true);

Expand Down Expand Up @@ -81,16 +80,13 @@ function fieldSelector(publicAPI, model) {
const legendSize = 15;

// Apply style
d3
.select(model.container)
d3.select(model.container)
.select('thead')
.classed(style.thead, true);
d3
.select(model.container)
d3.select(model.container)
.select('tbody')
.classed(style.tbody, true);
d3
.select(model.container)
d3.select(model.container)
.select('th.field-selector-mode')
.on('click', (d) => {
model.displayUnselected = !model.displayUnselected;
Expand Down Expand Up @@ -119,8 +115,7 @@ function fieldSelector(publicAPI, model) {
: model.provider.getFieldNames().length;

// Update header label
d3
.select(model.container)
d3.select(model.container)
.select('th.field-selector-label')
.style('text-align', 'left')
.text(
Expand Down Expand Up @@ -274,7 +269,7 @@ function fieldSelector(publicAPI, model) {
)
.attr('pname', fieldName)
.attr('y', (d) => model.fieldHistHeight * (1.0 - d / cmax))
.attr('x', (d, i) => model.fieldHistWidth / hsize * i)
.attr('x', (d, i) => (model.fieldHistWidth / hsize) * i)
.attr('height', (d) => model.fieldHistHeight * (d / cmax))
.attr('width', model.fieldHistWidth / hsize);

Expand All @@ -286,7 +281,7 @@ function fieldSelector(publicAPI, model) {
.on('mousemove', function inner(d, i) {
const mCoords = d3.mouse(this);
const binNum = Math.floor(
mCoords[0] / model.fieldHistWidth * hsize
(mCoords[0] / model.fieldHistWidth) * hsize
);
const state = {};
state[fieldName] = [binNum];
Expand Down
44 changes: 20 additions & 24 deletions src/InfoViz/Native/HistogramSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,15 @@ function histogramSelector(publicAPI, model) {
function updateHeader(dataLength) {
if (model.singleModeSticky) {
// header isn't useful for a single histogram.
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeader}`)
.style('display', 'none');
return;
}
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeader}`)
.style('display', null);
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsFieldsIcon}`)
// apply class - 'false' should come first to not remove common base class.
.classed(
Expand All @@ -310,24 +307,20 @@ function histogramSelector(publicAPI, model) {
);
scoreHelper.updateHeader();

d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeaderBoxes}`)
.style('display', model.singleModeName === null ? null : 'none');
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeaderBoxesNum}`)
.text(`${model.boxesPerRow} /row`);

d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeaderSingle}`)
.style('display', model.singleModeName === null ? 'none' : null);

if (model.provider.isA('LegendProvider') && model.singleModeName) {
const { color, shape } = model.provider.getLegend(model.singleModeName);
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeaderSingleField}`)
.html(
`<svg class='${
Expand All @@ -339,8 +332,7 @@ function histogramSelector(publicAPI, model) {
}'/></svg>`
);
} else {
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsHeaderSingleField}`)
.text(() => {
let name = model.singleModeName;
Expand All @@ -366,9 +358,10 @@ function histogramSelector(publicAPI, model) {
const deltaHeader = model.singleModeSticky ? 0 : model.headerSize;
if (clientRect.width !== 0 && clientRect.height > deltaHeader) {
model.containerHidden = false;
d3
.select(model.listContainer)
.style('height', `${clientRect.height - deltaHeader}px`);
d3.select(model.listContainer).style(
'height',
`${clientRect.height - deltaHeader}px`
);
// scrollbarWidth = model.listContainer.offsetWidth - clientRect.width;
publicAPI.render();
} else {
Expand Down Expand Up @@ -538,8 +531,7 @@ function histogramSelector(publicAPI, model) {
reusableNode = exitNodes[0][i];
if (reusableNode) {
exitNodes[0][i] = undefined;
d3
.select(reusableNode)
d3.select(reusableNode)
.selectAll('table')
.classed(style.hiddenBox, true);
return reusableNode;
Expand Down Expand Up @@ -729,7 +721,7 @@ function histogramSelector(publicAPI, model) {
)
.attr('pname', def.name)
.attr('y', (d) => model.histHeight * (1.0 - d / cmax))
.attr('x', (d, i) => model.histWidth / hsize * i)
.attr('x', (d, i) => (model.histWidth / hsize) * i)
.attr('height', (d) => model.histHeight * (d / cmax))
.attr('width', Math.ceil(model.histWidth / hsize));

Expand All @@ -747,7 +739,9 @@ function histogramSelector(publicAPI, model) {
svgOverlay
.on('mousemove.hs', (d, i) => {
const mCoords = publicAPI.getMouseCoords(tdsl);
const binNum = Math.floor(mCoords[0] / model.histWidth * hsize);
const binNum = Math.floor(
(mCoords[0] / model.histWidth) * hsize
);
const state = {};
state[def.name] = [binNum];
model.provider.setHoverState({ state });
Expand Down Expand Up @@ -796,7 +790,9 @@ function histogramSelector(publicAPI, model) {
// if they aren't 'nice'. Make exactly 5 ticks.
const myTicks = d3
.range(numTicks)
.map((d) => minRange + d / (numTicks - 1) * (maxRange - minRange));
.map(
(d) => minRange + (d / (numTicks - 1)) * (maxRange - minRange)
);
def.xAxis.tickValues(myTicks);
} else {
def.xAxis.tickValues(def.xScale.domain());
Expand Down
9 changes: 3 additions & 6 deletions src/InfoViz/Native/HistogramSelector/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ export default function init(inPublicAPI, inModel) {

function updateHeader() {
if (enabled()) {
d3
.select(model.container)
d3.select(model.container)
.select(`.${style.jsShowScoredIcon}`)
// apply class - 'false' should come first to not remove common base class.
.classed(
Expand Down Expand Up @@ -1059,15 +1058,13 @@ export default function init(inPublicAPI, inModel) {
if (oldRangeMax === oldRangeMin) {
// space dividers evenly in the middle - i.e. punt.
divider.value =
(index + 1) /
(def.dividers.length + 1) *
((index + 1) / (def.dividers.length + 1)) *
(hobj.max - hobj.min) +
hobj.min;
} else {
// this set the divider to hobj.min if the new hobj.min === hobj.max.
divider.value =
(divider.value - oldRangeMin) /
(oldRangeMax - oldRangeMin) *
((divider.value - oldRangeMin) / (oldRangeMax - oldRangeMin)) *
(hobj.max - hobj.min) +
hobj.min;
}
Expand Down
42 changes: 16 additions & 26 deletions src/InfoViz/Native/MutualInformationDiagram/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ function informationDiagram(publicAPI, model) {

model.clientRect = model.container.getBoundingClientRect();

d3
.select(model.container)
d3.select(model.container)
.select('div.status-bar-container')
.attr('data-width', `${model.clientRect.width - 20}px`);

Expand Down Expand Up @@ -156,8 +155,7 @@ function informationDiagram(publicAPI, model) {
// select text so user can press ctrl-c if desired.
if (model.statusBarVisible) {
// https://www.sitepoint.com/javascript-copy-to-clipboard/
d3
.select(model.container)
d3.select(model.container)
.select('input.status-bar-text')
.node()
.select();
Expand Down Expand Up @@ -188,13 +186,11 @@ function informationDiagram(publicAPI, model) {

if (variableList.length < 2 || !model.container) {
// Select the main circle and hide it and unhide placeholder
d3
.select(model.container)
d3.select(model.container)
.select('svg.information-diagram')
.classed(style.informationDiagramSvgShow, false)
.classed(style.informationDiagramSvgHide, true);
d3
.select(model.container)
d3.select(model.container)
.select('div.info-diagram-placeholder')
.classed(style.hidden, false);
publicAPI.updateStatusBarText('');
Expand Down Expand Up @@ -222,12 +218,10 @@ function informationDiagram(publicAPI, model) {
// Update
updateStatusBarVisibility();

d3
.select(model.container)
d3.select(model.container)
.select('div.info-diagram-placeholder')
.classed(style.hidden, true);
d3
.select(model.container)
d3.select(model.container)
.select('svg.information-diagram')
.classed(style.informationDiagramSvgHide, false)
.classed(style.informationDiagramSvgShow, true);
Expand Down Expand Up @@ -918,21 +912,17 @@ function informationDiagram(publicAPI, model) {
// drop the middle 50%.
let testStrLen = Math.floor(strLength * 0.25);
// estimate new length, +2 to account for adding '...'
d.textLength = (testStrLen * 2 + 2) / strLength * textLength;
d.textLength = ((testStrLen * 2 + 2) / strLength) * textLength;
if (d.textLength < availLength) {
d3
.select(this)
.text(
`${fullText.slice(0, testStrLen)}...${fullText.slice(
-testStrLen
)}`
);
d3.select(this).text(
`${fullText.slice(0, testStrLen)}...${fullText.slice(-testStrLen)}`
);
return;
}
// start at 1/3 of the string, go down to 3 chars plus ...
testStrLen = Math.floor(strLength / 2.99);
while (testStrLen >= 3) {
d.textLength = (testStrLen + 2) / strLength * textLength;
d.textLength = ((testStrLen + 2) / strLength) * textLength;
if (d.textLength < availLength) {
d3.select(this).text(`${fullText.slice(0, testStrLen)}...`);
return;
Expand Down Expand Up @@ -968,8 +958,8 @@ function informationDiagram(publicAPI, model) {
// Start at edge of arc, move to text anchor, back up half of text length and glyph size
const glyphAngle =
glyphData.startAngle +
pathLength * 0.25 / outerRadius -
(textLength + model.glyphSize) * 0.5 / avgRadius;
(pathLength * 0.25) / outerRadius -
((textLength + model.glyphSize) * 0.5) / avgRadius;
// console.log(model.mutualInformationData.vmap[glyphData.index].name, textLength, pathLength, glyphAngle);

glyph
Expand Down Expand Up @@ -1029,8 +1019,8 @@ function informationDiagram(publicAPI, model) {

function getBinRange(index, numberOfBins, paramRange) {
return [
index / numberOfBins * paramRange[2] + paramRange[0],
(index + 1) / numberOfBins * paramRange[2] + paramRange[0],
(index / numberOfBins) * paramRange[2] + paramRange[0],
((index + 1) / numberOfBins) * paramRange[2] + paramRange[0],
];
}

Expand All @@ -1056,7 +1046,7 @@ function informationDiagram(publicAPI, model) {
endAngle: (i + 1) * delta + groupData.startAngle,
innerRadius: outerRadius + 10,
outerRadius:
outerRadius + 10 + d / maxcnt * (histoRadius - outerRadius),
outerRadius + 10 + (d / maxcnt) * (histoRadius - outerRadius),
index: i,
value: d / total,
};
Expand Down
2 changes: 1 addition & 1 deletion src/InfoViz/Native/MutualInformationDiagram/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function freqToProb(src) {
for (let j = 0; j < hsz; ++j) {
const pj = pAB[i][j];
if (pj > 0) {
pmi[i][j] = -1 * Math.log(pj / pA[i][0] / pB[0][j]) / Math.log(pj);
pmi[i][j] = (-1 * Math.log(pj / pA[i][0] / pB[0][j])) / Math.log(pj);
}
}
}
Expand Down
Loading

0 comments on commit c7849d6

Please sign in to comment.