From bdf09d3087258c957b1e4ede10f8a2ae1b5b20a9 Mon Sep 17 00:00:00 2001 From: Peter Klimai Date: Sun, 6 Oct 2019 21:29:04 +0300 Subject: [PATCH 1/4] Update README --- README.md | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 783d9995..434dea40 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,40 @@ -# DataForge plugins for visualisation +# DataForge Plugins for Visualisation -## Common visualisation objects +This repository contains [DataForge](http://www.inr.ru/~nozik/dataforge/) +(also [here](https://github.com/mipt-npm/dataforge-core)) components useful for visualization in +various scientific applications. Currently, the main application is 3D visualization for accelerator +experiments. -## JavaFX utilities for meta manipulations +The project is developed as a Kotlin multiplatform application, currently +targeting browser JavaScript and JVM. -## 3D visualisation +## Modules contained in this repository: -Includes common discription and serializers, JavaFX and Three.js implementations. +### dataforge-vis-common + +Common visualisation objects such as VisualObject and VisualGroup. + +### dataforge-vis-fx + +JavaFX utilities for meta manipulations. + +### dataforge-vis-jsroot + +Some JSROOT bindings. + +Note: Currently, this part is experimental and put here for completeness. This module will not build. + +### dataforge-vis-spatial + +Includes common description and serializers for 3D visualisation, JavaFX and Three.js implementations. + +### dataforge-vis-spatial-gdml + +GDML bindings for 3D visualisation (to be moved to gdml project) + +### spatial-js-demo + +Contains a simple demonstration. To see the demo: run +`spatial-js-demo/distribution/installJsDist` Gradle task, then open +`build/distribuions/spatial-js-demo-0.0.0-dev/index.html`. -## GDML bindings for 3D visualisation (to be moved to gdml project) -- 2.34.1 From f49ad3ee2cb8485bed4ae571be26c1ddc4176f6e Mon Sep 17 00:00:00 2001 From: Peter Klimai Date: Wed, 9 Oct 2019 18:26:14 +0300 Subject: [PATCH 2/4] Doc updates --- README.md | 2 +- .../hep/dataforge/vis/common/AbstractVisualGroup.kt | 3 ++- .../hep/dataforge/vis/common/AbstractVisualObject.kt | 6 ++++++ .../kotlin/hep/dataforge/vis/common/Colors.kt | 9 ++++++++- .../hep/dataforge/vis/common/MutableVisualGroup.kt | 6 ++++++ .../kotlin/hep/dataforge/vis/common/VisualObject.kt | 10 ++++++++++ .../kotlin/hep/dataforge/vis/common/valueWidget.kt | 6 ++++++ .../kotlin/hep/dataforge/vis/spatial/Extruded.kt | 2 +- .../kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt | 3 +++ .../kotlin/hep/dataforge/vis/spatial/VisualObject3D.kt | 3 +++ .../vis/spatial/three/ThreeCompositeFactory.kt | 2 +- .../kotlin/hep/dataforge/vis/spatial/three/csg.kt | 3 +++ 12 files changed, 50 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 434dea40..dbddf3f7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DataForge Plugins for Visualisation -This repository contains [DataForge](http://www.inr.ru/~nozik/dataforge/) +This repository contains [DataForge](http://npm.mipt.ru/dataforge/) (also [here](https://github.com/mipt-npm/dataforge-core)) components useful for visualization in various scientific applications. Currently, the main application is 3D visualization for accelerator experiments. diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt index fda6c7fc..ca100ac8 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualGroup.kt @@ -8,7 +8,7 @@ import kotlinx.serialization.Transient /** - * Abstract implementation of group of [VisualObject] + * Abstract implementation of mutable group of [VisualObject] */ abstract class AbstractVisualGroup : AbstractVisualObject(), MutableVisualGroup { @@ -60,6 +60,7 @@ abstract class AbstractVisualGroup : AbstractVisualObject(), MutableVisualGroup } } + // TODO Consider renaming to `StructureChangeListener` (singular) private data class StructureChangeListeners(val owner: Any?, val callback: (Name, VisualObject?) -> Unit) @Transient diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt index 01e2c770..12043a27 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt @@ -12,6 +12,9 @@ internal data class PropertyListener( val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit ) +/** + * Abstract implementation of [VisualObject] + */ abstract class AbstractVisualObject : VisualObject { @Transient @@ -19,6 +22,9 @@ abstract class AbstractVisualObject : VisualObject { abstract override var properties: Config? + /** + * Style(s) of the object + */ override var style: List get() = properties?.let { it[STYLE_KEY].stringList } ?: emptyList() set(value) { diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Colors.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Colors.kt index 1f42d87c..2e77fa45 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Colors.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/Colors.kt @@ -3,7 +3,8 @@ package hep.dataforge.vis.common import kotlin.math.max /** - * Taken from https://github.com/markaren/three.kt/blob/master/threejs-wrapper/src/main/kotlin/info/laht/threekt/math/ColorConstants.kt + * Definitions of common colors. Taken from + * https://github.com/markaren/three.kt/blob/master/threejs-wrapper/src/main/kotlin/info/laht/threekt/math/ColorConstants.kt */ object Colors { const val aliceblue = 0xF0F8FF @@ -177,11 +178,17 @@ object Colors { const val yellow = 0xFFFF00 const val yellowgreen = 0x9ACD32 + /** + * Convert Int color to string of format #rrggbb + */ fun rgbToString(rgb: Int): String { val string = rgb.toString(16).padStart(6, '0') return "#" + string.substring(max(0, string.length - 6)) } + /** + * Convert three bytes representing color to string of format #rrggbb + */ fun rgbToString(red: UByte, green: UByte, blue: UByte): String { fun colorToString(color: UByte): String{ return color.toString(16).padStart(2,'0') diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/MutableVisualGroup.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/MutableVisualGroup.kt index f3b1ca7d..8aa3e8d5 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/MutableVisualGroup.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/MutableVisualGroup.kt @@ -4,6 +4,9 @@ import hep.dataforge.meta.Meta import hep.dataforge.names.* import hep.dataforge.provider.Provider +/** + * Represents a group of [VisualObject] instances + */ interface VisualGroup : Provider, Iterable, VisualObject { /** * A map of top level named children @@ -52,6 +55,9 @@ interface VisualGroup : Provider, Iterable, VisualObject { } } +/** + * Mutable version of [VisualGroup] + */ interface MutableVisualGroup : VisualGroup { /** diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualObject.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualObject.kt index 4a5ce8b3..93f368a4 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualObject.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/VisualObject.kt @@ -67,9 +67,19 @@ interface VisualObject : MetaRepr, Configurable { } } +/** + * Get [VisualObject] property using key as a String + */ fun VisualObject.getProperty(key: String, inherit: Boolean = true): MetaItem<*>? = getProperty(key.toName(), inherit) + +/** + * Set [VisualObject] property using key as a String + */ fun VisualObject.setProperty(key: String, value: Any?) = setProperty(key.toName(), value) +/** + * Apply style to [VisualObject] by adding it to the [style] list + */ fun VisualObject.applyStyle(name: String) { style = style + name } \ No newline at end of file diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/valueWidget.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/valueWidget.kt index fb4d5f32..8c45686f 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/valueWidget.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/valueWidget.kt @@ -3,12 +3,18 @@ package hep.dataforge.vis.common import hep.dataforge.descriptors.ValueDescriptor import hep.dataforge.meta.* +/** + * Extension property to access the "widget" key of [ValueDescriptor] + */ var ValueDescriptor.widget: Meta get() = this.config["widget"].node?: EmptyMeta set(value) { this.config["widget"] = value } +/** + * Extension property to access the "widget.type" key of [ValueDescriptor] + */ var ValueDescriptor.widgetType: String? get() = this["widget.type"].string set(value) { diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Extruded.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Extruded.kt index 32e8082d..6ae1f917 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Extruded.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/Extruded.kt @@ -62,7 +62,7 @@ class Extruded( override fun toGeometry(geometryBuilder: GeometryBuilder) { val shape: Shape2D = shape - if (shape.size < 3) error("Extruded shape requires more than points per layer") + if (shape.size < 3) error("Extruded shape requires more than 2 points per layer") /** * Expand the shape for specific layers diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt index d960cfc7..7cea1f28 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualGroup3D.kt @@ -27,6 +27,9 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers import kotlin.collections.set +/** + * Represents 3-dimensional Visual Group + */ @Serializable class VisualGroup3D : AbstractVisualGroup(), VisualObject3D { /** diff --git a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualObject3D.kt b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualObject3D.kt index cd9b22b3..0410677e 100644 --- a/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualObject3D.kt +++ b/dataforge-vis-spatial/src/commonMain/kotlin/hep/dataforge/vis/spatial/VisualObject3D.kt @@ -14,6 +14,9 @@ import hep.dataforge.vis.spatial.VisualObject3D.Companion.SELECTED_KEY import hep.dataforge.vis.spatial.VisualObject3D.Companion.VISIBLE_KEY import kotlinx.serialization.UseSerializers +/** + * Interface for 3-dimensional [VisualObject] + */ interface VisualObject3D : VisualObject { var position: Point3D? var rotation: Point3D? diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeCompositeFactory.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeCompositeFactory.kt index b6ee8852..8b88208d 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeCompositeFactory.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeCompositeFactory.kt @@ -6,7 +6,7 @@ import info.laht.threekt.core.BufferGeometry import info.laht.threekt.objects.Mesh /** - * This should be inner, becaulse it uses object builder + * This should be inner, because it uses object builder */ class ThreeCompositeFactory(val three: ThreePlugin) : MeshThreeFactory(Composite::class) { diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/csg.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/csg.kt index fa9a1c5b..036f729a 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/csg.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/csg.kt @@ -16,6 +16,9 @@ import info.laht.threekt.math.Matrix4 import info.laht.threekt.math.Vector3 import info.laht.threekt.objects.Mesh +/** + * Constructive Solid Geometry + */ open external class CSG { open var polygons: Array open fun clone(): CSG -- 2.34.1 From 0581d63315b3be69c27032f309255be4a723ed4f Mon Sep 17 00:00:00 2001 From: Peter Klimai Date: Sat, 12 Oct 2019 12:30:56 +0300 Subject: [PATCH 3/4] Makes sure the correct Element's clear() method is called - Fixes #4 --- .../kotlin/hep/dataforge/vis/spatial/editor/jsVisualTree.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsVisualTree.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsVisualTree.kt index 13868fdf..0a9495d7 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsVisualTree.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsVisualTree.kt @@ -16,6 +16,7 @@ import info.laht.threekt.loaders.Cache.clear import kotlinx.html.div import kotlinx.html.dom.append import org.w3c.dom.Element +import kotlin.dom.clear import kotlin.js.json operator fun Name.plus(other: NameToken): Name = Name(tokens + other) @@ -123,7 +124,7 @@ private fun VisualObject.toTree(onFocus: (VisualObject?, String?) -> Unit = { _, } fun Element.visualObjectTree(group: VisualObject, onFocus: (VisualObject?, String?) -> Unit) { - clear() + this.clear() append { card("Visual object tree") { val domConfig = jsObject { -- 2.34.1 From 486fb7c412beeff662c19899be6d0e85f73f1e5d Mon Sep 17 00:00:00 2001 From: Peter Klimai Date: Thu, 2 Jan 2020 15:18:26 +0300 Subject: [PATCH 4/4] README update --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6e94454f..ff2820f1 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,73 @@ [![JetBrains Research](https://jb.gg/badges/research.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) -# DataForge plugins for visualisation +# DataForge Visualisation Platform This repository contains [DataForge](http://npm.mipt.ru/dataforge/) (also [here](https://github.com/mipt-npm/dataforge-core)) components useful for visualization in -various scientific applications. Currently, the main application is 3D visualization for accelerator -experiments. +various scientific applications. Currently, the main application is 3D visualization for particle +physics experiments. The project is developed as a Kotlin multiplatform application, currently targeting browser JavaScript and JVM. +Main features: +- 3D visualization of complex experimental set-ups +- Event display such as particle tracks, etc. +- Scales up to few hundred thousands of elements +- Camera move, rotate, zoom-in and zoom-out +- Object tree with property editor +- Settings export and import +- Multiple platform support + + ## Modules contained in this repository: + ### dataforge-vis-common Common visualisation objects such as VisualObject and VisualGroup. -### dataforge-vis-fx - -JavaFX utilities for meta manipulations. - -### dataforge-vis-jsroot - -Some JSROOT bindings. - -Note: Currently, this part is experimental and put here for completeness. This module will not build. ### dataforge-vis-spatial Includes common description and serializers for 3D visualisation, JavaFX and Three.js implementations. + ### dataforge-vis-spatial-gdml -GDML bindings for 3D visualisation (to be moved to gdml project) +GDML bindings for 3D visualisation (to be moved to gdml project). -### spatial-js-demo -Contains a simple demonstration. To see the demo: run -`spatial-js-demo/distribution/installJsDist` Gradle task, then open -`build/distribuions/spatial-js-demo-0.0.0-dev/index.html`. +### dataforge-vis-jsroot +Some JSROOT bindings. + +Note: Currently, this part is experimental and put here for completeness. This module may not build. + + +### demo + +Several demonstrations of using the dataforge-vis framework: + +##### spatial-showcase + +Contains a simple demonstration (grid with a few shapes that you can rotate, move camera, etc.). + +To see the demo: run `demo/spatial-showcase/distribution/installJsDist` Gradle task, then open +`build/distribuions/spatial-showcase-js-0.1.0-dev/index.html` file in your browser. + +Other demos can be built similarly. + +##### muon-monitor + +A full-stack application example, showing the +[Muon Monitor](http://npm.mipt.ru/projects/physics.html#mounMonitor) experiment set-up. + +Includes server back-end generating events, as well as visualization front-end. + +To run full-stack app (both server and browser front-end), run +`demo/muon-monitor/application/run` task. + +##### gdml + +Visualization example for geometry defined as GDML file. -- 2.34.1