From b72300bfaab358ef8de3d266f404fef86b542490 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 30 Oct 2019 17:22:29 +0300 Subject: [PATCH] Moved to DF 0.1.4 --- .../vis/common/AbstractVisualGroup.kt | 2 +- .../vis/common/AbstractVisualObject.kt | 4 +-- .../dataforge/vis/fx/demo/MetaEditorDemo.kt | 10 +++---- .../hep/dataforge/vis/jsroot/JSRootDemoApp.kt | 2 +- .../dataforge/vis/jsroot/JSRootGeometry.kt | 26 +++++++++---------- .../vis/spatial/gdml/GDMLTransformer.kt | 2 +- .../kotlin/hep/dataforge/vis/spatial/Box.kt | 6 ++--- .../hep/dataforge/vis/spatial/Composite.kt | 6 ++--- .../hep/dataforge/vis/spatial/Convex.kt | 4 +-- .../hep/dataforge/vis/spatial/Material3D.kt | 4 +-- .../hep/dataforge/vis/spatial/ConvexTest.kt | 5 ++-- .../hep/dataforge/vis/spatial/GroupTest.kt | 6 ++--- .../vis/spatial/demo/ThreeDemoApp.kt | 6 ++--- .../vis/spatial/demo/ThreeDemoGrid.kt | 12 +++++---- 14 files changed, 48 insertions(+), 47 deletions(-) diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt index a09db3ed..c8637618 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt @@ -151,7 +151,7 @@ abstract class AbstractVisualGroup : AbstractVisualObject(), MutableVisualGroup protected fun MetaBuilder.updateChildren() { //adding named children children.forEach { - "children[${it.key}]" to it.value.toMeta() + "children[${it.key}]" put it.value.toMeta() } } diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt index e63382ca..5a4a0639 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt @@ -86,8 +86,8 @@ abstract class AbstractVisualObject : VisualObject { protected open fun MetaBuilder.updateMeta() {} override fun toMeta(): Meta = buildMeta { - "type" to this::class.simpleName - "properties" to properties + "type" putValue this::class.simpleName + "properties" put properties updateMeta() } } diff --git a/dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/demo/MetaEditorDemo.kt b/dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/demo/MetaEditorDemo.kt index 6ced3e79..4b12a3ff 100644 --- a/dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/demo/MetaEditorDemo.kt +++ b/dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/demo/MetaEditorDemo.kt @@ -16,12 +16,12 @@ class MetaEditorDemoApp : App(MetaEditorDemo::class) class MetaEditorDemo : View("Meta editor demo") { val meta = buildMeta { - "aNode" to { - "innerNode" to { - "innerValue" to true + "aNode" put { + "innerNode" put { + "innerValue" put true } - "b" to 223 - "c" to "StringValue" + "b" put 223 + "c" put "StringValue" } }.toConfig() diff --git a/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootDemoApp.kt b/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootDemoApp.kt index aa6eb542..9775dbb7 100644 --- a/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootDemoApp.kt +++ b/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootDemoApp.kt @@ -74,5 +74,5 @@ class JSRootDemoApp : ApplicationBase() { } } - override fun dispose() = emptyMap()//mapOf("lines" to presenter.dispose()) + override fun dispose() = emptyMap()//mapOf("lines" put presenter.dispose()) } \ No newline at end of file diff --git a/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootGeometry.kt b/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootGeometry.kt index c23546a1..f4ee6c42 100644 --- a/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootGeometry.kt +++ b/dataforge-vis-jsroot/src/main/kotlin/hep/dataforge/vis/jsroot/JSRootGeometry.kt @@ -15,37 +15,37 @@ class JSRootGeometry(parent: VisualObject?, meta: Meta) : DisplayLeaf(parent, me var facesLimit by int(0) fun box(xSize: Number, ySize: Number, zSize: Number) = buildMeta { - "_typename" to "TGeoBBox" - "fDX" to xSize - "fDY" to ySize - "fDZ" to zSize + "_typename" put "TGeoBBox" + "fDX" put xSize + "fDY" put ySize + "fDZ" put zSize } /** * Create a GDML union */ operator fun Meta.plus(other: Meta) = buildMeta { - "fNode.fLeft" to this - "fNode.fRight" to other - "fNode._typename" to "TGeoUnion" + "fNode.fLeft" put this + "fNode.fRight" put other + "fNode._typename" put "TGeoUnion" } /** * Create a GDML subtraction */ operator fun Meta.minus(other: Meta) = buildMeta { - "fNode.fLeft" to this - "fNode.fRight" to other - "fNode._typename" to "TGeoSubtraction" + "fNode.fLeft" put this + "fNode.fRight" put other + "fNode._typename" put "TGeoSubtraction" } /** * Intersect two GDML geometries */ infix fun Meta.intersect(other: Meta) = buildMeta { - "fNode.fLeft" to this - "fNode.fRight" to other - "fNode._typename" to "TGeoIntersection" + "fNode.fLeft" put this + "fNode.fRight" put other + "fNode._typename" put "TGeoIntersection" } companion object { diff --git a/dataforge-vis-spatial-gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/GDMLTransformer.kt b/dataforge-vis-spatial-gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/GDMLTransformer.kt index f4671bcc..6b11338c 100644 --- a/dataforge-vis-spatial-gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/GDMLTransformer.kt +++ b/dataforge-vis-spatial-gdml/src/commonMain/kotlin/hep/dataforge/vis/spatial/gdml/GDMLTransformer.kt @@ -54,7 +54,7 @@ class GDMLTransformer(val root: GDML) { obj.useStyle(styleName){ COLOR_KEY to Colors.rgbToString(random.nextInt(0, Int.MAX_VALUE)) - "gdml.material" to material.name + "gdml.material" put material.name } obj.solidConfiguration(parent, solid) 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 4d0f05be..e71803f1 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 @@ -47,9 +47,9 @@ class Box( } override fun MetaBuilder.updateMeta() { - "xSize" to xSize - "ySize" to ySize - "zSize" to ySize + "xSize" put xSize + "ySize" put ySize + "zSize" put ySize updatePosition() } diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Composite.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Composite.kt index 31f6f915..0b296fae 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Composite.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Composite.kt @@ -35,9 +35,9 @@ class Composite( override var properties: Config? = null override fun MetaBuilder.updateMeta() { - "compositeType" to compositeType - "first" to first.toMeta() - "second" to second.toMeta() + "compositeType" put compositeType + "first" put first.toMeta() + "second" put second.toMeta() updatePosition() } } diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Convex.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Convex.kt index 56062ca8..5f665bde 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Convex.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Convex.kt @@ -20,8 +20,8 @@ class Convex(val points: List) : AbstractVisualObject(), VisualObject3D override var scale: Point3D? = null override fun MetaBuilder.updateMeta() { - "points" to { - "point" to points.map { it.toMeta() } + "points" put { + "point" put points.map { it.toMeta() } } updatePosition() } diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Material3D.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Material3D.kt index aea1ed4c..e3947546 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Material3D.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Material3D.kt @@ -11,9 +11,9 @@ import hep.dataforge.vis.spatial.Material3D.Companion.OPACITY_KEY class Material3D(override val config: Config) : Specific { - val color by string() + var color by string() - val opacity by float(1f) + var opacity by float(1f) companion object : Specification { override fun wrap(config: Config): Material3D = Material3D(config) 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 beba580c..40cb4404 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 @@ -1,9 +1,8 @@ package hep.dataforge.vis.spatial import hep.dataforge.meta.get -import hep.dataforge.meta.getAll +import hep.dataforge.meta.getIndexed import hep.dataforge.meta.node -import hep.dataforge.names.toName import kotlin.test.Test import kotlin.test.assertEquals @@ -31,7 +30,7 @@ class ConvexTest { val pointsNode = convex.toMeta()["points"].node assertEquals(8, pointsNode?.items?.count()) - val points = pointsNode?.getAll("point".toName()) + val points = pointsNode?.getIndexed("points") assertEquals(8, convex.points.size) } diff --git a/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/GroupTest.kt b/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/GroupTest.kt index c1e81721..2608b53a 100644 --- a/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/GroupTest.kt +++ b/dataforge-vis-spatial/src/commonTest/kotlin/hep/dataforge/vis/spatial/GroupTest.kt @@ -18,8 +18,8 @@ class GroupTest { } box(100, 100, 100) material { - "color" to Colors.lightgreen - "opacity" to 0.3 + color(Colors.lightgreen) + opacity = 0.3f } } intersect("intersect") { @@ -46,6 +46,6 @@ class GroupTest { assertEquals(3, group.count()) assertEquals(300.0, (group["intersect"] as VisualObject3D).y.toDouble()) - assertEquals(-300.0, (group["subtract"] as VisualObject3D).y.toDouble()) + assertEquals(-300.0, (group["subtract"] as VisualObject3D).y.toDouble()) } } \ No newline at end of file diff --git a/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoApp.kt b/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoApp.kt index 7841fb30..41751d9d 100644 --- a/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoApp.kt +++ b/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoApp.kt @@ -99,8 +99,8 @@ private class ThreeDemoApp : Application { } sphere(50) material { - "color" to Colors.lightgreen - "opacity" to 0.3 + color(Colors.lightgreen) + opacity = 0.3f } } composite(CompositeType.INTERSECT) { @@ -148,7 +148,7 @@ private class ThreeDemoApp : Application { } - override fun dispose() = emptyMap()//mapOf("lines" to presenter.dispose()) + override fun dispose() = emptyMap()//mapOf("lines" put presenter.dispose()) } fun main() { diff --git a/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoGrid.kt b/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoGrid.kt index 0f2b8283..ff8a2f88 100644 --- a/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoGrid.kt +++ b/spatial-js-demo/src/main/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoGrid.kt @@ -35,7 +35,9 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager { private val gridRoot = document.create.div("row") private val outputs: MutableMap = HashMap() - override fun dependsOn(): List> = listOf(ThreePlugin) + init { + require(ThreePlugin) + } override fun attach(context: Context) { super.attach(context) @@ -52,9 +54,9 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager { return outputs.getOrPut(name) { if (type != VisualObject::class) error("Supports only DisplayObject") val output = three.output(meta = meta) { - "minSize" to 500 - "axis" to { - "size" to 500 + "minSize" put 500 + "axis" put { + "size" put 500 } } //TODO calculate cell width here using jquery @@ -85,7 +87,7 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager { fun ThreeDemoGrid.demo(name: String, title: String = name, block: VisualGroup3D.() -> Unit) { val meta = buildMeta { - "title" to title + "title" put title } val output = get(VisualObject::class, name.toName(), meta = meta) output.render(action = block)