Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
gui
fsl-gui-bet
Commits
e5cb9477
Commit
e5cb9477
authored
Feb 24, 2022
by
Taylor Hanayik
Browse files
Merge branch 'fix-canvas-render' into 'master'
fix multiple niivue rendering See merge request
!8
parents
ea026ff0
19ccb388
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/App.jsx
View file @
e5cb9477
...
...
@@ -20,11 +20,13 @@ const runSocket = io(`ws://${host}:${socketServerPort}`)
const
nv
=
new
Niivue
()
const
NiiVue
=
({
images
})
=>
{
const
NiiVue
=
({
url
})
=>
{
// use url string (primative) since object equality will not work with effects
const
canvas
=
useRef
()
useEffect
(()
=>
{
nv
.
attachToCanvas
(
canvas
.
current
)
},
[])
nv
.
loadVolumes
([{
url
:
url
}])
},
[
url
])
return
(
<
Grid
container
item
xs
=
{
12
}
m
=
{
2
}
alignItems
=
'center'
justifyContent
=
'center'
spacing
=
{
0
}
direction
=
'row'
>
...
...
@@ -300,6 +302,7 @@ export default function Bet() {
const
[
moreOptions
,
setMoreOptions
]
=
useState
(
false
)
const
[
commandString
,
setCommandString
]
=
useState
(
''
)
const
[
isRunning
,
setIsRunning
]
=
useState
(
false
)
const
[
niivueImage
,
setNiivueImage
]
=
useState
(
''
)
if
(
host
===
null
||
socketServerPort
===
null
||
fileServerPort
===
null
){
setSnackBarMessage
(
'
unable to contact backend application
'
)
...
...
@@ -307,26 +310,29 @@ export default function Bet() {
inFileSocket
.
on
(
'
files
'
,
(
data
)
=>
{
console
.
log
(
data
)
updateBetOptsValue
(
'
input
'
,
data
[
0
])
setNiivueImage
(
`http://
${
host
}
:
${
fileServerPort
}
/file/?filename=
${
data
[
0
]}
`
)
/*
nv.loadVolumes([
{url: `http://${host}:${fileServerPort}/file/?filename=${data[0]}`}
])
*/
})
runSocket
.
on
(
'
run
'
,
(
data
)
=>
{
console
.
log
(
'
run
'
,
data
)
setIsRunning
(
false
)
setNiivueImage
(
`http://
${
host
}
:
${
fileServerPort
}
/file/?filename=
${
betOpts
[
'
output
'
]}
`
)
/*
nv.loadVolumes([
{url: `http://${host}:${fileServerPort}/file/?filename=${betOpts['output']}`}
])
*/
})
function
handleSnackBarClose
()
{
setShowSnackBar
(
false
)
}
function
showSnackBarIfMsg
()
{
if
(
snackBarMessage
!==
''
)
{
setShowSnackBar
(
true
)
...
...
@@ -371,13 +377,13 @@ export default function Bet() {
function
updateBetOptsValue
(
option
,
value
)
{
setBetOpts
(
b
etOpts
=>
({
...
b
etOpts
,
setBetOpts
(
defaultB
etOpts
=>
({
...
defaultB
etOpts
,
...{[
option
]:
value
}
}))
if
(
option
===
'
input
'
)
{
setBetOpts
(
b
etOpts
=>
({
...
b
etOpts
,
setBetOpts
(
defaultB
etOpts
=>
({
...
defaultB
etOpts
,
...{
'
output
'
:
setOutputName
(
value
)}
}))
}
...
...
@@ -423,7 +429,7 @@ export default function Bet() {
updateBetOptsValue
=
{
updateBetOptsValue
}
/>
<
CommandStringPreview
commandString
=
{
commandString
}
/>
<
NiiVue
images
=
{
[]
}
/>
<
NiiVue
url
=
{
niivueImage
}
/>
<
Snackbar
anchorOrigin
=
{
{
horizontal
:
'
center
'
,
vertical
:
'
bottom
'
}
}
open
=
{
showSnackBar
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment