From 595512959c4e358a0eb86d11f24f104bd0284013 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 5 Dec 2023 16:39:15 +0300 Subject: [PATCH] DataForge 0.7.1 and other version updates --- build.gradle.kts | 4 +- .../visionforge/gdml/GDMLVisionTest.kt | 2 +- .../kotlin/ru/mipt/npm/muon/monitor/Model.kt | 2 +- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../bootstrap/visionPropertyEditor.kt | 2 +- ui/compose/build.gradle.kts | 3 +- .../visionforge/compose/PropertyEditor.kt | 5 +-- .../visionforge/compose/valueChooser.kt | 4 +- .../visionforge/react/PropertyEditor.kt | 7 ++-- .../visionforge/react/RangeValueChooser.kt | 4 +- .../space/kscience/visionforge/StyleSheet.kt | 6 +-- .../space/kscience/visionforge/Vision.kt | 4 +- .../kscience/visionforge/VisionProperties.kt | 42 +++++++++---------- .../kscience/visionforge/flowProperty.kt | 4 +- .../space/kscience/visionforge/useProperty.kt | 4 +- .../visionforge/meta/VisionPropertyTest.kt | 6 +-- .../visionforge/ElementVisionRenderer.kt | 4 +- .../kscience/visionforge/JsVisionClient.kt | 2 +- visionforge-plotly/build.gradle.kts | 2 +- .../visionforge/plotly/VisionOfPlotly.kt | 8 ++-- .../visionforge/server/VisionServer.kt | 2 +- .../kscience/visionforge/solid/Composite.kt | 2 +- .../kscience/visionforge/solid/Extruded.kt | 2 +- .../space/kscience/visionforge/solid/Solid.kt | 2 +- .../visionforge/solid/SolidMaterial.kt | 8 ++-- .../visionforge/solid/SolidReference.kt | 6 +-- .../kscience/visionforge/solid/Surface.kt | 2 +- .../kscience/visionforge/solid/geometry.kt | 6 +-- .../solid/transform/RemoveSingleChild.kt | 2 +- visionforge-tables/build.gradle.kts | 2 +- .../visionforge/tables/VisionOfTableTest.kt | 3 +- .../visionforge/solid/three/ThreeFactory.kt | 4 +- .../solid/three/ThreeLineFactory.kt | 2 +- .../visionforge/solid/three/ThreeMaterials.kt | 12 +++--- .../solid/three/ThreeMeshFactory.kt | 2 +- 36 files changed, 88 insertions(+), 88 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2da86b96..b578696d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,12 +7,12 @@ plugins { // id("org.jetbrains.kotlinx.kover") version "0.5.0" } -val dataforgeVersion by extra("0.6.2") +val dataforgeVersion by extra("0.7.1") val fxVersion by extra("11") allprojects { group = "space.kscience" - version = "0.3.0-dev-16" + version = "0.3.0-dev-17" } subprojects { diff --git a/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt b/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt index ba9cb333..6ade4ec8 100644 --- a/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt +++ b/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt @@ -34,6 +34,6 @@ class GDMLVisionTest { val child = cubes[Name.of("composite-000","segment-0")] assertNotNull(child) child.properties.setValue(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue()) - assertEquals("red", child.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).string) + assertEquals("red", child.properties[SolidMaterial.MATERIAL_COLOR_KEY].string) } } \ No newline at end of file diff --git a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt index 7f7958b9..34b750e9 100644 --- a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt +++ b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt @@ -71,7 +71,7 @@ class Model(val manager: VisionManager) { fun reset() { map.values.forEach { - it.properties.setMeta(SolidMaterial.MATERIAL_COLOR_KEY, null) + it.properties[SolidMaterial.MATERIAL_COLOR_KEY] = null } tracks.children.clear() } diff --git a/gradle.properties b/gradle.properties index 9413b93e..4e33feb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,6 @@ org.gradle.jvmargs=-Xmx4G org.jetbrains.compose.experimental.jscanvas.enabled=true -toolsVersion=0.15.0-kotlin-1.9.20 +toolsVersion=0.15.2-kotlin-1.9.21 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586a..a5952066 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt index 8e7e1208..8264ae43 100644 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt +++ b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt @@ -29,7 +29,7 @@ public fun RBuilder.visionPropertyEditor( this.descriptor = descriptor this.scope = vision.manager?.context ?: error("Orphan vision could not be observed") this.getPropertyState = { name -> - val ownMeta = vision.properties.own?.getMeta(name) + val ownMeta = vision.properties.own?.get(name) if (ownMeta != null && !ownMeta.isEmpty()) { EditorPropertyState.Defined } else if (vision.properties.root().getValue(name) != null) { diff --git a/ui/compose/build.gradle.kts b/ui/compose/build.gradle.kts index a2f2c4a7..f77c8e26 100644 --- a/ui/compose/build.gradle.kts +++ b/ui/compose/build.gradle.kts @@ -1,7 +1,8 @@ plugins { id("space.kscience.gradle.mpp") - id("org.jetbrains.compose") version "1.5.10" + alias(spclibs.plugins.compose) +// id("org.jetbrains.compose") version "1.5.11" // id("com.android.library") } diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt index d919cd77..0892b9af 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt +++ b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt @@ -17,9 +17,8 @@ import org.jetbrains.compose.web.dom.Text import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.ObservableMutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.ValueRequirement +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.remove import space.kscience.dataforge.names.* import space.kscience.visionforge.hidden @@ -104,7 +103,7 @@ public fun PropertyEditor( Text(token) } - if (!name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) { + if (!name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) { Div({ style { width(160.px) diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt index 0be879ad..b6aefee7 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt +++ b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt @@ -16,7 +16,7 @@ import org.w3c.dom.HTMLOptionElement import org.w3c.dom.asList import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.ValueRequirement +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.descriptors.allowedValues import space.kscience.visionforge.Colors import space.kscience.visionforge.widgetType @@ -199,7 +199,7 @@ public fun RangeValueChooser( FlexRow { - if (descriptor?.valueRequirement != ValueRequirement.REQUIRED) { + if (descriptor?.valueRestriction != ValueRestriction.REQUIRED) { Input(type = InputType.Checkbox) { if (!rangeDisabled) defaultChecked() diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt index 58986076..b13e7304 100644 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt +++ b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt @@ -16,9 +16,8 @@ import react.dom.attrs import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.ObservableMutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.ValueRequirement +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.remove import space.kscience.dataforge.names.* import space.kscience.visionforge.hidden @@ -146,7 +145,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { } +token } - if (!props.name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) { + if (!props.name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) { styledDiv { css { //+TreeStyles.resizeableInput @@ -185,7 +184,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { } +"\u00D7" attrs { - if (editorPropertyState!= EditorPropertyState.Defined) { + if (editorPropertyState != EditorPropertyState.Defined) { disabled = true } else { onClickFunction = removeClick diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt index 4a82a6e9..bec34fc1 100644 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt +++ b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt @@ -12,7 +12,7 @@ import react.dom.attrs import react.fc import react.useState import space.kscience.dataforge.meta.asValue -import space.kscience.dataforge.meta.descriptors.ValueRequirement +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.double import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.string @@ -43,7 +43,7 @@ public val RangeValueChooser: FC = fc("RangeValueChooser") { } flexRow { - if (props.descriptor?.valueRequirement != ValueRequirement.REQUIRED) { + if (props.descriptor?.valueRestriction != ValueRestriction.REQUIRED) { styledInput(type = InputType.checkBox) { attrs { defaultChecked = rangeDisabled.not() diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt index 00213644..ed893162 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt @@ -13,7 +13,7 @@ import kotlin.jvm.JvmInline @JvmInline public value class StyleSheet(private val owner: Vision) { - private val styleNode: Meta get() = owner.properties.getMeta(STYLESHEET_KEY) + private val styleNode: Meta get() = owner.properties[STYLESHEET_KEY] public val items: Map get() = styleNode.items @@ -23,7 +23,7 @@ public value class StyleSheet(private val owner: Vision) { * Define a style without notifying owner */ public fun define(key: String, style: Meta?) { - owner.properties.setMeta(STYLESHEET_KEY + key, style) + owner.properties[STYLESHEET_KEY + key] = style } /** @@ -92,7 +92,7 @@ public fun Vision.useStyle(name: String, notify: Boolean = true) { * Resolve a style with given name for given [Vision]. The style is not necessarily applied to this [Vision]. */ public fun Vision.getStyle(name: String): Meta? = - properties.own?.getMeta(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name) + properties.own?.get(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name) /** * Resolve a property from all styles diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt index 29965944..78f917a9 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt @@ -10,7 +10,7 @@ import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.boolean import space.kscience.dataforge.meta.descriptors.Described import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.misc.Type +import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties @@ -19,7 +19,7 @@ import space.kscience.visionforge.Vision.Companion.TYPE /** * A root type for display hierarchy */ -@Type(TYPE) +@DfType(TYPE) public interface Vision : Described { /** diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt index dfb06b50..3c375c62 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt @@ -34,13 +34,13 @@ public interface VisionProperties : MetaProvider { * @param inherit toggles parent node property lookup. Null means inference from descriptor. * @param includeStyles toggles inclusion of properties from styles. */ - public fun getMeta( + public fun get( name: Name, inherit: Boolean?, includeStyles: Boolean? = null, ): Meta - override fun getMeta(name: Name): Meta? = getMeta(name, null, null) + override fun get(name: Name): Meta? = get(name, null, null) public val changes: Flow @@ -54,7 +54,7 @@ public interface VisionProperties : MetaProvider { public interface MutableVisionProperties : VisionProperties, MutableMetaProvider { - override fun getMeta( + override fun get( name: Name, inherit: Boolean?, includeStyles: Boolean?, @@ -65,7 +65,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider includeStyles, ) - public fun setMeta( + public fun set( name: Name, node: Meta?, notify: Boolean, @@ -77,10 +77,10 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider notify: Boolean, ) - override fun getMeta(name: Name): MutableMeta = getMeta(name, null, null) + override fun get(name: Name): MutableMeta = get(name, null, null) - override fun setMeta(name: Name, node: Meta?) { - setMeta(name, node, true) + override fun set(name: Name, node: Meta?) { + set(name, node, true) } override fun setValue(name: Name, value: Value?) { @@ -89,7 +89,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider } public fun MutableVisionProperties.remove(name: Name) { - setMeta(name, null) + set(name, null) } public fun MutableVisionProperties.remove(name: String) { @@ -114,7 +114,7 @@ private class VisionPropertiesItem( override val items: Map get() { - val metaKeys = properties.own?.getMeta(nodeName)?.items?.keys ?: emptySet() + val metaKeys = properties.own?.get(nodeName)?.items?.keys ?: emptySet() val descriptorKeys = descriptor?.children?.map { NameToken(it.key) } ?: emptySet() val defaultKeys = default?.get(nodeName)?.items?.keys ?: emptySet() val inheritFlag = descriptor?.inherited ?: inherit @@ -148,8 +148,8 @@ private class VisionPropertiesItem( default ) - override fun setMeta(name: Name, node: Meta?) { - properties.setMeta(nodeName + name, node) + override fun set(name: Name, node: Meta?) { + properties[nodeName + name] = node } override fun toString(): String = Meta.toString(this) @@ -202,16 +202,16 @@ public abstract class AbstractVisionProperties( return descriptor?.defaultValue } - override fun setMeta(name: Name, node: Meta?, notify: Boolean) { + override fun set(name: Name, node: Meta?, notify: Boolean) { //ignore if the value is the same as existing - if (own?.getMeta(name) == node) return + if (own?.get(name) == node) return if (name.isEmpty()) { properties = node?.asMutableMeta() } else if (node == null) { - properties?.setMeta(name, node) + properties?.set(name, node) } else { - getOrCreateProperties().setMeta(name, node) + getOrCreateProperties()[name] = node } if (notify) { invalidate(name) @@ -223,7 +223,7 @@ public abstract class AbstractVisionProperties( if (own?.getValue(name) == value) return if (value == null) { - properties?.getMeta(name)?.value = null + properties?.get(name)?.value = null } else { getOrCreateProperties().setValue(name, value) } @@ -272,11 +272,11 @@ public fun VisionProperties.getValue( /** * Get [Vision] property using key as a String */ -public fun VisionProperties.getMeta( +public fun VisionProperties.get( name: String, inherit: Boolean? = null, includeStyles: Boolean? = null, -): Meta = getMeta(name.parseAsName(), inherit, includeStyles) +): Meta = get(name.parseAsName(), inherit, includeStyles) /** * The root property node with given inheritance and style flags @@ -286,17 +286,17 @@ public fun VisionProperties.getMeta( public fun MutableVisionProperties.root( inherit: Boolean? = null, includeStyles: Boolean? = null, -): MutableMeta = getMeta(Name.EMPTY, inherit, includeStyles) +): MutableMeta = get(Name.EMPTY, inherit, includeStyles) /** * Get [Vision] property using key as a String */ -public fun MutableVisionProperties.getMeta( +public fun MutableVisionProperties.get( name: String, inherit: Boolean? = null, includeStyles: Boolean? = null, -): MutableMeta = getMeta(name.parseAsName(), inherit, includeStyles) +): MutableMeta = get(name.parseAsName(), inherit, includeStyles) // //public operator fun MutableVisionProperties.set(name: Name, value: Number): Unit = diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt index f8d128e1..60c39c20 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt @@ -17,10 +17,10 @@ public fun Vision.flowProperty( includeStyles: Boolean? = null, ): Flow = flow { //Pass initial value. - emit(properties.getMeta(propertyName, inherit, includeStyles)) + emit(properties.get(propertyName, inherit, includeStyles)) properties.changes.collect { name -> if (name.startsWith(propertyName)) { - emit(properties.getMeta(propertyName, inherit, includeStyles)) + emit(properties.get(propertyName, inherit, includeStyles)) } } } diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt index cee3a002..8ffb272a 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt @@ -23,10 +23,10 @@ public fun Vision.useProperty( callback: (Meta) -> Unit, ): Job { //Pass initial value. - callback(properties.getMeta(propertyName, inherit, includeStyles)) + callback(properties.get(propertyName, inherit, includeStyles)) return properties.changes.onEach { name -> if (name.startsWith(propertyName)) { - callback(properties.getMeta(propertyName, inherit, includeStyles)) + callback(properties.get(propertyName, inherit, includeStyles)) } }.launchIn(scope ?: error("Orphan Vision can't observe properties")) } diff --git a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt index 38abe34c..b1ca970a 100644 --- a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt +++ b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt @@ -40,7 +40,7 @@ internal class VisionPropertyTest { @Test fun testPropertyEdit() { val vision = manager.group() - vision.properties.getMeta("fff.ddd").apply { + vision.properties.get("fff.ddd").apply { value = 2.asValue() } assertEquals(2, vision.properties.getValue("fff.ddd")?.int) @@ -50,7 +50,7 @@ internal class VisionPropertyTest { @Test fun testPropertyUpdate() { val vision = manager.group() - vision.properties.getMeta("fff").updateWith(TestScheme) { + vision.properties.get("fff").updateWith(TestScheme) { ddd = 2 } assertEquals(2, vision.properties.getValue("fff.ddd")?.int) @@ -85,7 +85,7 @@ internal class VisionPropertyTest { child.properties.remove("test") - assertEquals(11, child.properties.getMeta("test", inherit = true).int) + assertEquals(11, child.properties.get("test", inherit = true).int) // assertEquals(11, deferred.await()?.int) // assertEquals(2, callCounter) subscription.cancel() diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt index 8842e08e..8e1254d9 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt @@ -9,8 +9,8 @@ import kotlinx.serialization.serializerOrNull import org.w3c.dom.Element import org.w3c.dom.HTMLElement import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.misc.Named -import space.kscience.dataforge.misc.Type import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.parseAsName @@ -20,7 +20,7 @@ import kotlin.reflect.cast /** * A browser renderer for a [Vision]. */ -@Type(ElementVisionRenderer.TYPE) +@DfType(ElementVisionRenderer.TYPE) public interface ElementVisionRenderer : Named { /** diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt index 6ae70280..17958f97 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt @@ -161,7 +161,7 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { //launch backward property propagation vision.properties.changes.onEach { propertyName: Name -> - changeCollector.propertyChanged(visionName, propertyName, vision.properties.getMeta(propertyName)) + changeCollector.propertyChanged(visionName, propertyName, vision.properties[propertyName]) }.launchIn(this) //aggregate atomic changes diff --git a/visionforge-plotly/build.gradle.kts b/visionforge-plotly/build.gradle.kts index 9d313266..c4df8593 100644 --- a/visionforge-plotly/build.gradle.kts +++ b/visionforge-plotly/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("space.kscience.gradle.mpp") } -val plotlyVersion = "0.6.0" +val plotlyVersion = "0.6.1" kscience { jvm() diff --git a/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt b/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt index d5333dda..19d98171 100644 --- a/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt +++ b/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt @@ -33,8 +33,8 @@ public class VisionOfPlotly private constructor( @Transient override val properties: MutableVisionProperties = object : MutableVisionProperties { - override fun setMeta(name: Name, node: Meta?, notify: Boolean) { - meta.setMeta(name, node) + override fun set(name: Name, node: Meta?, notify: Boolean) { + meta[name] = node } override fun setValue(name: Name, value: Value?, notify: Boolean) { @@ -45,11 +45,11 @@ public class VisionOfPlotly private constructor( override val descriptor: MetaDescriptor? get() = this@VisionOfPlotly.descriptor - override fun getMeta( + override fun get( name: Name, inherit: Boolean?, includeStyles: Boolean?, - ): MutableMeta = meta.getMeta(name) ?: MutableMeta() + ): MutableMeta = meta[name] ?: MutableMeta() override fun getValue( name: Name, diff --git a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt b/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt index 4c5e093a..3c5e397a 100644 --- a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt +++ b/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt @@ -32,7 +32,7 @@ import kotlin.time.Duration.Companion.milliseconds public class VisionRoute( public val route: String, public val visionManager: VisionManager, - override val meta: ObservableMutableMeta = MutableMeta(), + override val meta: ObservableMutableMeta = ObservableMutableMeta(), ) : Configurable, ContextAware { public enum class Mode { diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt index 3cc6ff61..3ae6a681 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt @@ -39,7 +39,7 @@ public inline fun MutableVisionContainer.composite( } val res = Composite(type, children[0], children[1]) - res.properties.setMeta(Name.EMPTY, group.properties.own) + res.properties[Name.EMPTY] = group.properties.own setChild(name, res) return res diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt index 8276722e..c2157480 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt @@ -92,7 +92,7 @@ public class Extruded( } internal fun build(): Extruded = Extruded(shape, layers).apply { - this.properties.setMeta(Name.EMPTY, this@Builder.properties) + this.properties[Name.EMPTY] = this@Builder.properties } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt index a42427da..aab583a0 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt @@ -190,7 +190,7 @@ internal fun float32Vector( override fun setValue(thisRef: Solid, property: KProperty<*>, value: Float32Vector3D?) { if (value == null) { - thisRef.properties.setMeta(name, null) + thisRef.properties[name] = null } else { thisRef.properties[name + X_KEY] = value.x thisRef.properties[name + Y_KEY] = value.y diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt index 40857b14..c411cf4c 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt @@ -110,12 +110,12 @@ public val Solid.color: ColorAccessor get() = ColorAccessor(properties.root(true), MATERIAL_COLOR_KEY) public var Solid.material: SolidMaterial? - get() = SolidMaterial.read(properties.getMeta(MATERIAL_KEY)) - set(value) = properties.setMeta(MATERIAL_KEY, value?.meta) + get() = SolidMaterial.read(properties[MATERIAL_KEY]) + set(value) = properties.set(MATERIAL_KEY, value?.meta) @VisionBuilder public fun Solid.material(builder: SolidMaterial.() -> Unit) { - properties.getMeta(MATERIAL_KEY).updateWith(SolidMaterial, builder) + properties[MATERIAL_KEY].updateWith(SolidMaterial, builder) } public var Solid.opacity: Number? @@ -128,5 +128,5 @@ public var Solid.opacity: Number? @VisionBuilder public fun Solid.edges(enabled: Boolean = true, block: SolidMaterial.() -> Unit = {}) { properties[SolidMaterial.EDGES_ENABLED_KEY] = enabled - SolidMaterial.write(properties.getMeta(SolidMaterial.EDGES_MATERIAL_KEY)).apply(block) + SolidMaterial.write(properties[SolidMaterial.EDGES_MATERIAL_KEY]).apply(block) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt index 32e69520..b832865c 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt @@ -162,7 +162,7 @@ internal class SolidReferenceChild( override val properties: MutableVisionProperties = object : MutableVisionProperties { override val descriptor: MetaDescriptor get() = this@SolidReferenceChild.descriptor - override val own: MutableMeta by lazy { owner.properties.getMeta(childToken(childName).asName()) } + override val own: MutableMeta by lazy { owner.properties[childToken(childName).asName()] } override fun getValue( name: Name, @@ -170,8 +170,8 @@ internal class SolidReferenceChild( includeStyles: Boolean?, ): Value? = own.getValue(name) ?: prototype.properties.getValue(name, inherit, includeStyles) - override fun setMeta(name: Name, node: Meta?, notify: Boolean) { - own.setMeta(name, node) + override fun set(name: Name, node: Meta?, notify: Boolean) { + own[name] = node } override fun setValue(name: Name, value: Value?, notify: Boolean) { diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt index 35f9b75f..cf442c62 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt @@ -155,7 +155,7 @@ public class Surface( } internal fun build(): Surface = Surface(layers).apply { - properties.setMeta(Name.EMPTY, this@Builder.properties) + properties[Name.EMPTY] = this@Builder.properties } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt index 58c3021d..8f799f2e 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt @@ -36,9 +36,9 @@ internal fun Meta.toVector2D(): Float32Vector2D = //} internal fun MetaProvider.point3D(default: Float = 0f) = Float32Euclidean3DSpace.vector( - getMeta(X_KEY).float ?: default, - getMeta(Y_KEY).float ?: default, - getMeta(Z_KEY).float ?: default + get(X_KEY).float ?: default, + get(Y_KEY).float ?: default, + get(Z_KEY).float ?: default ) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt index cdc9caaf..bcf3baa9 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt @@ -19,7 +19,7 @@ internal fun Solid.updateFrom(other: Solid): Solid { scaleX *= other.scaleX scaleY *= other.scaleY scaleZ *= other.scaleZ - properties.setMeta(Name.EMPTY, other.properties.root()) + properties[Name.EMPTY] = other.properties.root() return this } diff --git a/visionforge-tables/build.gradle.kts b/visionforge-tables/build.gradle.kts index 33988cf0..f4197864 100644 --- a/visionforge-tables/build.gradle.kts +++ b/visionforge-tables/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("space.kscience.gradle.mpp") } -val tablesVersion = "0.2.1" +val tablesVersion = "0.3.0" kscience { jvm() diff --git a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt b/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt index e1210ffa..def7017b 100644 --- a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt +++ b/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt @@ -6,6 +6,7 @@ import space.kscience.dataforge.meta.double import space.kscience.dataforge.meta.int import space.kscience.tables.ColumnHeader import space.kscience.tables.ColumnTable +import space.kscience.tables.fill import space.kscience.tables.get import kotlin.math.pow import kotlin.test.Test @@ -18,7 +19,7 @@ internal class VisionOfTableTest { val y by ColumnHeader.typed() val table = ColumnTable(100) { - x.fill { it.asValue() } + fill(x, null) { it.asValue() } y.values = x.values.map { it?.double?.pow(2)?.asValue() } } diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt index 122a2c30..09b81053 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt @@ -1,6 +1,6 @@ package space.kscience.visionforge.solid.three -import space.kscience.dataforge.misc.Type +import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.Vision @@ -17,7 +17,7 @@ import kotlin.reflect.KClass /** * Builder and updater for three.js object */ -@Type(TYPE) +@DfType(TYPE) public interface ThreeFactory { public val type: KClass diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt index 42722254..68bfd7b2 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt @@ -24,7 +24,7 @@ public object ThreeLineFactory : ThreeFactory { } val material = ThreeMaterials.getLineMaterial( - vision.properties.getMeta(SolidMaterial.MATERIAL_KEY), + vision.properties[SolidMaterial.MATERIAL_KEY], false ) diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt index 49667c8e..8e1b2e3f 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt @@ -83,7 +83,7 @@ public object ThreeMaterials { private val visionMaterialCache = HashMap() internal fun cacheMaterial(vision: Vision): Material = visionMaterialCache.getOrPut(vision) { - buildMaterial(vision.properties.getMeta(SolidMaterial.MATERIAL_KEY)).apply { + buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]).apply { cached = true } } @@ -133,11 +133,11 @@ public fun Mesh.setMaterial(vision: Vision) { } else { material = vision.parent?.let { parent -> //TODO cache parent material - ThreeMaterials.buildMaterial(parent.properties.getMeta(SolidMaterial.MATERIAL_KEY)) + ThreeMaterials.buildMaterial(parent.properties[SolidMaterial.MATERIAL_KEY]) } ?: ThreeMaterials.cacheMaterial(vision) } } else { - material = ThreeMaterials.buildMaterial(vision.properties.getMeta(SolidMaterial.MATERIAL_KEY)) + material = ThreeMaterials.buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]) } } @@ -153,18 +153,18 @@ public fun Mesh.updateMaterialProperty(vision: Vision, propertyName: Name) { when (propertyName) { SolidMaterial.MATERIAL_COLOR_KEY -> { material.asDynamic().color = - vision.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).threeColor() + vision.properties[SolidMaterial.MATERIAL_COLOR_KEY].threeColor() ?: ThreeMaterials.DEFAULT_COLOR } SolidMaterial.SPECULAR_COLOR_KEY -> { material.asDynamic().specular = - vision.properties.getMeta(SolidMaterial.SPECULAR_COLOR_KEY).threeColor() + vision.properties[SolidMaterial.SPECULAR_COLOR_KEY].threeColor() ?: ThreeMaterials.DEFAULT_COLOR } SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY -> { - material.asDynamic().emissive = vision.properties.getMeta(SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY) + material.asDynamic().emissive = vision.properties[SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY] .threeColor() ?: ThreeMaterials.BLACK_COLOR } diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt index 4ba19998..2e5fc0ca 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt @@ -76,7 +76,7 @@ public fun Mesh.applyEdges(vision: Solid) { val edges = children.find { it.name == EDGES_OBJECT_NAME } as? LineSegments //inherited edges definition, enabled by default if (vision.properties.getValue(EDGES_ENABLED_KEY, inherit = false)?.boolean != false) { - val material = ThreeMaterials.getLineMaterial(vision.properties.getMeta(EDGES_MATERIAL_KEY), true) + val material = ThreeMaterials.getLineMaterial(vision.properties[EDGES_MATERIAL_KEY], true) if (edges == null) { add( LineSegments(