visionforge/demo/playground/src/jvmMain/kotlin/VisionForgePlayGroundForJupyter.kt

51 lines
1.3 KiB
Kotlin
Raw Normal View History

2021-12-31 13:59:27 +03:00
package space.kscience.visionforge.examples
2021-03-07 16:19:43 +03:00
2021-12-31 13:59:27 +03:00
import org.jetbrains.kotlinx.jupyter.api.libraries.resources
2021-05-05 15:28:06 +03:00
import space.kscience.dataforge.context.Context
2021-03-07 16:19:43 +03:00
import space.kscience.dataforge.misc.DFExperimental
2021-02-23 21:47:18 +03:00
import space.kscience.gdml.Gdml
2021-03-07 16:19:43 +03:00
import space.kscience.plotly.Plot
import space.kscience.visionforge.gdml.toVision
2022-01-02 14:28:24 +03:00
import space.kscience.visionforge.jupyter.JupyterPluginBase
2021-05-05 15:28:06 +03:00
import space.kscience.visionforge.plotly.PlotlyPlugin
2021-06-05 22:31:16 +03:00
import space.kscience.visionforge.plotly.asVision
2021-03-07 16:19:43 +03:00
import space.kscience.visionforge.solid.Solids
2021-02-23 21:47:18 +03:00
2021-02-24 18:26:15 +03:00
@DFExperimental
2022-01-02 14:28:24 +03:00
internal class VisionForgePlayGroundForJupyter : JupyterPluginBase(
Context("VisionForge") {
2021-05-05 15:28:06 +03:00
plugin(Solids)
plugin(PlotlyPlugin)
}
2022-01-02 14:28:24 +03:00
) {
2021-05-05 15:28:06 +03:00
2022-01-02 14:28:24 +03:00
override fun Builder.afterLoaded() {
2021-12-31 13:59:27 +03:00
resources {
2022-01-02 14:28:24 +03:00
js("VisionForge") {
2021-12-31 13:59:27 +03:00
classPath("js/visionforge-playground.js")
}
}
2021-02-23 21:47:18 +03:00
2021-02-24 22:48:17 +03:00
import(
"space.kscience.gdml.*",
2021-03-07 16:19:43 +03:00
"space.kscience.plotly.*",
"space.kscience.plotly.models.*",
"space.kscience.visionforge.solid.*",
2021-02-24 22:48:17 +03:00
)
2022-01-02 14:28:24 +03:00
2021-02-23 21:47:18 +03:00
render<Gdml> { gdmlModel ->
2022-01-02 14:28:24 +03:00
handler.produceHtml {
vision { gdmlModel.toVision() }
2021-02-24 18:26:15 +03:00
}
2021-02-23 21:47:18 +03:00
}
render<Plot> { plot ->
2022-01-02 14:28:24 +03:00
handler.produceHtml {
vision { plot.asVision() }
2021-02-23 21:47:18 +03:00
}
}
}
}