Skip to content

Commit

Permalink
fix(Simput): Fix editor when starting from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed May 10, 2018
1 parent 7bc6d57 commit 865d7a3
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/simput/AssemblyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default class AssemblyEditor extends React.Component {

render() {
const viz = this.props.ui.domain;
const vizData = Object.assign({ selected: this.props.viewData.id }, viz);
const selected = this.props.viewData.id;
const vizData = Object.assign({ selected }, viz);
return (
<div className={style.container}>
<div className={style.switch}>
Expand All @@ -119,7 +120,7 @@ export default class AssemblyEditor extends React.Component {
{this.state.is2D ? (
<MapEditor
data={this.props.data}
gridSize={viz.assembly[vizData.selected].size}
gridSize={viz.assemblyGridSize}
items={['0'].concat(Object.keys(viz.rods))}
names={viz.names}
colors={convertToRGB(viz.colors)}
Expand Down
2 changes: 1 addition & 1 deletion src/simput/CoreEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class CoreEditor extends React.Component {
{this.state.is2D ? (
<MapEditor
data={this.props.data}
gridSize={viz.core.size}
gridSize={viz.coreGridSize}
items={['0'].concat(Object.keys(viz.assembly))}
names={viz.names}
colors={convertToRGB(viz.colors)}
Expand Down
6 changes: 1 addition & 5 deletions src/simput/MapEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ export default class MapEditor extends React.Component {
}

render() {
if (
!this.props.data.value ||
!this.props.data.value[0] ||
!this.props.data.value[0].config
) {
if (!this.props.data.value || !this.props.data.value[0]) {
return null;
}

Expand Down
7 changes: 5 additions & 2 deletions src/simput/RodEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default class RodEditor extends React.Component {

render() {
const viz = this.props.ui.domain;
if (!viz.rods) {
return null;
}

const columns = [
{
Expand Down Expand Up @@ -177,7 +180,7 @@ export default class RodEditor extends React.Component {
// }

const rodData = Object.assign({ selected: this.props.viewData.id }, viz);
const rod = rodData.rods[rodData.selected];
const rod = rodData.rods[rodData.selected] || { offset: 0, length: 0 };

return (
<div>
Expand All @@ -194,7 +197,7 @@ export default class RodEditor extends React.Component {
zRange={[1, 0.01]}
orientation={[0, 1000, 0]}
viewUp={[1, 0, 0]}
zoom={10}
zoom={5}
/>
</ViewerWidget>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/utils/Cell2DViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ function vtkCell2DViewer(publicAPI, model) {
// --------------------------------------------------------------------------

publicAPI.render = () => {
if (!model.cell) {
if (
!model.cell ||
!model.cell.cells ||
!model.cell.cells[model.cell.selected]
) {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion src/utils/CellVTKViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,23 @@ function vtkCellVTKViewer(publicAPI, model) {
// [...]
// }
publicAPI.setData = (cell) => {
if (!cell.cells) {
return;
}
model.activeCell = cell.cells[cell.selected];
model.labels = cell.names;
model.source.clearRadius();

if (!model.activeCell || !model.activeCell.length) {
return;
}

const pitch = cell.cellPitch;
const { radius, cellFields, RGBPoints } = extractCellSettings(
model.activeCell,
cell.colors
);
model.lookupTable.applyColorMap({ RGBPoints });
model.source.clearRadius();
for (let i = 0; i < radius.length; i++) {
model.source.addRadius(radius[i], cellFields[i]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/CoreMapVTKViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ function vtkCoreMapVTKViewer(publicAPI, model) {
// },
// }
publicAPI.setData = (viz) => {
if (!viz) {
if (!viz || !viz.core || !viz.core[viz.selected]) {
publicAPI.removeAllActors();
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/RodMapVTKViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ function vtkRodMapVTKViewer(publicAPI, model) {
// },
// }
publicAPI.setData = (viz) => {
if (!viz) {
if (!viz || !viz.assembly || !viz.assembly[viz.selected]) {
publicAPI.removeAllActors();
return;
}

Expand Down
7 changes: 6 additions & 1 deletion src/utils/RodVTKViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ function vtkRodVTKViewer(publicAPI, model) {
// [...]
// }
publicAPI.setData = (viz) => {
publicAPI.removeAllActors();

if (!viz.rods[viz.selected]) {
return;
}

const { colors, cells, cellPitch } = viz;
const {
offset: originalOffset,
Expand All @@ -169,7 +175,6 @@ function vtkRodVTKViewer(publicAPI, model) {
const matIdMapping = processColors(colors, model.lookupTable);
const cellMap = processCells(cells, matIdMapping);

publicAPI.removeAllActors();
model.labels = viz.names;
model.stack = [];

Expand Down

0 comments on commit 865d7a3

Please sign in to comment.