@doe-casl/verain-view
Advanced tools
Comparing version 1.3.28 to 1.3.29
{ | ||
"name": "@doe-casl/verain-view", | ||
"version": "1.3.28", | ||
"version": "1.3.29", | ||
"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.", |
@@ -5,2 +5,3 @@ import React from 'react'; | ||
import VTKWidget from '../widgets/VTKWidget'; | ||
import ThreeDToolbar from '../widgets/ThreeDToolbar'; | ||
import MapEditor from './MapEditor'; | ||
@@ -130,7 +131,5 @@ | ||
<div className={style.viewer}> | ||
<VTKWidget | ||
viewer={this.assemblyViewer} | ||
data={vizData} | ||
zRange={[1, 0.01]} | ||
/> | ||
<VTKWidget viewer={this.assemblyViewer} data={vizData}> | ||
<ThreeDToolbar zRange={[1, 0.01]} /> | ||
</VTKWidget> | ||
</div> | ||
@@ -137,0 +136,0 @@ )} |
@@ -5,6 +5,7 @@ import React from 'react'; | ||
import VTKWidget from '../widgets/VTKWidget'; | ||
import Cell2DPreview from '../widgets/Cell2DPreview'; | ||
import EditableList from '../widgets/EditableList'; | ||
import ThreeDToolbar from '../widgets/ThreeDToolbar'; | ||
import vtkCellVTKViewer from '../utils/CellVTKViewer'; | ||
import vtkCell2DViewer from '../utils/Cell2DViewer'; | ||
@@ -22,2 +23,18 @@ import { zip } from './utils'; | ||
function Cell2DToolbar(props) { | ||
return ( | ||
<div className={style.imageOverlayText}> | ||
Contact radius: {props.pitch * 0.5} | ||
</div> | ||
); | ||
} | ||
Cell2DToolbar.propTypes = { | ||
pitch: PropTypes.number, | ||
}; | ||
Cell2DToolbar.defaultProps = { | ||
pitch: 0, | ||
}; | ||
export default class CellEditor extends React.Component { | ||
@@ -32,3 +49,15 @@ constructor(props) { | ||
this.cellViewer = vtkCellVTKViewer.newInstance(); | ||
this.cell2dViewer = vtkCell2DViewer.newInstance(); | ||
this.cell2dViewer.setToolTipCallback((mat) => { | ||
const viz = this.props.ui.domain; | ||
return mat ? ( | ||
<span> | ||
{mat.radius} cm | ||
<br /> | ||
{viz.names[mat.material]} | ||
</span> | ||
) : null; | ||
}); | ||
this.addRadius = this.addRadius.bind(this); | ||
@@ -190,18 +219,11 @@ this.onMaterialChange = this.onMaterialChange.bind(this); | ||
<span className={style.visualizerPanelHeadline}>2D</span> | ||
<Cell2DPreview | ||
cellData={dataToRender} | ||
tooltipFormat={(mat) => | ||
mat ? ( | ||
<span> | ||
{mat.radius} cm | ||
<br /> | ||
{viz.names[mat.material]} | ||
</span> | ||
) : null | ||
} | ||
/> | ||
<VTKWidget viewer={this.cell2dViewer} data={dataToRender}> | ||
<Cell2DToolbar pitch={dataToRender.cellPitch} /> | ||
</VTKWidget> | ||
</div> | ||
<div className={style.visualizerPanel}> | ||
<span className={style.visualizerPanelHeadline}>3D</span> | ||
<VTKWidget viewer={this.cellViewer} data={dataToRender} /> | ||
<VTKWidget viewer={this.cellViewer} data={dataToRender}> | ||
<ThreeDToolbar /> | ||
</VTKWidget> | ||
</div> | ||
@@ -208,0 +230,0 @@ </div> |
@@ -5,2 +5,3 @@ import React from 'react'; | ||
import VTKWidget from '../widgets/VTKWidget'; | ||
import ThreeDToolbar from '../widgets/ThreeDToolbar'; | ||
import MapEditor from './MapEditor'; | ||
@@ -130,7 +131,5 @@ | ||
<div className={style.viewer}> | ||
<VTKWidget | ||
viewer={this.coreViewer} | ||
data={vizData} | ||
zRange={[1, 0.01]} | ||
/> | ||
<VTKWidget viewer={this.coreViewer} data={vizData}> | ||
<ThreeDToolbar zRange={[1, 0.01]} /> | ||
</VTKWidget> | ||
</div> | ||
@@ -137,0 +136,0 @@ )} |
@@ -7,2 +7,3 @@ import React from 'react'; | ||
import VTKWidget from '../widgets/VTKWidget'; | ||
import ThreeDToolbar from '../widgets/ThreeDToolbar'; | ||
@@ -196,5 +197,5 @@ import vtkRodVTKViewer from '../utils/RodVTKViewer'; | ||
zoom={10} | ||
zScaling={0.1} | ||
zRange={[1, 0.01]} | ||
/> | ||
> | ||
<ThreeDToolbar zScaling={0.1} zRange={[1, 0.01]} /> | ||
</VTKWidget> | ||
</div> | ||
@@ -201,0 +202,0 @@ <EditableList |
@@ -11,13 +11,5 @@ import macro from 'vtk.js/Sources/macro'; | ||
let zSlider = 1; | ||
if (props.zRange) { | ||
const [a, b] = props.zRange; | ||
zSlider = Math.abs(Math.round(100 * (props.zScaling - a) / (b - a))); | ||
} | ||
this.state = { | ||
parallelRendering: false, | ||
capture: null, | ||
zSlider, | ||
zScaling: props.zScaling, | ||
}; | ||
@@ -29,3 +21,2 @@ | ||
this.resetCamera = this.resetCamera.bind(this); | ||
this.sliderZScale = this.sliderZScale.bind(this); | ||
} | ||
@@ -38,14 +29,15 @@ | ||
// resize handling | ||
setTimeout(() => this.props.viewer.resize(), 1); | ||
window.addEventListener('resize', this.resize); | ||
// Push data on first load | ||
this.componentWillReceiveProps(this.props); | ||
this.props.viewer.setData(this.props.data); | ||
this.resetCamera(); | ||
setTimeout(this.resetCamera, 0); | ||
setTimeout(this.resetCamera, 10); | ||
setTimeout(() => { | ||
this.props.viewer.resize(); | ||
this.resetCamera(); | ||
}, 10); | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
this.props.viewer.setZScale(this.state.zScaling); | ||
this.props.viewer.setData(nextProps.data); | ||
@@ -72,10 +64,12 @@ } | ||
sliderZScale(e) { | ||
const zSlider = Number(e.target.value); | ||
const [a, b] = this.props.zRange; | ||
const zScaling = a + (b - a) * zSlider / 100; | ||
this.setState({ zSlider, zScaling }); | ||
this.props.viewer.setZScale(zScaling); | ||
this.resetCamera(); | ||
decorateProps(children) { | ||
return React.Children.map(children, (child) => { | ||
if (child && typeof child.type === 'function') { | ||
return React.cloneElement(child, { | ||
viewer: this.props.viewer, | ||
resetCamera: this.resetCamera, | ||
}); | ||
} | ||
return child; | ||
}); | ||
} | ||
@@ -86,14 +80,3 @@ | ||
<div className={style.container}> | ||
<div className={style.resetCamera} onClick={this.resetCamera} /> | ||
{this.props.zRange ? ( | ||
<input | ||
type="range" | ||
min="0" | ||
max="100" | ||
value={this.state.zSlider} | ||
step="1" | ||
className={style.slider} | ||
onChange={this.sliderZScale} | ||
/> | ||
) : null} | ||
{this.decorateProps(this.props.children)} | ||
<div | ||
@@ -116,4 +99,3 @@ className={style.container} | ||
zoom: PropTypes.number, | ||
zScaling: PropTypes.number, | ||
zRange: PropTypes.array, | ||
children: PropTypes.node, | ||
}; | ||
@@ -126,4 +108,3 @@ | ||
zoom: 1, | ||
zScaling: 1, | ||
zRange: null, | ||
children: [], | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6279960
61
20114