From ab4765231467f2a7d17e46d31504a4cec66c2ee9 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 1 Mar 2020 11:00:43 +0300 Subject: [PATCH] Fix proxy child property update issue on Three. Name refactoring. --- .../vis/common/{VisualPlugin.kt => Visual.kt} | 8 +-- .../hep/dataforge/vis/common/VisualGroup.kt | 2 +- dataforge-vis-spatial-gdml/build.gradle.kts | 2 +- .../vis/spatial/gdml/generateSchema.kt | 2 +- .../kotlin/hep/dataforge/vis/spatial/Box.kt | 6 ++- .../kotlin/hep/dataforge/vis/spatial/Proxy.kt | 3 +- .../{Visual3DPlugin.kt => Visual3D.kt} | 25 +++++---- .../dataforge/vis/spatial/VisualGroup3D.kt | 2 +- .../hep/dataforge/vis/spatial/ConvexTest.kt | 2 +- .../vis/spatial/SerializationTest.kt | 2 +- .../vis/spatial/three/ThreeFactory.kt | 14 ++--- .../vis/spatial/three/ThreeMaterials.kt | 4 +- .../vis/spatial/three/ThreeProxyFactory.kt | 2 +- .../vis/spatial/three/outputConfig.kt | 4 +- .../dataforge/vis/spatial/gdml/demo/cubes.kt | 54 +++++++++++++++++++ .../vis/spatial/gdml/GDMLVisualTest.kt | 18 +++++++ .../vis/spatial/gdml/demo/GDMLDemoApp.kt | 6 +-- .../vis/spatial/gdml/demo/readFile.kt | 6 +-- .../vis/spatial/gdml/demo/saveToJson.kt | 4 +- .../ru/mipt/npm/muon/monitor/MMDemoApp.kt | 4 +- .../mipt/npm/muon/monitor/server/MMServer.kt | 4 +- 21 files changed, 126 insertions(+), 48 deletions(-) rename dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/{VisualPlugin.kt => Visual.kt} (82%) rename dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/{Visual3DPlugin.kt => Visual3D.kt} (83%) create mode 100644 demo/gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/cubes.kt create mode 100644 demo/gdml/src/commonTest/kotlin/hep/dataforge/vis/spatial/gdml/GDMLVisualTest.kt diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualPlugin.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Visual.kt similarity index 82% rename from dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualPlugin.kt rename to dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Visual.kt index 39a1abc0..a469ac63 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualPlugin.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Visual.kt @@ -13,7 +13,7 @@ interface VisualFactory { ): T } -class VisualPlugin(meta: Meta) : AbstractPlugin(meta) { +class Visual(meta: Meta) : AbstractPlugin(meta) { override val tag: PluginTag get() = Companion.tag /** @@ -27,11 +27,11 @@ class VisualPlugin(meta: Meta) : AbstractPlugin(meta) { return visualFactories[T::class]?.invoke(context, parent, meta) as T? } - companion object : PluginFactory { + companion object : PluginFactory { override val tag: PluginTag = PluginTag(name = "visual", group = PluginTag.DATAFORGE_GROUP) - override val type: KClass = VisualPlugin::class + override val type: KClass = Visual::class - override fun invoke(meta: Meta, context: Context): VisualPlugin = VisualPlugin(meta) + override fun invoke(meta: Meta, context: Context): Visual = Visual(meta) const val VISUAL_FACTORY_TYPE = "visual.factory" } diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualGroup.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualGroup.kt index 7108209e..c3f497bd 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualGroup.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualGroup.kt @@ -88,7 +88,7 @@ interface MutableVisualGroup : VisualGroup { operator fun set(name: Name, child: VisualObject?) } -operator fun VisualGroup.get(str: String?) = get(str?.toName() ?: Name.EMPTY) +operator fun VisualGroup.get(str: String?): VisualObject? = get(str?.toName() ?: Name.EMPTY) operator fun MutableVisualGroup.set(key: String, child: VisualObject?) { set(key.toName(), child) diff --git a/dataforge-vis-spatial-gdml/build.gradle.kts b/dataforge-vis-spatial-gdml/build.gradle.kts index a1a23902..c13e2e3f 100644 --- a/dataforge-vis-spatial-gdml/build.gradle.kts +++ b/dataforge-vis-spatial-gdml/build.gradle.kts @@ -7,7 +7,7 @@ kotlin { val commonMain by getting { dependencies { api(project(":dataforge-vis-spatial")) - api("scientifik:gdml:0.1.5") + api("scientifik:gdml:0.1.6") } } } diff --git a/dataforge-vis-spatial-gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/generateSchema.kt b/dataforge-vis-spatial-gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/generateSchema.kt index 628a8651..53768de4 100644 --- a/dataforge-vis-spatial-gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/generateSchema.kt +++ b/dataforge-vis-spatial-gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/generateSchema.kt @@ -135,7 +135,7 @@ private fun jsonSchema(descriptor: SerialDescriptor, context: SerialModule): Jso } fun main() { - val context = Visual3DPlugin.serialModule + val context = Visual3D.serialModule val definitions = json { "children" to json { "anyOf" to jsonArray { diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Box.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Box.kt index 438fe2f0..c2010a0f 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Box.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Box.kt @@ -11,13 +11,14 @@ import hep.dataforge.vis.common.AbstractVisualObject import hep.dataforge.vis.common.VisualFactory import hep.dataforge.vis.common.VisualObject import hep.dataforge.vis.common.set +import hep.dataforge.vis.spatial.Box.Companion.TYPE_NAME import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers import kotlin.reflect.KClass @Serializable -@SerialName("3d.box") +@SerialName(TYPE_NAME) class Box( val xSize: Float, val ySize: Float, @@ -53,7 +54,8 @@ class Box( } companion object : VisualFactory { - const val TYPE = "geometry.3d.box" + + const val TYPE_NAME = "3d.box" override val type: KClass get() = Box::class diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Proxy.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Proxy.kt index a9b755e6..13b13f2c 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Proxy.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Proxy.kt @@ -59,7 +59,7 @@ class Proxy(val templateName: Name) : AbstractVisualObject(), VisualGroup, Visua } override val children: Map - get() = (prototype as? MutableVisualGroup)?.children + get() = (prototype as? VisualGroup)?.children ?.filter { !it.key.toString().startsWith("@") } ?.mapValues { ProxyChild(it.key.asName()) @@ -85,7 +85,6 @@ class Proxy(val templateName: Name) : AbstractVisualObject(), VisualGroup, Visua //override fun findAllStyles(): Laminate = Laminate((styles + prototype.styles).mapNotNull { findStyle(it) }) - @Serializable inner class ProxyChild(val name: Name) : AbstractVisualObject(), VisualGroup { val prototype: VisualObject get() = prototypeFor(name) diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Visual3DPlugin.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Visual3D.kt similarity index 83% rename from dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Visual3DPlugin.kt rename to dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Visual3D.kt index 3f4a194d..cb362558 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Visual3DPlugin.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Visual3D.kt @@ -9,29 +9,32 @@ import hep.dataforge.io.serialization.MetaSerializer import hep.dataforge.io.serialization.NameSerializer import hep.dataforge.meta.* import hep.dataforge.names.Name +import hep.dataforge.names.toName +import hep.dataforge.vis.common.Visual import hep.dataforge.vis.common.VisualObject -import hep.dataforge.vis.common.VisualPlugin import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonConfiguration import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.contextual import kotlin.reflect.KClass -class Visual3DPlugin(meta: Meta) : AbstractPlugin(meta) { +class Visual3D(meta: Meta) : AbstractPlugin(meta) { + + val visual by require(Visual) + override val tag: PluginTag get() = Companion.tag - override fun provideTop(target: String): Map { - return if (target == VisualPlugin.VISUAL_FACTORY_TYPE) { - mapOf() - } else { - emptyMap() - } + override fun provideTop(target: String): Map = if (target == Visual.VISUAL_FACTORY_TYPE) { + mapOf(Box.TYPE_NAME.toName() to Box) + } else { + super.provideTop(target) } - companion object : PluginFactory { + + companion object : PluginFactory { override val tag: PluginTag = PluginTag(name = "visual.spatial", group = PluginTag.DATAFORGE_GROUP) - override val type: KClass = Visual3DPlugin::class - override fun invoke(meta: Meta, context: Context): Visual3DPlugin = Visual3DPlugin(meta) + override val type: KClass = Visual3D::class + override fun invoke(meta: Meta, context: Context): Visual3D = Visual3D(meta) val serialModule = SerializersModule { contextual(Point3DSerializer) diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt index 3922d970..1afa0647 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt @@ -112,7 +112,7 @@ class VisualGroup3D : AbstractVisualGroup(), VisualObject3D { // val PROTOTYPES_KEY = NameToken("@prototypes") fun fromJson(json: String): VisualGroup3D = - Visual3DPlugin.json.parse(serializer(), json).also { it.attachChildren() } + Visual3D.json.parse(serializer(), json).also { it.attachChildren() } } } diff --git a/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/ConvexTest.kt b/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/ConvexTest.kt index 3358fe84..0c2b4143 100644 --- a/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/ConvexTest.kt +++ b/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/ConvexTest.kt @@ -25,7 +25,7 @@ class ConvexTest { val convex = group.first() as Convex - val json = Visual3DPlugin.json.toJson(Convex.serializer(), convex) + val json = Visual3D.json.toJson(Convex.serializer(), convex) val meta = json.toMeta() val points = meta.getIndexed("points").values.map { (it as MetaItem.NodeItem<*>).node.point3D()} diff --git a/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/SerializationTest.kt b/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/SerializationTest.kt index 128b507b..ea242679 100644 --- a/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/SerializationTest.kt +++ b/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/SerializationTest.kt @@ -1,6 +1,6 @@ package hep.dataforge.vis.spatial -import hep.dataforge.vis.spatial.Visual3DPlugin.Companion.json +import hep.dataforge.vis.spatial.Visual3D.Companion.json import kotlinx.serialization.ImplicitReflectionSerializer import kotlin.test.Test import kotlin.test.assertEquals diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeFactory.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeFactory.kt index 65dc71ef..6828cd7b 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeFactory.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeFactory.kt @@ -31,12 +31,14 @@ interface ThreeFactory { /** * Update position, rotation and visibility */ -fun Object3D.updatePosition(obj: VisualObject3D) { +fun Object3D.updatePosition(obj: VisualObject) { visible = obj.visible ?: true - position.set(obj.x, obj.y, obj.z) - setRotationFromEuler(obj.euler) - scale.set(obj.scaleX, obj.scaleY, obj.scaleZ) - updateMatrix() + if(obj is VisualObject3D) { + position.set(obj.x, obj.y, obj.z) + setRotationFromEuler(obj.euler) + scale.set(obj.scaleX, obj.scaleY, obj.scaleZ) + updateMatrix() + } } ///** @@ -54,7 +56,7 @@ fun Object3D.updatePosition(obj: VisualObject3D) { /** * Update non-position non-geometry property */ -fun Object3D.updateProperty(source: VisualObject3D, propertyName: Name) { +fun Object3D.updateProperty(source: VisualObject, propertyName: Name) { if (this is Mesh && propertyName.startsWith(MATERIAL_KEY)) { this.material = getMaterial(source) } else if ( diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt index d0d7d390..786c0efd 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt @@ -3,8 +3,8 @@ package hep.dataforge.vis.spatial.three import hep.dataforge.meta.* import hep.dataforge.values.ValueType import hep.dataforge.vis.common.Colors +import hep.dataforge.vis.common.VisualObject import hep.dataforge.vis.spatial.Material3D -import hep.dataforge.vis.spatial.VisualObject3D import info.laht.threekt.materials.LineBasicMaterial import info.laht.threekt.materials.Material import info.laht.threekt.materials.MeshBasicMaterial @@ -37,7 +37,7 @@ object ThreeMaterials { } } - fun getMaterial(visualObject3D: VisualObject3D): Material { + fun getMaterial(visualObject3D: VisualObject): Material { val meta = visualObject3D.getProperty(Material3D.MATERIAL_KEY).node ?: return ThreeMaterials.DEFAULT return if (meta[Material3D.SPECULAR_COLOR_KEY] != null) { MeshPhongMaterial().apply { diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeProxyFactory.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeProxyFactory.kt index 84fcb86e..05bdd9e1 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeProxyFactory.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeProxyFactory.kt @@ -25,7 +25,7 @@ class ThreeProxyFactory(val three: ThreePlugin) : ThreeFactory { if (name.first()?.body == PROXY_CHILD_PROPERTY_PREFIX) { val childName = name.first()?.index?.toName() ?: error("Wrong syntax for proxy child property: '$name'") val propertyName = name.cutFirst() - val proxyChild = obj[childName] as? VisualObject3D ?: error("Proxy child with name '$childName' not found or not a 3D object") + val proxyChild = obj[childName] ?: error("Proxy child with name '$childName' not found") val child = object3D.findChild(childName)?: error("Object child with name '$childName' not found") child.updateProperty(proxyChild, propertyName) } else { diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/outputConfig.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/outputConfig.kt index 1f3c0a6d..f27a6754 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/outputConfig.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/outputConfig.kt @@ -2,7 +2,7 @@ package hep.dataforge.vis.spatial.three import hep.dataforge.js.requireJS import hep.dataforge.vis.js.editor.card -import hep.dataforge.vis.spatial.Visual3DPlugin +import hep.dataforge.vis.spatial.Visual3D import hep.dataforge.vis.spatial.VisualGroup3D import kotlinx.html.InputType import kotlinx.html.TagConsumer @@ -46,7 +46,7 @@ fun Element.displayCanvasControls(canvas: ThreeCanvas, block: TagConsumer - Visual3DPlugin.json.stringify( + Visual3D.json.stringify( VisualGroup3D.serializer(), group ) diff --git a/demo/gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/cubes.kt b/demo/gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/cubes.kt new file mode 100644 index 00000000..24e4845b --- /dev/null +++ b/demo/gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/cubes.kt @@ -0,0 +1,54 @@ +package hep.dataforge.vis.spatial.gdml.demo + +import scientifik.gdml.* + + +fun cubes(): GDML = GDML { + val center = define.position("center") + structure { + val air = ref("G4_AIR") + val tubeMaterial = ref("tube") + val boxMaterial = ref("box") + val segment = solids.tube("segment", 20, 5.0) { + rmin = 17 + deltaphi = 60 + aunit = DEG + } + val worldBox = solids.box("LargeBox", 200, 200, 200) + val smallBox = solids.box("smallBox", 30, 30, 30) + val segmentVolume = volume("segment", tubeMaterial, segment.ref()) {} + val circle = volume("composite", boxMaterial, smallBox.ref()) { + for (i in 0 until 6) { + physVolume(segmentVolume) { + name = "segment$i" + positionref = center.ref() + rotation { + z = 60 * i + unit = DEG + } + } + } + } + world = volume("world", air, worldBox.ref()) { + for (i in 0 until 3) { + for (j in 0 until 3) { + for (k in 0 until 3) { + physVolume(circle) { + name = "composite$i$j$k" + position { + x = (-50 + i * 50) + y = (-50 + j * 50) + z = (-50 + k * 50) + } + rotation { + x = i * 120 + y = j * 120 + z = 120 * k + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/demo/gdml/src/commonTest/kotlin/hep/dataforge/vis/spatial/gdml/GDMLVisualTest.kt b/demo/gdml/src/commonTest/kotlin/hep/dataforge/vis/spatial/gdml/GDMLVisualTest.kt new file mode 100644 index 00000000..bac4481e --- /dev/null +++ b/demo/gdml/src/commonTest/kotlin/hep/dataforge/vis/spatial/gdml/GDMLVisualTest.kt @@ -0,0 +1,18 @@ +package hep.dataforge.vis.spatial.gdml + +import hep.dataforge.meta.string +import hep.dataforge.names.toName +import hep.dataforge.vis.spatial.Material3D +import hep.dataforge.vis.spatial.gdml.demo.cubes +import kotlin.test.Test +import kotlin.test.assertEquals + +class GDMLVisualTest { + @Test + fun testPrototypeProperty() { + val gdml = cubes() + val visual = gdml.toVisual() + visual["composite000.segment0".toName()]?.setProperty(Material3D.MATERIAL_COLOR_KEY, "red") + assertEquals("red", visual["composite000.segment0".toName()]?.getProperty(Material3D.MATERIAL_COLOR_KEY).string) + } +} \ No newline at end of file diff --git a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/GDMLDemoApp.kt b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/GDMLDemoApp.kt index 23ac0290..ff07ebc6 100644 --- a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/GDMLDemoApp.kt +++ b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/GDMLDemoApp.kt @@ -4,7 +4,7 @@ import hep.dataforge.context.Global import hep.dataforge.vis.fx.editor.VisualObjectEditorFragment import hep.dataforge.vis.fx.editor.VisualObjectTreeFragment import hep.dataforge.vis.spatial.Material3D -import hep.dataforge.vis.spatial.Visual3DPlugin +import hep.dataforge.vis.spatial.Visual3D import hep.dataforge.vis.spatial.VisualGroup3D import hep.dataforge.vis.spatial.fx.FX3DPlugin import hep.dataforge.vis.spatial.fx.FXCanvas3D @@ -34,11 +34,11 @@ class GDMLView : View() { override val root: Parent = borderpane { top { buttonbar { - button("Load GDML") { + button("Load GDML/json") { action { val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull() ?: return@action - val visual: VisualGroup3D = Visual3DPlugin.readFile(file) + val visual: VisualGroup3D = Visual3D.readFile(file) canvas.render(visual) } } diff --git a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/readFile.kt b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/readFile.kt index e4d66bdc..532e1399 100644 --- a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/readFile.kt +++ b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/readFile.kt @@ -1,7 +1,7 @@ package hep.dataforge.vis.spatial.gdml.demo import hep.dataforge.vis.spatial.Material3D -import hep.dataforge.vis.spatial.Visual3DPlugin +import hep.dataforge.vis.spatial.Visual3D import hep.dataforge.vis.spatial.VisualGroup3D import hep.dataforge.vis.spatial.gdml.LUnit import hep.dataforge.vis.spatial.gdml.readFile @@ -11,7 +11,7 @@ import java.io.File import java.util.zip.GZIPInputStream import java.util.zip.ZipInputStream -fun Visual3DPlugin.Companion.readFile(file: File): VisualGroup3D = when { +fun Visual3D.Companion.readFile(file: File): VisualGroup3D = when { file.extension == "gdml" || file.extension == "xml" -> { GDML.readFile(file.toPath()).toVisual { lUnit = LUnit.CM @@ -46,4 +46,4 @@ fun Visual3DPlugin.Companion.readFile(file: File): VisualGroup3D = when { else -> error("Unknown extension ${file.extension}") } -fun Visual3DPlugin.Companion.readFile(fileName: String): VisualGroup3D = readFile(File(fileName)) \ No newline at end of file +fun Visual3D.Companion.readFile(fileName: String): VisualGroup3D = readFile(File(fileName)) \ No newline at end of file diff --git a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/saveToJson.kt b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/saveToJson.kt index 3f60546f..f2491423 100644 --- a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/saveToJson.kt +++ b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/saveToJson.kt @@ -1,6 +1,6 @@ package hep.dataforge.vis.spatial.gdml.demo -import hep.dataforge.vis.spatial.Visual3DPlugin +import hep.dataforge.vis.spatial.Visual3D import hep.dataforge.vis.spatial.VisualGroup3D import hep.dataforge.vis.spatial.gdml.LUnit import hep.dataforge.vis.spatial.gdml.readFile @@ -14,6 +14,6 @@ fun main() { val visual = gdml.toVisual { lUnit = LUnit.CM } - val json = Visual3DPlugin.json.stringify(VisualGroup3D.serializer(), visual) + val json = Visual3D.json.stringify(VisualGroup3D.serializer(), visual) File("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.json").writeText(json) } \ No newline at end of file diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt index 966a2e37..3e680952 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt @@ -15,7 +15,7 @@ import hep.dataforge.vis.js.editor.displayPropertyEditor import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_COLOR_KEY import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_OPACITY_KEY import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_WIREFRAME_KEY -import hep.dataforge.vis.spatial.Visual3DPlugin +import hep.dataforge.vis.spatial.Visual3D import hep.dataforge.vis.spatial.VisualObject3D import hep.dataforge.vis.spatial.VisualObject3D.Companion.VISIBLE_KEY import hep.dataforge.vis.spatial.three.ThreePlugin @@ -41,7 +41,7 @@ private class MMDemoApp : Application { private val connection = HttpClient { install(JsonFeature) { - serializer = KotlinxSerializer(Visual3DPlugin.json) + serializer = KotlinxSerializer(Visual3D.json) } } diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt index 1518aa35..f46f68e1 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt @@ -1,7 +1,7 @@ package ru.mipt.npm.muon.monitor.server -import hep.dataforge.vis.spatial.Visual3DPlugin +import hep.dataforge.vis.spatial.Visual3D import io.ktor.application.Application import io.ktor.application.call import io.ktor.application.install @@ -35,7 +35,7 @@ fun Application.module() { install(DefaultHeaders) install(CallLogging) install(ContentNegotiation) { - serialization(json = Visual3DPlugin.json) + serialization(json = Visual3D.json) } install(Routing) { get("/event") {