From 9221df785d2553b7890957fa1d7078e132db37a6 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 9 Aug 2022 14:53:46 +0300 Subject: [PATCH] [WIP] Completed solid refactoring --- build.gradle.kts | 2 +- .../kotlin/ru/mipt/npm/root/DObject.kt | 1 - .../kotlin/ru/mipt/npm/root/dRootToSolid.kt | 10 +++---- .../mipt/npm/root/serialization/jsonToRoot.kt | 7 +++-- .../visionforge/gdml/GDMLVisionTest.kt | 2 +- .../kotlin/ru/mipt/npm/muon/monitor/Model.kt | 2 +- .../src/jvmMain/kotlin/allThingsDemo.kt | 2 +- .../src/jvmMain/kotlin/rootParser.kt | 2 +- demo/playground/src/jvmMain/kotlin/tables.kt | 2 +- .../visionforge/solid/demo/VariableBox.kt | 2 +- .../visionforge/solid/demo/MetaEditorDemo.kt | 2 +- .../visionforge/react/MultiSelectChooser.kt | 4 +-- .../visionforge/react/RangeValueChooser.kt | 2 +- .../visionforge/react/valueChooser.kt | 4 --- .../space/kscience/visionforge/Colors.kt | 7 +---- .../space/kscience/visionforge/StyleSheet.kt | 2 -- .../space/kscience/visionforge/Vision.kt | 4 +-- .../kscience/visionforge/VisionChange.kt | 1 - .../space/kscience/visionforge/VisionGroup.kt | 2 +- .../kscience/visionforge/VisionProperties.kt | 7 +---- .../kscience/visionforge/visionDescriptor.kt | 3 +- .../visionforge/meta/VisionPropertyTest.kt | 8 +---- .../visionforge/editor/ColorValueChooser.kt | 6 +--- .../editor/ComboBoxValueChooser.kt | 6 +--- .../visionforge/editor/FXMetaModel.kt | 6 +--- .../kscience/visionforge/editor/MetaViewer.kt | 2 +- .../visionforge/editor/TextValueChooser.kt | 3 +- .../visionforge/editor/ValueCallback.kt | 2 +- .../visionforge/editor/ValueChooser.kt | 4 +-- .../visionforge/editor/ValueChooserBase.kt | 4 +-- .../editor/VisionEditorFragment.kt | 5 ++-- .../kscience/visionforge/solid/FX3DPlugin.kt | 3 +- .../kscience/visionforge/solid/FXMaterials.kt | 8 +---- .../solid/VisualObjectFXBinding.kt | 7 +++-- .../kscience/visionforge/gdml/gdmlLoader.kt | 2 +- .../visionforge/markup/VisionOfMarkup.kt | 10 +++---- .../visionforge/plotly/VisionOfPlotly.kt | 5 ++-- .../visionforge/solid/ColorAccessor.kt | 2 +- .../kscience/visionforge/solid/LightSource.kt | 2 +- .../space/kscience/visionforge/solid/Solid.kt | 4 +-- .../visionforge/solid/SolidMaterial.kt | 5 +--- .../visionforge/solid/SolidReference.kt | 1 - .../solid/specifications/Canvas3DOptions.kt | 2 +- .../visionforge/solid/DescriptorTest.kt | 2 +- .../visionforge/solid/PropertyTest.kt | 4 +-- .../visionforge/solid/VisionUpdateTest.kt | 2 +- .../visionforge/tables/VisionOfTable.kt | 13 ++++----- .../visionforge/tables/VisionOfTableTest.kt | 8 ++--- .../solid/three/MeshThreeFactory.kt | 11 +++---- .../solid/three/ThreeCanvasLabelFactory.kt | 3 +- .../visionforge/solid/three/ThreeJsVision.kt | 2 +- .../solid/three/ThreeLineFactory.kt | 3 +- .../visionforge/solid/three/ThreeMaterials.kt | 29 +++++++------------ 53 files changed, 97 insertions(+), 147 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f0c9d504..d02cd7c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { // id("org.jetbrains.kotlinx.kover") version "0.5.0" } -val dataforgeVersion by extra("0.6.0-dev-12") +val dataforgeVersion by extra("0.6.0-dev-13") val fxVersion by extra("11") allprojects{ diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/DObject.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/DObject.kt index 5af50c3f..8b67c108 100644 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/DObject.kt +++ b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/DObject.kt @@ -5,7 +5,6 @@ import space.kscience.dataforge.meta.* import space.kscience.dataforge.misc.Named import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.dataforge.values.doubleArray import kotlin.properties.ReadOnlyProperty public fun MetaProvider.doubleArray( diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt index 8cc4c258..48a21ff1 100644 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt +++ b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt @@ -1,13 +1,13 @@ package ru.mipt.npm.root import space.kscience.dataforge.meta.double +import space.kscience.dataforge.meta.doubleArray import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.int import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.doubleArray import space.kscience.visionforge.isEmpty -import space.kscience.visionforge.setPropertyValue +import space.kscience.visionforge.set import space.kscience.visionforge.solid.* import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY import kotlin.math.* @@ -321,7 +321,7 @@ private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid? } return if (group.children.isEmpty()) { null - } else if (group.items.size == 1 && group.meta== null) { + } else if (group.items.size == 1 && group.properties.raw == null) { group.items.values.first().apply { parent = null } } else { group @@ -348,7 +348,7 @@ private fun SolidGroup.addRootVolume( if (!cache) { val group = buildVolume(volume, context)?.apply { volume.fFillColor?.let { - setPropertyValue(MATERIAL_COLOR_KEY, RootColors[it]) + properties[MATERIAL_COLOR_KEY] = RootColors[it] } block() } @@ -365,7 +365,7 @@ private fun SolidGroup.addRootVolume( ref(templateName, name).apply { volume.fFillColor?.let { - setPropertyValue(MATERIAL_COLOR_KEY, RootColors[it]) + properties[MATERIAL_COLOR_KEY] = RootColors[it] } block() } diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/jsonToRoot.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/jsonToRoot.kt index 5d338394..b4a63748 100644 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/jsonToRoot.kt +++ b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/jsonToRoot.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.modules.subclass private fun jsonRootDeserializer( tSerializer: KSerializer, - builder: (JsonElement) -> T + builder: (JsonElement) -> T, ): DeserializationStrategy = object : DeserializationStrategy { private val jsonElementSerializer = JsonElement.serializer() @@ -46,6 +46,7 @@ private object RootDecoder { private val refCache: List, ) : KSerializer by tSerializer { + @OptIn(ExperimentalSerializationApi::class) @Suppress("UNCHECKED_CAST") override fun deserialize(decoder: Decoder): T { val input = decoder as JsonDecoder @@ -92,7 +93,7 @@ private object RootDecoder { @OptIn(ExperimentalSerializationApi::class) fun unrefSerializersModule( - refCache: List + refCache: List, ): SerializersModule = SerializersModule { contextual(TObjArray::class) { @@ -197,11 +198,13 @@ private object RootDecoder { fillCache(it) } } + is JsonArray -> { element.forEach { fillCache(it) } } + else -> { //ignore primitives } 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 c46f49ff..0f74e9a8 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 @@ -1,8 +1,8 @@ package space.kscience.visionforge.gdml +import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.Name -import space.kscience.dataforge.values.asValue import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.Vision import space.kscience.visionforge.get 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 dff6da3f..4bf18124 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 @@ -69,7 +69,7 @@ class Model(val manager: VisionManager) { fun reset() { map.values.forEach { - it.setPropertyValue(SolidMaterial.MATERIAL_COLOR_KEY, null) + it.properties[SolidMaterial.MATERIAL_COLOR_KEY] = null } tracks.children.clear() } diff --git a/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt b/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt index 23b73af4..328387c1 100644 --- a/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt +++ b/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt @@ -1,7 +1,7 @@ package space.kscience.visionforge.examples import kotlinx.html.h2 -import space.kscience.dataforge.values.ValueType +import space.kscience.dataforge.meta.ValueType import space.kscience.plotly.layout import space.kscience.plotly.models.ScatterMode import space.kscience.plotly.models.TextPosition diff --git a/demo/playground/src/jvmMain/kotlin/rootParser.kt b/demo/playground/src/jvmMain/kotlin/rootParser.kt index 184557da..f88793ee 100644 --- a/demo/playground/src/jvmMain/kotlin/rootParser.kt +++ b/demo/playground/src/jvmMain/kotlin/rootParser.kt @@ -6,7 +6,7 @@ import ru.mipt.npm.root.toSolid import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.isLeaf -import space.kscience.dataforge.values.string +import space.kscience.dataforge.meta.string import space.kscience.visionforge.solid.Solids import java.nio.file.Paths import java.util.zip.ZipInputStream diff --git a/demo/playground/src/jvmMain/kotlin/tables.kt b/demo/playground/src/jvmMain/kotlin/tables.kt index 46cad89d..ab27ebdf 100644 --- a/demo/playground/src/jvmMain/kotlin/tables.kt +++ b/demo/playground/src/jvmMain/kotlin/tables.kt @@ -1,6 +1,6 @@ package space.kscience.visionforge.examples -import space.kscience.dataforge.values.ValueType +import space.kscience.dataforge.meta.ValueType import space.kscience.tables.ColumnHeader import space.kscience.tables.valueRow import space.kscience.visionforge.html.ResourceLocation diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt index d429cafb..4ddc185a 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt @@ -3,12 +3,12 @@ package space.kscience.visionforge.solid.demo import info.laht.threekt.core.Object3D import info.laht.threekt.geometries.BoxGeometry import info.laht.threekt.objects.Mesh +import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.int import space.kscience.dataforge.meta.number import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.startsWith -import space.kscience.dataforge.values.asValue import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.set import space.kscience.visionforge.solid.SolidGroup diff --git a/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt b/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt index 3cdf058e..a4217555 100644 --- a/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt +++ b/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt @@ -2,10 +2,10 @@ package space.kscience.visionforge.demo import javafx.geometry.Orientation import space.kscience.dataforge.meta.MutableMeta +import space.kscience.dataforge.meta.ValueType import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.node import space.kscience.dataforge.meta.descriptors.value -import space.kscience.dataforge.values.ValueType import space.kscience.visionforge.editor.FXMetaModel import space.kscience.visionforge.editor.MetaViewer import space.kscience.visionforge.editor.MutableMetaEditor diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt index f3c81a57..612fdfe6 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt @@ -10,9 +10,9 @@ import react.dom.attrs import react.dom.option import react.dom.select import react.fc +import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.descriptors.allowedValues -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.string +import space.kscience.dataforge.meta.string @JsExport public val MultiSelectChooser: FC = fc("MultiSelectChooser") { props -> diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt index 8ccedc01..382209c2 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt @@ -10,11 +10,11 @@ import react.FC 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.double import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.string -import space.kscience.dataforge.values.asValue import styled.css import styled.styledInput diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/valueChooser.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/valueChooser.kt index 03996c04..cd769414 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/valueChooser.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/valueChooser.kt @@ -19,10 +19,6 @@ import react.useState import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.allowedValues -import space.kscience.dataforge.values.ValueType -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.int -import space.kscience.dataforge.values.string import space.kscience.visionforge.Colors import space.kscience.visionforge.widgetType import styled.css diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Colors.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Colors.kt index 58be399e..ad4a4c0e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Colors.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Colors.kt @@ -1,11 +1,6 @@ package space.kscience.visionforge -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.number -import space.kscience.dataforge.values.ValueType -import space.kscience.dataforge.values.int -import space.kscience.dataforge.values.string +import space.kscience.dataforge.meta.* import kotlin.math.max /** 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 aed19706..9fc148b3 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt @@ -5,8 +5,6 @@ import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.stringList import kotlin.jvm.JvmInline /** 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 7bdcbe54..9b8304de 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt @@ -4,14 +4,14 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import space.kscience.dataforge.context.Global +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.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.startsWith -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.boolean import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties import space.kscience.visionforge.Vision.Companion.TYPE import kotlin.reflect.KProperty1 diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt index 33bbd5ca..d0a7ec70 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt @@ -9,7 +9,6 @@ import kotlinx.serialization.Serializable import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.Null import kotlin.jvm.Synchronized import kotlin.time.Duration diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt index f666fcd8..8faa21b4 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt @@ -3,12 +3,12 @@ package space.kscience.visionforge import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.ValueType import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.value import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.ValueType import space.kscience.visionforge.Vision.Companion.STYLE_KEY import kotlin.js.JsName 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 a750df5b..7b6c6e7b 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt @@ -5,15 +5,10 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.launch import kotlinx.serialization.Transient -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MutableMeta -import space.kscience.dataforge.meta.asMutableMeta +import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get import space.kscience.dataforge.names.* -import space.kscience.dataforge.values.Value -import space.kscience.dataforge.values.asValue import kotlin.jvm.Synchronized public interface VisionProperties { diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDescriptor.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDescriptor.kt index 3fa6703f..66ee43e0 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDescriptor.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDescriptor.kt @@ -2,8 +2,7 @@ package space.kscience.visionforge import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.* -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.set +import space.kscience.dataforge.meta.set private const val INHERITED_DESCRIPTOR_ATTRIBUTE = "inherited" private const val STYLE_DESCRIPTOR_ATTRIBUTE = "useStyles" 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 f488bcf7..23517112 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 @@ -1,12 +1,6 @@ package space.kscience.visionforge.meta -import space.kscience.dataforge.meta.Scheme -import space.kscience.dataforge.meta.SchemeSpec -import space.kscience.dataforge.meta.int -import space.kscience.dataforge.meta.updateWith -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.boolean -import space.kscience.dataforge.values.int +import space.kscience.dataforge.meta.* import space.kscience.visionforge.VisionGroup import space.kscience.visionforge.get import space.kscience.visionforge.getValue diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ColorValueChooser.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ColorValueChooser.kt index 442c299f..1161d5bf 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ColorValueChooser.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ColorValueChooser.kt @@ -3,13 +3,9 @@ package space.kscience.visionforge.editor import javafx.scene.control.ColorPicker import javafx.scene.paint.Color import org.slf4j.LoggerFactory -import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.dataforge.values.Null -import space.kscience.dataforge.values.Value -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.string import tornadofx.* /** diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ComboBoxValueChooser.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ComboBoxValueChooser.kt index a99599ee..a4c4e583 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ComboBoxValueChooser.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ComboBoxValueChooser.kt @@ -8,14 +8,10 @@ package space.kscience.visionforge.editor import javafx.collections.FXCollections import javafx.scene.control.ComboBox import javafx.util.StringConverter -import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.allowedValues -import space.kscience.dataforge.meta.get import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.dataforge.values.Value -import space.kscience.dataforge.values.parseValue -import space.kscience.dataforge.values.string import java.util.* public class ComboBoxValueChooser(public val values: Collection? = null) : ValueChooserBase>() { diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/FXMetaModel.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/FXMetaModel.kt index 7d8e71b2..8c3d2584 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/FXMetaModel.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/FXMetaModel.kt @@ -5,14 +5,10 @@ import javafx.beans.binding.BooleanBinding import javafx.beans.binding.ListBinding import javafx.beans.binding.ObjectBinding import javafx.collections.ObservableList -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.ObservableMeta -import space.kscience.dataforge.meta.boolean +import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get import space.kscience.dataforge.names.* -import space.kscience.dataforge.values.Value import tornadofx.* /** diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/MetaViewer.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/MetaViewer.kt index 4563ade5..144b018e 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/MetaViewer.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/MetaViewer.kt @@ -21,7 +21,7 @@ import javafx.scene.control.TreeSortMode import javafx.scene.control.TreeTableView import javafx.scene.layout.BorderPane import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.values.string +import space.kscience.dataforge.meta.string import space.kscience.visionforge.dfIconView import tornadofx.* diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/TextValueChooser.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/TextValueChooser.kt index 9a1840ce..fd86ec72 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/TextValueChooser.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/TextValueChooser.kt @@ -9,11 +9,10 @@ import javafx.beans.value.ObservableValue import javafx.scene.control.TextField import javafx.scene.input.KeyCode import javafx.scene.input.KeyEvent -import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.validate import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.dataforge.values.* import tornadofx.* public class TextValueChooser : ValueChooserBase() { diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueCallback.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueCallback.kt index a4e72871..c6d654f5 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueCallback.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueCallback.kt @@ -5,7 +5,7 @@ */ package space.kscience.visionforge.editor -import space.kscience.dataforge.values.Value +import space.kscience.dataforge.meta.Value /** diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooser.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooser.kt index f62513b0..ea43547c 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooser.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooser.kt @@ -10,14 +10,14 @@ import javafx.beans.value.ObservableValue import javafx.scene.Node import space.kscience.dataforge.context.Context import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.Null +import space.kscience.dataforge.meta.Value import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.allowedValues import space.kscience.dataforge.meta.descriptors.validate import space.kscience.dataforge.misc.Named import space.kscience.dataforge.misc.Type import space.kscience.dataforge.names.Name -import space.kscience.dataforge.values.Null -import space.kscience.dataforge.values.Value import space.kscience.visionforge.widget import space.kscience.visionforge.widgetType import tornadofx.* diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooserBase.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooserBase.kt index e9b61886..a9adae8f 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooserBase.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/ValueChooserBase.kt @@ -8,9 +8,9 @@ package space.kscience.visionforge.editor import javafx.beans.property.SimpleObjectProperty import javafx.scene.Node import org.slf4j.LoggerFactory +import space.kscience.dataforge.meta.Null +import space.kscience.dataforge.meta.Value import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.values.Null -import space.kscience.dataforge.values.Value import tornadofx.* /** diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionEditorFragment.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionEditorFragment.kt index 0185dc43..0fcc45f3 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionEditorFragment.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionEditorFragment.kt @@ -10,6 +10,7 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.names.Name import space.kscience.visionforge.Vision import space.kscience.visionforge.getStyle +import space.kscience.visionforge.root import space.kscience.visionforge.styles import tornadofx.* @@ -20,7 +21,7 @@ public class VisionEditorFragment : Fragment() { public val descriptorProperty: SimpleObjectProperty = SimpleObjectProperty() private val configProperty: Binding = visionProperty.objectBinding { vision -> - vision?.getProperty(Name.EMPTY) + vision?.properties?.root() } private val configEditorProperty: Binding = configProperty.objectBinding(descriptorProperty) { @@ -28,7 +29,7 @@ public class VisionEditorFragment : Fragment() { val node:FXMetaModel = FXMetaModel( meta, vision?.descriptor, - vision?.meta, + vision?.properties?.root(), Name.EMPTY, "Vision properties" ) diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt index 90c94b35..bac388ee 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt @@ -16,6 +16,7 @@ import space.kscience.dataforge.context.* import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.boolean import space.kscience.dataforge.misc.Type +import space.kscience.visionforge.get import space.kscience.visionforge.solid.FX3DFactory.Companion.TYPE import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_KEY import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_WIREFRAME_KEY @@ -76,7 +77,7 @@ public class FX3DPlugin : AbstractPlugin() { is PolyLine -> PolyLine3D( obj.points.map { Point3D(it.x, it.y, it.z) }, obj.thickness.toFloat(), - obj.get(SolidMaterial.MATERIAL_COLOR_KEY).color() + obj.properties.get(SolidMaterial.MATERIAL_COLOR_KEY).color() ).apply { this.meshView.cullFace = CullFace.FRONT } diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXMaterials.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXMaterials.kt index ca5e6583..81bbad5b 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXMaterials.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXMaterials.kt @@ -3,13 +3,7 @@ package space.kscience.visionforge.solid import javafx.scene.paint.Color import javafx.scene.paint.Material import javafx.scene.paint.PhongMaterial -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.double -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.int -import space.kscience.dataforge.values.ValueType -import space.kscience.dataforge.values.int -import space.kscience.dataforge.values.string +import space.kscience.dataforge.meta.* import space.kscience.visionforge.Colors import space.kscience.visionforge.solid.FXMaterials.GREY diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt index 78d02164..8d3e2836 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt @@ -5,8 +5,8 @@ import javafx.beans.binding.* import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.startsWith -import space.kscience.dataforge.values.Value import space.kscience.visionforge.Vision +import space.kscience.visionforge.get import space.kscience.visionforge.onPropertyChange import tornadofx.* @@ -35,7 +35,7 @@ public class VisualObjectFXBinding(public val fx: FX3DPlugin, public val obj: Vi public operator fun get(key: Name): ObjectBinding { return bindings.getOrPut(key) { object : ObjectBinding() { - override fun computeValue(): Meta = obj.getProperty(key) + override fun computeValue(): Meta = obj.properties[key] } } } @@ -57,4 +57,5 @@ public fun ObjectBinding.float(default: Float): FloatBinding = floatBindi public fun ObjectBinding.int(default: Int): IntegerBinding = integerBinding { it.int ?: default } public fun ObjectBinding.long(default: Long): LongBinding = longBinding { it.long ?: default } -public fun ObjectBinding.transform(transform: (Meta) -> T): Binding = objectBinding { it?.let(transform) } +public fun ObjectBinding.transform(transform: (Meta) -> T): Binding = + objectBinding { it?.let(transform) } diff --git a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt index 34a9afa2..a102b2b3 100644 --- a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt +++ b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt @@ -30,7 +30,7 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { private val proto = SolidGroup() private val solids = proto.group(solidsName) { - setPropertyValue("edges.enabled", false) + properties["edges.enabled"] = false } private val referenceStore = HashMap>() diff --git a/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt b/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt index 93e7359e..ace39d2b 100644 --- a/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt +++ b/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt @@ -8,19 +8,19 @@ import kotlinx.serialization.modules.subclass import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName +import space.kscience.visionforge.AbstractVision import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionGroup -import space.kscience.visionforge.properties +import space.kscience.visionforge.root @Serializable @SerialName("vision.markup") public class VisionOfMarkup( - public val format: String = COMMONMARK_FORMAT -) : VisionGroup() { + public val format: String = COMMONMARK_FORMAT, +) : AbstractVision() { //TODO add templates - public var content: String? by properties().string(CONTENT_PROPERTY_KEY) + public var content: String? by properties.root().string(CONTENT_PROPERTY_KEY) public companion object { public val CONTENT_PROPERTY_KEY: Name = "content".asName() 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 732358bf..c23de631 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 @@ -9,16 +9,17 @@ import space.kscience.plotly.Plot import space.kscience.plotly.Plotly import space.kscience.visionforge.AbstractVision import space.kscience.visionforge.html.VisionOutput +import space.kscience.visionforge.root @Serializable @SerialName("vision.plotly") public class VisionOfPlotly private constructor() : AbstractVision() { public constructor(plot: Plot) : this() { - setProperty(Name.EMPTY, plot.meta) + properties[Name.EMPTY] = plot.meta } - public val plot: Plot get() = Plot(getProperty(Name.EMPTY).asObservable()) + public val plot: Plot get() = Plot(properties.root().asObservable()) } public fun Plot.asVision(): VisionOfPlotly = VisionOfPlotly(this) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ColorAccessor.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ColorAccessor.kt index 62a3b2a0..dde24ef0 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ColorAccessor.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ColorAccessor.kt @@ -1,9 +1,9 @@ package space.kscience.visionforge.solid +import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.* import space.kscience.visionforge.Colors import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionBuilder diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/LightSource.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/LightSource.kt index 3f90d903..13736fcd 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/LightSource.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/LightSource.kt @@ -2,11 +2,11 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import space.kscience.dataforge.meta.ValueType import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.node import space.kscience.dataforge.meta.descriptors.value import space.kscience.dataforge.meta.number -import space.kscience.dataforge.values.ValueType import space.kscience.visionforge.* @Serializable 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 1cfc1d3b..d932a4b3 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 @@ -1,15 +1,13 @@ package space.kscience.visionforge.solid +import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.enum import space.kscience.dataforge.meta.descriptors.node import space.kscience.dataforge.meta.descriptors.value -import space.kscience.dataforge.meta.float -import space.kscience.dataforge.meta.get import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.* import space.kscience.visionforge.* import space.kscience.visionforge.Vision.Companion.VISIBLE_KEY import space.kscience.visionforge.solid.Solid.Companion.DETAIL_KEY 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 87a39ac4..e8da3499 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 @@ -3,13 +3,10 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.value +import space.kscience.dataforge.meta.set import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.ValueType -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.number -import space.kscience.dataforge.values.set import space.kscience.visionforge.* import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_KEY 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 5428a7dd..e071d07b 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 @@ -7,7 +7,6 @@ import kotlinx.serialization.Transient import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.names.* -import space.kscience.dataforge.values.Value import space.kscience.visionforge.* import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties import space.kscience.visionforge.solid.SolidReference.Companion.REFERENCE_CHILD_PROPERTY_PREFIX diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt index aa53d424..78e35dfa 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt @@ -4,8 +4,8 @@ import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.scheme import space.kscience.dataforge.meta.descriptors.value +import space.kscience.dataforge.meta.set import space.kscience.dataforge.names.Name -import space.kscience.dataforge.values.set import space.kscience.visionforge.hide import space.kscience.visionforge.widgetType diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt index 6f004f5c..87527802 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt @@ -1,7 +1,7 @@ package space.kscience.visionforge.solid +import space.kscience.dataforge.meta.ValueType import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.values.ValueType import space.kscience.visionforge.solid.specifications.Canvas3DOptions import kotlin.test.Test import kotlin.test.assertNotNull diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt index bb6f5de1..2eb4c65d 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt @@ -4,9 +4,9 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import kotlinx.coroutines.withTimeout +import space.kscience.dataforge.meta.int +import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.asName -import space.kscience.dataforge.values.int -import space.kscience.dataforge.values.string import space.kscience.visionforge.* import kotlin.test.Test import kotlin.test.assertEquals diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt index 026499f4..e5a13594 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt @@ -3,8 +3,8 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.context.Global import space.kscience.dataforge.context.fetch import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.names.asName -import space.kscience.dataforge.values.asValue import space.kscience.visionforge.VisionChange import space.kscience.visionforge.get import kotlin.test.Test diff --git a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt index cb870da8..20332974 100644 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt +++ b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt @@ -8,13 +8,10 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import space.kscience.dataforge.meta.* import space.kscience.dataforge.misc.DFExperimental -import space.kscience.dataforge.values.Null -import space.kscience.dataforge.values.Value -import space.kscience.dataforge.values.asValue import space.kscience.tables.* import space.kscience.visionforge.AbstractVision import space.kscience.visionforge.html.VisionOutput -import space.kscience.visionforge.properties +import space.kscience.visionforge.root import kotlin.jvm.JvmName import kotlin.reflect.typeOf @@ -45,14 +42,14 @@ public class VisionOfTable( ) : AbstractVision(), Rows { public var data: List - get() = meta?.getIndexed("rows")?.entries?.sortedBy { + get() = properties.root().getIndexed("rows").entries.sortedBy { it.key?.toInt() - }?.map { + }.map { it.value - } ?: emptyList() + } set(value) { //TODO Make it better - properties()["rows"] = value + properties.root()["rows"] = value } public val rows: List get() = data.map(::MetaRow) 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 8c9f755c..e3b199d1 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 @@ -1,9 +1,9 @@ package space.kscience.visionforge.tables -import space.kscience.dataforge.values.Value -import space.kscience.dataforge.values.asValue -import space.kscience.dataforge.values.double -import space.kscience.dataforge.values.int +import space.kscience.dataforge.meta.Value +import space.kscience.dataforge.meta.asValue +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.get diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/MeshThreeFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/MeshThreeFactory.kt index b7d8244d..04f192fd 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/MeshThreeFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/MeshThreeFactory.kt @@ -10,8 +10,9 @@ import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.VisionBuilder +import space.kscience.visionforge.get import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.setPropertyValue +import space.kscience.visionforge.set import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.layer @@ -76,8 +77,8 @@ public abstract class MeshThreeFactory( @VisionBuilder public fun Solid.edges(enabled: Boolean = true, block: SolidMaterial.() -> Unit = {}) { - setPropertyValue(EDGES_ENABLED_KEY, enabled) - SolidMaterial.write(getProperty(EDGES_MATERIAL_KEY)).apply(block) + properties.set(EDGES_ENABLED_KEY, enabled) + SolidMaterial.write(properties[EDGES_MATERIAL_KEY]).apply(block) } internal fun Mesh.applyProperties(obj: Solid): Mesh = apply { @@ -93,9 +94,9 @@ internal fun Mesh.applyProperties(obj: Solid): Mesh = apply { public fun Mesh.applyEdges(obj: Solid) { val edges = children.find { it.name == "@edges" } as? LineSegments //inherited edges definition, enabled by default - if (obj.getProperty(EDGES_ENABLED_KEY, inherit = true).boolean != false) { + if (obj.properties.get(EDGES_ENABLED_KEY, inherit = true).boolean != false) { val bufferGeometry = geometry as? BufferGeometry ?: return - val material = ThreeMaterials.getLineMaterial(obj.getProperty(EDGES_MATERIAL_KEY), true) + val material = ThreeMaterials.getLineMaterial(obj.properties[EDGES_MATERIAL_KEY], true) if (edges == null) { add( LineSegments( diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvasLabelFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvasLabelFactory.kt index 42a8b6e6..8108389e 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvasLabelFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvasLabelFactory.kt @@ -11,6 +11,7 @@ import org.w3c.dom.CanvasRenderingContext2D import org.w3c.dom.CanvasTextBaseline import org.w3c.dom.HTMLCanvasElement import org.w3c.dom.MIDDLE +import space.kscience.visionforge.get import space.kscience.visionforge.solid.SolidLabel import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.three.ThreeCanvas.Companion.DO_NOT_HIGHLIGHT_TAG @@ -26,7 +27,7 @@ public object ThreeCanvasLabelFactory : ThreeFactory { val canvas = document.createElement("canvas") as HTMLCanvasElement val context = canvas.getContext("2d") as CanvasRenderingContext2D context.font = "Bold ${obj.fontSize}pt ${obj.fontFamily}" - context.fillStyle = obj.get(SolidMaterial.MATERIAL_COLOR_KEY)?.value ?: "black" + context.fillStyle = obj.properties[SolidMaterial.MATERIAL_COLOR_KEY].value ?: "black" context.textBaseline = CanvasTextBaseline.MIDDLE val metrics = context.measureText(obj.text) //canvas.width = metrics.width.toInt() diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeJsVision.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeJsVision.kt index 27a5da44..7c709a5c 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeJsVision.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeJsVision.kt @@ -6,6 +6,6 @@ import space.kscience.visionforge.solid.SolidBase /** * A custom visual object that has its own Three.js renderer */ -public abstract class ThreeJsVision : SolidBase() { +public abstract class ThreeJsVision : SolidBase() { public abstract fun render(three: ThreePlugin): Object3D } diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt index 6e9c7472..70938e99 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt @@ -4,6 +4,7 @@ import info.laht.threekt.core.BufferGeometry import info.laht.threekt.core.Object3D import info.laht.threekt.math.Color import info.laht.threekt.objects.LineSegments +import space.kscience.visionforge.get import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.solid.PolyLine import space.kscience.visionforge.solid.SolidMaterial @@ -24,7 +25,7 @@ public object ThreeLineFactory : ThreeFactory { } val material = ThreeMaterials.getLineMaterial( - obj.get(SolidMaterial.MATERIAL_KEY), + obj.properties[SolidMaterial.MATERIAL_KEY], false ) diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt index e0f3a4a6..a9f68f69 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt @@ -10,11 +10,7 @@ import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus -import space.kscience.dataforge.values.* -import space.kscience.visionforge.Colors -import space.kscience.visionforge.Vision -import space.kscience.visionforge.computePropertyNode -import space.kscience.visionforge.getStyleNodes +import space.kscience.visionforge.* import space.kscience.visionforge.solid.ColorAccessor import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.SolidReference @@ -98,7 +94,8 @@ public object ThreeMaterials { * Compute color */ public fun Meta.threeColor(): Color? { - val value = getValue(Name.EMPTY) + if(isEmpty()) return null + val value = value return if (isLeaf) { when { value == null -> null @@ -132,19 +129,15 @@ private var Material.cached: Boolean } public fun Mesh.updateMaterial(vision: Vision) { - val ownMaterialMeta = vision.meta.getMeta(SolidMaterial.MATERIAL_KEY) + val ownMaterialMeta = vision.properties.raw?.get(SolidMaterial.MATERIAL_KEY) if (ownMaterialMeta == null) { if (vision is SolidReference && vision.getStyleNodes(SolidMaterial.MATERIAL_KEY).isEmpty()) { updateMaterial(vision.prototype) } else { - material = vision.computePropertyNode(SolidMaterial.MATERIAL_KEY)?.let { - ThreeMaterials.cacheMaterial(it) - } ?: ThreeMaterials.DEFAULT + material = ThreeMaterials.cacheMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]) } } else { - material = vision.computePropertyNode(SolidMaterial.MATERIAL_KEY)?.let { - ThreeMaterials.buildMaterial(it) - } ?: ThreeMaterials.DEFAULT + material = ThreeMaterials.buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]) } } @@ -159,19 +152,19 @@ public fun Mesh.updateMaterialProperty(vision: Vision, propertyName: Name) { } else { when (propertyName) { SolidMaterial.MATERIAL_COLOR_KEY -> { - material.asDynamic().color = vision.computePropertyNode(SolidMaterial.MATERIAL_COLOR_KEY)?.threeColor() + material.asDynamic().color = vision.properties[SolidMaterial.MATERIAL_COLOR_KEY].threeColor() ?: ThreeMaterials.DEFAULT_COLOR } SolidMaterial.SPECULAR_COLOR_KEY -> { - material.asDynamic().specular = vision.computePropertyNode(SolidMaterial.SPECULAR_COLOR_KEY)?.threeColor() + material.asDynamic().specular = vision.properties[SolidMaterial.SPECULAR_COLOR_KEY].threeColor() ?: ThreeMaterials.DEFAULT_COLOR } SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY -> { - material.asDynamic().emissive = vision.computePropertyNode(SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY)?.threeColor() + material.asDynamic().emissive = vision.properties[SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY].threeColor() ?: ThreeMaterials.BLACK_COLOR } SolidMaterial.MATERIAL_OPACITY_KEY -> { - val opacity = vision.getProperty( + val opacity = vision.properties.getValue( SolidMaterial.MATERIAL_OPACITY_KEY, inherit = true, )?.double ?: 1.0 @@ -179,7 +172,7 @@ public fun Mesh.updateMaterialProperty(vision: Vision, propertyName: Name) { material.transparent = opacity < 1.0 } SolidMaterial.MATERIAL_WIREFRAME_KEY -> { - material.asDynamic().wireframe = vision.getProperty( + material.asDynamic().wireframe = vision.properties.getValue( SolidMaterial.MATERIAL_WIREFRAME_KEY, inherit = true, )?.boolean ?: false