v0.2.0-dev-22 #47

Merged
altavir merged 158 commits from dev into master 2021-07-17 11:04:22 +03:00
10 changed files with 115 additions and 17 deletions
Showing only changes of commit 8060933859 - Show all commits

View File

@ -5,8 +5,6 @@ plugins {
}
val dataforgeVersion by extra("0.4.0-dev-2")
val ktorVersion by extra(ru.mipt.npm.gradle.KScienceVersions.ktorVersion)
val htmlVersion by extra(ru.mipt.npm.gradle.KScienceVersions.htmlVersion)
val kotlinWrappersVersion by extra("pre.148-kotlin-1.4.30")
val fxVersion by extra("14")
@ -21,13 +19,10 @@ allprojects {
maven("http://maven.jzy3d.org/releases")
}
group = "hep.dataforge"
version = "0.2.0-dev-7"
group = "space.kscience"
version = "0.2.0-dev-8"
}
val githubProject by extra("visionforge")
val bintrayRepo by extra("dataforge")
subprojects {
if (name.startsWith("visionforge")) {
plugins.apply("maven-publish")

View File

@ -7,7 +7,7 @@ plugins {
group = "ru.mipt.npm"
val ktorVersion: String by rootProject.extra
val ktorVersion: String = ru.mipt.npm.gradle.KScienceVersions.ktorVersion
kscience {
useSerialization()

View File

@ -0,0 +1,16 @@
plugins {
id("ru.mipt.npm.gradle.jvm")
kotlin("jupyter.api")
}
description = "Jupyter api artifact for GDML rendering"
dependencies {
implementation(project(":visionforge-gdml"))
implementation(project(":visionforge-threejs:visionforge-threejs-server"))
}
readme{
maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL
}

View File

@ -0,0 +1,84 @@
package space.kscience.visionforge.gdml.jupyter
import kotlinx.html.div
import kotlinx.html.id
import kotlinx.html.script
import kotlinx.html.stream.createHTML
import kotlinx.html.unsafe
import org.jetbrains.kotlinx.jupyter.api.HTML
import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary
import org.jetbrains.kotlinx.jupyter.api.libraries.*
import space.kscience.dataforge.misc.DFExperimental
import space.kscience.gdml.Gdml
import space.kscience.visionforge.Vision
import space.kscience.visionforge.VisionForge
import space.kscience.visionforge.gdml.toVision
import space.kscience.visionforge.html.HtmlVisionFragment
import space.kscience.visionforge.html.Page
import space.kscience.visionforge.html.embedVisionFragment
import space.kscience.visionforge.html.fragment
import space.kscience.visionforge.plugins
import space.kscience.visionforge.solid.Solids
import space.kscience.visionforge.visionManager
@JupyterLibrary
@DFExperimental
internal class GdmlForJupyter : JupyterIntegration() {
private val jsBundle = ResourceFallbacksBundle(listOf(
ResourceLocation("js/visionforge-three.js", ResourcePathType.CLASSPATH_PATH))
)
private val jsResource = LibraryResource(name = "visionforge-three", type = ResourceType.JS, bundles = listOf(jsBundle))
private var counter = 0
private fun produceHtmlVisionString(fragment: HtmlVisionFragment) = createHTML().div {
val id = "visionforge.vision[${counter++}]"
div {
this.id = id
embedVisionFragment(VisionForge.visionManager, fragment = fragment)
}
script {
type = "text/javascript"
unsafe { +"window.renderVisionsAt(\"$id\");" }
}
}
override fun Builder.onLoaded() {
resource(jsResource)
onLoaded {
VisionForge.plugins.fetch(Solids)
}
import(
"space.kscience.gdml.*",
"kotlinx.html.*",
"space.kscience.visionforge.solid.*",
"space.kscience.visionforge.html.Page",
"space.kscience.visionforge.html.page",
"space.kscience.visionforge.gdml.jupyter.*"
)
import<VisionForge>()
render<Gdml> { gdmlModel ->
val fragment = VisionForge.fragment {
vision(gdmlModel.toVision())
}
HTML(produceHtmlVisionString(fragment))
}
render<Vision> { vision ->
val fragment = VisionForge.fragment {
vision(vision)
}
HTML(produceHtmlVisionString(fragment))
}
render<Page> { page ->
HTML(page.render(createHTML()), true)
}
}
}

View File

@ -1,6 +1,6 @@
pluginManagement {
val kotlinVersion = "1.4.31"
val toolsVersion = "0.9.0"
val toolsVersion = "0.9.1"
repositories {
maven("https://repo.kotlin.link")
@ -45,5 +45,6 @@ include(
":demo:muon-monitor",
":demo:sat-demo",
":demo:playground",
":demo:jupyter-playground"
)
":demo:jupyter-playground",
":jupyter:visionforge-gdml-jupyter"
)

View File

@ -4,7 +4,6 @@ plugins {
val dataforgeVersion: String by rootProject.extra
val kotlinWrappersVersion: String by rootProject.extra
val htmlVersion: String by rootProject.extra
kscience{
useSerialization()
@ -15,7 +14,7 @@ kotlin {
commonMain {
dependencies {
api("space.kscience:dataforge-context:$dataforgeVersion")
api("org.jetbrains.kotlinx:kotlinx-html:$htmlVersion")
api("org.jetbrains.kotlinx:kotlinx-html:${ru.mipt.npm.gradle.KScienceVersions.htmlVersion}")
api("org.jetbrains:kotlin-css:1.0.0-$kotlinWrappersVersion")
}
}

View File

@ -7,7 +7,7 @@ kotlin {
val commonMain by getting {
dependencies {
api(project(":visionforge-solid"))
api("space.kscience:gdml:0.3.0")
api("space.kscience:gdml:0.3.2")
}
}
}

View File

@ -13,7 +13,7 @@ public object GdmlShowcase {
val segment = solids.tube("segment", 20, 5.0) {
rmin = 17
deltaphi = 60
aunit = AUnit.DEG.title
aunit = AUnit.DEG
}
val worldBox = solids.box("largeBox", 200, 200, 200)
val smallBox = solids.box("smallBox", 30, 30, 30)
@ -25,7 +25,7 @@ public object GdmlShowcase {
positionref = center
rotation {
z = 60 * i
unit = AUnit.DEG.title
unit = AUnit.DEG
}
}
}

View File

@ -2,7 +2,7 @@ plugins {
id("ru.mipt.npm.gradle.jvm")
}
val ktorVersion: String by rootProject.extra
val ktorVersion = ru.mipt.npm.gradle.KScienceVersions.ktorVersion
dependencies {
api(project(":visionforge-core"))

View File

@ -1,5 +1,6 @@
package space.kscience.visionforge.three.server
import kotlinx.browser.window
import space.kscience.dataforge.misc.DFExperimental
import space.kscience.visionforge.VisionForge
import space.kscience.visionforge.solid.three.useThreeJs
@ -8,4 +9,6 @@ import space.kscience.visionforge.solid.three.useThreeJs
public fun main(): Unit = VisionForge.run {
useThreeJs()
renderVisionsInWindow()
window.asDynamic()["renderVisionsAt"] = ::renderVisionsAt
window.asDynamic()["renderVisionsInWindow"] = ::renderVisionsInWindow
}