@doe-casl/verain-view
Advanced tools
Comparing version 1.3.19 to 1.3.20
{ | ||
"name": "@doe-casl/verain-view", | ||
"version": "1.3.19", | ||
"version": "1.3.20", | ||
"description": "VeraInView is a standalone HTML file that can act as an application to visualize your VERAin XML files.", | ||
@@ -5,0 +5,0 @@ "author": "Kitware, Inc.", |
@@ -115,4 +115,3 @@ import React from 'react'; | ||
const materialOptions = Object.keys(materials).map((id) => { | ||
// adds on opaque alpha channel | ||
const color = ColorManager.toRGBA(materials[id].color.concat([1])); | ||
const color = ColorManager.toRGBA(materials[id].color); | ||
return ( | ||
@@ -137,4 +136,3 @@ <option | ||
render: (matId, item) => { | ||
// adds on opaque alpha channel | ||
const color = ColorManager.toRGBA(materials[matId].color.concat([1])); | ||
const color = ColorManager.toRGBA(materials[matId].color); | ||
return ( | ||
@@ -141,0 +139,0 @@ <select |
@@ -88,3 +88,3 @@ import React from 'react'; | ||
// adds alpha channel | ||
const background = ColorManager.toRGBA(color.concat([1])); | ||
const background = ColorManager.toRGBA(color); | ||
return ( | ||
@@ -98,3 +98,3 @@ <select | ||
{Object.keys(cells).map((id) => { | ||
const bg = ColorManager.toRGBA(cells[id].color.concat([1])); | ||
const bg = ColorManager.toRGBA(cells[id].color); | ||
return ( | ||
@@ -133,3 +133,3 @@ <option key={id} value={id} style={{ background: bg }}> | ||
// adds alpha channel | ||
const background = ColorManager.toRGBA(color.concat([1])); | ||
const background = ColorManager.toRGBA(color); | ||
return Object.assign( | ||
@@ -136,0 +136,0 @@ { |
@@ -122,2 +122,61 @@ import macro from 'vtk.js/Sources/macro'; | ||
publicAPI.indexToIJ = (idx) => [ | ||
idx % model.gridSize, | ||
Math.floor(idx / model.gridSize), | ||
]; | ||
publicAPI.ijToIndex = (ij) => ij[0] + model.gridSize * ij[1]; | ||
publicAPI.getIndices = (idx) => { | ||
if (model.replacementMode === ReplacementMode.ALL) { | ||
const value = model.grid[idx]; | ||
const ids = []; | ||
for (let i = 0; i < model.grid.length; i++) { | ||
if (model.grid[i] === value) { | ||
ids.push(i); | ||
} | ||
} | ||
return ids; | ||
} | ||
const fn = SymmetryFn[model.symmetry] || none; | ||
const list = fn(model.gridSize, ...publicAPI.indexToIJ(idx)); | ||
return list.map(publicAPI.ijToIndex); | ||
}; | ||
/* eslint-disable default-case */ | ||
/* eslint-disable no-fallthrough */ | ||
publicAPI.getSymmetryAxialIndices = () => { | ||
const idx = []; | ||
const quadOffset = (model.gridSize - 1) / 2; | ||
switch (model.symmetry) { | ||
case SymmetryModes.OCTANT: | ||
for (let i = 0; i < model.gridSize; i++) { | ||
idx.push(i + i * model.gridSize); | ||
idx.push(model.gridSize - i - 1 + i * model.gridSize); | ||
} | ||
case SymmetryModes.QUADRANT_MIRROR: | ||
case SymmetryModes.QUADRANT_ROTATION: | ||
for (let i = 0; i < model.gridSize; i++) { | ||
idx.push(quadOffset + i * model.gridSize); | ||
idx.push(i + quadOffset * model.gridSize); | ||
} | ||
} | ||
return idx; | ||
}; | ||
/* eslint-enable default-case */ | ||
/* eslint-enable no-fallthrough */ | ||
const superSymmetry = publicAPI.setSymmetry; | ||
publicAPI.setSymmetry = (mode) => { | ||
if (superSymmetry(mode)) { | ||
const range = Math.floor(model.gridSize / 2); | ||
for (let j = 0; j < range; j++) { | ||
for (let i = 0; i < range; i++) { | ||
publicAPI.setGridEntry(i, j, publicAPI.getGridEntry(i, j)); | ||
} | ||
} | ||
} | ||
}; | ||
if (!model.grid) { | ||
@@ -124,0 +183,0 @@ publicAPI.setGridSize(model.gridSize); |
@@ -12,2 +12,8 @@ import React from 'react'; | ||
const SYMMETRY_STYLE = { | ||
border: 'solid 2px #333', | ||
// outline: 'solid 2px #333', | ||
borderRadius: '5px', | ||
}; | ||
// ---------------------------------------------------------------------------- | ||
@@ -53,2 +59,3 @@ | ||
this.state = { | ||
activeIds: [], | ||
selected: null, | ||
@@ -71,2 +78,4 @@ }; | ||
this.udpateMode = this.udpateMode.bind(this); | ||
this.onEnter = this.onEnter.bind(this); | ||
this.onLeave = this.onLeave.bind(this); | ||
} | ||
@@ -97,2 +106,12 @@ | ||
onEnter(e) { | ||
const idx = Number(e.currentTarget.dataset.idx); | ||
const activeIds = this.gridMap.getIndices(idx); | ||
this.setState({ activeIds }); | ||
} | ||
onLeave() { | ||
this.setState({ activeIds: [] }); | ||
} | ||
onClick(e) { | ||
@@ -128,2 +147,3 @@ const idx = Number(e.currentTarget.dataset.idx); | ||
render() { | ||
const axisIds = this.gridMap.getSymmetryAxialIndices(); | ||
const { itemRenderer: Item, itemRendererProps } = this.props; | ||
@@ -227,6 +247,16 @@ return ( | ||
data-idx={i} | ||
className={style.gridItem} | ||
className={ | ||
this.state.activeIds.length && | ||
this.state.activeIds.indexOf(i) === -1 | ||
? style.gridItem | ||
: style.activeGridItem | ||
} | ||
onClick={this.onClick} | ||
onMouseEnter={this.onEnter} | ||
onMouseLeave={this.onLeave} | ||
> | ||
<div className={style.inner}> | ||
<div | ||
className={style.inner} | ||
style={axisIds.indexOf(i) !== -1 ? SYMMETRY_STYLE : null} | ||
> | ||
<Item value={v} {...itemRendererProps} /> | ||
@@ -233,0 +263,0 @@ </div> |
Sorry, the diff of this file is not supported yet
6242402
19006