Skip to content

Commit 487a350

Browse files
authored
Merge pull request #486 from Kitware/fix-travis
Fix travis
2 parents 59a860b + 2157d80 commit 487a350

File tree

21 files changed

+580
-383
lines changed

21 files changed

+580
-383
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
language: node_js
22
os: linux
3+
sudo: required
34
dist: trusty
45
group: travis_lts
56
before_install:
67
- sudo apt-get -qq update
78
- sudo apt-get install -y libgif-dev
9+
- npm install -g [email protected]
810
before_script:
911
- "export DISPLAY=:99.0"
1012
- "sh -e /etc/init.d/xvfb start"
@@ -27,7 +29,6 @@ cache:
2729
- Documentation/build-tmp
2830

2931
script:
30-
- npm install
3132
- npm run build:release
3233
- npm run validate
3334
- npm run test:travis

Examples/Applications/GeometryViewer/index.js

Lines changed: 100 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
import 'babel-polyfill';
55
import 'vtk.js/Sources/favicon';
66

7-
import HttpDataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper';
8-
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';
9-
import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/ColorMaps';
10-
import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction';
11-
import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow';
12-
import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
13-
import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract';
14-
import vtkXMLPolyDataReader from 'vtk.js/Sources/IO/XML/XMLPolyDataReader';
15-
import { ColorMode, ScalarMode } from 'vtk.js/Sources/Rendering/Core/Mapper/Constants';
7+
import HttpDataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper';
8+
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';
9+
import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/ColorMaps';
10+
import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction';
11+
import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow';
12+
import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
13+
import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract';
14+
import vtkXMLPolyDataReader from 'vtk.js/Sources/IO/XML/XMLPolyDataReader';
15+
import {
16+
ColorMode,
17+
ScalarMode,
18+
} from 'vtk.js/Sources/Rendering/Core/Mapper/Constants';
1619

1720
import style from './GeometryViewer.mcss';
1821
import icon from '../../../Documentation/content/icon/favicon-96x96.png';
@@ -29,12 +32,12 @@ const userParams = vtkURLExtract.extractURLParameters();
2932

3033
// Background handling
3134
if (userParams.background) {
32-
background = userParams.background.split(',').map(s => Number(s));
35+
background = userParams.background.split(',').map((s) => Number(s));
3336
}
3437
const selectorClass =
35-
(background.length === 3 && background.reduce((a, b) => a + b, 0) < 1.5)
36-
? style.dark
37-
: style.light;
38+
background.length === 3 && background.reduce((a, b) => a + b, 0) < 1.5
39+
? style.dark
40+
: style.light;
3841

3942
// name
4043
const defaultName = userParams.name || '';
@@ -47,12 +50,14 @@ const field = userParams.field || '';
4750

4851
// camera
4952
function updateCamera(camera) {
50-
['zoom', 'pitch', 'elevation', 'yaw', 'azimuth', 'roll', 'dolly'].forEach((key) => {
51-
if (userParams[key]) {
52-
camera[key](userParams[key]);
53+
['zoom', 'pitch', 'elevation', 'yaw', 'azimuth', 'roll', 'dolly'].forEach(
54+
(key) => {
55+
if (userParams[key]) {
56+
camera[key](userParams[key]);
57+
}
58+
renderWindow.render();
5359
}
54-
renderWindow.render();
55-
});
60+
);
5661
}
5762

5863
function preventDefaults(e) {
@@ -115,15 +120,31 @@ function createPipeline(fileName, fileContents) {
115120
// Create UI
116121
const presetSelector = document.createElement('select');
117122
presetSelector.setAttribute('class', selectorClass);
118-
presetSelector.innerHTML = vtkColorMaps
119-
.rgbPresetNames
120-
.map(name => `<option value="${name}" ${lutName === name ? 'selected="selected"' : ''}>${name}</option>`)
123+
presetSelector.innerHTML = vtkColorMaps.rgbPresetNames
124+
.map(
125+
(name) =>
126+
`<option value="${name}" ${
127+
lutName === name ? 'selected="selected"' : ''
128+
}>${name}</option>`
129+
)
121130
.join('');
122131

123132
const representationSelector = document.createElement('select');
124133
representationSelector.setAttribute('class', selectorClass);
125-
representationSelector.innerHTML = ['Hidden', 'Points', 'Wireframe', 'Surface', 'Surface with Edge']
126-
.map((name, idx) => `<option value="${idx === 0 ? 0 : 1}:${idx < 4 ? idx - 1 : 2}:${idx === 4 ? 1 : 0}">${name}</option>`).join('');
134+
representationSelector.innerHTML = [
135+
'Hidden',
136+
'Points',
137+
'Wireframe',
138+
'Surface',
139+
'Surface with Edge',
140+
]
141+
.map(
142+
(name, idx) =>
143+
`<option value="${idx === 0 ? 0 : 1}:${idx < 4 ? idx - 1 : 2}:${
144+
idx === 4 ? 1 : 0
145+
}">${name}</option>`
146+
)
147+
.join('');
127148
representationSelector.value = '1:2:0';
128149

129150
const colorBySelector = document.createElement('select');
@@ -188,7 +209,11 @@ function createPipeline(fileName, fileContents) {
188209
// --------------------------------------------------------------------
189210

190211
function updateRepresentation(event) {
191-
const [visibility, representation, edgeVisibility] = event.target.value.split(':').map(Number);
212+
const [
213+
visibility,
214+
representation,
215+
edgeVisibility,
216+
] = event.target.value.split(':').map(Number);
192217
actor.getProperty().set({ representation, edgeVisibility });
193218
actor.setVisibility(!!visibility);
194219
renderWindow.render();
@@ -212,25 +237,48 @@ function createPipeline(fileName, fileContents) {
212237
// --------------------------------------------------------------------
213238

214239
const colorByOptions = [{ value: ':', label: 'Solid color' }].concat(
215-
source.getPointData().getArrays().map(a => ({ label: `(p) ${a.getName()}`, value: `PointData:${a.getName()}` })),
216-
source.getCellData().getArrays().map(a => ({ label: `(c) ${a.getName()}`, value: `CellData:${a.getName()}` })));
240+
source
241+
.getPointData()
242+
.getArrays()
243+
.map((a) => ({
244+
label: `(p) ${a.getName()}`,
245+
value: `PointData:${a.getName()}`,
246+
})),
247+
source
248+
.getCellData()
249+
.getArrays()
250+
.map((a) => ({
251+
label: `(c) ${a.getName()}`,
252+
value: `CellData:${a.getName()}`,
253+
}))
254+
);
217255
colorBySelector.innerHTML = colorByOptions
218-
.map(({ label, value }) => `<option value="${value}" ${field === value ? 'selected="selected"' : ''}>${label}</option>`)
256+
.map(
257+
({ label, value }) =>
258+
`<option value="${value}" ${
259+
field === value ? 'selected="selected"' : ''
260+
}>${label}</option>`
261+
)
219262
.join('');
220263

221264
function updateColorBy(event) {
222265
const [location, colorByArrayName] = event.target.value.split(':');
223-
const interpolateScalarsBeforeMapping = (location === 'PointData');
266+
const interpolateScalarsBeforeMapping = location === 'PointData';
224267
let colorMode = ColorMode.DEFAULT;
225268
let scalarMode = ScalarMode.DEFAULT;
226-
const scalarVisibility = (location.length > 0);
269+
const scalarVisibility = location.length > 0;
227270
if (scalarVisibility) {
228-
const activeArray = source[`get${location}`]().getArrayByName(colorByArrayName);
271+
const activeArray = source[`get${location}`]().getArrayByName(
272+
colorByArrayName
273+
);
229274
const newDataRange = activeArray.getRange();
230275
dataRange[0] = newDataRange[0];
231276
dataRange[1] = newDataRange[1];
232277
colorMode = ColorMode.MAP_SCALARS;
233-
scalarMode = (location === 'PointData') ? ScalarMode.USE_POINT_FIELD_DATA : ScalarMode.USE_CELL_FIELD_DATA;
278+
scalarMode =
279+
location === 'PointData'
280+
? ScalarMode.USE_POINT_FIELD_DATA
281+
: ScalarMode.USE_CELL_FIELD_DATA;
234282

235283
const numberOfComponents = activeArray.getNumberOfComponents();
236284
if (numberOfComponents > 1) {
@@ -244,7 +292,9 @@ function createPipeline(fileName, fileContents) {
244292
while (compOpts.length <= numberOfComponents) {
245293
compOpts.push(`Component ${compOpts.length}`);
246294
}
247-
componentSelector.innerHTML = compOpts.map((t, index) => `<option value="${index - 1}">${t}</option>`).join('');
295+
componentSelector.innerHTML = compOpts
296+
.map((t, index) => `<option value="${index - 1}">${t}</option>`)
297+
.join('');
248298
} else {
249299
componentSelector.style.display = 'none';
250300
}
@@ -294,7 +344,14 @@ function createPipeline(fileName, fileContents) {
294344
renderer.resetCamera();
295345
renderWindow.render();
296346

297-
global.pipeline[fileName] = { actor, mapper, source, lookupTable, renderer, renderWindow };
347+
global.pipeline[fileName] = {
348+
actor,
349+
mapper,
350+
source,
351+
lookupTable,
352+
renderer,
353+
renderWindow,
354+
};
298355
}
299356

300357
// ----------------------------------------------------------------------------
@@ -326,11 +383,15 @@ export function load(container, options) {
326383
container.appendChild(progressContainer);
327384

328385
const progressCallback = (progressEvent) => {
329-
const percent = Math.floor(100 * progressEvent.loaded / progressEvent.total);
386+
const percent = Math.floor(
387+
100 * progressEvent.loaded / progressEvent.total
388+
);
330389
progressContainer.innerHTML = `Loading ${percent}%`;
331390
};
332391

333-
HttpDataAccessHelper.fetchBinary(options.fileURL, { progressCallback }).then((binary) => {
392+
HttpDataAccessHelper.fetchBinary(options.fileURL, {
393+
progressCallback,
394+
}).then((binary) => {
334395
container.removeChild(progressContainer);
335396
createViewer(container);
336397
createPipeline(defaultName, binary);
@@ -354,7 +415,9 @@ export function initLocalFileLoader(container) {
354415
}
355416

356417
const fileContainer = document.createElement('div');
357-
fileContainer.innerHTML = `<div class="${style.bigFileDrop}"/><input type="file" multiple accept=".vtp" style="display: none;"/>`;
418+
fileContainer.innerHTML = `<div class="${
419+
style.bigFileDrop
420+
}"/><input type="file" multiple accept=".vtp" style="display: none;"/>`;
358421
myContainer.appendChild(fileContainer);
359422

360423
const fileInput = fileContainer.querySelector('input');
@@ -371,11 +434,10 @@ export function initLocalFileLoader(container) {
371434

372435
fileInput.addEventListener('change', handleFile);
373436
fileContainer.addEventListener('drop', handleFile);
374-
fileContainer.addEventListener('click', e => fileInput.click());
437+
fileContainer.addEventListener('click', (e) => fileInput.click());
375438
fileContainer.addEventListener('dragover', preventDefaults);
376439
}
377440

378-
379441
// Look at URL an see if we should load a file
380442
// ?fileURL=https://data.kitware.com/api/v1/item/59cdbb588d777f31ac63de08/download
381443
if (userParams.url || userParams.fileURL) {

0 commit comments

Comments
 (0)