diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b57e1c0..412460ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,15 +8,26 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 40 steps: - - uses: actions/checkout@v3.5.3 - - name: Set up JDK 11 - uses: actions/setup-java@v3.12.0 + - uses: actions/checkout@v2 + - uses: DeLaGuardo/setup-graalvm@4.0 with: - java-version: 11 - distribution: liberica - - name: execute build - uses: gradle/gradle-build-action@v2.7.1 + graalvm: 21.2.0 + java: java11 + arch: amd64 + - uses: actions/cache@v2 with: - arguments: build + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + - uses: actions/cache@v2 + with: + path: ~/.konan + key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + - run: ./gradlew build --build-cache --no-daemon --stacktrace diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index aee354f6..134d3d48 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -10,15 +10,18 @@ jobs: timeout-minutes: 40 steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2.5.0 + - uses: DeLaGuardo/setup-graalvm@4.0 with: - java-version: 11 - distribution: liberica - - name: execute build - uses: gradle/gradle-build-action@v2 + graalvm: 21.2.0 + java: java11 + arch: amd64 + - uses: actions/cache@v2 with: - arguments: dokkaHtmlMultiModule + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + - run: ./gradlew dokkaHtmlMultiModule --build-cache --no-daemon --no-parallel --stacktrace - uses: JamesIves/github-pages-deploy-action@4.1.0 with: branch: gh-pages diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 99355168..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Gradle publish - -on: - workflow_dispatch: - release: - types: [ created ] - -jobs: - publish: - environment: - name: publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2.5.0 - with: - java-version: 11 - distribution: liberica - - name: execute build - uses: gradle/gradle-build-action@v2 - - name: Publish - shell: bash - run: > - ./gradlew release --no-daemon --build-cache -Ppublishing.enabled=true - -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} - -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} diff --git a/.gitignore b/.gitignore index 6d07da58..33607764 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,5 @@ out/ .gradle build/ -data/ !gradle-wrapper.jar - -/kotlin-js-store/yarn.lock diff --git a/.space.kts b/.space.kts deleted file mode 100644 index 45b2ed53..00000000 --- a/.space.kts +++ /dev/null @@ -1,4 +0,0 @@ -job("Build") { - gradlew("openjdk:11", "build") -} - diff --git a/CHANGELOG.md b/CHANGELOG.md index dbb44a80..d638f0c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,31 +2,6 @@ ## [Unreleased] ### Added -- Context receivers flag -- MeshLine for thick lines - -### Changed -- Color accessor property is now `colorProperty`. Color uses `invoke` instead of `set` -- API update for server and pages -- Edges moved to solids module for easier construction -- Visions **must** be rooted in order to subscribe to updates. -- Visions use flows instead of direct subscriptions. -- Radical change of inner workings of vision children and properties. -- Three package changed to `three`. -- Naming of Canvas3D options. -- Lights are added to the scene instead of 3D options. - -### Deprecated - -### Removed - -### Fixed -- Jupyter integration for IDEA and Jupyter lab. - -### Security - -## [0.2.0] -### Added - Server module - Change collector - Customizable accessors for colors @@ -34,9 +9,6 @@ - Hexagon interface and GenericHexagon implementation (Box inherits Hexagon) - Increased the default detail level for spheres and cones to 32 - Simple clipping for Solids in ThreeJs -- Markdown module -- Tables module - ### Changed - Vision does not implement ItemProvider anymore. Property changes are done via `getProperty`/`setProperty` and `property` delegate. @@ -53,16 +25,12 @@ - Property listeners are not triggered if there are no changes. - Feedback websocket connection in the client. - ### Deprecated ### Removed - Primary modules dependencies on UI - ### Fixed - Version conflicts - ### Security - diff --git a/README.md b/README.md index eeeaab9e..b8ff5212 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,15 @@ * [Features](#features) * [About DataForge](#about-dataforge) * [Modules contained in this repository](#modules-contained-in-this-repository) -* [Visualization for External Systems](#visualization-for-external-systems) + * [visionforge-core](#visionforge-core) + * [visionforge-solid](#visionforge-solid) + * [visionforge-gdml](#visionforge-gdml) + * [visionforge-fx](#visionforge-fx) + * [visionforge-markdown](#visionforge-markdown) + * [visionforge-plotly](#visionforge-plotly) + * [visionforge-server](#visionforge-server) + * [visionforge-threejs](#visionforge-threejs) +* [Visualization for External Systems](#visualization-for-external-systems) * [Demonstrations](#demonstrations) * [Simple Example - Solid Showcase](#simple-example---solid-showcase) * [Full-Stack Application Example - Muon Monitor](#full-stack-application-example---muon-monitor-visualization) @@ -23,13 +31,13 @@ ## Introduction -This repository contains a [DataForge](#about-dataforge)\-based framework -used for visualization in various scientific applications. +This repository contains a [DataForge](#about-dataforge)\-based framework +used for visualization in various scientific applications. -The main framework's use case for now is 3D visualization for particle physics experiments. +The main framework's use case for now is 3D visualization for particle physics experiments. Other applications including 2D plots are planned for the future. -The project is developed as a [Kotlin multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html) +The project is developed as a [Kotlin multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html) application, currently targeting browser JavaScript and JVM. ## Requirements @@ -54,165 +62,35 @@ Platform uses some of the concepts and modules of DataForge, including: `Meta`, `Provider`, and some others. To learn more about DataForge, please consult the following URLs: -* [Kotlin multiplatform implementation of DataForge](https://github.com/mipt-npm/dataforge-core) -* [DataForge documentation](http://npm.mipt.ru/dataforge/) -* [Original implementation of DataForge](https://bitbucket.org/Altavir/dataforge/src/default/) + * [Kotlin multiplatform implementation of DataForge](https://github.com/mipt-npm/dataforge-core) + * [DataForge documentation](http://npm.mipt.ru/dataforge/) + * [Original implementation of DataForge](https://bitbucket.org/Altavir/dataforge/src/default/) ## Modules contained in this repository -
- -* ### [cern-root-loader](cern-root-loader) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [demo](demo) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [jupyter](jupyter) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [ui](ui) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [visionforge-core](visionforge-core) -> +### visionforge-core +> Core classes, algebra definitions, basic linear algebra > > **Maturity**: DEVELOPMENT -
- -* ### [visionforge-fx](visionforge-fx) -> > -> **Maturity**: PROTOTYPE +> **Features:** +> - [vision](visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt) : an architecture of visions.
-* ### [visionforge-gdml](visionforge-gdml) -> -> -> **Maturity**: EXPERIMENTAL -
+Contains a general hierarchy of classes and interfaces useful for visualization. +This module is not specific to 3D-visualization. -* ### [visionforge-markdown](visionforge-markdown) -> -> -> **Maturity**: EXPERIMENTAL -
+The `visionforge-core` module also includes configuration editors for JS (in `jsMain`) and JVM (in `jvmMain`). -* ### [visionforge-plotly](visionforge-plotly) -> -> -> **Maturity**: EXPERIMENTAL -
+**Class diagram:** -* ### [visionforge-server](visionforge-server) -> -> -> **Maturity**: EXPERIMENTAL -
+![](docs/images/class-diag-core.png) -* ### [visionforge-solid](visionforge-solid) -> -> -> **Maturity**: DEVELOPMENT -
-* ### [visionforge-tables](visionforge-tables) -> -> -> **Maturity**: PROTOTYPE -
- -* ### [visionforge-threejs](visionforge-threejs) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [gdml](demo/gdml) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [js-playground](demo/js-playground) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [muon-monitor](demo/muon-monitor) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [playground](demo/playground) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [plotly-fx](demo/plotly-fx) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [sat-demo](demo/sat-demo) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [solid-showcase](demo/solid-showcase) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [visionforge-jupyter-gdml](jupyter/visionforge-jupyter-gdml) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [bootstrap](ui/bootstrap) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [react](ui/react) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [ring](ui/ring) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [visionforge-threejs-server](visionforge-threejs/visionforge-threejs-server) -> -> -> **Maturity**: EXPERIMENTAL -
+### visionforge-solid +Includes common classes and serializers for 3D visualization, as well as Three.js and JavaFX implementations. **Class diagram:** @@ -221,26 +99,30 @@ To learn more about DataForge, please consult the following URLs: ##### Prototypes One of the important features of the framework is support for 3D object prototypes (sometimes -also referred to as templates). The idea is that prototype geometry can be rendered once and reused +also referred to as templates). The idea is that prototype geometry can be rendered once and reused for multiple objects. This helps to significantly decrease memory usage. -The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and +The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and `SolidReference` class helps to reuse a template object. ##### Styles -`VisionGroup` has a `styleSheet` property that can optionally define styles at the Group's -level. Styles are applied to child (descendant) objects using `Vision.styles: List` property. +`SolidGroup` has a `styleSheet` property that can optionally define styles at the Group's +level. Styles are applied to child (descendant) objects using `Vision.styles: List` property. -### visionforge-threejs -## Visualization for External Systems +### visionforge-gdml + +GDML bindings for 3D visualization (to be moved to gdml project). + + +## Visualization for External Systems The `visionforge` framework can be used to visualize geometry and events from external, non-Kotlin based systems, such as ROOT. This will require a plugin to convert data model of the external system to that of `visionforge`. Performing such integration is a work currently in progress. - + ## Demonstrations @@ -262,7 +144,7 @@ Some shapes will also periodically change their color and visibility. ### Full-Stack Application Example - Muon Monitor Visualization -A full-stack application example, showing the +A full-stack application example, showing the [Muon Monitor](http://npm.mipt.ru/en/projects/physics#mounMonitor) experiment set-up. [More details](demo/muon-monitor/README.md) @@ -274,7 +156,7 @@ A full-stack application example, showing the ### GDML Example -Visualization example for geometry defined as GDML file. +Visualization example for geometry defined as GDML file. [More details](demo/gdml/README.md) diff --git a/build.gradle.kts b/build.gradle.kts index 68c3569b..44f0d885 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,63 +1,39 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile -import space.kscience.gradle.isInDevelopment -import space.kscience.gradle.useApache2Licence -import space.kscience.gradle.useSPCTeam - plugins { - id("space.kscience.gradle.project") -// id("org.jetbrains.kotlinx.kover") version "0.5.0" + id("ru.mipt.npm.gradle.project") +// kotlin("multiplatform") version "1.5.30-RC" apply false +// kotlin("js") version "1.5.30-RC" apply false } -val dataforgeVersion by extra("0.6.1") +val dataforgeVersion by extra("0.5.1") val fxVersion by extra("11") allprojects { + repositories { + mavenLocal() + mavenCentral() + maven("https://repo.kotlin.link") + maven("https://maven.jzy3d.org/releases") + } + group = "space.kscience" - version = "0.3.0-dev-13" + version = "0.2.0-dev-23" } subprojects { - if (name.startsWith("visionforge")) apply() - - repositories { - mavenLocal() - maven("https://repo.kotlin.link") - mavenCentral() - maven("https://maven.jzy3d.org/releases") - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - } - - tasks.withType { - kotlinOptions { - freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers" - } - } - - tasks.withType{ - kotlinOptions{ - useEsClasses = true - } + if (name.startsWith("visionforge")) { + plugins.apply("maven-publish") } } ksciencePublish { - pom("https://github.com/SciProgCentre/visionforge") { - useApache2Licence() - useSPCTeam() - } - github(githubProject = "visionforge", githubOrg = "SciProgCentre") - space( - if (isInDevelopment) { - "https://maven.pkg.jetbrains.space/spc/p/sci/dev" - } else { - "https://maven.pkg.jetbrains.space/spc/p/sci/maven" - } - ) + github("visionforge") + space() sonatype() } apiValidation { + validationDisabled = true ignoredPackages.add("info.laht.threekt") } -readme.readmeTemplate = file("docs/templates/README-TEMPLATE.md") \ No newline at end of file +//workaround for https://youtrack.jetbrains.com/issue/KT-48273 diff --git a/cern-root-loader/README.md b/cern-root-loader/README.md deleted file mode 100644 index b032852d..00000000 --- a/cern-root-loader/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module cern-root-loader - - - diff --git a/cern-root-loader/api/cern-root-loader.api b/cern-root-loader/api/cern-root-loader.api deleted file mode 100644 index 2788976b..00000000 --- a/cern-root-loader/api/cern-root-loader.api +++ /dev/null @@ -1,926 +0,0 @@ -public final class ru/mipt/npm/root/DGeoBoolNode : ru/mipt/npm/root/DObject { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFLeft ()Lru/mipt/npm/root/DGeoShape; - public final fun getFLeftMat ()Lru/mipt/npm/root/DGeoMatrix; - public final fun getFRight ()Lru/mipt/npm/root/DGeoShape; - public final fun getFRightMat ()Lru/mipt/npm/root/DGeoMatrix; -} - -public final class ru/mipt/npm/root/DGeoManager : ru/mipt/npm/root/DNamed { - public static final field Companion Lru/mipt/npm/root/DGeoManager$Companion; - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFMatrices ()Ljava/util/List; - public final fun getFNodes ()Ljava/util/List; - public final fun getFShapes ()Ljava/util/List; - public final fun getFVolumes ()Ljava/util/List; -} - -public final class ru/mipt/npm/root/DGeoManager$Companion { - public final fun parse (Ljava/lang/String;)Lru/mipt/npm/root/DGeoManager; -} - -public final class ru/mipt/npm/root/DGeoMaterial : ru/mipt/npm/root/DNamed { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V -} - -public class ru/mipt/npm/root/DGeoMatrix : ru/mipt/npm/root/DNamed { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V -} - -public final class ru/mipt/npm/root/DGeoMedium : ru/mipt/npm/root/DNamed { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFMaterial ()Lru/mipt/npm/root/DGeoMaterial; - public final fun getFParams ()[D -} - -public final class ru/mipt/npm/root/DGeoNode : ru/mipt/npm/root/DNamed { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFVolume ()Lru/mipt/npm/root/DGeoVolume; -} - -public class ru/mipt/npm/root/DGeoScale : ru/mipt/npm/root/DGeoMatrix { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFScale ()[D - public final fun getX ()D - public final fun getY ()D - public final fun getZ ()D -} - -public final class ru/mipt/npm/root/DGeoShape : ru/mipt/npm/root/DNamed { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFDX ()D - public final fun getFDY ()D - public final fun getFDZ ()D -} - -public final class ru/mipt/npm/root/DGeoVolume : ru/mipt/npm/root/DNamed, space/kscience/dataforge/misc/Named { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFFillColor ()Ljava/lang/Integer; - public final fun getFMedium ()Lru/mipt/npm/root/DGeoMedium; - public final fun getFNodes ()Ljava/util/List; - public final fun getFShape ()Lru/mipt/npm/root/DGeoShape; - public fun getName ()Lspace/kscience/dataforge/names/Name; -} - -public class ru/mipt/npm/root/DNamed : ru/mipt/npm/root/DObject { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getFName ()Ljava/lang/String; - public final fun getFTitle ()Ljava/lang/String; -} - -public class ru/mipt/npm/root/DObject { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V - public final fun getMeta ()Lspace/kscience/dataforge/meta/Meta; - public final fun getRefCache ()Lru/mipt/npm/root/DObjectCache; - public final fun getTypename ()Ljava/lang/String; -} - -public final class ru/mipt/npm/root/DObjectCache { - public static final field Companion Lru/mipt/npm/root/DObjectCache$Companion; - public fun (Ljava/util/List;Ljava/util/List;)V - public synthetic fun (Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun get (I)Lspace/kscience/dataforge/meta/Meta; - public final fun getRefStack ()Ljava/util/List; - public final fun stack (I)Lru/mipt/npm/root/DObjectCache; -} - -public final class ru/mipt/npm/root/DObjectCache$Companion { - public final fun getEmpty ()Lru/mipt/npm/root/DObjectCache; -} - -public final class ru/mipt/npm/root/DObjectKt { - public static final fun doubleArray (Lspace/kscience/dataforge/meta/MetaProvider;[DLspace/kscience/dataforge/names/Name;)Lkotlin/properties/ReadOnlyProperty; - public static synthetic fun doubleArray$default (Lspace/kscience/dataforge/meta/MetaProvider;[DLspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; -} - -public final class ru/mipt/npm/root/DRootToSolidKt { - public static final fun toSolid (Lru/mipt/npm/root/DGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup; -} - -public final class ru/mipt/npm/root/RootColors { - public static final field INSTANCE Lru/mipt/npm/root/RootColors; - public final fun get (I)Ljava/lang/String; -} - -public final class ru/mipt/npm/root/serialization/JsonToRootKt { - public static final fun decodeFromJson (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/KSerializer;Lkotlinx/serialization/json/JsonElement;)Lru/mipt/npm/root/serialization/TObject; - public static final fun decodeFromString (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/KSerializer;Ljava/lang/String;)Lru/mipt/npm/root/serialization/TObject; -} - -public final class ru/mipt/npm/root/serialization/RootToSolidKt { - public static final fun toSolid (Lru/mipt/npm/root/serialization/TGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup; -} - -public class ru/mipt/npm/root/serialization/TGeoBBox : ru/mipt/npm/root/serialization/TGeoShape { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoBBox$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFDX ()D - public final fun getFDY ()D - public final fun getFDZ ()D - public final fun getFOrigin ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoBBox;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoBBox$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoBBox$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoBBox; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoBBox;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoBBox$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract class ru/mipt/npm/root/serialization/TGeoBoolNode : ru/mipt/npm/root/serialization/TObject { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoBoolNode$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public abstract fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; - public final fun getFLeftMat ()Lru/mipt/npm/root/serialization/TGeoMatrix; - public abstract fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public final fun getFRightMat ()Lru/mipt/npm/root/serialization/TGeoMatrix; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoBoolNode$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoCombiTrans : ru/mipt/npm/root/serialization/TGeoMatrix { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoCombiTrans$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLru/mipt/npm/root/serialization/TGeoRotation;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun ([DLru/mipt/npm/root/serialization/TGeoRotation;)V - public synthetic fun ([DLru/mipt/npm/root/serialization/TGeoRotation;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFRotation ()Lru/mipt/npm/root/serialization/TGeoRotation; - public final fun getFTranslation ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoCombiTrans;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoCombiTrans$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoCombiTrans$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoCombiTrans; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoCombiTrans;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoCombiTrans$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoCompositeShape : ru/mipt/npm/root/serialization/TGeoBBox { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoCompositeShape$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lru/mipt/npm/root/serialization/TGeoBoolNode;)V - public final fun getFNode ()Lru/mipt/npm/root/serialization/TGeoBoolNode; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoCompositeShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoCompositeShape$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoCompositeShape$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoCompositeShape; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoCompositeShape;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoCompositeShape$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoHMatrix : ru/mipt/npm/root/serialization/TGeoMatrix { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoHMatrix$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun ([D[D[D)V - public final fun getFRotationMatrix ()[D - public final fun getFScale ()[D - public final fun getFTranslation ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoHMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoHMatrix$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoHMatrix$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoHMatrix; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoHMatrix;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoHMatrix$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoIdentity : ru/mipt/npm/root/serialization/TGeoMatrix { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoIdentity$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoIdentity;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoIdentity$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoIdentity$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoIdentity; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoIdentity;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoIdentity$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoIntersection : ru/mipt/npm/root/serialization/TGeoBoolNode { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoIntersection$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V - public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; - public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoIntersection;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoIntersection$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoIntersection$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoIntersection; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoIntersection;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoIntersection$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoManager : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoManager$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFMatrices ()Lru/mipt/npm/root/serialization/TObjArray; - public final fun getFNodes ()Lru/mipt/npm/root/serialization/TObjArray; - public final fun getFShapes ()Lru/mipt/npm/root/serialization/TObjArray; - public final fun getFVolumes ()Lru/mipt/npm/root/serialization/TObjArray; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoManager;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoManager$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoManager$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoManager; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoManager;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoManager$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoMaterial : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoMaterial$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMaterial;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoMaterial$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMaterial$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMaterial; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoMaterial;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoMaterial$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract class ru/mipt/npm/root/serialization/TGeoMatrix : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoMatrix$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoMatrix$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoMedium : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoMedium$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;ILru/mipt/npm/root/serialization/TGeoMaterial;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (ILru/mipt/npm/root/serialization/TGeoMaterial;[D)V - public final fun getFId ()I - public final fun getFMaterial ()Lru/mipt/npm/root/serialization/TGeoMaterial; - public final fun getFParams ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMedium;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoMedium$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMedium$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMedium; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoMedium;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoMedium$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoMixture : ru/mipt/npm/root/serialization/TGeoMaterial { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoMixture$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMixture;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoMixture$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMixture$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMixture; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoMixture;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoMixture$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoNode : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoNode$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[ILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFGeoAtt-pVg5ArA ()I - public final fun getFNovlp ()I - public final fun getFNumber ()I - public final fun getFOverlaps ()[I - public final fun getFVolume ()Lru/mipt/npm/root/serialization/TGeoVolume; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoNode$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNode$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNode; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoNode;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoNode$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix : ru/mipt/npm/root/serialization/TGeoNode { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoNodeMatrix$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[ILru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFMatrix ()Lru/mipt/npm/root/serialization/TGeoMatrix; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNodeMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNodeMatrix$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNodeMatrix; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoNodeMatrix;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoNodeOffset : ru/mipt/npm/root/serialization/TGeoNode { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoNodeOffset$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[IDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFOffset ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNodeOffset;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoNodeOffset$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNodeOffset$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNodeOffset; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoNodeOffset;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoNodeOffset$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoPcon : ru/mipt/npm/root/serialization/TGeoBBox { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoPcon$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIDD[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFDphi ()D - public final fun getFNz ()I - public final fun getFPhi1 ()D - public final fun getFRmax ()[D - public final fun getFRmin ()[D - public final fun getFZ ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoPcon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoPcon$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoPcon$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoPcon; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoPcon;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoPcon$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoPgon : ru/mipt/npm/root/serialization/TGeoPcon { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoPgon$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIDD[D[D[DILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFNedges ()I - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoPgon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoPgon$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoPgon$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoPgon; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoPgon;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoPgon$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoRotation : ru/mipt/npm/root/serialization/TGeoMatrix { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoRotation$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun ([D)V - public final fun getFRotationMatrix ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoRotation;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoRotation$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoRotation$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoRotation; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoRotation;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoRotation$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract class ru/mipt/npm/root/serialization/TGeoShape : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoShape$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFShapeBits-pVg5ArA ()I - public final fun getFShapeId ()I - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoShape$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly : ru/mipt/npm/root/serialization/TGeoBBox { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoShapeAssembly$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLru/mipt/npm/root/serialization/TGeoVolumeAssembly;ZLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Z)V - public synthetic fun (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFBBoxOK ()Z - public final fun getFVolume ()Lru/mipt/npm/root/serialization/TGeoVolumeAssembly; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoShapeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoShapeAssembly$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoShapeAssembly; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoShapeAssembly;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoShapeRef : ru/mipt/npm/root/serialization/TGeoShape { - public fun (Lkotlin/jvm/functions/Function0;)V - public final fun getValue ()Lru/mipt/npm/root/serialization/TGeoShape; -} - -public final class ru/mipt/npm/root/serialization/TGeoSubtraction : ru/mipt/npm/root/serialization/TGeoBoolNode { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoSubtraction$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V - public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; - public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoSubtraction;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoSubtraction$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoSubtraction$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoSubtraction; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoSubtraction;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoSubtraction$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoTranslation : ru/mipt/npm/root/serialization/TGeoMatrix { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoTranslation$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun ([D)V - public final fun getFTranslation ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTranslation;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoTranslation$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTranslation$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTranslation; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoTranslation;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoTranslation$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoTube : ru/mipt/npm/root/serialization/TGeoBBox { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoTube$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DDDDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFDz ()D - public final fun getFRmax ()D - public final fun getFRmin ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTube;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoTube$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTube$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTube; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoTube;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoTube$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoTubeSeg : ru/mipt/npm/root/serialization/TGeoTube { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoTubeSeg$Companion; - public fun (DDDDDDDDD)V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DDDDDDDDDDDDDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFC1 ()D - public final fun getFC2 ()D - public final fun getFCdfi ()D - public final fun getFCm ()D - public final fun getFPhi1 ()D - public final fun getFPhi2 ()D - public final fun getFS1 ()D - public final fun getFS2 ()D - public final fun getFSm ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTubeSeg;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoTubeSeg$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTubeSeg$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTubeSeg; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoTubeSeg;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoTubeSeg$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoUnion : ru/mipt/npm/root/serialization/TGeoBoolNode { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoUnion$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V - public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; - public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoUnion;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoUnion$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoUnion$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoUnion; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoUnion;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoUnion$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoVolume : ru/mipt/npm/root/serialization/TNamed { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoVolume$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILjava/lang/Integer;Lkotlin/UInt;Ljava/lang/Integer;Ljava/lang/Integer;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoMedium;IIILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFFillColor ()Ljava/lang/Integer; - public final fun getFFillStyle ()Ljava/lang/Integer; - public final fun getFGeoAtt-pVg5ArA ()I - public final fun getFLineColor ()I - public final fun getFLineStyle ()Ljava/lang/Integer; - public final fun getFLineWidth-pVg5ArA ()I - public final fun getFMedium ()Lru/mipt/npm/root/serialization/TGeoMedium; - public final fun getFNodes ()Lru/mipt/npm/root/serialization/TObjArray; - public final fun getFNtotal ()I - public final fun getFNumber ()I - public final fun getFRefCount ()I - public final fun getFShape ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolume;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoVolume$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoVolume$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoVolume; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoVolume;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoVolume$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TGeoVolumeAssembly : ru/mipt/npm/root/serialization/TGeoVolume { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoVolumeAssembly$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILjava/lang/Integer;Lkotlin/UInt;Ljava/lang/Integer;Ljava/lang/Integer;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoMedium;IIILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoVolumeAssembly$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoVolumeAssembly$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoVolumeAssembly; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoVolumeAssembly$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoVolumeAssemblyRef : ru/mipt/npm/root/serialization/TGeoVolumeAssembly { - public fun (Lkotlin/jvm/functions/Function0;)V - public final fun getValue ()Lru/mipt/npm/root/serialization/TGeoVolumeAssembly; -} - -public final class ru/mipt/npm/root/serialization/TGeoVolumeRef : ru/mipt/npm/root/serialization/TGeoVolume { - public fun (Lkotlin/jvm/functions/Function0;)V - public final fun getValue ()Lru/mipt/npm/root/serialization/TGeoVolume; -} - -public final class ru/mipt/npm/root/serialization/TGeoXtru : ru/mipt/npm/root/serialization/TGeoBBox { - public static final field Companion Lru/mipt/npm/root/serialization/TGeoXtru$Companion; - public fun (IID[D[D[D[D[D[D)V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIID[D[D[D[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFNvert ()I - public final fun getFNz ()I - public final fun getFScale ()[D - public final fun getFX ()[D - public final fun getFX0 ()[D - public final fun getFY ()[D - public final fun getFY0 ()[D - public final fun getFZ ()[D - public final fun getFZcurrent ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoXtru;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TGeoXtru$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoXtru$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoXtru; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoXtru;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TGeoXtru$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/THashList : ru/mipt/npm/root/serialization/TObject { - public static final field Companion Lru/mipt/npm/root/serialization/THashList$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/util/List;)V - public final fun getArr ()Ljava/util/List; - public static final fun write$Self (Lru/mipt/npm/root/serialization/THashList;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/THashList$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/THashList$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/THashList; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/THashList;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/THashList$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TList : ru/mipt/npm/root/serialization/TObject { - public static final field Companion Lru/mipt/npm/root/serialization/TList$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/util/List;)V - public final fun getArr ()Ljava/util/List; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TList;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TList$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TList$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TList; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TList;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TList$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public class ru/mipt/npm/root/serialization/TNamed : ru/mipt/npm/root/serialization/TObject { - public static final field Companion Lru/mipt/npm/root/serialization/TNamed$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFName ()Ljava/lang/String; - public final fun getFTitle ()Ljava/lang/String; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TNamed;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TNamed$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/root/serialization/TNamed$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TNamed; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TNamed;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TNamed$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TObjArray : ru/mipt/npm/root/serialization/TObject { - public static final field Companion Lru/mipt/npm/root/serialization/TObjArray$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/util/List;)V - public final fun getArr ()Ljava/util/List; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TObjArray;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;Lkotlinx/serialization/KSerializer;)V -} - -public final class ru/mipt/npm/root/serialization/TObjArray$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun (Lkotlinx/serialization/KSerializer;)V - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TObjArray; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TObjArray;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/root/serialization/TObjArray$Companion { - public final fun getEmpty ()Lru/mipt/npm/root/serialization/TObjArray; - public final fun serializer (Lkotlinx/serialization/KSerializer;)Lkotlinx/serialization/KSerializer; -} - -public abstract class ru/mipt/npm/root/serialization/TObject { - public static final field Companion Lru/mipt/npm/root/serialization/TObject$Companion; - public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFBits-pVg5ArA ()I - public final fun getFUniqueID-pVg5ArA ()I - public static final fun write$Self (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/root/serialization/TObject$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - diff --git a/cern-root-loader/build.gradle.kts b/cern-root-loader/build.gradle.kts deleted file mode 100644 index fb787187..00000000 --- a/cern-root-loader/build.gradle.kts +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -kscience{ - jvm() - js() - dependencies { - api(projects.visionforgeSolid) - } - useSerialization { - json() - } -} \ No newline at end of file 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 deleted file mode 100644 index 8b67c108..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/DObject.kt +++ /dev/null @@ -1,144 +0,0 @@ -package ru.mipt.npm.root - -import kotlinx.serialization.json.Json -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.misc.Named -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName -import kotlin.properties.ReadOnlyProperty - -public fun MetaProvider.doubleArray( - vararg default: Double, - key: Name? = null, -): ReadOnlyProperty = value(key) { - it?.doubleArray ?: doubleArrayOf(*default) -} - -public class DObjectCache(private val cache: List, public val refStack: List = emptyList()) { - public operator fun get(index: Int): Meta = cache[index] - - public fun stack(ref: Int): DObjectCache = DObjectCache(cache, refStack + ref) - - public companion object { - public val empty: DObjectCache = DObjectCache(emptyList(), emptyList()) - } -} - -public open class DObject(public val meta: Meta, public val refCache: DObjectCache) { - - public val typename: String by meta.string(key = "_typename".asName()) { - error("Type is not defined") - } - - private fun resolve(builder: (Meta, DObjectCache) -> T, meta: Meta): T? { - meta["\$ref"]?.int?.let { refId -> - if (refCache.refStack.contains(refId)) { - println("Circular reference $refId in stack ${refCache.refStack}") - return null - } - return builder(refCache[refId], refCache.stack(refId)) - } - return builder(meta, refCache) - } - - internal fun tObjectArray( - builder: (Meta, DObjectCache) -> T - ): ReadOnlyProperty> = ReadOnlyProperty { _, property -> - meta.getIndexed(Name.of(property.name, "arr")).values.mapNotNull { - resolve(builder, it) - } - } - - internal fun dObject( - builder: (Meta, DObjectCache) -> T, - key: Name? = null - ): ReadOnlyProperty = ReadOnlyProperty { _, property -> - meta[key ?: property.name.asName()]?.let { resolve(builder, it) } - } -} - -public open class DNamed(meta: Meta, refCache: DObjectCache) : DObject(meta, refCache) { - public val fName: String by meta.string("") - public val fTitle: String by meta.string("") -} - -public class DGeoMaterial(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) { -} - -public class DGeoMedium(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) { - public val fMaterial: DGeoMaterial? by dObject(::DGeoMaterial) - public val fParams: DoubleArray by meta.doubleArray() -} - -public class DGeoShape(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) { - public val fDX: Double by meta.double(0.0) - public val fDY: Double by meta.double(0.0) - public val fDZ: Double by meta.double(0.0) -} - -public class DGeoVolume(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache), Named { - public val fNodes: List by tObjectArray(::DGeoNode) - public val fShape: DGeoShape? by dObject(::DGeoShape) - public val fMedium: DGeoMedium? by dObject(::DGeoMedium) - - public val fFillColor: Int? by meta.int() - - override val name: Name by lazy { Name.parse(fName.ifEmpty { "volume[${meta.hashCode().toUInt()}]" }) } -} - -public class DGeoNode(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) { - public val fVolume: DGeoVolume? by dObject(::DGeoVolume) -} - -public open class DGeoMatrix(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) - -public open class DGeoScale(meta: Meta, refCache: DObjectCache) : DGeoMatrix(meta, refCache) { - public val fScale: DoubleArray by meta.doubleArray(1.0, 1.0, 1.0) - public val x: Double get() = fScale[0] - public val y: Double get() = fScale[1] - public val z: Double get() = fScale[2] -} - - -public class DGeoBoolNode(meta: Meta, refCache: DObjectCache) : DObject(meta, refCache) { - public val fLeft: DGeoShape? by dObject(::DGeoShape) - public val fLeftMat: DGeoMatrix? by dObject(::DGeoMatrix) - - public val fRight: DGeoShape? by dObject(::DGeoShape) - public val fRightMat: DGeoMatrix? by dObject(::DGeoMatrix) -} - - -public class DGeoManager(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) { - public val fMatrices: List by tObjectArray(::DGeoMatrix) - - public val fShapes: List by tObjectArray(::DGeoShape) - - public val fVolumes: List by tObjectArray(::DGeoVolume) - - public val fNodes: List by tObjectArray(::DGeoNode) - - public companion object { - - public fun parse(string: String): DGeoManager { - val meta = Json.decodeFromString(MetaSerializer, string) - val res = ArrayList(4096) - - fun fillCache(element: Meta) { - if (element["\$ref"] == null) { - res.add(element) - element.items.values.forEach { - if (!it.isLeaf) { - fillCache(it) - } - } - } - } - - fillCache(meta) - - val refCache = DObjectCache(res) - return DGeoManager(meta, refCache) - } - } -} 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 deleted file mode 100644 index 07112c06..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt +++ /dev/null @@ -1,388 +0,0 @@ -package ru.mipt.npm.root - -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.parseAsName -import space.kscience.dataforge.names.plus -import space.kscience.dataforge.names.withIndex -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.isEmpty -import space.kscience.visionforge.set -import space.kscience.visionforge.solid.* -import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY -import kotlin.math.* - -private val volumesName = Name.EMPTY //"volumes".asName() - -private operator fun Number.times(d: Double) = toDouble() * d - -private operator fun Number.times(f: Float) = toFloat() * f - -private fun degToRad(d: Double) = d * PI / 180.0 - -private data class RootToSolidContext( - val prototypeHolder: PrototypeHolder, - val currentLayer: Int = 0, - val maxLayer: Int = 5, - val ignoreRootColors: Boolean = false, - val colorCache: MutableMap = mutableMapOf(), -) - -// converting to XYZ to Tait–Bryan angles according to https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix -private fun Solid.rotate(rot: DoubleArray) { - val xAngle = atan2(-rot[5], rot[8]) - val yAngle = atan2(rot[2], sqrt(1.0 - rot[2].pow(2))) - val zAngle = atan2(-rot[1], rot[0]) - rotation = Float32Vector3D(xAngle, yAngle, zAngle) -} - -private fun Solid.translate(trans: DoubleArray) { - val (x, y, z) = trans - position = Float32Vector3D(x, y, z) -} - -private fun Solid.useMatrix(matrix: DGeoMatrix?) { - if (matrix == null) return - when (matrix.typename) { - "TGeoIdentity" -> { - //do nothing - } - - "TGeoTranslation" -> { - val fTranslation by matrix.meta.doubleArray() - translate(fTranslation) - } - - "TGeoRotation" -> { - val fRotationMatrix by matrix.meta.doubleArray() - rotate(fRotationMatrix) - } - - "TGeoCombiTrans" -> { - val fTranslation by matrix.meta.doubleArray() - - translate(fTranslation) - matrix.meta["fRotation.fRotationMatrix"]?.value?.let { - rotate(it.doubleArray) - } - } - - "TGeoHMatrix" -> { - val fTranslation by matrix.meta.doubleArray() - val fRotationMatrix by matrix.meta.doubleArray() - val fScale by matrix.meta.doubleArray() - translate(fTranslation) - rotate(fRotationMatrix) - scale = Float32Vector3D(fScale[0], fScale[1], fScale[2]) - } - } -} - -private fun SolidGroup.addShape( - shape: DGeoShape, - context: RootToSolidContext, - name: String? = shape.fName.ifEmpty { null }, - block: Solid.() -> Unit = {}, -) { - when (shape.typename) { - "TGeoCompositeShape" -> { - val fNode: DGeoBoolNode? by shape.dObject(::DGeoBoolNode) - val node = fNode ?: error("Composite shape node not resolved") - val compositeType = when (node.typename) { - "TGeoIntersection" -> CompositeType.INTERSECT - "TGeoSubtraction" -> CompositeType.SUBTRACT - "TGeoUnion" -> CompositeType.GROUP - else -> error("Unknown bool node type ${node.typename}") - } - smartComposite(compositeType, name = name) { - addShape(node.fLeft!!, context, null) { - this.useMatrix(node.fLeftMat) - } - addShape(node.fRight!!, context, null) { - this.useMatrix(node.fRightMat) - } - }.apply(block) - } - - "TGeoXtru" -> { - val fNvert by shape.meta.int(0) - val fX by shape.meta.doubleArray() - val fY by shape.meta.doubleArray() - val fNz by shape.meta.int(0) - val fZ by shape.meta.doubleArray() - val fX0 by shape.meta.doubleArray() - val fY0 by shape.meta.doubleArray() - val fScale by shape.meta.doubleArray() - - extruded(name = name) { - (0 until fNvert).forEach { index -> - shape { - point(fX[index], fY[index]) - } - } - - (0 until fNz).forEach { index -> - layer( - fZ[index], - fX0[index], - fY0[index], - fScale[index] - ) - } - }.apply(block) - } - - "TGeoTube" -> { - val fRmax by shape.meta.double(0.0) - val fDz by shape.meta.double(0.0) - val fRmin by shape.meta.double(0.0) - - tube( - radius = fRmax, - height = fDz * 2, - innerRadius = fRmin, - name = name, - block = block - ) - } - - "TGeoTubeSeg" -> { - val fRmax by shape.meta.double(0.0) - val fDz by shape.meta.double(0.0) - val fRmin by shape.meta.double(0.0) - val fPhi1 by shape.meta.double(0.0) - val fPhi2 by shape.meta.double(0.0) - - tube( - radius = fRmax, - height = fDz * 2, - innerRadius = fRmin, - startAngle = degToRad(fPhi1), - angle = degToRad(fPhi2 - fPhi1), - name = name, - block = block - ) - } - - "TGeoPcon" -> { - val fDphi by shape.meta.double(0.0) - val fNz by shape.meta.int(2) - val fPhi1 by shape.meta.double(360.0) - val fRmax by shape.meta.doubleArray() - val fRmin by shape.meta.doubleArray() - val fZ by shape.meta.doubleArray() - if (fNz == 2) { - coneSurface( - bottomOuterRadius = fRmax[0], - bottomInnerRadius = fRmin[0], - height = fZ[1] - fZ[0], - topOuterRadius = fRmax[1], - topInnerRadius = fRmin[1], - startAngle = degToRad(fPhi1), - angle = degToRad(fDphi), - name = name, - ) { - z = (fZ[1] + fZ[0]) / 2 - - }.apply(block) - } else { - TODO() - } - } - - "TGeoPgon" -> { - //TODO add a inner polygone layer - val fDphi by shape.meta.double(0.0) - val fNz by shape.meta.int(2) - val fPhi1 by shape.meta.double(360.0) - val fRmax by shape.meta.doubleArray() - val fRmin by shape.meta.doubleArray() - val fZ by shape.meta.doubleArray() - - val fNedges by shape.meta.int(1) - - val startphi = degToRad(fPhi1) - val deltaphi = degToRad(fDphi) - - extruded(name) { - //getting the radius of first - require(fNz > 1) { "The polyhedron geometry requires at least two planes" } - val baseRadius = fRmax[0] - shape { - (0.. - //scaling all radii relative to first layer radius - layer(fZ[index], scale = fRmax[index] / baseRadius) - } - }.apply(block) - } - - "TGeoShapeAssembly" -> { - val fVolume by shape.dObject(::DGeoVolume) - fVolume?.let { volume -> - addRootVolume(volume, context, name = volume.fName.ifEmpty { null }, block = block) - } - } - - "TGeoBBox" -> { - box(shape.fDX * 2, shape.fDY * 2, shape.fDZ * 2, name = name, block = block) - } - - "TGeoTrap" -> { - val fTheta by shape.meta.double(0.0) - val fPhi by shape.meta.double(0.0) - val fAlpha1 by shape.meta.double(0.0) - val fAlpha2 by shape.meta.double(0.0) - if (fAlpha1 != 0.0 || fAlpha2 != 0.0 || fTheta != 0.0 || fPhi != 0.0) { - TODO("Angled trapezoid not implemented") - } - val fH1 by shape.meta.double(0.0) - val fBl1 by shape.meta.double(0.0) - val fTl1 by shape.meta.double(0.0) - val fH2 by shape.meta.double(0.0) - val fBl2 by shape.meta.double(0.0) - val fTl2 by shape.meta.double(0.0) - - val fDz by shape.meta.double(0.0) - //TODO check proper node order - val node1 = Float32Vector3D(-fBl1, -fH1, -fDz) - val node2 = Float32Vector3D(fBl1, -fH1, -fDz) - val node3 = Float32Vector3D(fTl1, fH1, -fDz) - val node4 = Float32Vector3D(-fTl1, fH1, -fDz) - val node5 = Float32Vector3D(-fBl2, -fH2, fDz) - val node6 = Float32Vector3D(fBl2, -fH2, fDz) - val node7 = Float32Vector3D(fTl2, fH2, fDz) - val node8 = Float32Vector3D(-fTl2, fH2, fDz) - hexagon(node1, node2, node3, node4, node5, node6, node7, node8, name) - } - - "TGeoScaledShape" -> { - val fShape by shape.dObject(::DGeoShape) - val fScale by shape.dObject(::DGeoScale) - fShape?.let { scaledShape -> - solidGroup(name?.let { Name.parse(it) }) { - scale = Float32Vector3D(fScale?.x ?: 1.0, fScale?.y ?: 1.0, fScale?.z ?: 1.0) - addShape(scaledShape, context) - apply(block) - } - } - } - - else -> { - TODO("A shape with type ${shape.typename} not implemented") - } - } -} - -private fun SolidGroup.addRootNode(obj: DGeoNode, context: RootToSolidContext) { - val volume = obj.fVolume ?: return - addRootVolume(volume, context, obj.fName) { - when (obj.typename) { - "TGeoNodeMatrix" -> { - val fMatrix by obj.dObject(::DGeoMatrix) - this.useMatrix(fMatrix) - } - - "TGeoNodeOffset" -> { - val fOffset by obj.meta.double(0.0) - x = fOffset - } - } - } -} - -private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid? { - val group = SolidGroup().apply { - //set current layer - layer = context.currentLayer - val nodes = volume.fNodes - - if (volume.typename != "TGeoVolumeAssembly" && (nodes.isEmpty() || context.currentLayer >= context.maxLayer)) { - //TODO add smart filter - volume.fShape?.let { shape -> - addShape(shape, context) - } - } else { - val newLayer = if (nodes.size <= 2) { - context.currentLayer - } else if (nodes.size > 10) { - context.currentLayer + 2 - } else { - context.currentLayer + 1 - } - val newContext = context.copy(currentLayer = newLayer) - nodes.forEach { node -> - //add children to the next layer - addRootNode(node, newContext) - } - } - } - return if (group.children.isEmpty()) { - null - } else if (group.items.size == 1 && group.properties.own == null) { - group.items.values.first().apply { parent = null } - } else { - group - }.apply { - volume.fMedium?.let { medium -> - color(context.colorCache.getOrPut(medium.meta) { RootColors[11 + context.colorCache.size] }) - } - - if (!context.ignoreRootColors) { - volume.fFillColor?.let { - properties[MATERIAL_COLOR_KEY] = RootColors[it] - } - } - } -} - -//private val SolidGroup.rootPrototypes: SolidGroup get() = (parent as? SolidGroup)?.rootPrototypes ?: this - -private fun SolidGroup.addRootVolume( - volume: DGeoVolume, - context: RootToSolidContext, - name: String? = null, - cache: Boolean = true, - block: Solid.() -> Unit = {}, -) { - val combinedName = name?.parseAsName()?.let { - // this fix is required to work around malformed root files with duplicated node names - if (get(it) != null) { - it.withIndex(volume.hashCode().toString(16)) - } else { - it - } - } - - if (!cache) { - val group = buildVolume(volume, context)?.apply(block) ?: return - setChild(combinedName, group) - } else { - val templateName = volumesName + volume.name - val existing = context.prototypeHolder.getPrototype(templateName) - if (existing == null) { - context.prototypeHolder.prototypes { - val group = buildVolume(volume, context) ?: return@prototypes - setChild(templateName, group) - } - } - - ref(templateName, combinedName).apply(block) - } -} - -public fun MutableVisionContainer.rootGeo( - dGeoManager: DGeoManager, - name: String? = null, - maxLayer: Int = 5, - ignoreRootColors: Boolean = false, -): SolidGroup = solidGroup(name = name?.parseAsName()) { - val context = RootToSolidContext(this, maxLayer = maxLayer, ignoreRootColors = ignoreRootColors) - dGeoManager.fNodes.forEach { node -> - addRootNode(node, context) - } -} \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/rootColor.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/rootColor.kt deleted file mode 100644 index 9f06125e..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/rootColor.kt +++ /dev/null @@ -1,42 +0,0 @@ -package ru.mipt.npm.root - -public object RootColors { - private val colorMap = MutableList(924) { "white" } - - //colorMap[110] = "white" - - private val moreCol = listOf( - 11 to "c1b7ad4d4d4d6666668080809a9a9ab3b3b3cdcdcde6e6e6f3f3f3cdc8accdc8acc3c0a9bbb6a4b3a697b8a49cae9a8d9c8f83886657b1cfc885c3a48aa9a1839f8daebdc87b8f9a768a926983976e7b857d9ad280809caca6c0d4cf88dfbb88bd9f83c89a7dc08378cf5f61ac8f94a6787b946971d45a549300ff7b00ff6300ff4b00ff3300ff1b00ff0300ff0014ff002cff0044ff005cff0074ff008cff00a4ff00bcff00d4ff00ecff00fffd00ffe500ffcd00ffb500ff9d00ff8500ff6d00ff5500ff3d00ff2600ff0e0aff0022ff003aff0052ff006aff0082ff009aff00b1ff00c9ff00e1ff00f9ff00ffef00ffd700ffbf00ffa700ff8f00ff7700ff6000ff4800ff3000ff1800ff0000", - 201 to "5c5c5c7b7b7bb8b8b8d7d7d78a0f0fb81414ec4848f176760f8a0f14b81448ec4876f1760f0f8a1414b84848ec7676f18a8a0fb8b814ecec48f1f1768a0f8ab814b8ec48ecf176f10f8a8a14b8b848ecec76f1f1", - 390 to "ffffcdffff9acdcd9affff66cdcd669a9a66ffff33cdcd339a9a33666633ffff00cdcd009a9a00666600333300", - 406 to "cdffcd9aff9a9acd9a66ff6666cd66669a6633ff3333cd33339a3333663300ff0000cd00009a00006600003300", - 422 to "cdffff9affff9acdcd66ffff66cdcd669a9a33ffff33cdcd339a9a33666600ffff00cdcd009a9a006666003333", - 590 to "cdcdff9a9aff9a9acd6666ff6666cd66669a3333ff3333cd33339a3333660000ff0000cd00009a000066000033", - 606 to "ffcdffff9affcd9acdff66ffcd66cd9a669aff33ffcd33cd9a339a663366ff00ffcd00cd9a009a660066330033", - 622 to "ffcdcdff9a9acd9a9aff6666cd66669a6666ff3333cd33339a3333663333ff0000cd00009a0000660000330000", - 791 to "ffcd9acd9a669a66339a6600cd9a33ffcd66ff9a00ffcd33cd9a00ffcd00ff9a33cd66006633009a3300cd6633ff9a66ff6600ff6633cd3300ff33009aff3366cd00336600339a0066cd339aff6666ff0066ff3333cd0033ff00cdff9a9acd66669a33669a009acd33cdff669aff00cdff339acd00cdff009affcd66cd9a339a66009a6633cd9a66ffcd00ff6633ffcd00cd9a00ffcd33ff9a00cd66006633009a3333cd6666ff9a00ff9a33ff6600cd3300ff339acdff669acd33669a00339a3366cd669aff0066ff3366ff0033cd0033ff339aff0066cd00336600669a339acd66cdff009aff33cdff009acd00cdffcd9aff9a66cd66339a66009a9a33cdcd66ff9a00ffcd33ff9a00cdcd00ff9a33ff6600cd33006633009a6633cd9a66ff6600ff6633ff3300cd3300ffff339acd00666600339a0033cd3366ff669aff0066ff3366cd0033ff0033ff9acdcd669a9a33669a0066cd339aff66cdff009acd009aff33cdff009a", - 920 to "cdcdcd9a9a9a666666333333" - ) - - init { - colorMap[0] = "white" - colorMap[1] = "black" - colorMap[2] = "red" - colorMap[3] = "green" - colorMap[4] = "blue" - colorMap[5] = "yellow" - colorMap[6] = "magenta" - colorMap[7] = "cyan" - colorMap[8] = "rgb(89,212,84)" - colorMap[9] = "rgb(89,84,217)" - colorMap[10] = "white" - - moreCol.forEach { (n, s) -> - for (i in 0 until (s.length / 6)) { - colorMap[n + i] = "#" + s.substring(i * 6, (i + 1) * 6) - } - } - } - - public operator fun get(index: Int): String = colorMap[index] -} \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoManager.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoManager.kt deleted file mode 100644 index 59957364..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoManager.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -@SerialName("TGeoManager") -public class TGeoManager : TNamed() { - - public val fMatrices: TObjArray = TObjArray.getEmpty() - - public val fShapes: TObjArray = TObjArray.getEmpty() - - public val fVolumes: TObjArray = TObjArray.getEmpty() - - public val fNodes: TObjArray = TObjArray.getEmpty() -} diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMaterial.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMaterial.kt deleted file mode 100644 index e13d30b4..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMaterial.kt +++ /dev/null @@ -1,12 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -@SerialName("TGeoMaterial") -public open class TGeoMaterial: TNamed() - -@Serializable -@SerialName("TGeoMixture") -public class TGeoMixture: TGeoMaterial() \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMatrix.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMatrix.kt deleted file mode 100644 index 63ee38a7..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMatrix.kt +++ /dev/null @@ -1,42 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - - -@Serializable -@SerialName("TGeoMatrix") -public sealed class TGeoMatrix : TNamed() - -@Serializable -@SerialName("TGeoIdentity") -public class TGeoIdentity : TGeoMatrix() - -@Serializable -@SerialName("TGeoHMatrix") -public class TGeoHMatrix( - public val fTranslation: DoubleArray, - public val fRotationMatrix: DoubleArray, - public val fScale: DoubleArray -) : TGeoMatrix() - -@Serializable -@SerialName("TGeoTranslation") -public class TGeoTranslation( - public val fTranslation: DoubleArray -) : TGeoMatrix() - -@Serializable -@SerialName("TGeoRotation") -public class TGeoRotation( - public val fRotationMatrix: DoubleArray -) : TGeoMatrix() - -@Serializable -@SerialName("TGeoCombiTrans") -public class TGeoCombiTrans( - public val fTranslation: DoubleArray, - @Contextual - public val fRotation: TGeoRotation? = null, -) : TGeoMatrix() \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMedium.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMedium.kt deleted file mode 100644 index 630826e8..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoMedium.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -@SerialName("TGeoMedium") -public class TGeoMedium( - public val fId: Int, - @Contextual - public val fMaterial: TGeoMaterial, - public val fParams: DoubleArray -) : TNamed() \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoNode.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoNode.kt deleted file mode 100644 index 1babbbfc..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoNode.kt +++ /dev/null @@ -1,34 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -@SerialName("TGeoNode") -public open class TGeoNode : TNamed() { - public val fGeoAtt: UInt = 0u - - @Contextual - public val fVolume: TGeoVolume? = null - -// @Contextual -// public val fMother: TGeoVolume? = null - - public val fNumber: Int = 0 - public val fNovlp: Int = 0 - public val fOverlaps: IntArray = intArrayOf() -} - -@Serializable -@SerialName("TGeoNodeMatrix") -public class TGeoNodeMatrix : TGeoNode() { - @Contextual - public val fMatrix: TGeoMatrix? = null -} - -@Serializable -@SerialName("TGeoNodeOffset") -public class TGeoNodeOffset : TGeoNode() { - public val fOffset: Double = 0.0 -} \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoShape.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoShape.kt deleted file mode 100644 index faf47121..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoShape.kt +++ /dev/null @@ -1,136 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlin.math.PI - -@Serializable -@SerialName("TGeoShape") -public sealed class TGeoShape : TNamed() { - public val fShapeBits: UInt = 0u - public val fShapeId: Int = 0 -} - -@Serializable -@SerialName("TGeoBBox") -public open class TGeoBBox : TGeoShape() { - public val fDX: Double = 0.0 - public val fDY: Double = 0.0 - public val fDZ: Double = 0.0 - public val fOrigin: DoubleArray = doubleArrayOf(0.0, 0.0, 0.0) -} - -@Serializable -@SerialName("TGeoBoolNode") -public sealed class TGeoBoolNode : TObject() { - @Contextual - public abstract val fLeft: TGeoShape - - @Contextual - public val fLeftMat: TGeoMatrix? = null - - @Contextual - public abstract val fRight: TGeoShape - - @Contextual - public val fRightMat: TGeoMatrix? = null -} - -@Serializable -@SerialName("TGeoUnion") -public class TGeoUnion( - @Contextual - override val fLeft: TGeoShape, - @Contextual - override val fRight: TGeoShape, -) : TGeoBoolNode() - -@Serializable -@SerialName("TGeoSubtraction") -public class TGeoSubtraction( - @Contextual - override val fLeft: TGeoShape, - @Contextual - override val fRight: TGeoShape, -) : TGeoBoolNode() - -@Serializable -@SerialName("TGeoIntersection") -public class TGeoIntersection( - @Contextual - override val fLeft: TGeoShape, - @Contextual - override val fRight: TGeoShape, -) : TGeoBoolNode() - - -@Serializable -@SerialName("TGeoCompositeShape") -public class TGeoCompositeShape(public val fNode: TGeoBoolNode) : TGeoBBox() - -@Serializable -@SerialName("TGeoXtru") -public class TGeoXtru( - public val fNvert: Int, - public val fNz: Int, - public val fZcurrent: Double, - public val fX: DoubleArray, - public val fY: DoubleArray, - public val fZ: DoubleArray, - public val fScale: DoubleArray, - public val fX0: DoubleArray, - public val fY0: DoubleArray -) : TGeoBBox() - - -@Serializable -@SerialName("TGeoTube") -public open class TGeoTube : TGeoBBox() { - public val fRmin: Double = 0.0 - public val fRmax: Double = 0.0 - public val fDz: Double = 0.0 -} - -@Serializable -@SerialName("TGeoTubeSeg") -public class TGeoTubeSeg( - public val fPhi1: Double, - public val fPhi2: Double, - public val fS1: Double, - public val fC1: Double, - public val fS2: Double, - public val fC2: Double, - public val fSm: Double, - public val fCm: Double, - public val fCdfi: Double, -) : TGeoTube() - -@Serializable -@SerialName("TGeoPcon") -public open class TGeoPcon : TGeoBBox() { - public val fNz: Int = 0 // number of z planes (at least two) - public val fPhi1: Double = 0.0 // lower phi limit (converted to [0,2*pi) - public val fDphi: Double = PI * 2 // phi range - public val fRmin: DoubleArray = doubleArrayOf() //[fNz] pointer to array of inner radii - public val fRmax: DoubleArray = doubleArrayOf() //[fNz] pointer to array of outer radii - public val fZ: DoubleArray = doubleArrayOf() //[fNz] pointer to array of Z planes positions -} - -@Serializable -@SerialName("TGeoPgon") -public open class TGeoPgon : TGeoPcon() { - public val fNedges: Int = 0 -} - -@Serializable -@SerialName("TGeoShapeAssembly") -public class TGeoShapeAssembly( - @Contextual - public val fVolume: TGeoVolumeAssembly, - public val fBBoxOK: Boolean = true -) : TGeoBBox() - -public class TGeoShapeRef(provider: () -> TGeoShape) : TGeoShape() { - public val value: TGeoShape by lazy(provider) -} \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoVolume.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoVolume.kt deleted file mode 100644 index 77c99e54..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TGeoVolume.kt +++ /dev/null @@ -1,41 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -@SerialName("TGeoVolume") -public open class TGeoVolume : TNamed() { - public val fGeoAtt: UInt = 0u - public val fLineColor: Int = 2 - public val fLineStyle: Int? = null - public val fLineWidth: UInt = 1u - public val fFillColor: Int? = null - public val fFillStyle: Int? = null - - @Contextual - public val fNodes: TObjArray<@Contextual TGeoNode>? = null - - @Contextual - public val fShape: TGeoShape? = null - - @Contextual - public val fMedium: TGeoMedium? = null - - public val fNumber: Int = 1 - public val fNtotal: Int = 1 - public val fRefCount: Int = 1 -} - -public class TGeoVolumeRef(provider: () -> TGeoVolume) : TGeoVolume() { - public val value: TGeoVolume by lazy(provider) -} - -@Serializable -@SerialName("TGeoVolumeAssembly") -public open class TGeoVolumeAssembly : TGeoVolume() - -public class TGeoVolumeAssemblyRef(provider: () -> TGeoVolumeAssembly) : TGeoVolumeAssembly() { - public val value: TGeoVolumeAssembly by lazy(provider) -} \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TObject.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TObject.kt deleted file mode 100644 index 644c05a4..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/TObject.kt +++ /dev/null @@ -1,34 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -public abstract class TObject { - public val fUniqueID: UInt = 0u - public val fBits: UInt = 0u -} - -@Serializable -public open class TNamed : TObject() { - public val fName: String = "" - public val fTitle: String = "" -} - - -@Serializable -@SerialName("TObjArray") -public class TObjArray(public val arr: List<@Contextual T>): TObject() { - public companion object{ - public fun getEmpty(): TObjArray = TObjArray(emptyList()) - } -} - -@Serializable -@SerialName("TList") -public class TList(public val arr: List<@Contextual TObject>): TObject() - -@Serializable -@SerialName("THashList") -public class THashList(public val arr: List<@Contextual TObject>): TObject() \ No newline at end of file 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 deleted file mode 100644 index c443f646..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/jsonToRoot.kt +++ /dev/null @@ -1,239 +0,0 @@ -package ru.mipt.npm.root.serialization - -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.json.* -import kotlinx.serialization.modules.SerializersModule -import kotlinx.serialization.modules.contextual -import kotlinx.serialization.modules.polymorphic -import kotlinx.serialization.modules.subclass - - -private fun jsonRootDeserializer( - tSerializer: KSerializer, - builder: (JsonElement) -> T, -): DeserializationStrategy = object : - DeserializationStrategy { - private val jsonElementSerializer = JsonElement.serializer() - - override val descriptor: SerialDescriptor - get() = jsonElementSerializer.descriptor - - override fun deserialize(decoder: Decoder): T { - val json = decoder.decodeSerializableValue(jsonElementSerializer) - return builder(json) - } -} - -/** - * Load Json encoded TObject - */ -public fun TObject.decodeFromJson(serializer: KSerializer, jsonElement: JsonElement): T = - RootDecoder.decode(serializer, jsonElement) - -public fun TObject.decodeFromString(serializer: KSerializer, string: String): T { - val json = Json.parseToJsonElement(string) - return RootDecoder.decode(serializer, json) -} - -private object RootDecoder { - - private class RootUnrefSerializer( - private val tSerializer: KSerializer, - private val refCache: List, - ) : KSerializer by tSerializer { - - @OptIn(ExperimentalSerializationApi::class) - @Suppress("UNCHECKED_CAST") - override fun deserialize(decoder: Decoder): T { - val input = decoder as JsonDecoder - val element = input.decodeJsonElement() - val refId = (element as? JsonObject)?.get("\$ref")?.jsonPrimitive?.int - val ref = if (refId != null) { - println("Substituting ${tSerializer.descriptor.serialName} ref $refId") - //Forward ref for shapes - when (tSerializer.descriptor.serialName) { - "TGeoShape" -> return TGeoShapeRef { - refCache[refId].getOrPutValue { - input.json.decodeFromJsonElement(tSerializer, it) as TGeoShape - } - } as T - - "TGeoVolumeAssembly" -> return TGeoVolumeAssemblyRef { - refCache[refId].getOrPutValue { - input.json.decodeFromJsonElement(tSerializer, it) as TGeoVolumeAssembly - } - } as T - - "TGeoVolume" -> return TGeoVolumeRef { - refCache[refId].getOrPutValue { - input.json.decodeFromJsonElement(tSerializer, it) as TGeoVolume - } - } as T - - //Do unref - else -> refCache[refId] - } - } else { - refCache.find { it.element == element } ?: error("Element '$element' not found in the cache") - } - - return ref.getOrPutValue { -// println("Decoding $it") - val actualTypeName = it.jsonObject["_typename"]?.jsonPrimitive?.content - input.json.decodeFromJsonElement(tSerializer, it) - } - } - } - - private fun KSerializer.unref(refCache: List): KSerializer = RootUnrefSerializer(this, refCache) - - fun unrefSerializersModule( - refCache: List, - ): SerializersModule = SerializersModule { - - contextual(TObjArray::class) { - TObjArray.serializer(it[0]).unref(refCache) - } - - contextual(TGeoMedium.serializer().unref(refCache)) - - polymorphic(TGeoBoolNode::class) { - subclass(TGeoIntersection.serializer().unref(refCache)) - subclass(TGeoUnion.serializer().unref(refCache)) - subclass(TGeoSubtraction.serializer().unref(refCache)) - } - - polymorphic(TGeoShape::class) { - subclass(TGeoBBox.serializer()) - subclass(TGeoXtru.serializer()) - subclass(TGeoTube.serializer()) - subclass(TGeoTubeSeg.serializer()) - subclass(TGeoPcon.serializer()) - subclass(TGeoPgon.serializer()) - - subclass(TGeoCompositeShape.serializer().unref(refCache)) - subclass(TGeoShapeAssembly.serializer().unref(refCache)) - - defaultDeserializer { - if (it == null) { - TGeoShape.serializer().unref(refCache) - } else { - error("Unrecognized shape $it") - } - } - } - - polymorphic(TGeoMatrix::class) { - subclass(TGeoIdentity.serializer()) - subclass(TGeoHMatrix.serializer().unref(refCache)) - subclass(TGeoTranslation.serializer()) - subclass(TGeoRotation.serializer()) - subclass(TGeoCombiTrans.serializer().unref(refCache)) - - - val unrefed = TGeoMatrix.serializer().unref(refCache) - defaultDeserializer { - if (it == null) { - unrefed - } else { - error("Unrecognized matrix $it") - } - } - } - - polymorphic(TGeoVolume::class, TGeoVolume.serializer().unref(refCache)) { - subclass(TGeoVolumeAssembly.serializer().unref(refCache)) - - val unrefed = TGeoVolume.serializer().unref(refCache) - defaultDeserializer { - if (it == null) { - unrefed - } else { - error("Unrecognized volume $it") - } - } - } - - polymorphic(TGeoNode::class, TGeoNode.serializer().unref(refCache)) { - subclass(TGeoNodeMatrix.serializer().unref(refCache)) - subclass(TGeoNodeOffset.serializer().unref(refCache)) - - val unrefed = TGeoNode.serializer().unref(refCache) - defaultDeserializer { - if (it == null) { - unrefed - } else { - error("Unrecognized node $it") - } - } - } - } - - /** - * Create an instance of Json with unfolding Root references. This instance could not be reused because of the cache. - */ - private fun unrefJson(refCache: MutableList): Json = Json { - encodeDefaults = true - ignoreUnknownKeys = true - classDiscriminator = "_typename" - serializersModule = unrefSerializersModule(refCache) - } - - - fun decode(sourceDeserializer: KSerializer, source: JsonElement): T { - val refCache = ArrayList() - - fun fillCache(element: JsonElement) { - when (element) { - is JsonObject -> { - if (element["_typename"] != null) { - refCache.add(RefEntry(element)) - } - element.values.forEach { - fillCache(it) - } - } - - is JsonArray -> { - element.forEach { - fillCache(it) - } - } - - else -> { - //ignore primitives - } - } - } - fillCache(source) - - return unrefJson(refCache).decodeFromJsonElement(sourceDeserializer.unref(refCache), source) - } - - class RefEntry(val element: JsonElement) { - - var value: Any? = null - - @Suppress("UNCHECKED_CAST") - fun getOrPutValue(builder: (JsonElement) -> T): T { - if (value == null) { - value = builder(element) - } - return value as T - } - - override fun toString(): String = element.toString() - } - -// val json = Json { -// encodeDefaults = true -// ignoreUnknownKeys = true -// classDiscriminator = "_typename" -// serializersModule = this@RootDecoder.serializersModule -// } - -} \ No newline at end of file diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/rootToSolid.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/rootToSolid.kt deleted file mode 100644 index eb39b8e7..00000000 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/serialization/rootToSolid.kt +++ /dev/null @@ -1,188 +0,0 @@ -package ru.mipt.npm.root.serialization - -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName -import space.kscience.dataforge.names.plus -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.solid.* -import kotlin.math.PI -import kotlin.math.atan2 -import kotlin.math.pow -import kotlin.math.sqrt - - -private val solidsName = "solids".asName() -private val volumesName = "volumes".asName() - -private operator fun Number.times(d: Double) = toDouble() * d - -private operator fun Number.times(f: Float) = toFloat() * f - -private fun degToRad(d: Double) = d * PI / 180.0 - -// converting to XYZ to Tait–Bryan angles according to https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix -private fun Solid.rotate(rot: DoubleArray) { - val xAngle = atan2(-rot[5], rot[8]) - val yAngle = atan2(rot[2], sqrt(1.0 - rot[2].pow(2))) - val zAngle = atan2(-rot[1], rot[0]) - rotation = Float32Vector3D(xAngle, yAngle, zAngle) -} - -private fun Solid.translate(trans: DoubleArray) { - val (x, y, z) = trans - position = Float32Vector3D(x, y, z) -} - -private fun Solid.useMatrix(matrix: TGeoMatrix?) { - when (matrix) { - null, is TGeoIdentity -> { - //do nothing - } - is TGeoTranslation -> { - translate(matrix.fTranslation) - } - is TGeoRotation -> { - rotate(matrix.fRotationMatrix) - } - is TGeoCombiTrans -> { - translate(matrix.fTranslation) - matrix.fRotation?.let { rotate(it.fRotationMatrix) } - } - is TGeoHMatrix -> { - translate(matrix.fTranslation) - rotate(matrix.fRotationMatrix) - val (xScale, yScale, zScale) = matrix.fScale - scale = Float32Vector3D(xScale, yScale, zScale) - } - } -} - -private fun SolidGroup.addShape(shape: TGeoShape) { - when (shape) { - is TGeoShapeRef -> addShape(shape.value) - is TGeoCompositeShape -> { - val bool: TGeoBoolNode = shape.fNode - val compositeType = when (bool) { - is TGeoIntersection -> CompositeType.INTERSECT - is TGeoSubtraction -> CompositeType.SUBTRACT - is TGeoUnion -> CompositeType.UNION - } - composite(compositeType, name = shape.fName) { - addShape(bool.fLeft).apply { - useMatrix(bool.fLeftMat) - } - addShape(bool.fRight).apply { - useMatrix(bool.fRightMat) - } - } - } - is TGeoXtru -> extruded(name = shape.fName) { - - (0 until shape.fNvert).forEach { index -> - shape { - point(shape.fX[index], shape.fY[index]) - } - } - - (0 until shape.fNz).forEach { index -> - layer( - shape.fZ[index], - shape.fX0[index], - shape.fY0[index], - shape.fScale[index] - ) - } - } - is TGeoTube -> tube( - radius = shape.fRmax, - height = shape.fDz * 2, - innerRadius = shape.fRmin, - name = shape.fName - ) - is TGeoTubeSeg -> tube( - radius = shape.fRmax, - height = shape.fDz * 2, - innerRadius = shape.fRmin, - startAngle = degToRad(shape.fPhi1), - angle = degToRad(shape.fPhi2 - shape.fPhi1), - name = shape.fName - ) - is TGeoPcon -> TODO() - is TGeoPgon -> TODO() - is TGeoShapeAssembly -> volume(shape.fVolume) - is TGeoBBox -> box(shape.fDX * 2, shape.fDY * 2, shape.fDZ * 2, name = shape.fName) - } -} - -private fun SolidGroup.node(obj: TGeoNode) { - if (obj.fVolume != null) { - volume(obj.fVolume, obj.fName).apply { - when (obj) { - is TGeoNodeMatrix -> { - useMatrix(obj.fMatrix) - } - is TGeoNodeOffset -> { - x = obj.fOffset - } - } - } - } -} - -private fun buildGroup(volume: TGeoVolume): SolidGroup { - return if (volume is TGeoVolumeAssemblyRef) { - buildGroup(volume.value) - } else { - SolidGroup().apply { - volume.fShape?.let { addShape(it) } - volume.fNodes?.let { - it.arr.forEach { obj -> - node(obj) - } - } - } - } -} - -private val SolidGroup.rootPrototypes: SolidGroup get() = (parent as? SolidGroup)?.rootPrototypes ?: this - -private fun SolidGroup.volume(volume: TGeoVolume, name: String? = null, cache: Boolean = true): Solid { - val group = buildGroup(volume) - val combinedName = if (volume.fName.isEmpty()) { - name - } else if (name == null) { - volume.fName - } else { - "${name}_${volume.fName}" - } - return if (!cache) { - group - } else newRef( - name = combinedName, - obj = group, - prototypeHolder = rootPrototypes, - prototypeName = volumesName + Name.parse(combinedName ?: "volume[${group.hashCode()}]") - ) -} - -// private fun load(geo: TGeoManager): SolidGroup { -//// /** -//// * A special group for local templates -//// */ -//// val proto = SolidGroup() -//// -//// val solids = proto.group(solidsName) { -//// setPropertyNode("edges.enabled", false) -//// } -//// -//// val volumes = proto.group(volumesName) -//// -//// val referenceStore = HashMap>() -// } - - -public fun MutableVisionContainer.rootGeo(tGeoManager: TGeoManager): SolidGroup = solidGroup { - tGeoManager.fNodes.arr.forEach { - node(it) - } -} \ No newline at end of file diff --git a/demo/README.md b/demo/README.md deleted file mode 100644 index e2a13c47..00000000 --- a/demo/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module demo - - - diff --git a/demo/build.gradle.kts b/demo/build.gradle.kts deleted file mode 100644 index 49476bc7..00000000 --- a/demo/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode -import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension -import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper - -subprojects { - plugins.withType { - configure { - explicitApi = ExplicitApiMode.Disabled - } - } -} \ No newline at end of file diff --git a/demo/gdml/README.md b/demo/gdml/README.md index b9de634c..5c2a5abe 100644 --- a/demo/gdml/README.md +++ b/demo/gdml/README.md @@ -1,4 +1,13 @@ -# Module gdml +### GDML Example +Visualization example for geometry defined as GDML file. +##### Building project +To build the app, run `demo/gdml/Tasks/kotlin browser/jsBrowserDistribution` Gradle task, then +drag-and-drop GDML file to the window to see visualization. For an example file, you can use +`demo/gdml/src/jsMain/resources/cubes.gdml`. + +##### Example view: + +![](../../docs/images/gdml-demo.png) diff --git a/demo/gdml/api/gdml.api b/demo/gdml/api/gdml.api deleted file mode 100644 index 480385c3..00000000 --- a/demo/gdml/api/gdml.api +++ /dev/null @@ -1,27 +0,0 @@ -public final class space/kscience/visionforge/gdml/demo/GDMLDemoApp : tornadofx/App { - public fun ()V -} - -public final class space/kscience/visionforge/gdml/demo/GDMLView : tornadofx/View { - public static final field Companion Lspace/kscience/visionforge/gdml/demo/GDMLView$Companion; - public fun ()V - public fun getRoot ()Ljavafx/scene/Parent; -} - -public final class space/kscience/visionforge/gdml/demo/GDMLView$Companion { -} - -public final class space/kscience/visionforge/gdml/demo/GdmlFxDemoAppKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/gdml/demo/ReadFileKt { - public static final fun readFile (Lspace/kscience/visionforge/VisionManager;Ljava/io/File;)Lspace/kscience/visionforge/Vision; - public static final fun readFile (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;)Lspace/kscience/visionforge/Vision; -} - -public final class space/kscience/visionforge/gdml/demo/SaveToJsonKt { - public static final fun main ([Ljava/lang/String;)V -} - diff --git a/demo/gdml/build.gradle.kts b/demo/gdml/build.gradle.kts index 72b1b283..ead65970 100644 --- a/demo/gdml/build.gradle.kts +++ b/demo/gdml/build.gradle.kts @@ -1,66 +1,58 @@ +import ru.mipt.npm.gradle.DependencyConfiguration +import ru.mipt.npm.gradle.FXModule + plugins { - id("space.kscience.gradle.mpp") + id("ru.mipt.npm.gradle.mpp") + application } kscience { - jvm() - js { - useCommonJs() - browser { - binaries.executable() - commonWebpackConfig { - cssSupport { - enabled.set(false) - } - } - } - } - dependencies { - implementation(projects.visionforgeSolid) - implementation(projects.visionforgeGdml) - } - jvmMain { -// implementation(project(":visionforge-fx")) - implementation(spclibs.logback.classic) - } - jsMain { - implementation(projects.ui.ring) - implementation(projects.visionforgeThreejs) - implementation(npm("react-file-drop", "3.0.6")) - } + val fxVersion: String by rootProject.extra + useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION) + application() } kotlin { - explicitApi = null + jvm { + withJava() + } + js { + useCommonJs() + browser { + commonWebpackConfig { + cssSupport.enabled = false + } + } + } + sourceSets { + commonMain { + dependencies { + implementation(project(":visionforge-solid")) + implementation(project(":visionforge-gdml")) + } + } + jvmMain { + dependencies { + implementation(project(":visionforge-fx")) + implementation("ch.qos.logback:logback-classic:1.2.5") + } + } + jsMain { + dependencies { + implementation(project(":ui:ring")) + implementation(project(":visionforge-threejs")) + implementation(npm("react-file-drop", "3.0.6")) + } + } + } } -//kotlin { -// -// sourceSets { -// commonMain { -// dependencies { -// implementation(project(":visionforge-solid")) -// implementation(project(":visionforge-gdml")) -// } -// } -// jvmMain { -// dependencies { -//// implementation(project(":visionforge-fx")) -// implementation("ch.qos.logback:logback-classic:1.2.11") -// } -// } -// jsMain { -// dependencies { -// implementation(project(":ui:ring")) -// implementation(project(":visionforge-threejs")) -// implementation(npm("react-file-drop", "3.0.6")) -// } -// } -// } -//} +application { + mainClass.set("space.kscience.visionforge.gdml.demo.GdmlFxDemoAppKt") +} -//val convertGdmlToJson by tasks.creating(JavaExec::class) { -// group = "application" -// classpath = sourceSets["main"].runtimeClasspath -// mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt") -//} \ No newline at end of file +val convertGdmlToJson by tasks.creating(JavaExec::class) { + group = "application" + classpath = sourceSets["main"].runtimeClasspath + mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt") +} \ No newline at end of file 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 294af3ee..12918532 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,11 +1,13 @@ 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.dataforge.values.string import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.Vision -import space.kscience.visionforge.getChild +import space.kscience.visionforge.computeProperties +import space.kscience.visionforge.get +import space.kscience.visionforge.setProperty import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.material @@ -18,8 +20,8 @@ class GDMLVisionTest { @Test fun testCubesStyles(){ - val segment = cubes.children.getChild("composite-000.segment-0") as Solid - println(segment.properties.getValue(Vision.STYLE_KEY)) + val segment = cubes["composite-000.segment-0"] as Solid + println(segment.computeProperties().getValue(Vision.STYLE_KEY)) // println(segment.computePropertyNode(SolidMaterial.MATERIAL_KEY)) // println(segment.computeProperty(SolidMaterial.MATERIAL_COLOR_KEY)) @@ -33,7 +35,7 @@ class GDMLVisionTest { fun testPrototypeProperty() { val child = cubes[Name.of("composite-000","segment-0")] assertNotNull(child) - child.properties.setValue(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue()) - assertEquals("red", child.properties.getProperty(SolidMaterial.MATERIAL_COLOR_KEY).string) + child.setProperty(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue()) + assertEquals("red", child.getPropertyValue(SolidMaterial.MATERIAL_COLOR_KEY)?.string) } } \ No newline at end of file diff --git a/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt b/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt index 635c4580..a52343b0 100644 --- a/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt +++ b/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt @@ -6,8 +6,8 @@ package drop import org.w3c.dom.DragEvent import org.w3c.files.FileList import react.Component -import react.Props -import react.State +import react.RProps +import react.RState external enum class DropEffects { copy, @@ -16,7 +16,7 @@ external enum class DropEffects { none } -external interface FileDropProps: Props { +external interface FileDropProps: RProps { var className: String? var targetClassName: String? var draggingOverFrameClassName: String? @@ -32,7 +32,7 @@ external interface FileDropProps: Props { var dropEffect: DropEffects? } -external interface FileDropState: State { +external interface FileDropState: RState { var draggingOverFrame: Boolean var draggingOverTarget: Boolean } diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt index 37c178f4..2bad5e8d 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt @@ -3,38 +3,38 @@ package space.kscience.visionforge.gdml.demo import kotlinx.browser.window import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Deferred -import kotlinx.css.* +import kotlinx.css.height +import kotlinx.css.pt +import kotlinx.css.vh import org.w3c.files.File import org.w3c.files.FileReader import org.w3c.files.get -import react.Props +import react.* import react.dom.h2 -import react.fc -import react.useState +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.names.Name import space.kscience.gdml.Gdml import space.kscience.gdml.decodeFromString -import space.kscience.visionforge.Colors import space.kscience.visionforge.gdml.markLayers import space.kscience.visionforge.gdml.toVision import space.kscience.visionforge.ring.ThreeCanvasWithControls import space.kscience.visionforge.ring.tab -import space.kscience.visionforge.setAsRoot +import space.kscience.visionforge.root import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.ambientLight -import space.kscience.visionforge.solid.invoke import styled.css import styled.styledDiv -external interface GDMLAppProps : Props { - var solids: Solids +external interface GDMLAppProps : RProps { + var context: Context var vision: Solid? var selected: Name? } @JsExport -val GDMLApp = fc("GDMLApp") { props -> +val GDMLApp = functionalComponent("GDMLApp") { props -> + val visionManager = useMemo(props.context) { props.context.fetch(Solids).visionManager } var deferredVision: Deferred by useState { CompletableDeferred(props.vision) } @@ -49,15 +49,12 @@ val GDMLApp = fc("GDMLApp") { props -> name.endsWith(".gdml") || name.endsWith(".xml") -> { val gdml = Gdml.decodeFromString(data) gdml.toVision().apply { - setAsRoot(props.solids.visionManager) + root(visionManager) console.info("Marking layers for file $name") markLayers() - ambientLight { - color(Colors.white) - } } } - name.endsWith(".json") -> props.solids.visionManager.decodeFromString(data) + name.endsWith(".json") -> visionManager.decodeFromString(data) else -> { window.alert("File extension is not recognized: $name") error("File extension is not recognized: $name") @@ -74,11 +71,10 @@ val GDMLApp = fc("GDMLApp") { props -> styledDiv { css { height = 100.vh - 12.pt - width = 100.vw } child(ThreeCanvasWithControls) { attrs { - this.solids = props.solids + this.context = props.context this.builderOfSolid = deferredVision this.selected = props.selected tab("Load") { diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt index 7c6514bf..dc659c7c 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt @@ -1,18 +1,13 @@ package space.kscience.visionforge.gdml.demo +import kotlinx.browser.document import kotlinx.css.* -import org.w3c.dom.Document -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request +import react.child +import react.dom.render +import space.kscience.dataforge.context.Global import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.Application -import space.kscience.visionforge.Colors import space.kscience.visionforge.gdml.toVision -import space.kscience.visionforge.react.createRoot -import space.kscience.visionforge.react.render -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.ambientLight -import space.kscience.visionforge.solid.invoke import space.kscience.visionforge.solid.three.ThreePlugin import space.kscience.visionforge.startApplication import styled.injectGlobal @@ -20,8 +15,8 @@ import styled.injectGlobal private class GDMLDemoApp : Application { - override fun start(document: Document, state: Map) { - val context = Context("gdml-demo"){ + override fun start(state: Map) { + val context = Global.buildContext("gdml-demo"){ plugin(ThreePlugin) } @@ -45,16 +40,12 @@ private class GDMLDemoApp : Application { val element = document.getElementById("application") ?: error("Element with id 'application' not found on page") - createRoot(element).render { + render(element) { child(GDMLApp) { - val vision = GdmlShowCase.cubes().toVision().apply { - ambientLight { - color(Colors.white) - } - } + val vision = GdmlShowCase.cubes().toVision() //println(context.plugins.fetch(VisionManager).encodeToString(vision)) attrs { - this.solids = context.request(Solids) + this.context = context this.vision = vision } } diff --git a/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt b/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt index 92cc69aa..f2371f44 100644 --- a/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt +++ b/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt @@ -1,83 +1,84 @@ -//package space.kscience.visionforge.gdml.demo -// -//import javafx.geometry.Orientation -//import javafx.scene.Parent -//import javafx.stage.FileChooser -//import space.kscience.dataforge.context.Context -//import space.kscience.dataforge.context.fetch -//import space.kscience.gdml.GdmlShowCase -//import space.kscience.visionforge.VisionManager -//import space.kscience.visionforge.editor.VisionEditorFragment -//import space.kscience.visionforge.editor.VisionTreeFragment -//import space.kscience.visionforge.gdml.toVision -//import space.kscience.visionforge.solid.FX3DPlugin -//import space.kscience.visionforge.solid.FXCanvas3D -//import space.kscience.visionforge.solid.Solid -//import space.kscience.visionforge.solid.SolidMaterial -//import tornadofx.* -// -//class GDMLDemoApp : App(GDMLView::class) -// -//class GDMLView : View() { -// private val context = Context { -// plugin(FX3DPlugin) -// } -// -// private val fx3d = context.fetch(FX3DPlugin) -// private val visionManager = context.fetch(VisionManager) -// private val canvas = FXCanvas3D(fx3d) -// -// private val treeFragment = VisionTreeFragment().apply { -// this.itemProperty.bind(canvas.rootObjectProperty) -// } -// -// private val propertyEditor = VisionEditorFragment().apply { -// descriptorProperty.set(SolidMaterial.descriptor) -// visionProperty.bind(treeFragment.selectedProperty) -// } -// -// override val root: Parent = borderpane { -// top { -// buttonbar { -// button("Load GDML/json") { -// action { -// val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull() -// if (file != null) { -// runAsync { -// visionManager.readFile(file) as Solid -// } ui { -// canvas.render(it) -// } -// } -// } -// } -// } -// } -// center { -// splitpane(Orientation.HORIZONTAL, treeFragment.root, canvas.root, propertyEditor.root) { -// setDividerPositions(0.2, 0.6, 0.2) -// } -// } -// } -// -// init { -// runAsync { -// GdmlShowCase.cubes().toVision() -// } ui { -// canvas.render(it) -// } -// } -// -// companion object { -// private val fileNameFilter = arrayOf( -// FileChooser.ExtensionFilter("GDML", "*.gdml", "*.xml"), -// FileChooser.ExtensionFilter("JSON", "*.json"), -// FileChooser.ExtensionFilter("JSON.ZIP", "*.json.zip"), -// FileChooser.ExtensionFilter("JSON.GZ", "*.json.gz") -// ) -// } -//} -// -//fun main() { -// launch() -//} \ No newline at end of file +package space.kscience.visionforge.gdml.demo + +import javafx.geometry.Orientation +import javafx.scene.Parent +import javafx.stage.FileChooser +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.fetch +import space.kscience.gdml.GdmlShowCase +import space.kscience.visionforge.VisionManager +import space.kscience.visionforge.editor.VisionEditorFragment +import space.kscience.visionforge.editor.VisionTreeFragment +import space.kscience.visionforge.gdml.toVision +import space.kscience.visionforge.solid.FX3DPlugin +import space.kscience.visionforge.solid.FXCanvas3D +import space.kscience.visionforge.solid.Solid +import space.kscience.visionforge.solid.SolidMaterial +import tornadofx.* + +class GDMLDemoApp : App(GDMLView::class) + +class GDMLView : View() { + private val context = Context { + plugin(FX3DPlugin) + plugin(VisionManager) + } + + private val fx3d = context.fetch(FX3DPlugin) + private val visionManager = context.fetch(VisionManager) + private val canvas = FXCanvas3D(fx3d) + + private val treeFragment = VisionTreeFragment().apply { + this.itemProperty.bind(canvas.rootObjectProperty) + } + + private val propertyEditor = VisionEditorFragment().apply { + descriptorProperty.set(SolidMaterial.descriptor) + visionProperty.bind(treeFragment.selectedProperty) + } + + override val root: Parent = borderpane { + top { + buttonbar { + button("Load GDML/json") { + action { + val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull() + if (file != null) { + runAsync { + visionManager.readFile(file) as Solid + } ui { + canvas.render(it) + } + } + } + } + } + } + center { + splitpane(Orientation.HORIZONTAL, treeFragment.root, canvas.root, propertyEditor.root) { + setDividerPositions(0.2, 0.6, 0.2) + } + } + } + + init { + runAsync { + GdmlShowCase.cubes().toVision() + } ui { + canvas.render(it) + } + } + + companion object { + private val fileNameFilter = arrayOf( + FileChooser.ExtensionFilter("GDML", "*.gdml", "*.xml"), + FileChooser.ExtensionFilter("JSON", "*.json"), + FileChooser.ExtensionFilter("JSON.ZIP", "*.json.zip"), + FileChooser.ExtensionFilter("JSON.GZ", "*.json.gz") + ) + } +} + +fun main() { + launch() +} \ No newline at end of file diff --git a/demo/js-playground/README.md b/demo/js-playground/README.md deleted file mode 100644 index 6b899a57..00000000 --- a/demo/js-playground/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module js-playground - - - diff --git a/demo/js-playground/build.gradle.kts b/demo/js-playground/build.gradle.kts index 94835588..ccec7015 100644 --- a/demo/js-playground/build.gradle.kts +++ b/demo/js-playground/build.gradle.kts @@ -1,21 +1,18 @@ plugins { - id("space.kscience.gradle.js") + id("ru.mipt.npm.gradle.js") } kscience{ useCoroutines() + application() } kotlin{ - explicitApi = null - js{ + js(IR){ useCommonJs() browser { - binaries.executable() commonWebpackConfig { - cssSupport{ - enabled.set(false) - } + cssSupport.enabled = false } } } diff --git a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt index d77d8f52..a1ffa4ff 100644 --- a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt +++ b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt @@ -1,17 +1,15 @@ +import kotlinx.browser.document import kotlinx.css.* -import org.w3c.dom.Document +import react.child +import react.dom.render import ringui.SmartTabs import ringui.Tab import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request import space.kscience.plotly.models.Trace import space.kscience.plotly.scatter import space.kscience.visionforge.Application -import space.kscience.visionforge.Colors import space.kscience.visionforge.VisionClient import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.react.createRoot -import space.kscience.visionforge.react.render import space.kscience.visionforge.ring.ThreeCanvasWithControls import space.kscience.visionforge.ring.ThreeWithControlsPlugin import space.kscience.visionforge.ring.solid @@ -30,7 +28,7 @@ fun Trace.appendXYLatest(x: Number, y: Number, history: Int = 400, xErr: Number? private class JsPlaygroundApp : Application { - override fun start(document: Document, state: Map) { + override fun start(state: Map) { val playgroundContext = Context { plugin(ThreeWithControlsPlugin) @@ -40,7 +38,7 @@ private class JsPlaygroundApp : Application { val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page") - createRoot(element).render { + render(element) { styledDiv { css { padding(0.pt) @@ -50,9 +48,9 @@ private class JsPlaygroundApp : Application { } SmartTabs("gravity") { Tab("gravity") { - GravityDemo { + GravityDemo{ attrs { - this.solids = playgroundContext.request(Solids) + this.context = playgroundContext } } } @@ -73,11 +71,8 @@ private class JsPlaygroundApp : Application { child(ThreeCanvasWithControls) { val random = Random(112233) attrs { - solids = playgroundContext.request(Solids) + context = playgroundContext solid { - ambientLight { - color(Colors.white) - } repeat(100) { sphere(5, name = "sphere[$it]") { x = random.nextDouble(-300.0, 300.0) diff --git a/demo/js-playground/src/main/kotlin/gravityDemo.kt b/demo/js-playground/src/main/kotlin/gravityDemo.kt index a4bc9057..e8ea5856 100644 --- a/demo/js-playground/src/main/kotlin/gravityDemo.kt +++ b/demo/js-playground/src/main/kotlin/gravityDemo.kt @@ -2,11 +2,11 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.css.* -import react.Props -import react.fc -import space.kscience.plotly.layout +import react.RProps +import react.child +import react.functionalComponent +import space.kscience.dataforge.context.Context import space.kscience.plotly.models.Trace -import space.kscience.visionforge.Colors import space.kscience.visionforge.markup.VisionOfMarkup import space.kscience.visionforge.react.flexRow import space.kscience.visionforge.ring.ThreeCanvasWithControls @@ -16,15 +16,15 @@ import styled.css import styled.styledDiv import kotlin.math.sqrt -external interface DemoProps : Props { - var solids: Solids +external interface DemoProps : RProps { + var context: Context } -val GravityDemo = fc { props -> - val velocityTrace = Trace { +val GravityDemo = functionalComponent { props -> + val velocityTrace = Trace{ name = "velocity" } - val energyTrace = Trace { + val energyTrace = Trace{ name = "energy" } val markup = VisionOfMarkup() @@ -39,19 +39,14 @@ val GravityDemo = fc { props -> } child(ThreeCanvasWithControls) { attrs { - solids = props.solids + context = props.context solid { - pointLight(200, 200, 200, name = "light"){ - color(Colors.white) - } - ambientLight() - sphere(5.0, "ball") { detail = 16 color("red") val h = 100.0 y = h - solids.context.launch { + context.launch { val g = 10.0 val dt = 0.1 var time = 0.0 @@ -96,10 +91,7 @@ val GravityDemo = fc { props -> height = 50.vh - 50.pt } plotly { - traces(velocityTrace, energyTrace) - layout { - xaxis.title = "time" - } + traces(velocityTrace) } Markup { attrs { diff --git a/demo/js-playground/src/main/kotlin/markupComponent.kt b/demo/js-playground/src/main/kotlin/markupComponent.kt index 4bbe4b80..5a5f6df2 100644 --- a/demo/js-playground/src/main/kotlin/markupComponent.kt +++ b/demo/js-playground/src/main/kotlin/markupComponent.kt @@ -6,8 +6,8 @@ import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor import org.w3c.dom.Element import org.w3c.dom.HTMLElement -import react.Props -import react.fc +import react.RProps +import react.functionalComponent import react.useEffect import react.useRef import space.kscience.visionforge.markup.VisionOfMarkup @@ -16,11 +16,11 @@ import space.kscience.visionforge.useProperty import styled.css import styled.styledDiv -external interface MarkupProps : Props { +external interface MarkupProps : RProps { var markup: VisionOfMarkup? } -val Markup = fc("Markup") { props -> +val Markup = functionalComponent("Markup") { props -> val elementRef = useRef(null) useEffect(props.markup, elementRef) { @@ -32,7 +32,7 @@ val Markup = fc("Markup") { props -> //TODO add new formats via plugins else -> error("Format ${vision.format} not recognized") } - vision.useProperty(VisionOfMarkup::content) { content: String? -> + vision.useProperty(VisionOfMarkup::content) { content -> element.clear() element.append { markdown(flavour) { content ?: "" } diff --git a/demo/js-playground/src/main/kotlin/plotlyComponent.kt b/demo/js-playground/src/main/kotlin/plotlyComponent.kt index 322e80c5..22f63ac8 100644 --- a/demo/js-playground/src/main/kotlin/plotlyComponent.kt +++ b/demo/js-playground/src/main/kotlin/plotlyComponent.kt @@ -9,20 +9,20 @@ import space.kscience.plotly.plot import styled.css import styled.styledDiv -external interface PlotlyProps : Props { +external interface PlotlyProps : RProps { var plot: Plot? } -val Plotly = fc("Plotly") { props -> +val Plotly = functionalComponent("Plotly") { props -> val elementRef = useRef(null) useEffect(props.plot, elementRef) { val element = elementRef.current as? HTMLElement ?: error("Plotly element not found") props.plot?.let { - element.plot(PlotlyConfig { + element.plot(it, PlotlyConfig { responsive = true - }, it) + }) } } diff --git a/demo/jupyter-playground/build.gradle.kts b/demo/jupyter-playground/build.gradle.kts new file mode 100644 index 00000000..903b991b --- /dev/null +++ b/demo/jupyter-playground/build.gradle.kts @@ -0,0 +1,35 @@ +plugins { + kotlin("jvm") + kotlin("jupyter.api") + id("com.github.johnrengelman.shadow") version "6.1.0" +} + +repositories { + mavenCentral() + maven("https://repo.kotlin.link") +} + +dependencies { + implementation(project(":demo:playground")) +} + +tasks.withType { + kotlinOptions { + useIR = true + jvmTarget = ru.mipt.npm.gradle.KScienceVersions.JVM_TARGET.toString() + } +} + +extensions.findByType()?.apply { + targetCompatibility = ru.mipt.npm.gradle.KScienceVersions.JVM_TARGET +} + +tasks.withType { + useJUnitPlatform() +} + +tasks.processJupyterApiResources { + libraryProducers = listOf("space.kscience.dataforge.playground.VisionForgePlayGroundForJupyter") +} + +tasks.findByName("shadowJar")?.dependsOn("processJupyterApiResources") \ No newline at end of file diff --git a/demo/jupyter-playground/src/main/kotlin/hep/dataforge/playground/VisionForgePlayGroundForJupyter.kt b/demo/jupyter-playground/src/main/kotlin/hep/dataforge/playground/VisionForgePlayGroundForJupyter.kt new file mode 100644 index 00000000..88e4effb --- /dev/null +++ b/demo/jupyter-playground/src/main/kotlin/hep/dataforge/playground/VisionForgePlayGroundForJupyter.kt @@ -0,0 +1,98 @@ +package space.kscience.dataforge.playground + +import kotlinx.html.div +import kotlinx.html.id +import kotlinx.html.script +import kotlinx.html.stream.createHTML +import kotlinx.html.unsafe +import org.jetbrains.kotlinx.jupyter.api.HTML +import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary +import org.jetbrains.kotlinx.jupyter.api.libraries.* +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.gdml.Gdml +import space.kscience.plotly.Plot +import space.kscience.visionforge.Vision +import space.kscience.visionforge.gdml.toVision +import space.kscience.visionforge.html.HtmlVisionFragment +import space.kscience.visionforge.html.Page +import space.kscience.visionforge.html.embedVisionFragment +import space.kscience.visionforge.plotly.PlotlyPlugin +import space.kscience.visionforge.plotly.asVision +import space.kscience.visionforge.solid.Solids +import space.kscience.visionforge.visionManager + +@JupyterLibrary +@DFExperimental +internal class VisionForgePlayGroundForJupyter : JupyterIntegration() { + + private val context = Context("VisionForge") { + plugin(Solids) + plugin(PlotlyPlugin) + } + + private val jsBundle = ResourceFallbacksBundle(listOf( + ResourceLocation("js/visionforge-playground.js", ResourcePathType.CLASSPATH_PATH)) + ) + private val jsResource = LibraryResource(name = "VisionForge", type = ResourceType.JS, bundles = listOf(jsBundle)) + + private var counter = 0 + + private fun produceHtmlVisionString(fragment: HtmlVisionFragment) = createHTML().div { + val id = "visionforge.vision[${counter++}]" + div { + this.id = id + embedVisionFragment(context.visionManager, fragment = fragment) + } + script { + type = "text/javascript" + unsafe { +"window.renderAllVisionsById(\"$id\");" } + } + } + + override fun Builder.onLoaded() { + resource(jsResource) + + import( + "space.kscience.gdml.*", + "space.kscience.plotly.*", + "space.kscience.plotly.models.*", + "kotlinx.html.*", + "space.kscience.visionforge.solid.*", + "space.kscience.visionforge.html.Page", + "space.kscience.visionforge.html.page" + ) + + render { gdmlModel -> + val fragment = HtmlVisionFragment { + vision(gdmlModel.toVision()) + } + HTML(produceHtmlVisionString(fragment)) + } + + render { vision -> + val fragment = HtmlVisionFragment { + vision(vision) + } + + HTML(produceHtmlVisionString(fragment)) + } + + render { plot -> + val fragment = HtmlVisionFragment { + vision(plot.asVision()) + } + + HTML(produceHtmlVisionString(fragment)) + } + + render { fragment -> + HTML(createHTML().apply(fragment.visit).finalize()) + } + + render { page -> + HTML(page.render(createHTML()), true) + } + } + +} diff --git a/demo/muon-monitor/README.md b/demo/muon-monitor/README.md index 74c935e4..df95c968 100644 --- a/demo/muon-monitor/README.md +++ b/demo/muon-monitor/README.md @@ -1,4 +1,33 @@ -# Module muon-monitor +### Muon Monitor Visualization +This directory contains a full-stack application example built with `visionforge`. +It is visualizing the +[Muon Monitor](http://npm.mipt.ru/projects/physics.html#mounMonitor) experiment set-up, +including experiment's geometry and events (particle tracks). +#### Reusing code and going Full-Stack with Kotlin Multiplatform + +The application includes both server back-end generating events, as well as client +visualization front-end. + +As is common for Kotlin multiplatform projects, the code base of this simple application +is put in the following main directories: +* `commonMain` - common code, used by both JS client and JVM server. For example, the `Monitor` +object describes general geometry definitions needed in all parts of the application. +* `jsMain` - JavaScript client code. It performs visualization and reads events from the server. +* `jvmMain` - JVM server code. It runs `ktor` HTTP server, responding with event data when +client requests them. + +Note that in a more traditional approach when client and server are developed separately +and possibly using different languages, there would be no common code and benefits associated +with it. + +##### Building project + +To run full-stack Muon Monitor Visualization application (both JVM server and Web browser front-end), +run `demo/muon-monitor/Tasks/application/run` task. + +##### Example view: + +![](../../docs/images/muon-monitor.png) diff --git a/demo/muon-monitor/api/muon-monitor.api b/demo/muon-monitor/api/muon-monitor.api deleted file mode 100644 index da3a84ed..00000000 --- a/demo/muon-monitor/api/muon-monitor.api +++ /dev/null @@ -1,148 +0,0 @@ -public final class ru/mipt/npm/muon/monitor/Event { - public static final field Companion Lru/mipt/npm/muon/monitor/Event$Companion; - public synthetic fun (IILjava/util/List;Ljava/util/Collection;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (ILjava/util/List;Ljava/util/Collection;)V - public final fun component1 ()I - public final fun component2 ()Ljava/util/List; - public final fun component3 ()Ljava/util/Collection; - public final fun copy (ILjava/util/List;Ljava/util/Collection;)Lru/mipt/npm/muon/monitor/Event; - public static synthetic fun copy$default (Lru/mipt/npm/muon/monitor/Event;ILjava/util/List;Ljava/util/Collection;ILjava/lang/Object;)Lru/mipt/npm/muon/monitor/Event; - public fun equals (Ljava/lang/Object;)Z - public final fun getHits ()Ljava/util/Collection; - public final fun getId ()I - public final fun getTrack ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lru/mipt/npm/muon/monitor/Event;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class ru/mipt/npm/muon/monitor/Event$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lru/mipt/npm/muon/monitor/Event$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/muon/monitor/Event; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/muon/monitor/Event;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/muon/monitor/Event$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class ru/mipt/npm/muon/monitor/Model { - public fun (Lspace/kscience/visionforge/VisionManager;)V - public final fun displayEvent (Lru/mipt/npm/muon/monitor/Event;)V - public final fun encodeToString ()Ljava/lang/String; - public final fun getManager ()Lspace/kscience/visionforge/VisionManager; - public final fun getRoot ()Lspace/kscience/visionforge/solid/SolidGroup; - public final fun getTracks ()Lspace/kscience/visionforge/solid/SolidGroup; - public final fun reset ()V - public final fun setTracks (Lspace/kscience/visionforge/solid/SolidGroup;)V -} - -public final class ru/mipt/npm/muon/monitor/Monitor { - public static final field CENTRAL_LAYER_Z F - public static final field GEOMETRY_TOLERANCE D - public static final field INSTANCE Lru/mipt/npm/muon/monitor/Monitor; - public static final field LOWER_LAYER_Z F - public static final field PIXEL_XY_SIZE F - public static final field PIXEL_XY_SPACING F - public static final field PIXEL_Z_SIZE F - public static final field UPPER_LAYER_Z F - public final fun getDetectors ()Ljava/util/Collection; - public final fun getPixels ()Ljava/util/Collection; -} - -public final class ru/mipt/npm/muon/monitor/ReadResourceKt { - public static final fun readResource (Ljava/lang/String;)Ljava/lang/String; -} - -public final class ru/mipt/npm/muon/monitor/SC1 { - public fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;FFF)V - public synthetic fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getCenter ()Lspace/kscience/visionforge/solid/Point3D; - public final fun getName ()Ljava/lang/String; - public final fun getXSize ()F - public final fun getYSize ()F - public final fun getZSize ()F -} - -public final class ru/mipt/npm/muon/monitor/SC16 { - public fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;)V - public final fun getCenter ()Lspace/kscience/visionforge/solid/Point3D; - public final fun getName ()Ljava/lang/String; - public final fun getPixels ()Ljava/util/Collection; -} - -public final class ru/mipt/npm/muon/monitor/server/MMServerKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V - public static final fun module (Lio/ktor/application/Application;Lspace/kscience/dataforge/context/Context;)V - public static synthetic fun module$default (Lio/ktor/application/Application;Lspace/kscience/dataforge/context/Context;ILjava/lang/Object;)V -} - -public final class ru/mipt/npm/muon/monitor/sim/Cos2TrackGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator { - public fun (Lorg/apache/commons/math3/random/RandomGenerator;DFF)V - public synthetic fun (Lorg/apache/commons/math3/random/RandomGenerator;DFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public final fun getMaxX ()F - public final fun getMaxY ()F - public final fun getPower ()D - public fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator; -} - -public final class ru/mipt/npm/muon/monitor/sim/FixedAngleGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator { - public fun (Lorg/apache/commons/math3/random/RandomGenerator;DDFF)V - public synthetic fun (Lorg/apache/commons/math3/random/RandomGenerator;DDFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public final fun getMaxX ()F - public final fun getMaxY ()F - public final fun getPhi ()D - public fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator; - public final fun getTheta ()D -} - -public final class ru/mipt/npm/muon/monitor/sim/LineKt { - public static final fun getPhi (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D - public static final fun getTheta (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D - public static final fun getX (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D - public static final fun getY (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D - public static final fun makeTrack (DDDD)Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public static final fun makeTrack (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public static final fun toPoint (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun toPoints (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)Ljava/util/List; -} - -public final class ru/mipt/npm/muon/monitor/sim/MonitorKt { - public static final fun buildEventByTrack (ILorg/apache/commons/math3/geometry/euclidean/threed/Line;Lkotlin/jvm/functions/Function1;)Lru/mipt/npm/muon/monitor/Event; - public static synthetic fun buildEventByTrack$default (ILorg/apache/commons/math3/geometry/euclidean/threed/Line;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lru/mipt/npm/muon/monitor/Event; - public static final fun findLayer (F)Lorg/apache/commons/math3/geometry/euclidean/threed/Plane; - public static final fun getDefaultHitResolver ()Lkotlin/jvm/functions/Function1; - public static final fun readEffs ()Ljava/util/Map; -} - -public final class ru/mipt/npm/muon/monitor/sim/PixelKt { - public static final fun isHit (Lru/mipt/npm/muon/monitor/SC1;Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)Z -} - -public final class ru/mipt/npm/muon/monitor/sim/SimulationKt { - public static final fun simulateOne (Lru/mipt/npm/muon/monitor/sim/TrackGenerator;)Lru/mipt/npm/muon/monitor/Event; -} - -public abstract interface class ru/mipt/npm/muon/monitor/sim/TrackGenerator { - public abstract fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public abstract fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator; -} - -public final class ru/mipt/npm/muon/monitor/sim/UniformTrackGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator { - public fun (Lorg/apache/commons/math3/random/RandomGenerator;FF)V - public synthetic fun (Lorg/apache/commons/math3/random/RandomGenerator;FFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public final fun getMaxX ()F - public final fun getMaxY ()F - public fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator; -} - diff --git a/demo/muon-monitor/build.gradle.kts b/demo/muon-monitor/build.gradle.kts index 73336f1b..3818cada 100644 --- a/demo/muon-monitor/build.gradle.kts +++ b/demo/muon-monitor/build.gradle.kts @@ -1,51 +1,75 @@ plugins { - id("space.kscience.gradle.mpp") + id("ru.mipt.npm.gradle.mpp") application } group = "ru.mipt.npm" -val ktorVersion: String = spclibs.versions.ktor.get() +val ktorVersion: String = ru.mipt.npm.gradle.KScienceVersions.ktorVersion kscience { useCoroutines() useSerialization() - useKtor() - fullStack( - "muon-monitor.js", - jvmConfig = { withJava() }, - jsConfig = { useCommonJs() } - ) { - commonWebpackConfig { - cssSupport { - enabled.set(false) + application() +} + +kotlin { + jvm { + withJava() + } + js { + useCommonJs() + browser { + commonWebpackConfig { + cssSupport.enabled = false } } } - commonMain { - implementation(projects.visionforgeSolid) + afterEvaluate { + val jsBrowserDistribution by tasks.getting + + tasks.getByName("jvmProcessResources") { + dependsOn(jsBrowserDistribution) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from(jsBrowserDistribution) + } } - jvmMain { - implementation("org.apache.commons:commons-math3:3.6.1") - implementation("io.ktor:ktor-server-cio:${ktorVersion}") - implementation("io.ktor:ktor-server-content-negotiation:${ktorVersion}") - implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}") - implementation("ch.qos.logback:logback-classic:1.2.11") - } - jsMain { - implementation(project(":ui:ring")) - implementation(project(":visionforge-threejs")) - //implementation(devNpm("webpack-bundle-analyzer", "4.4.0")) + + sourceSets { + commonMain { + dependencies { + implementation(project(":visionforge-solid")) + } + } + jvmMain { + dependencies { + implementation("org.apache.commons:commons-math3:3.6.1") + implementation("io.ktor:ktor-server-cio:$ktorVersion") + implementation("io.ktor:ktor-serialization:$ktorVersion") + } + } + jsMain { + dependencies { + implementation(project(":ui:ring")) + implementation("io.ktor:ktor-client-js:$ktorVersion") + implementation("io.ktor:ktor-client-serialization:$ktorVersion") + implementation(project(":visionforge-threejs")) + implementation(devNpm("webpack-bundle-analyzer", "4.4.0")) + } + } } } -kotlin.explicitApi = null - application { mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt") } +tasks.withType() { + kotlinOptions { + freeCompilerArgs = freeCompilerArgs + "-Xir-property-lazy-initialization" + } +} //distributions { // main { diff --git a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Event.kt b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Event.kt index 22a9d2e1..b47c2b66 100644 --- a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Event.kt +++ b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Event.kt @@ -1,9 +1,9 @@ package ru.mipt.npm.muon.monitor import kotlinx.serialization.Serializable -import space.kscience.visionforge.solid.Float32Vector3D +import space.kscience.visionforge.solid.Point3D -typealias Track = List +typealias Track = List /** * 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 f11c9e01..0c5e0af0 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 @@ -3,20 +3,20 @@ package ru.mipt.npm.muon.monitor import ru.mipt.npm.muon.monitor.Monitor.CENTRAL_LAYER_Z import ru.mipt.npm.muon.monitor.Monitor.LOWER_LAYER_Z import ru.mipt.npm.muon.monitor.Monitor.UPPER_LAYER_Z -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.setAsRoot +import space.kscience.visionforge.removeAll +import space.kscience.visionforge.root +import space.kscience.visionforge.setProperty import space.kscience.visionforge.solid.* -import kotlin.collections.set import kotlin.math.PI class Model(val manager: VisionManager) { private val map = HashMap() private val events = HashSet() - private fun MutableVisionContainer.pixel(pixel: SC1) { - val group = solidGroup(pixel.name) { - position = Float32Vector3D(pixel.center.x, pixel.center.y, pixel.center.z) + private fun SolidGroup.pixel(pixel: SC1) { + val group = group(pixel.name) { + position = Point3D(pixel.center.x, pixel.center.y, pixel.center.z) box(pixel.xSize, pixel.ySize, pixel.zSize) label(pixel.name) { z = -Monitor.PIXEL_Z_SIZE / 2 - 5 @@ -27,7 +27,7 @@ class Model(val manager: VisionManager) { } private fun SolidGroup.detector(detector: SC16) { - solidGroup(detector.name) { + group(detector.name) { detector.pixels.forEach { pixel(it) } @@ -37,41 +37,42 @@ class Model(val manager: VisionManager) { var tracks: SolidGroup val root: SolidGroup = SolidGroup().apply { - setAsRoot(this@Model.manager) + root(this@Model.manager) material { + wireframe color("darkgreen") } rotationX = PI / 2 - solidGroup("bottom") { + group("bottom") { Monitor.detectors.filter { it.center.z == LOWER_LAYER_Z }.forEach { detector(it) } } - solidGroup("middle") { + group("middle") { Monitor.detectors.filter { it.center.z == CENTRAL_LAYER_Z }.forEach { detector(it) } } - solidGroup("top") { + group("top") { Monitor.detectors.filter { it.center.z == UPPER_LAYER_Z }.forEach { detector(it) } } - tracks = solidGroup("tracks") + tracks = group("tracks") } private fun highlight(pixel: String) { println("highlight $pixel") - map[pixel]?.color("blue") + map[pixel]?.color?.invoke("blue") } fun reset() { map.values.forEach { - it.properties.setProperty(SolidMaterial.MATERIAL_COLOR_KEY, null) + it.setProperty(SolidMaterial.MATERIAL_COLOR_KEY, null) } - tracks.children.clear() + tracks.removeAll() } fun displayEvent(event: Event) { @@ -82,6 +83,7 @@ class Model(val manager: VisionManager) { } event.track?.let { tracks.polyline(*it.toTypedArray(), name = "track[${event.id}]") { + thickness = 4 color("red") } } diff --git a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Monitor.kt b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Monitor.kt index 48fe83d1..3e1db5bc 100644 --- a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Monitor.kt +++ b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Monitor.kt @@ -2,21 +2,21 @@ package ru.mipt.npm.muon.monitor import ru.mipt.npm.muon.monitor.Monitor.PIXEL_XY_SIZE import ru.mipt.npm.muon.monitor.Monitor.PIXEL_Z_SIZE -import space.kscience.visionforge.solid.Float32Euclidean3DSpace -import space.kscience.visionforge.solid.Float32Vector3D +import space.kscience.visionforge.solid.Point3D +import space.kscience.visionforge.solid.plus /** * A single pixel */ class SC1( val name: String, - val center: Float32Vector3D, - val xSize: Float = PIXEL_XY_SIZE, val ySize: Float = PIXEL_XY_SIZE, val zSize: Float = PIXEL_Z_SIZE, + val center: Point3D, + val xSize: Float = PIXEL_XY_SIZE, val ySize: Float = PIXEL_XY_SIZE, val zSize: Float = PIXEL_Z_SIZE ) class SC16( val name: String, - val center: Float32Vector3D, + val center: Point3D ) { /** @@ -28,90 +28,77 @@ class SC16( val y: Double when (index) { 7 -> { - x = 1.5 * Monitor.PIXEL_XY_SPACING - y = 1.5 * Monitor.PIXEL_XY_SPACING + x = 1.5 * Monitor.PIXEL_XY_SPACING; + y = 1.5 * Monitor.PIXEL_XY_SPACING; } - 4 -> { - x = 0.5 * Monitor.PIXEL_XY_SPACING - y = 1.5 * Monitor.PIXEL_XY_SPACING + x = 0.5 * Monitor.PIXEL_XY_SPACING; + y = 1.5 * Monitor.PIXEL_XY_SPACING; } - 6 -> { - x = 1.5 * Monitor.PIXEL_XY_SPACING - y = 0.5 * Monitor.PIXEL_XY_SPACING + x = 1.5 * Monitor.PIXEL_XY_SPACING; + y = 0.5 * Monitor.PIXEL_XY_SPACING; } - 5 -> { - x = 0.5 * Monitor.PIXEL_XY_SPACING - y = 0.5 * Monitor.PIXEL_XY_SPACING + x = 0.5 * Monitor.PIXEL_XY_SPACING; + y = 0.5 * Monitor.PIXEL_XY_SPACING; } 3 -> { - x = -1.5 * Monitor.PIXEL_XY_SPACING - y = 1.5 * Monitor.PIXEL_XY_SPACING + x = -1.5 * Monitor.PIXEL_XY_SPACING; + y = 1.5 * Monitor.PIXEL_XY_SPACING; } - 0 -> { - x = -0.5 * Monitor.PIXEL_XY_SPACING - y = 1.5 * Monitor.PIXEL_XY_SPACING + x = -0.5 * Monitor.PIXEL_XY_SPACING; + y = 1.5 * Monitor.PIXEL_XY_SPACING; } - 2 -> { - x = -1.5 * Monitor.PIXEL_XY_SPACING - y = 0.5 * Monitor.PIXEL_XY_SPACING + x = -1.5 * Monitor.PIXEL_XY_SPACING; + y = 0.5 * Monitor.PIXEL_XY_SPACING; } - 1 -> { - x = -0.5 * Monitor.PIXEL_XY_SPACING - y = 0.5 * Monitor.PIXEL_XY_SPACING + x = -0.5 * Monitor.PIXEL_XY_SPACING; + y = 0.5 * Monitor.PIXEL_XY_SPACING; } 11 -> { - x = -1.5 * Monitor.PIXEL_XY_SPACING - y = -1.5 * Monitor.PIXEL_XY_SPACING + x = -1.5 * Monitor.PIXEL_XY_SPACING; + y = -1.5 * Monitor.PIXEL_XY_SPACING; } - 8 -> { - x = -0.5 * Monitor.PIXEL_XY_SPACING - y = -1.5 * Monitor.PIXEL_XY_SPACING + x = -0.5 * Monitor.PIXEL_XY_SPACING; + y = -1.5 * Monitor.PIXEL_XY_SPACING; } - 10 -> { - x = -1.5 * Monitor.PIXEL_XY_SPACING - y = -0.5 * Monitor.PIXEL_XY_SPACING + x = -1.5 * Monitor.PIXEL_XY_SPACING; + y = -0.5 * Monitor.PIXEL_XY_SPACING; } - 9 -> { - x = -0.5 * Monitor.PIXEL_XY_SPACING - y = -0.5 * Monitor.PIXEL_XY_SPACING + x = -0.5 * Monitor.PIXEL_XY_SPACING; + y = -0.5 * Monitor.PIXEL_XY_SPACING; } 15 -> { - x = 1.5 * Monitor.PIXEL_XY_SPACING - y = -1.5 * Monitor.PIXEL_XY_SPACING + x = 1.5 * Monitor.PIXEL_XY_SPACING; + y = -1.5 * Monitor.PIXEL_XY_SPACING; } - 12 -> { - x = 0.5 * Monitor.PIXEL_XY_SPACING - y = -1.5 * Monitor.PIXEL_XY_SPACING + x = 0.5 * Monitor.PIXEL_XY_SPACING; + y = -1.5 * Monitor.PIXEL_XY_SPACING; } - 14 -> { - x = 1.5 * Monitor.PIXEL_XY_SPACING - y = -0.5 * Monitor.PIXEL_XY_SPACING + x = 1.5 * Monitor.PIXEL_XY_SPACING; + y = -0.5 * Monitor.PIXEL_XY_SPACING; } - 13 -> { - x = 0.5 * Monitor.PIXEL_XY_SPACING - y = -0.5 * Monitor.PIXEL_XY_SPACING + x = 0.5 * Monitor.PIXEL_XY_SPACING; + y = -0.5 * Monitor.PIXEL_XY_SPACING; } - - else -> throw Error() + else -> throw Error(); } - val offset = Float32Vector3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0)); + val offset = Point3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0)); val pixelName = "${name}_${index}" - SC1(pixelName, with(Float32Euclidean3DSpace) { offset + center }) + SC1(pixelName, offset + center) } } } @@ -150,11 +137,11 @@ object Monitor { .mapNotNull { line -> if (line.startsWith(" ")) { val split = line.trim().split("\\s+".toRegex()) - val detectorName = split[1] + val detectorName = split[1]; val x = split[4].toDouble() - 500 val y = split[5].toDouble() - 500 val z = 180 - split[6].toDouble() - SC16(detectorName, Float32Vector3D(x, y, z)) + SC16(detectorName, Point3D(x, y, z)) } else { null } diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt index 07dc7c7c..1a7fe071 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt @@ -1,65 +1,54 @@ package ru.mipt.npm.muon.monitor -import kotlinx.browser.window +import io.ktor.client.HttpClient +import io.ktor.client.request.get import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.await import kotlinx.coroutines.launch import kotlinx.css.* import kotlinx.html.js.onClickFunction -import kotlinx.serialization.json.Json -import org.w3c.fetch.RequestInit -import react.Props +import react.* import react.dom.attrs import react.dom.button import react.dom.p -import react.fc -import react.useMemo -import react.useState -import space.kscience.dataforge.meta.invoke +import space.kscience.dataforge.context.Context import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Colors import space.kscience.visionforge.react.flexColumn import space.kscience.visionforge.react.flexRow import space.kscience.visionforge.ring.ThreeCanvasWithControls import space.kscience.visionforge.ring.tab -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.ambientLight -import space.kscience.visionforge.solid.edges -import space.kscience.visionforge.solid.invoke +import space.kscience.visionforge.solid.specifications.Camera import space.kscience.visionforge.solid.specifications.Canvas3DOptions +import space.kscience.visionforge.solid.three.edges import styled.css import styled.styledDiv import styled.styledSpan import kotlin.math.PI -external interface MMAppProps : Props { +external interface MMAppProps : RProps { var model: Model - var solids: Solids + var context: Context + var connection: HttpClient var selected: Name? } @OptIn(DelicateCoroutinesApi::class) @JsExport -val MMApp = fc("Muon monitor") { props -> +val MMApp = functionalComponent("Muon monitor") { props -> val mmOptions = useMemo { Canvas3DOptions { - camera { + camera = Camera { distance = 2100.0 latitude = PI / 6 azimuth = PI + PI / 6 } - } } val root = useMemo(props.model) { props.model.root.apply { edges() - ambientLight{ - color(Colors.white) - } } } @@ -71,7 +60,7 @@ val MMApp = fc("Muon monitor") { props -> } child(ThreeCanvasWithControls) { attrs { - this.solids = props.solids + this.context = props.context this.builderOfSolid = CompletableDeferred(root) this.selected = props.selected this.options = mmOptions @@ -82,19 +71,10 @@ val MMApp = fc("Muon monitor") { props -> +"Next" attrs { onClickFunction = { - solids.context.launch { - val event = window.fetch( - "http://localhost:8080/event", - RequestInit("GET") - ).then { response -> - if (response.ok) { - response.text() - } else { - error("Failed to get event") - } - }.then { body -> - Json.decodeFromString(Event.serializer(), body) - }.await() + context.launch { + val event = props.connection.get( + "http://localhost:8080/event" + ) events = events + event props.model.displayEvent(event) } @@ -119,7 +99,7 @@ val MMApp = fc("Muon monitor") { props -> } +" : " styledSpan { - css { + css{ color = Color.blue } +event.hits.toString() diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt index afc9ce80..f777d383 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt @@ -1,34 +1,42 @@ package ru.mipt.npm.muon.monitor -import org.w3c.dom.Document +import io.ktor.client.HttpClient +import io.ktor.client.features.json.JsonFeature +import io.ktor.client.features.json.serializer.KotlinxSerializer +import kotlinx.browser.document +import react.child +import react.dom.render import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request +import space.kscience.dataforge.context.fetch import space.kscience.visionforge.Application import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.react.createRoot -import space.kscience.visionforge.react.render -import space.kscience.visionforge.solid.Solids import space.kscience.visionforge.solid.three.ThreePlugin import space.kscience.visionforge.startApplication private class MMDemoApp : Application { - override fun start(document: Document, state: Map) { + private val connection = HttpClient { + install(JsonFeature) { + serializer = KotlinxSerializer() + } + } - val context = Context("MM-demo") { + override fun start(state: Map) { + + val context = Context("MM-demo"){ plugin(ThreePlugin) } - - val visionManager = context.request(VisionManager) + val visionManager = context.fetch(VisionManager) val model = Model(visionManager) val element = document.getElementById("app") ?: error("Element with id 'app' not found on page") - createRoot(element).render { + render(element) { child(MMApp) { attrs { this.model = model - this.solids = context.request(Solids) + this.connection = this@MMDemoApp.connection + this.context = context } } } diff --git a/demo/muon-monitor/src/jsMain/resources/index.html b/demo/muon-monitor/src/jsMain/resources/index.html index f9dee8bd..dbca2406 100644 --- a/demo/muon-monitor/src/jsMain/resources/index.html +++ b/demo/muon-monitor/src/jsMain/resources/index.html @@ -5,6 +5,7 @@ Three js demo for particle physics +
diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/MMServer.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt similarity index 70% rename from demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/MMServer.kt rename to demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt index d3d50c5b..29abd7ca 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/MMServer.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/server/MMServer.kt @@ -1,28 +1,31 @@ package ru.mipt.npm.muon.monitor.server +import io.ktor.application.Application +import io.ktor.application.call +import io.ktor.application.install +import io.ktor.application.log +import io.ktor.features.CallLogging +import io.ktor.features.ContentNegotiation +import io.ktor.features.DefaultHeaders import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode -import io.ktor.serialization.kotlinx.json.json -import io.ktor.server.application.Application -import io.ktor.server.application.call -import io.ktor.server.application.install -import io.ktor.server.application.log +import io.ktor.http.content.resources +import io.ktor.http.content.static +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Routing +import io.ktor.routing.get +import io.ktor.serialization.json import io.ktor.server.cio.CIO import io.ktor.server.engine.embeddedServer -import io.ktor.server.http.content.staticResources -import io.ktor.server.plugins.contentnegotiation.ContentNegotiation -import io.ktor.server.response.respond -import io.ktor.server.response.respondText -import io.ktor.server.routing.Routing -import io.ktor.server.routing.get import org.apache.commons.math3.random.JDKRandomGenerator import ru.mipt.npm.muon.monitor.Model import ru.mipt.npm.muon.monitor.sim.Cos2TrackGenerator import ru.mipt.npm.muon.monitor.sim.simulateOne import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.request +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.misc.DFExperimental import space.kscience.visionforge.solid.Solids import java.awt.Desktop @@ -35,8 +38,10 @@ private val generator = Cos2TrackGenerator(JDKRandomGenerator(223)) fun Application.module(context: Context = Global) { val currentDir = File(".").absoluteFile environment.log.info("Current directory: $currentDir") - val solidManager = context.request(Solids) + val solidManager = context.fetch(Solids) + install(DefaultHeaders) + install(CallLogging) install(ContentNegotiation) { json() } @@ -52,7 +57,9 @@ fun Application.module(context: Context = Global) { status = HttpStatusCode.OK ) } - staticResources("/", null) + static("/") { + resources() + } } try { Desktop.getDesktop().browse(URI("http://localhost:8080/index.html")) diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt index d62d3b0f..7cd54417 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt @@ -67,7 +67,7 @@ internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) { UPPER_LAYER_Z -> 1 CENTRAL_LAYER_Z -> 2; LOWER_LAYER_Z -> 3; - else -> error("Unknown layer"); + else -> throw RuntimeException("Unknown layer"); } } diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/line.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/line.kt index d9492a74..c2578783 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/line.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/line.kt @@ -5,7 +5,7 @@ import org.apache.commons.math3.geometry.euclidean.threed.Plane import org.apache.commons.math3.geometry.euclidean.threed.Vector3D import ru.mipt.npm.muon.monitor.Monitor.CENTRAL_LAYER_Z import ru.mipt.npm.muon.monitor.Monitor.GEOMETRY_TOLERANCE -import space.kscience.visionforge.solid.Float32Vector3D +import space.kscience.visionforge.solid.Point3D /** * Created by darksnake on 11-May-16. @@ -50,12 +50,12 @@ fun makeTrack(x: Double, y: Double, theta: Double, phi: Double): Line { ) } -fun Vector3D.toKMathVector() = Float32Vector3D(x, y, z) +fun Vector3D.toPoint() = Point3D(x, y, z) -fun Line.toKMathVectors(): List { +fun Line.toPoints(): List { val basePoint = basePlane.intersection(this) val bottom = basePoint.subtract(2000.0, direction) val top = basePoint.add(2000.0, direction) - return listOf(bottom.toKMathVector(), top.toKMathVector()) + return listOf(bottom.toPoint(), top.toPoint()) } diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/monitor.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/monitor.kt index e55b74db..d2ec7235 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/monitor.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/monitor.kt @@ -43,7 +43,7 @@ fun readEffs(): Map { fun buildEventByTrack(index: Int, track: Line, hitResolver: (Line) -> Collection = defaultHitResolver): Event { - return Event(index, track.toKMathVectors(), hitResolver(track).map { it.name }) + return Event(index, track.toPoints(), hitResolver(track).map { it.name }) } val defaultHitResolver: (Line) -> Collection = { track: Line -> diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt index cee085bc..f8d45fd4 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt @@ -78,6 +78,6 @@ class Cos2TrackGenerator( return makeTrack(x, y, thetaCandidate, phi) } } - error("Failed to generate theta from distribution") + throw RuntimeException("Failed to generate theta from distribution") } } \ No newline at end of file diff --git a/demo/playground/README.md b/demo/playground/README.md deleted file mode 100644 index d2c8bc02..00000000 --- a/demo/playground/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module playground - - - diff --git a/demo/playground/api/playground.api b/demo/playground/api/playground.api deleted file mode 100644 index 7a050caa..00000000 --- a/demo/playground/api/playground.api +++ /dev/null @@ -1,60 +0,0 @@ -public final class space/kscience/visionforge/examples/AllThingsDemoKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/FormServerKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/GdmlCubesKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/GdmlCurveKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/GdmlIaxoKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/GenerateSchemaKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/PlotlyVisionKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/RandomSpheresKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/RootParserKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/ServerExtensionsKt { - public static final fun makeVisionFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;)V - public static synthetic fun makeVisionFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V -} - -public final class space/kscience/visionforge/examples/SimpleCubeKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/examples/TablesKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - diff --git a/demo/playground/build.gradle.kts b/demo/playground/build.gradle.kts index 36bd6b7b..a89fe123 100644 --- a/demo/playground/build.gradle.kts +++ b/demo/playground/build.gradle.kts @@ -1,14 +1,14 @@ plugins { kotlin("multiplatform") - kotlin("jupyter.api") - id("com.github.johnrengelman.shadow") version "7.1.2" -// application } -repositories { - mavenCentral() - maven("https://jitpack.io") - maven("https://repo.kotlin.link") +repositories{ + jcenter() + maven("https://kotlin.bintray.com/kotlinx") + maven("https://dl.bintray.com/kotlin/kotlin-eap") + maven("https://dl.bintray.com/mipt-npm/dataforge") + maven("https://dl.bintray.com/mipt-npm/kscience") + maven("https://dl.bintray.com/mipt-npm/dev") } kotlin { @@ -17,82 +17,60 @@ kotlin { useCommonJs() browser { webpackTask { - outputFileName = "js/visionforge-playground.js" + this.outputFileName = "js/visionforge-playground.js" } commonWebpackConfig { sourceMaps = true - cssSupport{ - enabled.set(false) - } + cssSupport.enabled = false } } binaries.executable() } - jvm { -// withJava() + jvm{ compilations.all { - kotlinOptions { - jvmTarget = "11" - freeCompilerArgs = - freeCompilerArgs + "-Xjvm-default=all" + "-Xopt-in=kotlin.RequiresOptIn" + "-Xlambdas=indy" + "-Xcontext-receivers" - } + kotlinOptions.jvmTarget = "11" } testRuns["test"].executionTask.configure { useJUnitPlatform() } } + afterEvaluate { + val jsBrowserDistribution = tasks.getByName("jsBrowserDevelopmentExecutableDistribution") + + tasks.getByName("jvmProcessResources") { + dependsOn(jsBrowserDistribution) + afterEvaluate { + from(jsBrowserDistribution) + } + } + } + + sourceSets { val commonMain by getting { dependencies { - implementation(projects.visionforgeSolid) - implementation(projects.visionforgePlotly) - implementation(projects.visionforgeMarkdown) - implementation(projects.visionforgeTables) - implementation(projects.cernRootLoader) - api(projects.visionforgeJupyter.visionforgeJupyterCommon) + implementation(project(":visionforge-solid")) + implementation(project(":visionforge-gdml")) + implementation(project(":visionforge-plotly")) + implementation(projects.visionforge.visionforgeMarkdown) } } - val jsMain by getting { + val jsMain by getting{ dependencies { - implementation(projects.ui.ring) - implementation(projects.visionforgeThreejs) - compileOnly(npm("webpack-bundle-analyzer","4.5.0")) + implementation(project(":ui:ring")) + implementation(project(":visionforge-threejs")) } } - val jvmMain by getting { + val jvmMain by getting{ dependencies { - implementation("io.ktor:ktor-server-cio:${spclibs.versions.ktor.get()}") - implementation(projects.visionforgeGdml) - implementation(projects.visionforgeServer) - implementation(spclibs.logback.classic) + implementation(project(":visionforge-server")) + implementation("ch.qos.logback:logback-classic:1.2.3") implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6") } } - all { - languageSettings.optIn("space.kscience.dataforge.misc.DFExperimental") - } } } - -val jsBrowserDistribution = tasks.getByName("jsBrowserDistribution") - -tasks.getByName("jvmProcessResources") { - dependsOn(jsBrowserDistribution) - from(jsBrowserDistribution) { - exclude("**/*.js.map") - } -} - -val processJupyterApiResources by tasks.getting(org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask::class) { - libraryProducers = listOf("space.kscience.visionforge.examples.VisionForgePlayGroundForJupyter") -} - -tasks.findByName("shadowJar")?.dependsOn(processJupyterApiResources) - -//application{ -// mainClass.set("space.kscience.visionforge.examples.ShapesKt") -//} \ No newline at end of file diff --git a/demo/playground/notebooks/common-demo.ipynb b/demo/playground/notebooks/common-demo.ipynb deleted file mode 100644 index 78797545..00000000 --- a/demo/playground/notebooks/common-demo.ipynb +++ /dev/null @@ -1,101 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "@file:Repository(\"*mavenLocal\")\n", - "@file:Repository(\"https://repo.kotlin.link\")\n", - "@file:Repository(\"https://maven.pkg.jetbrains.space/spc/p/sci/dev\")\n", - "@file:DependsOn(\"space.kscience:visionforge-jupyter-common-jvm:0.3.0-dev-12\")\n", - "//import space.kscience.visionforge.jupyter.JupyterCommonIntegration\n", - "//\n", - "//val integration = JupyterCommonIntegration()\n", - "//USE(integration.getDefinitions(notebook).first())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "vf.fragment {\n", - " h1 { +\"AAA\" }\n", - " vision {\n", - " solid {\n", - " ambientLight()\n", - " box(100, 100, 200)\n", - "\n", - " sphere(100) {\n", - " x = 300\n", - " }\n", - " }\n", - " }\n", - "\n", - " vision {\n", - " plotly {\n", - " scatter {\n", - " x(1, 2, 3, 1)\n", - " y(1, 2, 3, 4)\n", - " }\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "outputs_hidden": false - }, - "tags": [] - }, - "outputs": [], - "source": [ - "Plotly.plot { \n", - " scatter{\n", - " x(1,2,3)\n", - " y(1,2,3)\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Kotlin", - "language": "kotlin", - "name": "kotlin" - }, - "ktnbPluginMetadata": { - "isAddProjectLibrariesToClasspath": false - }, - "language_info": { - "codemirror_mode": "text/x-kotlin", - "file_extension": ".kt", - "mimetype": "text/x-kotlin", - "name": "kotlin", - "nbconvert_exporter": "", - "pygments_lexer": "kotlin", - "version": "1.8.20" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/demo/playground/notebooks/dynamic-demo.ipynb b/demo/playground/notebooks/dynamic-demo.ipynb deleted file mode 100644 index ac70b4c2..00000000 --- a/demo/playground/notebooks/dynamic-demo.ipynb +++ /dev/null @@ -1,92 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [], - "pycharm": { - "is_executing": true - } - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vf.startServer()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false, - "jupyter": { - "outputs_hidden": false - } - }, - "outputs": [], - "source": [ - "import kotlinx.coroutines.*\n", - "import kotlin.random.Random\n", - "\n", - "Plotly.plot{\n", - " scatter{\n", - " x(1,2,3)\n", - " y(1,2,3)\n", - " if(vf.isServerRunning()){\n", - " vf.launch{\n", - " while(isActive){\n", - " delay(500)\n", - " y(Random.nextDouble(), Random.nextDouble(), Random.nextDouble())\n", - " }\n", - " }\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vf.stopServer()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Kotlin", - "language": "kotlin", - "name": "kotlin" - }, - "language_info": { - "codemirror_mode": "text/x-kotlin", - "file_extension": ".kt", - "mimetype": "text/x-kotlin", - "name": "kotlin", - "nbconvert_exporter": "", - "pygments_lexer": "kotlin", - "version": "1.8.0-dev-3517" - }, - "ktnbPluginMetadata": { - "isAddProjectLibrariesToClasspath": false - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/demo/playground/src/jsMain/kotlin/playgroundMain.kt b/demo/playground/src/jsMain/kotlin/playgroundMain.kt index feff4de1..0ea9abe5 100644 --- a/demo/playground/src/jsMain/kotlin/playgroundMain.kt +++ b/demo/playground/src/jsMain/kotlin/playgroundMain.kt @@ -1,16 +1,12 @@ import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.jupyter.VFNotebookClient import space.kscience.visionforge.markup.MarkupPlugin import space.kscience.visionforge.plotly.PlotlyPlugin import space.kscience.visionforge.ring.ThreeWithControlsPlugin import space.kscience.visionforge.runVisionClient -import space.kscience.visionforge.tables.TableVisionJsPlugin @DFExperimental fun main() = runVisionClient { plugin(ThreeWithControlsPlugin) plugin(PlotlyPlugin) plugin(MarkupPlugin) - plugin(TableVisionJsPlugin) - plugin(VFNotebookClient) } \ No newline at end of file diff --git a/demo/playground/src/jsMain/resources/css/common.css b/demo/playground/src/jsMain/resources/css/common.css new file mode 100644 index 00000000..316c4f0e --- /dev/null +++ b/demo/playground/src/jsMain/resources/css/common.css @@ -0,0 +1,40 @@ +/* Remove default bullets */ +ul, .tree { + list-style-type: none; +} + +/* Style the caret/arrow */ +.tree-caret { + cursor: pointer; + user-select: none; /* Prevent text selection */ +} + +/* Create the caret/arrow with a unicode, and style it */ +.tree-caret::before { + content: "\25B6"; + color: black; + display: inline-block; + margin-right: 6px; +} + +/* Rotate the caret/arrow icon when clicked on (using JavaScript) */ +.tree-caret-down::before { + transform: rotate(90deg); +} + +ul, .tree { + list-style-type: none; +} + +i, .tree-caret{ + display: inline-block; + margin-right: 6px; +} + +.rotate { + transform: rotate(90deg); +} + +.tree-label-inactive { + color: gray; +} diff --git a/demo/playground/src/jsMain/resources/index.html b/demo/playground/src/jsMain/resources/index.html new file mode 100644 index 00000000..1917c33d --- /dev/null +++ b/demo/playground/src/jsMain/resources/index.html @@ -0,0 +1,16 @@ + + + + + Playground + + + + + +
+

Playground

+
+
+ + \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt b/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt deleted file mode 100644 index 5b272b72..00000000 --- a/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt +++ /dev/null @@ -1,183 +0,0 @@ -package space.kscience.visionforge.examples - -import kotlinx.html.h2 -import space.kscience.dataforge.meta.ValueType -import space.kscience.dataforge.meta.invoke -import space.kscience.plotly.layout -import space.kscience.plotly.models.ScatterMode -import space.kscience.plotly.models.TextPosition -import space.kscience.plotly.scatter -import space.kscience.tables.ColumnHeader -import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.markup.markdown -import space.kscience.visionforge.plotly.plotly -import space.kscience.visionforge.solid.box -import space.kscience.visionforge.solid.solid -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import space.kscience.visionforge.solid.z -import space.kscience.visionforge.tables.columnTable -import kotlin.io.path.Path - - -fun main() = makeVisionFile( - Path("VisionForgeDemo.html"), - resourceLocation = ResourceLocation.EMBED -) { - markdown { - //language=markdown - """ - # VisionForge - - This is a demo for current VisionForge features. This text is written in [MarkDown](https://github.com/JetBrains/markdown) - """.trimIndent() - } - - h2 { +"3D visualization with Three-js" } - vision("3D") { - solid( - Canvas3DOptions { - axes { - size = 200.0 - visible = true - } - } - ) { - box(100, 100, 100, name = "aBox") { - z = 50.0 - } - } - } - - h2 { +"Interactive plots with Plotly" } - vision("plot") { - plotly { - scatter { - x(1, 2, 3, 4) - y(10, 15, 13, 17) - mode = ScatterMode.markers - name = "Team A" - text("A-1", "A-2", "A-3", "A-4", "A-5") - textposition = TextPosition.`top center` - textfont { - family = "Raleway, sans-serif" - } - marker { size = 12 } - } - - scatter { - x(2, 3, 4, 5) - y(10, 15, 13, 17) - mode = ScatterMode.lines - name = "Team B" - text("B-a", "B-b", "B-c", "B-d", "B-e") - textposition = TextPosition.`bottom center` - textfont { - family = "Times New Roman" - } - marker { size = 12 } - } - - layout { - title = "Data Labels Hover" - xaxis { - range(0.75..5.25) - } - legend { - y = 0.5 - font { - family = "Arial, sans-serif" - size = 20 - color("grey") - } - } - } - } - } - h2 { +"Interactive tables with Tabulator" } - vision("table") { - val x by ColumnHeader.value(ValueType.NUMBER) - val y by ColumnHeader.value(ValueType.NUMBER) - columnTable( - x to listOf(2, 3, 4, 5), - y to listOf(10, 15, 13, 17) - ) - } - markdown { - //language=markdown - """ - ## The code for everything above - ```kotlin - markdown { - //language=markdown - ""${'"'} - # VisionForge - - This is a demo for current VisionForge features. This text is written in [MarkDown](https://github.com/JetBrains/markdown) - ""${'"'}.trimIndent() - } - - h2 { +"3D visualization with Three-js" } - vision("3D") { - solid { - box(100, 100, 100, name = "aBox") - } - } - - h2 { +"Interactive plots with Plotly" } - vision("plot") { - plotly { - scatter { - x(1, 2, 3, 4) - y(10, 15, 13, 17) - mode = ScatterMode.markers - name = "Team A" - text("A-1", "A-2", "A-3", "A-4", "A-5") - textposition = TextPosition.`top center` - textfont { - family = "Raleway, sans-serif" - } - marker { size = 12 } - } - - scatter { - x(2, 3, 4, 5) - y(10, 15, 13, 17) - mode = ScatterMode.lines - name = "Team B" - text("B-a", "B-b", "B-c", "B-d", "B-e") - textposition = TextPosition.`bottom center` - textfont { - family = "Times New Roman" - } - marker { size = 12 } - } - - layout { - title = "Data Labels Hover" - xaxis { - range(0.75..5.25) - } - legend { - y = 0.5 - font { - family = "Arial, sans-serif" - size = 20 - color("grey") - } - } - } - } - } - h2 { +"Interactive tables with Tabulator" } - vision("table") { - val x by ColumnHeader.value(ValueType.NUMBER) - val y by ColumnHeader.value(ValueType.NUMBER) - columnTable( - x to listOf(2, 3, 4, 5), - y to listOf(10, 15, 13, 17) - ) - } - ``` - """.trimIndent() - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/antenna.kt b/demo/playground/src/jvmMain/kotlin/antenna.kt deleted file mode 100644 index 6e9b759b..00000000 --- a/demo/playground/src/jvmMain/kotlin/antenna.kt +++ /dev/null @@ -1,102 +0,0 @@ -package space.kscience.visionforge.examples - -import kotlinx.coroutines.delay -import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch -import space.kscience.dataforge.meta.configure -import space.kscience.kmath.complex.Quaternion -import space.kscience.kmath.complex.QuaternionField -import space.kscience.kmath.complex.conjugate -import space.kscience.kmath.geometry.* -import space.kscience.visionforge.solid.* -import kotlin.math.PI -import kotlin.math.cos -import kotlin.math.sin - -fun main() = serve { - - val azimuth = 60.degrees - val inclination = 15.degrees - - val direction = with(QuaternionField) { - Quaternion.fromRotation(-azimuth, Euclidean3DSpace.zAxis) * - Quaternion.fromRotation(Angle.piDiv2 - inclination, Euclidean3DSpace.yAxis) - } - - //val direction2 = Quaternion.fromEuler(Angle.zero, Angle.piDiv2 - inclination, -azimuth, RotationOrder.ZYX) - - val target = Quaternion.fromEuler((-45).degrees, 45.degrees, Angle.zero, RotationOrder.XYZ) - - - vision("canvas") { - requirePlugin(Solids) - - solid(options = { - configure { "controls.enabled" put false } - }) { - rotationX = -PI / 2 - rotationZ = PI - //axes(200) - ambientLight() - val platform = solidGroup("platform") { - cylinder(50, 5, name = "base") - solidGroup("frame") { - z = 60 - - val antenna = solidGroup("antenna") { - axes(200) - tube(40, 10, 30) - sphereLayer(100, 95, theta = PI / 6) { - z = 100 - rotationX = -PI / 2 - } - cylinder(5, 30) { - z = 15 - } - - sphereLayer(101, 94, phi = PI / 32, theta = PI / 6) { - z = 100 - rotationX = -PI / 2 - color("red") - } - - quaternion = target - } - } - } - - val frame = platform["frame"] as SolidGroup - - val antenna = frame["antenna"] as SolidGroup - - val xPeriod = 5000 //ms - val yPeriod = 7000 //ms - - val incRot = Quaternion.fromRotation(30.degrees, Euclidean3DSpace.zAxis) - - - val rotationJob = context.launch { - var time: Long = 0L - while (isActive) { - with(QuaternionField) { - delay(200) - platform.quaternion = Quaternion.fromRotation( - 15.degrees * sin(time.toDouble() * 2 * PI / xPeriod), - Euclidean3DSpace.xAxis - ) * Quaternion.fromRotation( - 15.degrees * cos(time * 2 * PI / yPeriod), - Euclidean3DSpace.yAxis - ) - - val qi = platform.quaternion * incRot - - antenna.quaternion = qi.conjugate * incRot.conjugate * target - - time += 200 - //antenna.quaternion = Quaternion.fromRotation(5.degrees, Euclidean3DSpace.zAxis) * antenna.quaternion - } - } - } - } - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/axes.kt b/demo/playground/src/jvmMain/kotlin/axes.kt deleted file mode 100644 index b8178887..00000000 --- a/demo/playground/src/jvmMain/kotlin/axes.kt +++ /dev/null @@ -1,22 +0,0 @@ -package space.kscience.visionforge.examples - -import space.kscience.kmath.geometry.Euclidean3DSpace -import space.kscience.kmath.geometry.radians -import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.solid.* -import kotlin.math.PI - -fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { - vision("canvas") { - requirePlugin(Solids) - solid { - axes(100, "root-axes") - solidGroup("group") { - z = 100 - rotate((PI / 4).radians, Euclidean3DSpace.vector(1, 1, 1)) - axes(100, "local-axes") - box(50, 50, 50, "box") - } - } - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/extruded.kt b/demo/playground/src/jvmMain/kotlin/extruded.kt deleted file mode 100644 index 8a25549f..00000000 --- a/demo/playground/src/jvmMain/kotlin/extruded.kt +++ /dev/null @@ -1,21 +0,0 @@ -package space.kscience.visionforge.examples - -import space.kscience.visionforge.solid.ambientLight -import space.kscience.visionforge.solid.extruded -import space.kscience.visionforge.solid.polygon -import space.kscience.visionforge.solid.solid - -fun main() = makeVisionFile { - vision("canvas") { - solid { - ambientLight() - extruded("extruded") { - shape{ - polygon(8, 100) - layer(-30) - layer(30) - } - } - } - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/formServer.kt b/demo/playground/src/jvmMain/kotlin/formServer.kt deleted file mode 100644 index d832d85a..00000000 --- a/demo/playground/src/jvmMain/kotlin/formServer.kt +++ /dev/null @@ -1,83 +0,0 @@ -package space.kscience.visionforge.examples - -import io.ktor.server.cio.CIO -import io.ktor.server.engine.embeddedServer -import io.ktor.server.http.content.staticResources -import io.ktor.server.routing.routing -import kotlinx.html.* -import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.request -import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.html.VisionOfHtmlForm -import space.kscience.visionforge.html.VisionPage -import space.kscience.visionforge.html.bindForm -import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.server.close -import space.kscience.visionforge.server.openInBrowser -import space.kscience.visionforge.server.visionPage - -@Suppress("ExtractKtorModule") -fun main() { - val visionManager = Global.request(VisionManager) - - val server = embeddedServer(CIO) { - - routing { - staticResources("/", null) - } - - val form = VisionOfHtmlForm("form").apply { - onPropertyChange(visionManager.context) { - println(values) - } - } - - visionPage( - visionManager, - VisionPage.scriptHeader("js/visionforge-playground.js"), - ) { - bindForm(form) { - label { - htmlFor = "fname" - +"First name:" - } - br() - input { - type = InputType.text - id = "fname" - name = "fname" - value = "John" - } - br() - label { - htmlFor = "lname" - +"Last name:" - } - br() - input { - type = InputType.text - id = "lname" - name = "lname" - value = "Doe" - } - br() - br() - input { - type = InputType.submit - value = "Submit" - } - } - println(form.values) - vision(form) - } - - }.start(false) - - server.openInBrowser() - - while (readln() != "exit") { - - } - - server.close() -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/gdmlCurve.kt b/demo/playground/src/jvmMain/kotlin/gdmCurve.kt similarity index 97% rename from demo/playground/src/jvmMain/kotlin/gdmlCurve.kt rename to demo/playground/src/jvmMain/kotlin/gdmCurve.kt index 4cac02b1..cbdac68a 100644 --- a/demo/playground/src/jvmMain/kotlin/gdmlCurve.kt +++ b/demo/playground/src/jvmMain/kotlin/gdmCurve.kt @@ -1,7 +1,6 @@ -@file:Suppress("UNUSED_VARIABLE") - package space.kscience.visionforge.examples +import space.kscience.dataforge.context.Context import space.kscience.gdml.* import space.kscience.visionforge.gdml.toVision import space.kscience.visionforge.html.ResourceLocation @@ -11,9 +10,13 @@ import space.kscience.visionforge.solid.invoke import space.kscience.visionforge.visible import java.nio.file.Path -fun main() = makeVisionFile(Path.of("curves.html"), resourceLocation = ResourceLocation.EMBED) { +fun main() { + val context = Context { + plugin(Solids) + } + + context.makeVisionFile(Path.of("curves.html"), resourceLocation = ResourceLocation.EMBED) { vision("canvas") { - requirePlugin(Solids) Gdml { // geometry variables val worldSize = 500 @@ -223,7 +226,7 @@ fun main() = makeVisionFile(Path.of("curves.html"), resourceLocation = ResourceL } } }.toVision { - solids { _, solid, _ -> + configure { parent, solid, material -> //disable visibility for the world box if(solid.name == "world"){ visible = false @@ -237,4 +240,5 @@ fun main() = makeVisionFile(Path.of("curves.html"), resourceLocation = ResourceL } } } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/gdmlCubes.kt b/demo/playground/src/jvmMain/kotlin/gdmlCubes.kt index 3e5b0475..9de22003 100644 --- a/demo/playground/src/jvmMain/kotlin/gdmlCubes.kt +++ b/demo/playground/src/jvmMain/kotlin/gdmlCubes.kt @@ -1,13 +1,19 @@ package space.kscience.visionforge.examples +import space.kscience.dataforge.context.Context import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.gdml.toVision import space.kscience.visionforge.html.ResourceLocation import space.kscience.visionforge.solid.Solids -fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { - vision("canvas") { - requirePlugin(Solids) - GdmlShowCase.cubes().toVision() +fun main() { + val context = Context { + plugin(Solids) + } + + context.makeVisionFile(resourceLocation = ResourceLocation.SYSTEM){ + vision("canvas") { + GdmlShowCase.cubes().toVision() + } } } \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt b/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt index 954a30c9..a9070af7 100644 --- a/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt +++ b/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt @@ -1,15 +1,16 @@ package space.kscience.visionforge.examples +import space.kscience.dataforge.context.Context import space.kscience.gdml.GdmlShowCase -import space.kscience.visionforge.gdml.gdml +import space.kscience.visionforge.gdml.toVision import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.solid -fun main() = makeVisionFile { - vision("canvas") { - requirePlugin(Solids) - solid { - gdml(GdmlShowCase.babyIaxo(), "D0") - } +fun main() { + val context = Context { + plugin(Solids) + } + + context.makeVisionFile { + vision("canvas") { GdmlShowCase.babyIaxo().toVision() } } } \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/generateSchema.kt b/demo/playground/src/jvmMain/kotlin/generateSchema.kt index 672cd0b3..75c6f9cd 100644 --- a/demo/playground/src/jvmMain/kotlin/generateSchema.kt +++ b/demo/playground/src/jvmMain/kotlin/generateSchema.kt @@ -6,19 +6,16 @@ import kotlinx.serialization.json.Json import space.kscience.visionforge.solid.SolidGroup import space.kscience.visionforge.solid.Solids -@OptIn(ExperimentalSerializationApi::class) -private val json = Json { - serializersModule = Solids.serializersModuleForSolids - prettyPrintIndent = " " - prettyPrint = true - ignoreUnknownKeys = true - isLenient = true - coerceInputValues = true - encodeDefaults = true -} - @ExperimentalSerializationApi fun main() { - val schema = json.encodeToSchema(SolidGroup.serializer(), generateDefinitions = false) + val schema = Json { + serializersModule = Solids.serializersModuleForSolids + prettyPrintIndent = " " + prettyPrint = true + ignoreUnknownKeys = true + isLenient = true + coerceInputValues = true + encodeDefaults = true + }.encodeToSchema(SolidGroup.serializer(), generateDefinitions = false) println(schema) } \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/markdownDemo.kt b/demo/playground/src/jvmMain/kotlin/markdownDemo.kt new file mode 100644 index 00000000..cb4b7cf0 --- /dev/null +++ b/demo/playground/src/jvmMain/kotlin/markdownDemo.kt @@ -0,0 +1,91 @@ +package space.kscience.visionforge.examples + +import kotlinx.html.div +import kotlinx.html.h1 +import space.kscience.dataforge.context.Context +import space.kscience.plotly.layout +import space.kscience.plotly.models.ScatterMode +import space.kscience.plotly.models.TextPosition +import space.kscience.plotly.scatter +import space.kscience.visionforge.html.ResourceLocation +import space.kscience.visionforge.markup.markdown +import space.kscience.visionforge.plotly.PlotlyPlugin +import space.kscience.visionforge.plotly.plotly +import space.kscience.visionforge.solid.* + +fun main() { + val context = Context { + plugin(Solids) + plugin(PlotlyPlugin) + } + + context.makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { + markdown { + //language=markdown + """ + # Section + + **TBD** + + ## Subsection + """.trimIndent() + } + + div { + h1 { +"Canvas" } + vision("canvas") { + solid { + box(100, 100, 100) + material { + emissiveColor("red") + } + } + } + } + + vision("plot") { + plotly { + scatter { + x(1, 2, 3, 4) + y(10, 15, 13, 17) + mode = ScatterMode.markers + name = "Team A" + text("A-1", "A-2", "A-3", "A-4", "A-5") + textposition = TextPosition.`top center` + textfont { + family = "Raleway, sans-serif" + } + marker { size = 12 } + } + + scatter { + x(2, 3, 4, 5) + y(10, 15, 13, 17) + mode = ScatterMode.lines + name = "Team B" + text("B-a", "B-b", "B-c", "B-d", "B-e") + textposition = TextPosition.`bottom center` + textfont { + family = "Times New Roman" + } + marker { size = 12 } + } + + layout { + title = "Data Labels Hover" + xaxis { + range(0.75..5.25) + } + legend { + y = 0.5 + font { + family = "Arial, sans-serif" + size = 20 + color("grey") + } + } + } + } + } + } +} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/plotlyVision.kt b/demo/playground/src/jvmMain/kotlin/plotlyVision.kt index c1ef18a8..4575b952 100644 --- a/demo/playground/src/jvmMain/kotlin/plotlyVision.kt +++ b/demo/playground/src/jvmMain/kotlin/plotlyVision.kt @@ -1,92 +1,22 @@ package space.kscience.visionforge.examples -import space.kscience.dataforge.meta.Value -import space.kscience.plotly.layout -import space.kscience.plotly.models.* +import space.kscience.dataforge.context.Context +import space.kscience.plotly.scatter import space.kscience.visionforge.html.ResourceLocation +import space.kscience.visionforge.plotly.PlotlyPlugin import space.kscience.visionforge.plotly.plotly -fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { - vision { - val trace1 = Violin { - text("sample length: 32") - marker { - line { - width = 2 - color("#bebada") +fun main() { + val context = Context { + plugin(PlotlyPlugin) + } + context.makeVisionFile(resourceLocation = ResourceLocation.SYSTEM){ + vision { + plotly { + scatter { + x(1, 2, 3) + y(5, 8, 7) } - symbol = Symbol.valueOf("line-ns") - } - orientation = Orientation.h - hoveron = ViolinHoveron.`points+kde` - meanline { - visible = true - } - legendgroup = "F" - scalegroup = "F" - points = ViolinPoints.all - pointpos = 1.2 - jitter = 0 - box { - visible = true - } - scalemode = ViolinScaleMode.count - showlegend = false - side = ViolinSide.positive - y0 = Value.of(0) - line { - color("#bebada") - } - name = "F" - - x(10.07, 34.83, 10.65, 12.43, 24.08, 13.42, 12.48, 29.8, 14.52, 11.38, - 20.27, 11.17, 12.26, 18.26, 8.51, 10.33, 14.15, 13.16, 17.47, 27.05, 16.43, - 8.35, 18.64, 11.87, 19.81, 43.11, 13.0, 12.74, 13.0, 16.4, 16.47, 18.78) - } - - val trace2 = Violin { - text("sample length: 32") - marker { - line { - width = 2 - color("#8dd3c7") - } - symbol = Symbol.valueOf("line-ns") - } - orientation = Orientation.h - hoveron = ViolinHoveron.`points+kde` - meanline { - visible = true - } - legendgroup = "M" - scalegroup = "M" - points = ViolinPoints.all - pointpos = -1.2 - jitter = 0 - box { - visible = true - } - scalemode = ViolinScaleMode.count - showlegend = false - side = ViolinSide.negative - y0 = Value.of(0) - - line { - color("#8dd3c7") - } - name = "M" - - x(27.2, 22.76, 17.29, 19.44, 16.66, 32.68, 15.98, 13.03, 18.28, 24.71, - 21.16, 11.69, 14.26, 15.95, 8.52, 22.82, 19.08, 16.0, 34.3, 41.19, 9.78, - 7.51, 28.44, 15.48, 16.58, 7.56, 10.34, 13.51, 18.71, 20.53) - } - - plotly { - traces(trace1, trace2) - layout { - width = 800 - height = 800 - title = "Advanced Violin Plot" } } } diff --git a/demo/playground/src/jvmMain/kotlin/randomSpheres.kt b/demo/playground/src/jvmMain/kotlin/randomSpheres.kt index fd1b9865..0185bdc8 100644 --- a/demo/playground/src/jvmMain/kotlin/randomSpheres.kt +++ b/demo/playground/src/jvmMain/kotlin/randomSpheres.kt @@ -2,34 +2,37 @@ package space.kscience.visionforge.examples import kotlinx.html.div import kotlinx.html.h1 -import space.kscience.visionforge.Colors +import space.kscience.dataforge.context.Context import space.kscience.visionforge.html.ResourceLocation import space.kscience.visionforge.solid.* import java.nio.file.Paths import kotlin.random.Random -private val random = Random(112233) +fun main() { + val context = Context { + plugin(Solids) + } -fun main() = makeVisionFile( - Paths.get("randomSpheres.html"), - resourceLocation = ResourceLocation.SYSTEM -) { - h1 { +"Happy new year!" } - div { - vision { - solid { - ambientLight { - color(Colors.white) - } - repeat(100) { - sphere(5, name = "sphere[$it]") { - x = random.nextDouble(-300.0, 300.0) - y = random.nextDouble(-300.0, 300.0) - z = random.nextDouble(-300.0, 300.0) - material { - color(random.nextInt()) + val random = Random(112233) + + context.makeVisionFile( + Paths.get("randomSpheres.html"), + resourceLocation = ResourceLocation.SYSTEM + ) { + h1 { +"Happy new year!" } + div { + vision { + solid { + repeat(100) { + sphere(5, name = "sphere[$it]") { + x = random.nextDouble(-300.0, 300.0) + y = random.nextDouble(-300.0, 300.0) + z = random.nextDouble(-300.0, 300.0) + material { + color(random.nextInt()) + } + detail = 16 } - detail = 16 } } } diff --git a/demo/playground/src/jvmMain/kotlin/rootParser.kt b/demo/playground/src/jvmMain/kotlin/rootParser.kt deleted file mode 100644 index 1faa8d0b..00000000 --- a/demo/playground/src/jvmMain/kotlin/rootParser.kt +++ /dev/null @@ -1,55 +0,0 @@ -package space.kscience.visionforge.examples - -import ru.mipt.npm.root.DGeoManager -import ru.mipt.npm.root.rootGeo -import ru.mipt.npm.root.serialization.TGeoManager -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.isLeaf -import space.kscience.dataforge.meta.string -import space.kscience.visionforge.Colors -import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.ambientLight -import space.kscience.visionforge.solid.invoke -import space.kscience.visionforge.solid.solid -import java.util.zip.ZipInputStream -import kotlin.io.path.Path -import kotlin.io.path.writeText - - -private fun Meta.countTypes(): Sequence = sequence { - if (!isLeaf) { - get("_typename")?.value?.let { yield(it.string) } - items.forEach { yieldAll(it.value.countTypes()) } - } -} - -fun main() { - val string = ZipInputStream(TGeoManager::class.java.getResourceAsStream("/root/geometry_run_7-2076.zip")!!).use { - it.nextEntry - it.readAllBytes().decodeToString() - } - - val geo = DGeoManager.parse(string) - - - val sizes = geo.meta.countTypes().groupBy { it }.mapValues { it.value.size } - sizes.forEach { - println(it) - } - - makeVisionFile(path = Path("data/output.html"), resourceLocation = ResourceLocation.EMBED) { - vision("canvas") { - requirePlugin(Solids) - solid { - ambientLight { - color(Colors.white) - } - rootGeo(geo,"BM@N", ignoreRootColors = true).also { - Path("data/BM@N.vf.json").writeText(Solids.encodeToString(it)) - } - } - } - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/serverExtensions.kt b/demo/playground/src/jvmMain/kotlin/serverExtensions.kt index c20f27c7..e4111afc 100644 --- a/demo/playground/src/jvmMain/kotlin/serverExtensions.kt +++ b/demo/playground/src/jvmMain/kotlin/serverExtensions.kt @@ -1,83 +1,36 @@ package space.kscience.visionforge.examples -import io.ktor.server.cio.CIO -import io.ktor.server.engine.embeddedServer -import io.ktor.server.http.content.staticResources -import io.ktor.server.routing.routing import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.Global -import space.kscience.visionforge.html.* -import space.kscience.visionforge.markup.MarkupPlugin -import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.server.close -import space.kscience.visionforge.server.openInBrowser -import space.kscience.visionforge.server.visionPage -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.tables.TableVisionPlugin -import space.kscience.visionforge.visionManager +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.visionforge.html.ResourceLocation +import space.kscience.visionforge.html.VisionTagConsumer +import space.kscience.visionforge.html.page +import space.kscience.visionforge.html.scriptHeader +import space.kscience.visionforge.makeFile +import space.kscience.visionforge.three.server.VisionServer +import space.kscience.visionforge.three.server.useScript import java.awt.Desktop import java.nio.file.Path -public fun makeVisionFile( +public fun VisionServer.usePlayground(): Unit { + useScript("js/visionforge-playground.js") +} + +@OptIn(DFExperimental::class) +public fun Context.makeVisionFile( path: Path? = null, title: String = "VisionForge page", resourceLocation: ResourceLocation = ResourceLocation.SYSTEM, show: Boolean = true, - content: HtmlVisionFragment, + content: VisionTagConsumer<*>.() -> Unit ): Unit { - val actualPath = VisionPage(Global.visionManager, content = content).makeFile(path) { actualPath -> - mapOf( - "title" to VisionPage.title(title), - "playground" to VisionPage.importScriptHeader( - "js/visionforge-playground.js", - resourceLocation, - actualPath - ), - ) + val actualPath = page(title, content = content).makeFile(path) { actualPath -> + mapOf("playground" to scriptHeader("js/visionforge-playground.js", resourceLocation, actualPath)) } if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI()) } -public fun serve( - title: String = "VisionForge page", - show: Boolean = true, - content: HtmlVisionFragment, -) { - val context = Context("playground") { - plugin(Solids) - plugin(PlotlyPlugin) - plugin(MarkupPlugin) - plugin(TableVisionPlugin) - } - - val server = embeddedServer(CIO, port = 7779) { - routing { - staticResources("", null, null) - } - - visionPage( - context.visionManager, - VisionPage.scriptHeader("js/visionforge-playground.js") { - defer = true - }, - VisionPage.title(title), - visionFragment = content - ) - }.start(false) - - if (show) { - server.openInBrowser() - } - - println("Enter 'exit' to close server") - while (readlnOrNull() != "exit") { - // - } - - server.close() -} - //@DFExperimental //public fun Context.makeVisionFile( // vision: Vision, diff --git a/demo/playground/src/jvmMain/kotlin/shapes.kt b/demo/playground/src/jvmMain/kotlin/shapes.kt deleted file mode 100644 index 55ce28d5..00000000 --- a/demo/playground/src/jvmMain/kotlin/shapes.kt +++ /dev/null @@ -1,40 +0,0 @@ -package space.kscience.visionforge.examples - -import space.kscience.visionforge.Colors -import space.kscience.visionforge.solid.* -import kotlin.math.PI - -fun main() = makeVisionFile { - vision("canvas") { - solid { - ambientLight() - box(100.0, 100.0, 100.0) { - z = -110.0 - color("teal") - } - sphere(50.0) { - x = 110 - detail = 16 - color("red") - } - tube(50, height = 10, innerRadius = 25, angle = PI) { - y = 110 - detail = 16 - rotationX = PI / 4 - color("blue") - } - sphereLayer(50, 40, theta = PI / 2) { - rotationX = -PI * 3 / 4 - z = 110 - color(Colors.pink) - } - - - cylinder(30,20, name = "cylinder"){ - detail = 31 - y = -220 - z = 15 - } - } - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/simpleCube.kt b/demo/playground/src/jvmMain/kotlin/simpleCube.kt index e1fc91eb..f804228b 100644 --- a/demo/playground/src/jvmMain/kotlin/simpleCube.kt +++ b/demo/playground/src/jvmMain/kotlin/simpleCube.kt @@ -1,17 +1,21 @@ package space.kscience.visionforge.examples +import space.kscience.dataforge.context.Context import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.solid.box -import space.kscience.visionforge.solid.invoke -import space.kscience.visionforge.solid.material -import space.kscience.visionforge.solid.solid +import space.kscience.visionforge.solid.* -fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { - vision("canvas") { - solid { - box(100, 100, 100) - material { - emissiveColor("red") +fun main() { + val context = Context { + plugin(Solids) + } + + context.makeVisionFile(resourceLocation = ResourceLocation.SYSTEM){ + vision("canvas") { + solid { + box(100, 100, 100) + material { + emissiveColor("red") + } } } } diff --git a/demo/playground/src/jvmMain/kotlin/tables.kt b/demo/playground/src/jvmMain/kotlin/tables.kt deleted file mode 100644 index ab27ebdf..00000000 --- a/demo/playground/src/jvmMain/kotlin/tables.kt +++ /dev/null @@ -1,23 +0,0 @@ -package space.kscience.visionforge.examples - -import space.kscience.dataforge.meta.ValueType -import space.kscience.tables.ColumnHeader -import space.kscience.tables.valueRow -import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.tables.table -import kotlin.math.pow - -fun main() { - val x by ColumnHeader.value(ValueType.NUMBER) - val y by ColumnHeader.value(ValueType.NUMBER) - - makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { - vision { - table(x, y) { - repeat(100) { - valueRow(x to it, y to it.toDouble().pow(2)) - } - } - } - } -} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/resources/root/BM@N_geometry.zip b/demo/playground/src/jvmMain/resources/root/BM@N_geometry.zip deleted file mode 100644 index 47701be0..00000000 Binary files a/demo/playground/src/jvmMain/resources/root/BM@N_geometry.zip and /dev/null differ diff --git a/demo/playground/src/jvmMain/resources/root/geometry_run_7-2076.zip b/demo/playground/src/jvmMain/resources/root/geometry_run_7-2076.zip deleted file mode 100644 index 1680404c..00000000 Binary files a/demo/playground/src/jvmMain/resources/root/geometry_run_7-2076.zip and /dev/null differ diff --git a/demo/playground/webpack.config.d/01.ring.js b/demo/playground/webpack.config.d/01.ring.js index b3cc4770..41da041c 100644 --- a/demo/playground/webpack.config.d/01.ring.js +++ b/demo/playground/webpack.config.d/01.ring.js @@ -1,23 +1,3 @@ const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; -const path = require('path'); -config.module.rules.push(...ringConfig.module.rules) - -config.module.rules.push( - { - test: /\.css$/, - exclude: [ - path.resolve(__dirname, "../../node_modules/@jetbrains/ring-ui") - ], - use: [ - { - loader: 'style-loader', - options: {} - }, - { - loader: 'css-loader', - options: {} - } - ] - } -) \ No newline at end of file +config.module.rules.push(...ringConfig.module.rules) \ No newline at end of file diff --git a/demo/playground/webpack.config.d/02.bundle.js b/demo/playground/webpack.config.d/02.bundle.js deleted file mode 100644 index 947253ca..00000000 --- a/demo/playground/webpack.config.d/02.bundle.js +++ /dev/null @@ -1,10 +0,0 @@ -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - -module.exports = { - plugins: [ - new BundleAnalyzerPlugin({ - analyzerMode: "static", - reportFilename: "bundle-report.html" - }) - ] -} \ No newline at end of file diff --git a/demo/plotly-fx/README.md b/demo/plotly-fx/README.md deleted file mode 100644 index d8679f77..00000000 --- a/demo/plotly-fx/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module plotly-fx - - - diff --git a/demo/sat-demo/README.md b/demo/sat-demo/README.md deleted file mode 100644 index ea15abe0..00000000 --- a/demo/sat-demo/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module sat-demo - - - diff --git a/demo/sat-demo/api/sat-demo.api b/demo/sat-demo/api/sat-demo.api deleted file mode 100644 index 00e5cedd..00000000 --- a/demo/sat-demo/api/sat-demo.api +++ /dev/null @@ -1,5 +0,0 @@ -public final class ru/mipt/npm/sat/SatServerKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - diff --git a/demo/sat-demo/build.gradle.kts b/demo/sat-demo/build.gradle.kts index 5e881b63..267e4a82 100644 --- a/demo/sat-demo/build.gradle.kts +++ b/demo/sat-demo/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("space.kscience.gradle.jvm") + id("ru.mipt.npm.gradle.jvm") application } @@ -8,15 +8,15 @@ kscience { // useSerialization { // json() // } - useKtor() - dependencies{ - implementation("io.ktor:ktor-server-cio") - implementation(projects.visionforgeThreejs.visionforgeThreejsServer) - implementation(spclibs.logback.classic) - } + application() } -group = "center.sciprog" +group = "ru.mipt.npm" + +dependencies{ + implementation(project(":visionforge-threejs:visionforge-threejs-server")) + implementation("ch.qos.logback:logback-classic:1.2.3") +} application { mainClass.set("ru.mipt.npm.sat.SatServerKt") diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/geometry.kt b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/geometry.kt index d2c30422..546c7b51 100644 --- a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/geometry.kt +++ b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/geometry.kt @@ -1,12 +1,14 @@ package ru.mipt.npm.sat import space.kscience.dataforge.meta.set +import space.kscience.dataforge.misc.DFExperimental import space.kscience.visionforge.solid.* import space.kscience.visionforge.style import space.kscience.visionforge.useStyle import kotlin.math.PI -internal fun Solids.visionOfSatellite( +@DFExperimental +internal fun visionOfSatellite( layers: Int = 10, layerHeight: Number = 10, xSegments: Int = 3, @@ -14,7 +16,7 @@ internal fun Solids.visionOfSatellite( xSegmentSize: Number = 30, ySegmentSize: Number = xSegmentSize, fiberDiameter: Number = 1.0, -): SolidGroup = solidGroup { +): SolidGroup = SolidGroup { color("darkgreen") val transparent by style { this[SolidMaterial.MATERIAL_OPACITY_KEY] = 0.3 @@ -31,7 +33,7 @@ internal fun Solids.visionOfSatellite( val totalXSize = xSegments * xSegmentSize.toDouble() val totalYSize = ySegments * ySegmentSize.toDouble() for (layer in 1..layers) { - solidGroup("layer[$layer]") { + group("layer[$layer]") { for (i in 1..xSegments) { for (j in 1..ySegments) { box(xSegmentSize, ySegmentSize, layerHeight, name = "segment[$i,$j]") { @@ -42,7 +44,7 @@ internal fun Solids.visionOfSatellite( } } } - solidGroup("fibers") { + group("fibers") { for (i in 1..xSegments) { cylinder(fiberDiameter, totalYSize) { useStyle(red) diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt index 9f2f7e59..8b286e07 100644 --- a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt +++ b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt @@ -1,61 +1,42 @@ package ru.mipt.npm.sat -import io.ktor.server.cio.CIO -import io.ktor.server.engine.embeddedServer -import io.ktor.server.http.content.staticResources -import io.ktor.server.routing.routing -import kotlinx.coroutines.* +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch import kotlinx.html.div import kotlinx.html.h1 -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request -import space.kscience.dataforge.meta.Null +import space.kscience.dataforge.context.Global import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Colors -import space.kscience.visionforge.html.VisionPage -import space.kscience.visionforge.server.close -import space.kscience.visionforge.server.openInBrowser -import space.kscience.visionforge.server.visionPage import space.kscience.visionforge.solid.* -import space.kscience.visionforge.three.threeJsHeader +import space.kscience.visionforge.three.server.* +import space.kscience.visionforge.visionManager import kotlin.random.Random - -@Suppress("ExtractKtorModule") fun main() { - val satContext = Context("sat") { + val satContext = Global.buildContext ("sat") { plugin(Solids) } - val solids = satContext.request(Solids) - //Create a geometry - val sat = solids.visionOfSatellite(ySegments = 3).apply { - ambientLight { - color(Colors.white) - } - } - val server = embeddedServer(CIO, port = 7777) { - routing { - staticResources("", null, null) - } + val sat = visionOfSatellite(ySegments = 3) - visionPage( - solids.visionManager, VisionPage.threeJsHeader, - VisionPage.styleSheetHeader("css/styles.css") - ) { + val server = satContext.visionManager.serve { + //use client library + useThreeJs() + //use css + useCss("css/styles.css") + page { div("flex-column") { h1 { +"Satellite detector demo" } - vision { sat } + vision(sat) } } + } - }.start(false) + server.show() - server.openInBrowser() - - @OptIn(DelicateCoroutinesApi::class) GlobalScope.launch { while (isActive) { val randomLayer = Random.nextInt(1, 11) @@ -65,8 +46,7 @@ fun main() { val targetVision = sat[target] as Solid targetVision.color("red") delay(1000) - //use to ensure that color is cleared - targetVision.color.value = Null + targetVision.color.clear() delay(500) } } diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/static.kt b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/static.kt deleted file mode 100644 index 89dc3a09..00000000 --- a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/static.kt +++ /dev/null @@ -1,21 +0,0 @@ -package ru.mipt.npm.sat - -import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.solid.box -import space.kscience.visionforge.solid.invoke -import space.kscience.visionforge.solid.material -import space.kscience.visionforge.solid.solid -import space.kscience.visionforge.three.makeThreeJsFile - -@OptIn(DFExperimental::class) -fun main() = makeThreeJsFile(resourceLocation = ResourceLocation.SYSTEM) { - vision ("canvas") { - solid { - box(100, 100, 100) - material { - emissiveColor("red") - } - } - } -} \ No newline at end of file diff --git a/demo/solid-showcase/README.md b/demo/solid-showcase/README.md index 059597ef..f8771e13 100644 --- a/demo/solid-showcase/README.md +++ b/demo/solid-showcase/README.md @@ -1,4 +1,19 @@ -# Module solid-showcase +### Spatial Showcase +Contains a simple demonstration with a grid including a few shapes that you can rotate, move camera, and so on. +Some shapes will also periodically change their color and visibility. +##### Building project + +To see the JS demo: run `demo/solid-showcase/Tasks/kotlin browser/jsBrowserRun` Gradle task, then open +`build/distribuions/solid-showcase-js-0.1.3-dev/index.html` file in your browser. +To see Java FX demo, run `demo/spatial-showcase/Tasks/application/run` Gradle task, or `main()` from `FXDemoApp.kt`. + +##### Example view for JS: + +![](../../docs/images/spatial-showcase.png) + +##### Example view for Java FX: + +![](../../docs/images/spatial-showcase-FX.png) diff --git a/demo/solid-showcase/api/solid-showcase.api b/demo/solid-showcase/api/solid-showcase.api deleted file mode 100644 index 4cc47c7d..00000000 --- a/demo/solid-showcase/api/solid-showcase.api +++ /dev/null @@ -1,48 +0,0 @@ -public final class space/kscience/visionforge/demo/MetaEditorDemo : tornadofx/View { - public fun ()V - public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public final fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public synthetic fun getRoot ()Ljavafx/scene/Parent; - public fun getRoot ()Ljavafx/scene/control/SplitPane; -} - -public final class space/kscience/visionforge/demo/MetaEditorDemoApp : tornadofx/App { - public fun ()V -} - -public final class space/kscience/visionforge/demo/MetaEditorDemoKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/solid/demo/DemoKt { - public static final fun demo (Lspace/kscience/visionforge/solid/demo/VisionLayout;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public static synthetic fun demo$default (Lspace/kscience/visionforge/solid/demo/VisionLayout;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public static final fun getCanvasOptions ()Lspace/kscience/visionforge/solid/specifications/Canvas3DOptions; - public static final fun showcase (Lspace/kscience/visionforge/solid/demo/VisionLayout;)V - public static final fun showcaseCSG (Lspace/kscience/visionforge/solid/demo/VisionLayout;)V -} - -public final class space/kscience/visionforge/solid/demo/FXDemoApp : tornadofx/App { - public fun ()V - public final fun getView ()Lspace/kscience/visionforge/solid/demo/FXDemoGrid; - public fun start (Ljavafx/stage/Stage;)V -} - -public final class space/kscience/visionforge/solid/demo/FXDemoAppKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/solid/demo/FXDemoGrid : tornadofx/View, space/kscience/visionforge/solid/demo/VisionLayout { - public fun ()V - public fun getRoot ()Ljavafx/scene/Parent; - public synthetic fun render (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V - public fun render (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/dataforge/meta/Meta;)V -} - -public abstract interface class space/kscience/visionforge/solid/demo/VisionLayout { - public abstract fun render (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V - public static synthetic fun render$default (Lspace/kscience/visionforge/solid/demo/VisionLayout;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V -} - diff --git a/demo/solid-showcase/build.gradle.kts b/demo/solid-showcase/build.gradle.kts index 05a02260..bc391b9d 100644 --- a/demo/solid-showcase/build.gradle.kts +++ b/demo/solid-showcase/build.gradle.kts @@ -1,26 +1,44 @@ +import ru.mipt.npm.gradle.DependencyConfiguration +import ru.mipt.npm.gradle.FXModule + plugins { - id("space.kscience.gradle.mpp") -// application + id("ru.mipt.npm.gradle.mpp") + application } kscience { useCoroutines() - jvm() - js{ - binaries.executable() - } - dependencies { - implementation(projects.visionforgeSolid) - implementation(projects.visionforgeGdml) + val fxVersion: String by rootProject.extra + useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION) + application() +} + +kotlin { + + jvm { + withJava() } - jsMain { - implementation(projects.visionforgeThreejs) + sourceSets { + commonMain { + dependencies { + implementation(project(":visionforge-solid")) +// implementation(project(":visionforge-gdml")) + } + } + jvmMain { + dependencies { + implementation(project(":visionforge-fx")) + } + } + jsMain { + dependencies { + implementation(project(":visionforge-threejs")) + } + } } } -kotlin.explicitApi = null - -//application { -// mainClass.set("space.kscience.visionforge.solid.demo.FXDemoAppKt") -//} \ No newline at end of file +application { + mainClassName = "space.kscience.visionforge.solid.demo.FXDemoAppKt" +} \ No newline at end of file diff --git a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/VisionLayout.kt b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/VisionLayout.kt index 4b5bdf53..016f2ecf 100644 --- a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/VisionLayout.kt +++ b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/VisionLayout.kt @@ -3,10 +3,7 @@ package space.kscience.visionforge.solid.demo import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.names.Name import space.kscience.visionforge.Vision -import space.kscience.visionforge.solid.Solids -interface VisionLayout { - val solids: Solids - - fun render(name: Name, vision: V, meta: Meta = Meta.EMPTY) +public interface VisionLayout { + public fun render(name: Name, vision: V, meta: Meta = Meta.EMPTY) } \ No newline at end of file diff --git a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt index 9e2ecedb..a0ab9273 100644 --- a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt +++ b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt @@ -4,8 +4,6 @@ import kotlinx.coroutines.* import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.invoke import space.kscience.dataforge.names.Name -import space.kscience.kmath.geometry.Euclidean3DSpace -import space.kscience.kmath.geometry.radians import space.kscience.visionforge.Colors import space.kscience.visionforge.solid.* import space.kscience.visionforge.solid.specifications.Canvas3DOptions @@ -20,12 +18,7 @@ fun VisionLayout.demo(name: String, title: String = name, block: SolidGro val meta = Meta { "title" put title } - val vision = solids.solidGroup { - block() - ambientLight { - color(Colors.white) - } - } + val vision = SolidGroup(block) render(Name.parse(name), vision, meta) } @@ -46,7 +39,6 @@ val canvasOptions = Canvas3DOptions { @OptIn(DelicateCoroutinesApi::class) fun VisionLayout.showcase() { demo("shapes", "Basic shapes") { - ambientLight() box(100.0, 100.0, 100.0) { z = -110.0 color("teal") @@ -70,7 +62,7 @@ fun VisionLayout.showcase() { } demo("dynamic", "Dynamic properties") { - val group = solidGroup { + val group = group { box(100, 100, 100) { z = 110.0 opacity = 0.5 @@ -102,18 +94,11 @@ fun VisionLayout.showcase() { demo("rotation", "Rotations") { box(100, 100, 100) - solidGroup { + group { x = 200 rotationY = PI / 4 - axes(200) box(100, 100, 100) { - rotate((PI / 4).radians, Euclidean3DSpace.zAxis) - GlobalScope.launch(Dispatchers.Main) { - while (isActive) { - delay(100) - rotate((PI/20).radians,Euclidean3DSpace.yAxis) - } - } + rotationZ = PI / 4 color(Colors.red) } } @@ -139,10 +124,7 @@ fun VisionLayout.showcase() { color(Colors.blue) } repeat(20) { - polyline( - Float32Vector3D(100, 100, 100), - Float32Vector3D(-100, -100, -100) - ) { + polyline(Point3D(100, 100, 100), Point3D(-100, -100, -100)) { thickness = 3.0 rotationX = it * PI2 / 20 color(Colors.green) @@ -159,10 +141,6 @@ fun VisionLayout.showcase() { z = 26 } } - - demo("STL", "STL loaded from URL") { - stl("https://ozeki.hu/attachments/116/Menger_sponge_sample.stl") - } } fun VisionLayout.showcaseCSG() { diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt index 5bdbcefe..db6ebbff 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt @@ -1,9 +1,10 @@ package space.kscience.visionforge.solid.demo +import kotlinx.browser.document +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import org.w3c.dom.Document import space.kscience.visionforge.Application import space.kscience.visionforge.solid.x import space.kscience.visionforge.solid.y @@ -12,7 +13,7 @@ import kotlin.random.Random private class ThreeDemoApp : Application { - override fun start(document: Document, state: Map) { + override fun start(state: Map) { val element = document.getElementById("demo") ?: error("Element with id 'demo' not found on page") @@ -29,8 +30,7 @@ private class ThreeDemoApp : Application { } } } - - launch { + GlobalScope.launch { while (isActive) { delay(500) boxes.forEach { box -> diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt index 50e7f174..6dcfa36f 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt @@ -10,13 +10,12 @@ import org.w3c.dom.Element import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLElement import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.request +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.Name import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.Solids import space.kscience.visionforge.solid.three.ThreeCanvas import space.kscience.visionforge.solid.three.ThreePlugin @@ -26,9 +25,7 @@ class ThreeDemoGrid(element: Element) : VisionLayout { private val outputs: MutableMap = HashMap() - private val three = Global.request(ThreePlugin) - - override val solids: Solids get() = three.solids + private val three = Global.fetch(ThreePlugin) init { element.clear() 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 701df81b..af828f46 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 @@ -1,19 +1,20 @@ package space.kscience.visionforge.solid.demo -import space.kscience.dataforge.meta.asValue +import info.laht.threekt.core.Object3D +import info.laht.threekt.geometries.BoxGeometry +import info.laht.threekt.objects.Mesh +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.setChild +import space.kscience.visionforge.set +import space.kscience.visionforge.setProperty import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.SolidMaterial.Companion.EDGES_KEY import space.kscience.visionforge.solid.layer import space.kscience.visionforge.solid.three.* -import three.core.Object3D -import three.geometries.BoxGeometry -import three.objects.Mesh import kotlin.math.max internal fun SolidGroup.varBox( @@ -21,11 +22,11 @@ internal fun SolidGroup.varBox( ySize: Number, name: String = "", action: VariableBox.() -> Unit = {}, -): VariableBox = VariableBox(xSize, ySize).apply(action).also { setChild(name, it) } +): VariableBox = VariableBox(xSize, ySize).apply(action).also { set(name, it) } internal class VariableBox(val xSize: Number, val ySize: Number) : ThreeJsVision() { - override suspend fun render(three: ThreePlugin): Object3D { + override fun render(three: ThreePlugin): Object3D { val geometry = BoxGeometry(xSize, ySize, 1) val material = ThreeMaterials.DEFAULT.clone() @@ -43,13 +44,13 @@ internal class VariableBox(val xSize: Number, val ySize: Number) : ThreeJsVision it.layers.enable(this@VariableBox.layer) } } - mesh.scale.z = properties.getValue(VALUE)?.number?.toDouble() ?: 1.0 + mesh.scale.z = meta[VALUE].number?.toDouble() ?: 1.0 //add listener to object properties onPropertyChange { name -> when { name == VALUE -> { - val value = properties.getValue(VALUE)?.int ?: 0 + val value = meta.get(VALUE).int ?: 0 val size = value.toFloat() / 255f * 20f mesh.scale.z = size.toDouble() mesh.position.z = size.toDouble() / 2 @@ -60,8 +61,7 @@ internal class VariableBox(val xSize: Number, val ySize: Number) : ThreeJsVision material.color.setRGB(r.toFloat() / 256, g.toFloat() / 256, b.toFloat() / 256) mesh.updateMatrix() } - - name.startsWith(EDGES_KEY) -> mesh.applyEdges(this@VariableBox) + name.startsWith(MeshThreeFactory.EDGES_KEY) -> mesh.applyEdges(this@VariableBox) else -> mesh.updateProperty(this@VariableBox, name) } } @@ -70,9 +70,9 @@ internal class VariableBox(val xSize: Number, val ySize: Number) : ThreeJsVision } var value: Int - get() = properties.getValue(VALUE)?.int ?: 0 + get() = meta[VALUE].int ?: 0 set(value) { - properties.setValue(VALUE, value.asValue()) + setProperty(VALUE, value.asValue()) } companion object { diff --git a/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt b/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt similarity index 100% rename from demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt rename to demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt diff --git a/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt b/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt similarity index 91% rename from demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt rename to demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt index 81501016..ef03092a 100644 --- a/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt +++ b/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt @@ -10,11 +10,9 @@ import space.kscience.dataforge.names.Name import space.kscience.visionforge.solid.FX3DPlugin import space.kscience.visionforge.solid.FXCanvas3D import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.Solids import tornadofx.* class FXDemoGrid : View(title = "DataForge-vis FX demo"), VisionLayout { - private val outputs = FXCollections.observableHashMap() override val root: Parent = borderpane { @@ -26,9 +24,6 @@ class FXDemoGrid : View(title = "DataForge-vis FX demo"), VisionLayout { } private val fx3d = Global.fetch(FX3DPlugin) - override val solids: Solids get() = fx3d.solids - - override fun render(name: Name, vision: Solid, meta: Meta) { outputs.getOrPut(name) { FXCanvas3D(fx3d, canvasOptions) }.render(vision) diff --git a/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt b/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt similarity index 96% rename from demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt rename to demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt index a4217555..3cdf058e 100644 --- a/demo/solid-showcase/src/jvmMain-fx/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/docs/hierarchy.md b/docs/hierarchy.md index 15f3306e..a534c5f1 100644 --- a/docs/hierarchy.md +++ b/docs/hierarchy.md @@ -3,10 +3,10 @@ ![](../docs/images/hierarchy.png) ### Vision -* function `getProperty(name: Name, inherit: Boolean = false, includeStyles: Boolean = true, includeDefaults: Boolean = true)` - get property value with given layer flags. +* function `getPropertyValue(name: Name, inherit: Boolean = false, includeStyles: Boolean = true, includeDefaults: Boolean = true)` - get property value with given layer flags. * function `setProperty(name: Name, item: Any?)` - a convenient method to set property node or value. If `item` is null, then node is removed, not a value - Sets the `item` property to the element with the `name` identification. +Sets the `item` property to the element with the `name` identification. ### VisionBase @@ -27,24 +27,17 @@ low structure changes of this group. Unconsumed changes are discarded. Interface for 3-dimensional Vision. ### SolidGroup -3D Visual Group with a container for templates visible inside this group. It has an interface `PrototypeHolder` which stands for being a container with prototype support. * function `getPrototype(name: Name)` - get a prototype redirecting the request to the parent if prototype is not found. If prototype is a ref, then it is unfolded automatically. -* function `prototypes(builder: VisionContainerBuilder.() -> Unit)` - create or edit prototype node as a group. +* function `prototypes(builder: VisionContainerBuilder.() -> Unit)` - create or edit prototype node as a group. ### SolidReferenceGroup -A class with `SolidReference` interface with reference `Solid`s for template objects reuse. - -### VisionGroupBase - -Abstract implementation of mutable group of `Vision`. +A reference Solid to reuse a template object. ### RootVisionGroup Non-serializable root group used to propagate manager to its children. -### MutableVisionGroup - -Just a mutable version of `VisionGroup` \ No newline at end of file +* function Vision.root(manager: VisionManager) - designate this [VisionGroup] as a root group and assign a [VisionManager] as its parent. diff --git a/docs/images/hierarchy.png b/docs/images/hierarchy.png index 9e9394ac..91da7d4b 100644 Binary files a/docs/images/hierarchy.png and b/docs/images/hierarchy.png differ diff --git a/docs/images/solid-showcase-FX.png b/docs/images/spatial-showcase-FX.png similarity index 100% rename from docs/images/solid-showcase-FX.png rename to docs/images/spatial-showcase-FX.png diff --git a/docs/images/solid-showcase.png b/docs/images/spatial-showcase.png similarity index 100% rename from docs/images/solid-showcase.png rename to docs/images/spatial-showcase.png diff --git a/docs/inheritance.md b/docs/inheritance.md index 1fad27d2..82c27b1c 100644 --- a/docs/inheritance.md +++ b/docs/inheritance.md @@ -2,21 +2,22 @@ Inheritance is an ability of an element to transfer a pack of properties to its `children` elements 'wrapped inside'. -Properties, which can be inherited by objects, are `styles`, `prototypes` (if the object is a reference), `inherit` (it stands for the presence of `parent` objects), and `defaults`. - -All values of `styles` property are contained in class `StyleSheet`, where they all are defined at `Group`s level. The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and -`SolidReference` class helps to reuse a template object. - -The order of inheritance of properties is set in function `getProperty` in `VisionBase` class. -The order is this: -* own styles -* prototypes -* parent +Properties have to be set in a specific order: +### Main properties' inheritance: +* styles +* parents * parent's styles * defaults - -Let's take a closer look using a [Muon Monitor Visualization](../demo/muon-monitor/README.md). +As for `prototypes`, this property has to be set after styles, but before parents. So the order will be this: +### Reference properties' inheritance: +* styles +* prototypes +* parents +* parent's styles +* defaults +------------------------ +Let's take a closer look using a [Muon Monitor Visualization](demo/muon-monitor/README.md). Running the demo, we will see this: ![](../docs/images/inheritance-1.png) @@ -30,15 +31,15 @@ On the right, there is a list with changeable properties. ![](../docs/images/inheritance-properties.png) Properties, which can or cannot be inherited, are these: -* `visible` – toggles the visibility of an element. To be exact, the invisibility of an element is inheritable. +* `visible` - toggles the visibility of an element. To be exact, the invisibility of an element is inheritable. If a `parent` element is invisible, other elements are invisible as well, and they cannot be changed to visible mode. ![](../docs/images/inheritance-2-1-1.png) ![](../docs/images/inheritance-2-1-2.png) -* `material` – a group of properties, which can be inherited and which can be changed in `children` elements. - * `color` – color of an element. - * `opacity` – a number from 0 to 1 which represents percents of opacity (0 for 0%, 1 for 100%). - * `wireframe` – toggles the wireframe mode. +* `material` - a group of properties, which can be inherited and which can be changed in `children` elements. + * `color` - color of an element. + * `opacity` - a number from 0 to 1 which represents percents of opacity (0 for 0%, 1 for 100%). + * `wireframe` - toggles the wireframe mode. Let's see how elements of the `material` group inherit changing `color` property; ***other properties of this group inherit in the same way.*** @@ -50,7 +51,7 @@ Properties, which can or cannot be inherited, are these: ![](../docs/images/inheritance-2-2-2.png) It changes only, 'bottom' and 'middle' stays the same. - 'top' is a `parent` element as well: it has `children` – 'SC72', 'SC73', ... ,'SC80'. + 'top' is a `parent` element as well: it has `children` - 'SC72', 'SC73', ... ,'SC80'. Let's change the color of 'SC76': ![](../docs/images/inheritance-2-2-3.png) Again, only 'SC76' has changed among other 'siblings'. @@ -63,5 +64,7 @@ Properties, which can or cannot be inherited, are these: If after all those changes we set at the 'World' element grey color, changes won't disappear: ![](../docs/images/inheritance-2-2-5.png) -* `rotation` – rotation of an element. Here, it is set by `x` value. It is inheritable and unable to be changed in `children` elements. -* `position` – position of an element, cannot be inherited. +* `rotation` - rotation of an element. Here, it is set by `x` value. It is inheritable and unable to be changed in `children` elements. + +* `position` — position of an element, cannot be inherited. + diff --git a/docs/templates/ARTIFACT-TEMPLATE.md b/docs/templates/ARTIFACT-TEMPLATE.md deleted file mode 100644 index 5d397423..00000000 --- a/docs/templates/ARTIFACT-TEMPLATE.md +++ /dev/null @@ -1,15 +0,0 @@ -## Artifact: - -The Maven coordinates of this project are `${group}:${name}:${version}`. - -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("${group}:${name}:${version}") -} -``` \ No newline at end of file diff --git a/docs/templates/README-TEMPLATE.md b/docs/templates/README-TEMPLATE.md deleted file mode 100644 index 04ab1752..00000000 --- a/docs/templates/README-TEMPLATE.md +++ /dev/null @@ -1,153 +0,0 @@ -[![JetBrains Research](https://jb.gg/badges/research.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) -[![DOI](https://zenodo.org/badge/174502624.svg)](https://zenodo.org/badge/latestdoi/174502624) - -![Gradle build](https://github.com/mipt-npm/visionforge/workflows/Gradle%20build/badge.svg) - -[![Slack](https://img.shields.io/badge/slack-channel-green?logo=slack)](https://kotlinlang.slack.com/archives/CEXV2QWNM) - -# DataForge Visualization Platform - -## Table of Contents - -* [Introduction](#introduction) -* [Requirements](#requirements) -* [Features](#features) -* [About DataForge](#about-dataforge) -* [Modules contained in this repository](#modules-contained-in-this-repository) -* [Visualization for External Systems](#visualization-for-external-systems) -* [Demonstrations](#demonstrations) - * [Simple Example - Solid Showcase](#simple-example---solid-showcase) - * [Full-Stack Application Example - Muon Monitor](#full-stack-application-example---muon-monitor-visualization) - * [GDML Example](#gdml-example) - - -## Introduction - -This repository contains a [DataForge](#about-dataforge)\-based framework -used for visualization in various scientific applications. - -The main framework's use case for now is 3D visualization for particle physics experiments. -Other applications including 2D plots are planned for the future. - -The project is developed as a [Kotlin multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html) -application, currently targeting browser JavaScript and JVM. - -## Requirements - -JVM backend requires JDK 11 or later - -## Features - -The main framework's features for now include: -- 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 -- Scene graph as an object tree with property editor -- Settings export and import -- Multiple platform support - -## About DataForge - -DataForge is a software framework for automated scientific data processing. DataForge Visualization -Platform uses some of the concepts and modules of DataForge, including: `Meta`, `Configuration`, `Context`, -`Provider`, and some others. - -To learn more about DataForge, please consult the following URLs: -* [Kotlin multiplatform implementation of DataForge](https://github.com/mipt-npm/dataforge-core) -* [DataForge documentation](http://npm.mipt.ru/dataforge/) -* [Original implementation of DataForge](https://bitbucket.org/Altavir/dataforge/src/default/) - - -## Modules contained in this repository - -${modules} - -**Class diagram:** - -![](docs/images/class-diag-solid.png) - -##### Prototypes - -One of the important features of the framework is support for 3D object prototypes (sometimes -also referred to as templates). The idea is that prototype geometry can be rendered once and reused -for multiple objects. This helps to significantly decrease memory usage. - -The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and -`SolidReference` class helps to reuse a template object. - -##### Styles - -`VisionGroup` has a `styleSheet` property that can optionally define styles at the Group's -level. Styles are applied to child (descendant) objects using `Vision.styles: List` property. - -### visionforge-threejs - -## Visualization for External Systems - -The `visionforge` framework can be used to visualize geometry and events from external, -non-Kotlin based systems, such as ROOT. This will require a plugin to convert data model -of the external system to that of `visionforge`. Performing such integration is a work -currently in progress. - - -## Demonstrations - -The `demo` module contains several example projects (demonstrations) of using the `visionforge` framework. -They are briefly described in this section, for more details please consult the corresponding per-project -README file. - -### Simple Example - Solid Showcase - -Contains a simple demonstration with a grid including a few shapes that you can rotate, move camera, and so on. -Some shapes will also periodically change their color and visibility. - -[More details](demo/solid-showcase/README.md) - -**Example view:** - -![](docs/images/solid-showcase.png) - - -### Full-Stack Application Example - Muon Monitor Visualization - -A full-stack application example, showing the -[Muon Monitor](http://npm.mipt.ru/en/projects/physics#mounMonitor) experiment set-up. - -[More details](demo/muon-monitor/README.md) - -**Example view:** - -![](docs/images/muon-monitor.png) - - -### GDML Example - -Visualization example for geometry defined as GDML file. - -[More details](demo/gdml/README.md) - -##### Example view: - -![](docs/images/gdml-demo.png) - - -## Stability and documentation - -VisionForge is a modular library. Different modules provide different features with different API stability guarantees. All core modules are released with the same version, but with different API change policy. The features are described in module definitions below. The module stability could have the following levels: - -* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version. -* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked - with `@DFExperimental` or other stability warning annotations. -* **DEVELOPMENT**. API breaking generally follows semantic versioning ideology. There could be changes in minor - versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool. -* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases. - -Additionally, one should note that the VisionForge Json format impacts the reproducibility of stored vision fragments. There should not be any breaks of the format between major releases. All problems should be reported. - -The documentation for the project is a work in progress. Please report any issues with missing, vague or wrong information. The contributions into documentation are quite welcome. - -## Thanks and references -The original three.js bindings were made by [Lars Ivar Hatledal](https://github.com/markaren), but the project is discontinued right now. - -All other libraries are explicitly shown as dependencies. We would like to express specific thanks to JetBrains Kotlin-JS team for consulting us during the work. diff --git a/docs/tutorials/tutorial-solids.md b/docs/tutorial.md similarity index 91% rename from docs/tutorials/tutorial-solids.md rename to docs/tutorial.md index 2b1e7b57..8989bd49 100644 --- a/docs/tutorials/tutorial-solids.md +++ b/docs/tutorial.md @@ -59,7 +59,7 @@ box(10, 10, 10, name = "small box"){ rotation = Point3D(0, 0, 0) } ``` -![](../images/small-box.png) +![](../docs/images/small-box.png) The `big box` will have properties with custom values. ```kotlin @@ -72,7 +72,7 @@ box(40, 40, 40, name = "big box"){ rotation = Point3D(60, 80, 0) } ``` -![](../images/big-rotated-box.png) +![](../docs/images/big-rotated-box.png) If we compare these boxes, we will see all differences. Here is the function `main` with both boxes. @@ -111,8 +111,8 @@ fun main(){ } } ``` -![](../images/two-boxes-1.png) -![](../images/two-boxes-2.png) +![](../docs/images/two-boxes-1.png) +![](../docs/images/two-boxes-2.png) ***There is plenty of other properties, especially those, which you can create by yourself. Here we mention just a small part.*** @@ -142,8 +142,8 @@ polyline(Point3D(30, 20, 10), Point3D(30, -100, 30), Point3D(30, -100, 30), Poin } ``` -![](../images/polyline-points.png) -![](../images/polyline-points-2.png) +![](../docs/images/polyline-points.png) +![](../docs/images/polyline-points-2.png) ### 2) Box @@ -165,7 +165,7 @@ Let's create just usual `box` with equal ribs. color("pink") } ``` - ![](../images/box.png) + ![](../docs/images/box.png) Now, let's make `box` with bigger `y` value. ```kotlin @@ -175,7 +175,7 @@ Now, let's make `box` with bigger `y` value. ``` As you can see, only the rib of `y-axis` differs from other ribs. - ![](../images/high-box.png) + ![](../docs/images/high-box.png) For a final trial, let's create a `box` with a bigger `x` value. @@ -189,7 +189,7 @@ For a final trial, let's create a `box` with a bigger `x` value. ``` Predictably, only the `x-axis` rib is bigger than other ribs. - ![](../images/wide-box.png) + ![](../docs/images/wide-box.png) ### 3) Sphere @@ -206,7 +206,7 @@ As for `radius`, it has `Float` type, and, as you can guess, it sets the radius color("blue") } ``` - ![](../images/sphere.png) + ![](../docs/images/sphere.png) ### 4) Hexagon @@ -220,7 +220,7 @@ It is solid which has six edges. It is set by eight values: `node1`,..., `node8` 5) Edge with vertices `node1`, `node5`, `node8`, `node4` 6) Edge with vertices `node8`, `node5`, `node6`, `node7` -![](../images/scheme.png) +![](../docs/images/scheme.png) As the hexagon takes in specific points, we understand that this solid cannot be moved, it is fixed in space, and it can't make pivots. @@ -239,7 +239,7 @@ Let's make classic parallelepiped. color("green") } ``` - ![](../images/classic-hexagon.png) + ![](../docs/images/classic-hexagon.png) Now, let's make a custom hexagon. @@ -258,7 +258,7 @@ hexagon( color("brown") } ``` - ![](../images/custom-hexagon.png) + ![](../docs/images/custom-hexagon.png) ### 3) Cone It takes in six values: `bottomRadius`, `height`, `upperRadius`, `startAngle`, `angle`, and `name`. @@ -274,8 +274,8 @@ Let's build a classic cone: color("beige") } ``` - ![](../images/cone-1.png) - ![](../images/cone-2.png) + ![](../docs/images/cone-1.png) + ![](../docs/images/cone-2.png) First of all, we have to try to build a frustum cone: ```kotlin @@ -283,7 +283,7 @@ cone(60, 80, name = "cone") { color(0u, 40u, 0u) } ``` -![](../images/frustum-cone.png) +![](../docs/images/frustum-cone.png) Now, we need to make a try to build a cone segment: @@ -292,8 +292,8 @@ cone(60, 80, angle = PI, name = "cone") { color(0u, 0u, 200u) } ``` -![](../images/cone-segment-1.png) -![](../images/cone-segment-2.png) +![](../docs/images/cone-segment-1.png) +![](../docs/images/cone-segment-2.png) Finally, the segment of frustum cone is left for a try: ```kotlin @@ -301,7 +301,7 @@ cone(60, 100, 20, PI*3/4, angle = PI/3, name = "cone") { color(190u, 0u, 0u) } ``` -![](../images/frustum-cone-segment.png) +![](../docs/images/frustum-cone-segment.png) ### 4) Cone Surface This solid is set by seven values:`bottomOuterRadius`, `bottomInnerRadius`, `height`, `topOuterRadius`, `topInnerRadius`, `startAngle`, and `angle`. @@ -318,8 +318,8 @@ Let's build usual cone surface with almost all properties set: rotation = Point3D(2, 50, -9) } ``` -![](../images/cone-surface-1.png) -![](../images/cone-surface-2.png) +![](../docs/images/cone-surface-1.png) +![](../docs/images/cone-surface-2.png) Now, let's create a cone surface and set all it's properties: @@ -329,8 +329,8 @@ coneSurface(30, 25, 10, 10, 8,0f, pi*3/4, name = "cone surface") { rotation = Point3D(2, 50, -9) } ``` -![](../images/cone-surface-fragment.png) -![](../images/cone-surface-fragment-2.png) +![](../docs/images/cone-surface-fragment.png) +![](../docs/images/cone-surface-fragment-2.png) ### 5) Cylinder @@ -344,8 +344,8 @@ cylinder(40, 100, "cylinder"){ color("indigo") } ``` -![](../images/cylinder-1.png) -![](../images/cylinder-2.png) +![](../docs/images/cylinder-1.png) +![](../docs/images/cylinder-2.png) ### 6) Tube `tube` takes in `radius`, `height`, `innerRadius`, `startAngle`, `angle`, and `name`. *All values are familiar from `cone`, and `coneSurface` solids.* @@ -356,7 +356,7 @@ tube(50, 40, 20, name = "usual tube"){ opacity = 0.4 } ``` -![](../images/tube.png) +![](../docs/images/tube.png) This is an example of tube fragment: @@ -365,7 +365,7 @@ tube(50, 40, 20, 0f, PI, name = "fragmented tube"){ color("white") } ``` -![](../images/tube-fragment.png) +![](../docs/images/tube-fragment.png) ### 7) Extruded `extruded` is set by two values: `shape`, and `layer`. diff --git a/docs/uml/Vision.puml b/docs/uml/Vision.puml index f590a13e..2b4d9953 100644 --- a/docs/uml/Vision.puml +++ b/docs/uml/Vision.puml @@ -3,7 +3,7 @@ interface Vision{ val parent: VisionGroup? - fun getProperty(name,inherit,includeStyles,includeDefaults): Value? + fun getPropertyValue(name,inherit,includeStyles,includeDefaults): Value? } interface Solid{ @@ -81,20 +81,18 @@ Solid <--- Composite interface SolidReference{ val prototype: Solid - fun getProperty(name,inherit,includeStyles,includeDefaults): Value? + fun getPropertyValue(name,inherit,includeStyles,includeDefaults): Value? } VisionGroup <---- SolidReference -SolidReferenceGroup -- SolidReference class SolidReferenceGroup{ val refName: Name var properties: MutableMeta? val prototype: Solid val children: Map - fun getProperty(name,inherit,includeStyles,includeDefaults): Value? + fun getPropertyValue(name,inherit,includeStyles,includeDefaults): Value? } VisionBase <-- SolidReferenceGroup -VisionGroup <-- SolidReferenceGroup interface MutableVisionGroup{ fun onStructureChanged(owner, block) diff --git a/gradle.properties b/gradle.properties index e3a218ba..2ffacd8f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,7 @@ kotlin.code.style=official +kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.stability.nowarn=true -kotlin.js.compiler=ir -kotlin.incremental.js.ir=true +kotlin.native.enableDependencyPropagation=false -org.gradle.parallel=true -org.gradle.jvmargs=-Xmx4G - -toolsVersion=0.14.9-kotlin-1.8.20 -org.jetbrains.compose.experimental.jscanvas.enabled=true \ No newline at end of file +org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G +org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049..ffed3a25 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.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jupyter/visionforge-gdml-jupyter/build.gradle.kts b/jupyter/visionforge-gdml-jupyter/build.gradle.kts new file mode 100644 index 00000000..896b44a4 --- /dev/null +++ b/jupyter/visionforge-gdml-jupyter/build.gradle.kts @@ -0,0 +1,59 @@ +plugins { + id("ru.mipt.npm.gradle.mpp") +} + +description = "Jupyter api artifact for GDML rendering" + +kotlin { + explicitApi = null + js { + useCommonJs() + browser { + webpackTask { + this.outputFileName = "js/gdml-jupyter.js" + } + commonWebpackConfig { + sourceMaps = false + cssSupport.enabled = false + } + } + binaries.executable() + } + + afterEvaluate { + val jsBrowserDistribution by tasks.getting + + tasks.getByName("jvmProcessResources") { + dependsOn(jsBrowserDistribution) + from(jsBrowserDistribution) + } + } + + sourceSets { + commonMain { + dependencies { + api(project(":visionforge-solid")) + } + } + jvmMain { + dependencies { + implementation(project(":visionforge-gdml")) + } + } + jsMain { + dependencies { + api(project(":visionforge-threejs")) + implementation(project(":ui:ring")) + } + } + + } +} + +kscience { + useJupyter() +} + +readme { + maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL +} \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt b/jupyter/visionforge-gdml-jupyter/src/jsMain/kotlin/gdmlJupyter.kt similarity index 69% rename from visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt rename to jupyter/visionforge-gdml-jupyter/src/jsMain/kotlin/gdmlJupyter.kt index d1635ddf..fef274a2 100644 --- a/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt +++ b/jupyter/visionforge-gdml-jupyter/src/jsMain/kotlin/gdmlJupyter.kt @@ -1,11 +1,12 @@ -package space.kscience.visionforge.three +package space.kscience.visionforge.gdml.jupyter import space.kscience.dataforge.misc.DFExperimental import space.kscience.visionforge.ring.ThreeWithControlsPlugin import space.kscience.visionforge.runVisionClient - @DFExperimental -public fun main(): Unit = runVisionClient { +@JsExport +fun main(): Unit = runVisionClient { plugin(ThreeWithControlsPlugin) -} \ No newline at end of file +} + diff --git a/jupyter/visionforge-gdml-jupyter/src/jvmMain/kotlin/GdmlForJupyter.kt b/jupyter/visionforge-gdml-jupyter/src/jvmMain/kotlin/GdmlForJupyter.kt new file mode 100644 index 00000000..0b12d3fb --- /dev/null +++ b/jupyter/visionforge-gdml-jupyter/src/jvmMain/kotlin/GdmlForJupyter.kt @@ -0,0 +1,62 @@ +package space.kscience.visionforge.gdml.jupyter + +import kotlinx.html.stream.createHTML +import org.jetbrains.kotlinx.jupyter.api.HTML +import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary +import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration +import org.jetbrains.kotlinx.jupyter.api.libraries.resources +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.gdml.Gdml +import space.kscience.visionforge.Vision +import space.kscience.visionforge.gdml.toVision +import space.kscience.visionforge.html.HtmlVisionFragment +import space.kscience.visionforge.html.Page +import space.kscience.visionforge.html.embedAndRenderVisionFragment +import space.kscience.visionforge.solid.Solids +import space.kscience.visionforge.visionManager + +@JupyterLibrary +@DFExperimental +internal class GdmlForJupyter : JupyterIntegration() { + + private val context = Context("GDML") { + plugin(Solids) + } + + private var counter = 0 + + private fun produceHtmlVisionString(fragment: HtmlVisionFragment) = createHTML().apply { + embedAndRenderVisionFragment(context.visionManager, counter++, fragment) + }.finalize() + + override fun Builder.onLoaded() { + + resources { + js("three") { + classPath("js/gdml-jupyter.js") + } + } + + import( + "space.kscience.gdml.*", + "kotlinx.html.*", + "space.kscience.visionforge.solid.*", + "space.kscience.visionforge.html.Page", + "space.kscience.visionforge.html.page", + "space.kscience.visionforge.gdml.jupyter.*" + ) + + render { vision -> + HTML(produceHtmlVisionString { vision(vision) }) + } + + render { gdmlModel -> + HTML(produceHtmlVisionString { vision(gdmlModel.toVision()) }) + } + + render { page -> + HTML(page.render(createHTML()), true) + } + } +} diff --git a/jupyter/visionforge-gdml-jupyter/webpack.config.d/01.ring.js b/jupyter/visionforge-gdml-jupyter/webpack.config.d/01.ring.js new file mode 100644 index 00000000..41da041c --- /dev/null +++ b/jupyter/visionforge-gdml-jupyter/webpack.config.d/01.ring.js @@ -0,0 +1,3 @@ +const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; + +config.module.rules.push(...ringConfig.module.rules) \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 31119a06..d4616ea7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,43 +1,24 @@ -rootProject.name = "visionforge" - -enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") - pluginManagement { - val toolsVersion: String by extra + val toolsVersion = "0.10.2" repositories { - mavenLocal() maven("https://repo.kotlin.link") mavenCentral() gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } plugins { - id("space.kscience.gradle.project") version toolsVersion - id("space.kscience.gradle.mpp") version toolsVersion - id("space.kscience.gradle.jvm") version toolsVersion - id("space.kscience.gradle.js") version toolsVersion + id("ru.mipt.npm.gradle.project") version toolsVersion + id("ru.mipt.npm.gradle.mpp") version toolsVersion + id("ru.mipt.npm.gradle.jvm") version toolsVersion + id("ru.mipt.npm.gradle.js") version toolsVersion } } -dependencyResolutionManagement { +rootProject.name = "visionforge" - val toolsVersion: String by extra - - repositories { - mavenLocal() - maven("https://repo.kotlin.link") - mavenCentral() - } - - versionCatalogs { - create("spclibs") { - from("space.kscience:version-catalog:$toolsVersion") - } - } -} +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") include( // ":ui", @@ -45,25 +26,22 @@ include( ":ui:ring", // ":ui:material", ":ui:bootstrap", -// ":ui:compose", ":visionforge-core", ":visionforge-solid", -// ":visionforge-fx", + ":visionforge-fx", ":visionforge-threejs", ":visionforge-threejs:visionforge-threejs-server", ":visionforge-gdml", - ":cern-root-loader", ":visionforge-server", ":visionforge-plotly", - ":visionforge-tables", ":visionforge-markdown", ":demo:solid-showcase", ":demo:gdml", ":demo:muon-monitor", ":demo:sat-demo", ":demo:playground", -// ":demo:plotly-fx", + ":demo:jupyter-playground", + ":demo:plotly-fx", ":demo:js-playground", - ":visionforge-jupyter", - ":visionforge-jupyter:visionforge-jupyter-common" + ":jupyter:visionforge-gdml-jupyter" ) diff --git a/ui/README.md b/ui/README.md deleted file mode 100644 index ec08d176..00000000 --- a/ui/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module ui - - - diff --git a/ui/bootstrap/README.md b/ui/bootstrap/README.md deleted file mode 100644 index 0cc57002..00000000 --- a/ui/bootstrap/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module bootstrap - - - diff --git a/ui/bootstrap/build.gradle.kts b/ui/bootstrap/build.gradle.kts index c0b980d9..b1b0588e 100644 --- a/ui/bootstrap/build.gradle.kts +++ b/ui/bootstrap/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("js") - id("space.kscience.gradle.js") + id("ru.mipt.npm.gradle.js") } val dataforgeVersion: String by rootProject.extra diff --git a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt index a37469ca..7c7e7b37 100644 --- a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt +++ b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt @@ -1,22 +1,18 @@ package space.kscience.visionforge.bootstrap -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope import kotlinx.css.BorderStyle import kotlinx.css.Color import kotlinx.css.padding import kotlinx.css.properties.border import kotlinx.css.px import kotlinx.html.js.onClickFunction -import kotlinx.html.org.w3c.dom.events.Event +import org.w3c.dom.events.Event import org.w3c.files.Blob import org.w3c.files.BlobPropertyBag -import react.FC -import react.Props -import react.RBuilder +import react.* import react.dom.attrs import react.dom.button -import react.fc +import space.kscience.dataforge.meta.withDefault import space.kscience.visionforge.Vision import space.kscience.visionforge.encodeToString import space.kscience.visionforge.react.flexColumn @@ -34,8 +30,8 @@ private fun saveData(event: Event, fileName: String, mimeType: String = "text/pl fileSaver.saveAs(blob, fileName) } -public fun RBuilder.canvasControls(canvasOptions: Canvas3DOptions, vision: Vision?) { - child(CanvasControls) { +public fun RBuilder.canvasControls(canvasOptions: Canvas3DOptions, vision: Vision?): ReactElement { + return child(CanvasControls) { attrs { this.canvasOptions = canvasOptions this.vision = vision @@ -43,20 +39,19 @@ public fun RBuilder.canvasControls(canvasOptions: Canvas3DOptions, vision: Visio } } -public external interface CanvasControlsProps : Props { +public external interface CanvasControlsProps : RProps { public var canvasOptions: Canvas3DOptions public var vision: Vision? } - -public val CanvasControls: FC = fc("CanvasControls") { props -> +public val CanvasControls: FunctionComponent = functionalComponent("CanvasControls") { props -> flexColumn { flexRow { css { border(1.px, BorderStyle.solid, Color.blue) padding(4.px) } - props.vision?.let { vision -> + props.vision?.let{ vision -> button { +"Export" attrs { @@ -70,10 +65,9 @@ public val CanvasControls: FC = fc("CanvasControls") { prop } } } - @OptIn(DelicateCoroutinesApi::class) propertyEditor( - scope = props.vision?.manager?.context ?: GlobalScope, - properties = props.canvasOptions.meta, + ownProperties = props.canvasOptions.meta, + allProperties = props.canvasOptions.meta.withDefault(Canvas3DOptions.descriptor.defaultNode), descriptor = Canvas3DOptions.descriptor, expanded = false ) diff --git a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt index b37637fe..dca591fe 100644 --- a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt +++ b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt @@ -5,6 +5,7 @@ import kotlinx.html.DIV import kotlinx.html.id import kotlinx.html.js.onClickFunction import react.RBuilder +import react.ReactElement import react.dom.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken @@ -15,7 +16,7 @@ import styled.styledDiv import styled.styledNav -public inline fun RBuilder.card(title: String, crossinline block: StyledDOMBuilder
.() -> Unit): Unit = +public inline fun RBuilder.card(title: String, crossinline block: StyledDOMBuilder
.() -> Unit): ReactElement = styledDiv { css { +"card" @@ -35,7 +36,7 @@ public inline fun RBuilder.card(title: String, crossinline block: StyledDOMBuild public fun RBuilder.accordion( id: String, elements: List.() -> Unit>>, -): Unit = styledDiv { +): ReactElement = styledDiv { css { +"accordion" //+"p-1" @@ -81,7 +82,7 @@ public fun RBuilder.accordion( } -public fun RBuilder.nameCrumbs(name: Name?, rootTitle: String, link: (Name) -> Unit): Unit = styledNav { +public fun RBuilder.nameCrumbs(name: Name?, rootTitle: String, link: (Name) -> Unit): ReactElement = styledNav { css { +"p-0" } @@ -126,9 +127,9 @@ public fun RSectionsBuilder.entry(title: String, builder: StyledDOMBuilder
. add(title to builder) } -public fun RBuilder.accordion(id: String, builder: RSectionsBuilder.() -> Unit): Unit { +public fun RBuilder.accordion(id: String, builder: RSectionsBuilder.() -> Unit): ReactElement { val list = ArrayList.() -> Unit>>().apply(builder) - accordion(id, list) + return accordion(id, list) } public enum class ContainerSize(public val suffix: String) { @@ -143,7 +144,7 @@ public enum class ContainerSize(public val suffix: String) { public inline fun RBuilder.container( size: ContainerSize = ContainerSize.FLUID, block: StyledDOMBuilder
.() -> Unit, -): Unit = styledDiv { +): ReactElement = styledDiv { css { classes.add("container${size.suffix}") } @@ -163,7 +164,7 @@ public inline fun RBuilder.gridColumn( weight: Int? = null, maxSize: GridMaxSize = GridMaxSize.NONE, block: StyledDOMBuilder
.() -> Unit, -): Unit = styledDiv { +): ReactElement = styledDiv { val weightSuffix = weight?.let { "-$it" } ?: "" css { classes.add("col${maxSize.suffix}$weightSuffix") @@ -173,7 +174,7 @@ public inline fun RBuilder.gridColumn( public inline fun RBuilder.gridRow( block: StyledDOMBuilder
.() -> Unit, -): Unit = styledDiv { +): ReactElement = styledDiv { css { classes.add("row") } diff --git a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt index 23b5071b..987dbc0e 100644 --- a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt +++ b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt @@ -12,25 +12,25 @@ import space.kscience.visionforge.react.flexColumn import styled.StyledDOMBuilder import styled.styledDiv -public external interface TabProps : PropsWithChildren { +public external class TabProps : RProps { public var id: String public var title: String? } @JsExport -public val Tab: FC = fc { props -> +public val Tab: FunctionComponent = functionalComponent { props -> props.children() } -public external interface TabPaneProps : PropsWithChildren { +public external class TabPaneProps : RProps { public var activeTab: String? } @JsExport -public val TabPane: FC = fc("TabPane") { props -> +public val TabPane: FunctionComponent = functionalComponent("TabPane") { props -> var activeTab: String? by useState(props.activeTab) - val children: Array?> = Children.map(props.children) { + val children: Array = Children.map(props.children) { it.asElementOrNull() } ?: emptyArray() diff --git a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt index 9ab0403c..95219db1 100644 --- a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt +++ b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt @@ -2,21 +2,18 @@ package space.kscience.visionforge.bootstrap import kotlinx.css.* import kotlinx.css.properties.border -import react.FC -import react.PropsWithChildren -import react.RBuilder +import react.* import react.dom.h2 -import react.fc import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.isEmpty import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionGroup import space.kscience.visionforge.react.visionTree -import space.kscience.visionforge.solid.SolidGroup import space.kscience.visionforge.solid.specifications.Canvas3DOptions import styled.css import styled.styledDiv -public external interface ThreeControlsProps : PropsWithChildren { +public external interface ThreeControlsProps : RProps { public var canvasOptions: Canvas3DOptions public var vision: Vision? public var selected: Name? @@ -24,7 +21,7 @@ public external interface ThreeControlsProps : PropsWithChildren { } @JsExport -public val ThreeControls: FC = fc { props -> +public val ThreeControls: FunctionComponent = functionalComponent { props -> tabPane(if (props.selected != null) "Properties" else null) { tab("Canvas") { card("Canvas configuration") { @@ -51,7 +48,7 @@ public val ThreeControls: FC = fc { props -> val selectedObject: Vision? = when { selected == null -> null selected.isEmpty() -> props.vision - else -> (props.vision as? SolidGroup)?.get(selected) + else -> (props.vision as? VisionGroup)?.get(selected) } if (selectedObject != null) { visionPropertyEditor(selectedObject, key = selected) @@ -70,7 +67,7 @@ public fun RBuilder.threeControls( selected: Name?, onSelect: (Name) -> Unit = {}, builder: TabBuilder.() -> Unit = {}, -): Unit = child(ThreeControls) { +): ReactElement = child(ThreeControls) { attrs { this.canvasOptions = canvasOptions this.vision = vision diff --git a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt index 8e7e1208..a65c1f42 100644 --- a/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt +++ b/ui/bootstrap/src/main/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt @@ -2,15 +2,13 @@ package space.kscience.visionforge.bootstrap import org.w3c.dom.Element import react.RBuilder +import react.dom.render import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.isEmpty import space.kscience.visionforge.Vision +import space.kscience.visionforge.computeProperties import space.kscience.visionforge.getStyle -import space.kscience.visionforge.react.EditorPropertyState -import space.kscience.visionforge.react.PropertyEditor import space.kscience.visionforge.react.metaViewer -import space.kscience.visionforge.react.render -import space.kscience.visionforge.root +import space.kscience.visionforge.react.propertyEditor import space.kscience.visionforge.solid.SolidReference import space.kscience.visionforge.styles @@ -21,26 +19,12 @@ public fun RBuilder.visionPropertyEditor( ) { card("Properties") { - child(PropertyEditor) { - attrs { - this.key = key?.toString() - this.meta = vision.properties.root() - this.updates = vision.properties.changes - 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) - if (ownMeta != null && !ownMeta.isEmpty()) { - EditorPropertyState.Defined - } else if (vision.properties.root().getValue(name) != null) { - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - } - } - } + propertyEditor( + ownProperties = vision.meta, + allProperties = vision.computeProperties(), + descriptor = descriptor, + key = key + ) } val styles = if (vision is SolidReference) { (vision.styles + vision.prototype.styles).distinct() @@ -66,6 +50,6 @@ public fun RBuilder.visionPropertyEditor( public fun Element.visionPropertyEditor( item: Vision, descriptor: MetaDescriptor? = item.descriptor, -): Unit = space.kscience.visionforge.react.createRoot(this).render { +): Unit = render(this) { visionPropertyEditor(item, descriptor = descriptor) } \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeJS.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeJS.kt deleted file mode 100644 index 6033c712..00000000 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeJS.kt +++ /dev/null @@ -1,11 +0,0 @@ -package space.kscience.visionforge.compose - -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable - -@Composable -public fun ThreeJs(){ - Surface { - - } -} \ No newline at end of file diff --git a/ui/react/README.md b/ui/react/README.md deleted file mode 100644 index 9f862213..00000000 --- a/ui/react/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module react - - - diff --git a/ui/react/build.gradle.kts b/ui/react/build.gradle.kts index acbe40cb..40853ca9 100644 --- a/ui/react/build.gradle.kts +++ b/ui/react/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("space.kscience.gradle.js") + id("ru.mipt.npm.gradle.js") } dependencies{ diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/MetaViewer.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/MetaViewer.kt index d6fff754..69683bc5 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/MetaViewer.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/MetaViewer.kt @@ -3,7 +3,7 @@ package space.kscience.visionforge.react import kotlinx.css.Align import kotlinx.css.alignItems import kotlinx.html.js.onClickFunction -import kotlinx.html.org.w3c.dom.events.Event +import org.w3c.dom.events.Event import react.* import react.dom.a import react.dom.attrs @@ -20,7 +20,7 @@ import styled.css import styled.styledDiv import styled.styledSpan -public external interface MetaViewerProps : Props { +public external interface MetaViewerProps : RProps { /** * Root meta */ @@ -42,7 +42,7 @@ public external interface MetaViewerProps : Props { public var descriptor: MetaDescriptor? } -private val MetaViewerItem: FC = fc("MetaViewerItem") { props -> +private val MetaViewerItem: FunctionComponent = functionalComponent("MetaViewerItem") { props -> metaViewerItem(props) } @@ -127,16 +127,17 @@ private fun RBuilder.metaViewerItem(props: MetaViewerProps) { } @JsExport -public val MetaViewer: FC = fc("MetaViewer") { props -> - child(MetaViewerItem) { - attrs { - this.key = "" - this.root = props.root - this.name = Name.EMPTY - this.descriptor = props.descriptor +public val MetaViewer: FunctionComponent = + functionalComponent("MetaViewer") { props -> + child(MetaViewerItem) { + attrs { + this.key = "" + this.root = props.root + this.name = Name.EMPTY + this.descriptor = props.descriptor + } } } -} public fun RBuilder.metaViewer(meta: Meta, descriptor: MetaDescriptor? = null, key: Any? = null) { child(MetaViewer) { 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 5e8da06c..84181340 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 @@ -1,38 +1,39 @@ package space.kscience.visionforge.react import kotlinx.html.js.onChangeFunction -import kotlinx.html.org.w3c.dom.events.Event import org.w3c.dom.HTMLOptionElement import org.w3c.dom.HTMLSelectElement import org.w3c.dom.asList -import react.FC +import org.w3c.dom.events.Event +import react.FunctionComponent import react.dom.attrs import react.dom.option import react.dom.select -import react.fc -import space.kscience.dataforge.meta.asValue +import react.functionalComponent import space.kscience.dataforge.meta.descriptors.allowedValues -import space.kscience.dataforge.meta.string +import space.kscience.dataforge.values.asValue +import space.kscience.dataforge.values.string @JsExport -public val MultiSelectChooser: FC = fc("MultiSelectChooser") { props -> - val onChange: (Event) -> Unit = { event: Event -> - val newSelected = (event.target as HTMLSelectElement).selectedOptions.asList() - .map { (it as HTMLOptionElement).value.asValue() } - props.onValueChange(newSelected.asValue()) - } - - select { - attrs { - multiple = true - values = (props.value?.list ?: emptyList()).mapTo(HashSet()) { it.string } - onChangeFunction = onChange +public val MultiSelectChooser: FunctionComponent = + functionalComponent("MultiSelectChooser") { props -> + val onChange: (Event) -> Unit = { event: Event -> + val newSelected = (event.target as HTMLSelectElement).selectedOptions.asList() + .map { (it as HTMLOptionElement).value.asValue() } + props.meta.value = newSelected.asValue() } - props.descriptor?.allowedValues?.forEach { optionValue -> - option { - +optionValue.string + + select { + attrs { + multiple = true + values = (props.actual.value?.list ?: emptyList()).mapTo(HashSet()) { it.string } + onChangeFunction = onChange + } + props.descriptor?.allowedValues?.forEach { optionValue -> + option { + +optionValue.string + } } - } - } -} \ No newline at end of file + } + } \ No newline at end of file diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt index a31a04fb..9ff77f2c 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt @@ -1,18 +1,13 @@ package space.kscience.visionforge.react -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.launch import kotlinx.css.* import kotlinx.css.properties.TextDecoration import kotlinx.html.js.onClickFunction -import kotlinx.html.org.w3c.dom.events.Event +import org.w3c.dom.Element +import org.w3c.dom.events.Event import react.* import react.dom.attrs +import react.dom.render import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.ValueRequirement @@ -24,30 +19,17 @@ import styled.styledButton import styled.styledDiv import styled.styledSpan -/** - * The display state of a property - */ -public sealed class EditorPropertyState { - public object Defined : EditorPropertyState() - public class Default(public val source: String = "unknown") : EditorPropertyState() - - public object Undefined : EditorPropertyState() - -} - - -public external interface PropertyEditorProps : Props { +public external interface PropertyEditorProps : RProps { /** * Root config object - always non-null */ - public var meta: MutableMeta + public var meta: ObservableMutableMeta - public var getPropertyState: (Name) -> EditorPropertyState - - public var scope: CoroutineScope - - public var updates: Flow + /** + * Provide default item (greyed out if used) + */ + public var withDefault: MetaProvider /** * Full path to the displayed node in [meta]. Could be empty @@ -65,16 +47,15 @@ public external interface PropertyEditorProps : Props { public var expanded: Boolean? } -private val PropertyEditorItem: FC = fc("PropertyEditorItem") { props -> - propertyEditorItem(props) -} +private val PropertyEditorItem: FunctionComponent = + functionalComponent("PropertyEditorItem") { props -> + propertyEditorItem(props) + } private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { var expanded: Boolean by useState { props.expanded ?: true } val descriptor: MetaDescriptor? = useMemo(props.descriptor, props.name) { props.descriptor?.get(props.name) } - var property: MutableMeta by useState { props.meta.getOrCreate(props.name) } - var editorPropertyState: EditorPropertyState by useState { props.getPropertyState(props.name) } - + var ownProperty: ObservableMutableMeta by useState { props.meta.getOrCreate(props.name) } val keys = useMemo(descriptor) { buildSet { @@ -90,19 +71,17 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { val token = props.name.lastOrNull()?.toString() ?: "Properties" fun update() { - property = props.meta.getOrCreate(props.name) - editorPropertyState = props.getPropertyState(props.name) + ownProperty = props.meta.getOrCreate(props.name) } useEffect(props.meta) { - val job = props.updates.onEach { updatedName -> + props.meta.onChange(props) { updatedName -> if (updatedName == props.name) { update() } - }.launchIn(props.scope) - + } cleanup { - job.cancel() + props.meta.removeListener(props) } } @@ -137,7 +116,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { styledSpan { css { +TreeStyles.treeLabel - if (editorPropertyState != EditorPropertyState.Defined) { + if (ownProperty.isEmpty()) { +TreeStyles.treeLabelInactive } } @@ -150,15 +129,11 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { width = 160.px margin(1.px, 5.px) } - ValueChooser { + ValueChooser{ attrs { this.descriptor = descriptor - this.state = editorPropertyState - this.value = property.value - this.onValueChange = { - property.value = it - editorPropertyState = props.getPropertyState(props.name) - } + this.meta = ownProperty + this.actual = props.withDefault.getMeta(props.name) ?: ownProperty } } } @@ -182,7 +157,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { } +"\u00D7" attrs { - if (editorPropertyState!= EditorPropertyState.Defined) { + if (ownProperty.isEmpty()) { disabled = true } else { onClickFunction = removeClick @@ -205,11 +180,9 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { attrs { this.key = props.name.toString() this.meta = props.meta + this.withDefault = props.withDefault this.name = props.name + token this.descriptor = props.descriptor - this.scope = props.scope - this.getPropertyState = { props.getPropertyState(props.name + token) } - this.updates = props.updates } } //configEditor(props.root, props.name + token, props.descriptor, props.default) @@ -220,56 +193,49 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { } @JsExport -public val PropertyEditor: FC = fc("PropertyEditor") { props -> +public val PropertyEditor: FunctionComponent = functionalComponent("PropertyEditor") { props -> child(PropertyEditorItem) { attrs { this.key = "" this.meta = props.meta + this.withDefault = props.withDefault this.name = Name.EMPTY this.descriptor = props.descriptor this.expanded = props.expanded - this.scope = props.scope - this.getPropertyState = props.getPropertyState - this.updates = props.updates } } } -@OptIn(ExperimentalCoroutinesApi::class) public fun RBuilder.propertyEditor( - scope: CoroutineScope, - properties: ObservableMutableMeta, + ownProperties: ObservableMutableMeta, + allProperties: MetaProvider = ownProperties, descriptor: MetaDescriptor? = null, key: Any? = null, - expanded: Boolean? = null, + expanded: Boolean? = null ) { child(PropertyEditor) { attrs { - this.meta = properties + this.meta = ownProperties + this.withDefault = allProperties this.descriptor = descriptor this.key = key?.toString() ?: "" this.expanded = expanded - this.scope = scope - this.getPropertyState = { name -> - if (properties[name] != null) { - EditorPropertyState.Defined - } else if (descriptor?.get(name)?.defaultValue != null) { - EditorPropertyState.Default("descriptor") - } else { - EditorPropertyState.Undefined - } - } - this.updates = callbackFlow { - properties.onChange(scope) { name -> - scope.launch { - send(name) - } - } - - invokeOnClose { - properties.removeListener(scope) - } - } } } +} + +public fun RBuilder.configEditor( + config: ObservableMutableMeta, + default: MetaProvider = config, + descriptor: MetaDescriptor? = null, + key: Any? = null, +): Unit = propertyEditor(config, default, descriptor, key = key) + +public fun Element.configEditor( + config: ObservableMutableMeta, + default: Meta = config, + descriptor: MetaDescriptor? = null, + key: Any? = null, +): Unit = render(this) { + configEditor(config, default, descriptor, key = key) } \ No newline at end of file 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 3ebe4d51..c753271f 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 @@ -4,74 +4,73 @@ import kotlinx.css.pct import kotlinx.css.width import kotlinx.html.InputType import kotlinx.html.js.onChangeFunction -import kotlinx.html.org.w3c.dom.events.Event import org.w3c.dom.HTMLInputElement -import react.FC +import org.w3c.dom.events.Event +import react.FunctionComponent import react.dom.attrs -import react.fc +import react.functionalComponent 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 @JsExport -public val RangeValueChooser: FC = fc("RangeValueChooser") { props -> - var innerValue by useState(props.value?.double) - var rangeDisabled: Boolean by useState(props.state != EditorPropertyState.Defined) +public val RangeValueChooser: FunctionComponent = + functionalComponent("RangeValueChooser") { props -> + var innerValue by useState(props.actual.double) + var rangeDisabled: Boolean by useState(props.meta.value == null) - val handleDisable: (Event) -> Unit = { - val checkBoxValue = (it.target as HTMLInputElement).checked - rangeDisabled = !checkBoxValue - props.onValueChange( - if (!checkBoxValue) { + val handleDisable: (Event) -> Unit = { + val checkBoxValue = (it.target as HTMLInputElement).checked + rangeDisabled = !checkBoxValue + props.meta.value = if(!checkBoxValue) { null } else { innerValue?.asValue() } - ) - } + } - val handleChange: (Event) -> Unit = { - val newValue = (it.target as HTMLInputElement).value - props.onValueChange(newValue.toDoubleOrNull()?.asValue()) - innerValue = newValue.toDoubleOrNull() - } + val handleChange: (Event) -> Unit = { + val newValue = (it.target as HTMLInputElement).value + props.meta.value = newValue.toDoubleOrNull()?.asValue() + innerValue = newValue.toDoubleOrNull() + } - flexRow { - if (props.descriptor?.valueRequirement != ValueRequirement.REQUIRED) { - styledInput(type = InputType.checkBox) { + flexRow { + if(props.descriptor?.valueRequirement != ValueRequirement.REQUIRED) { + styledInput(type = InputType.checkBox) { + attrs { + defaultChecked = rangeDisabled.not() + onChangeFunction = handleDisable + } + } + } + + styledInput(type = InputType.range) { + css{ + width = 100.pct + } attrs { - defaultChecked = rangeDisabled.not() - onChangeFunction = handleDisable + disabled = rangeDisabled + value = innerValue?.toString() ?: "" + onChangeFunction = handleChange + consumer.onTagEvent(this, "input", handleChange) + val minValue = props.descriptor?.attributes?.get("min").string + minValue?.let { + min = it + } + val maxValue = props.descriptor?.attributes?.get("max").string + maxValue?.let { + max = it + } + props.descriptor?.attributes?.get("step").string?.let { + step = it + } } } } - - styledInput(type = InputType.range) { - css { - width = 100.pct - } - attrs { - disabled = rangeDisabled - value = innerValue?.toString() ?: "" - onChangeFunction = handleChange - consumer.onTagEvent(this, "input", handleChange) - val minValue = props.descriptor?.attributes?.get("min").string - minValue?.let { - min = it - } - val maxValue = props.descriptor?.attributes?.get("max").string - maxValue?.let { - max = it - } - props.descriptor?.attributes?.get("step").string?.let { - step = it - } - } - } - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt index 8cfa515d..6be75689 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt @@ -2,9 +2,10 @@ package space.kscience.visionforge.react import kotlinx.css.* import org.w3c.dom.Element +import org.w3c.dom.HTMLElement import react.* import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.names.Name import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.specifications.Canvas3DOptions @@ -13,22 +14,24 @@ import space.kscience.visionforge.solid.three.ThreePlugin import styled.css import styled.styledDiv -public external interface ThreeCanvasProps : Props { +public external interface ThreeCanvasProps : RProps { public var context: Context public var options: Canvas3DOptions? public var solid: Solid? public var selected: Name? } -public val ThreeCanvasComponent: FC = fc("ThreeCanvasComponent") { props -> +public val ThreeCanvasComponent: FunctionComponent = functionalComponent( + "ThreeCanvasComponent" +) { props -> val elementRef = useRef(null) var canvas by useState(null) - val three: ThreePlugin = useMemo(props.context) { props.context.request(ThreePlugin) } + val three: ThreePlugin = useMemo(props.context){ props.context.fetch(ThreePlugin) } useEffect(props.solid, props.options, elementRef) { if (canvas == null) { - val element = elementRef.current ?: error("Canvas element not found") + val element = elementRef.current as? HTMLElement ?: error("Canvas element not found") canvas = ThreeCanvas(three, element, props.options ?: Canvas3DOptions()) } } diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/VisionTree.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/VisionTree.kt index 8ec0185c..6be045d6 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/VisionTree.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/VisionTree.kt @@ -7,7 +7,7 @@ import kotlinx.css.cursor import kotlinx.css.properties.TextDecorationLine import kotlinx.css.properties.textDecoration import kotlinx.html.js.onClickFunction -import kotlinx.html.org.w3c.dom.events.Event +import org.w3c.dom.events.Event import react.* import react.dom.attrs import space.kscience.dataforge.names.Name @@ -16,20 +16,19 @@ import space.kscience.dataforge.names.plus import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionGroup -import space.kscience.visionforge.asSequence import space.kscience.visionforge.isEmpty import styled.css import styled.styledDiv import styled.styledSpan -public external interface ObjectTreeProps : Props { +public external interface ObjectTreeProps : RProps { public var name: Name public var selected: Name? public var obj: Vision public var clickCallback: (Name) -> Unit } -private val TreeLabel = fc { props -> +private val TreeLabel = functionalComponent { props -> val token = useMemo(props.name) { props.name.lastOrNull()?.toString() ?: "World" } styledSpan { css { @@ -62,7 +61,7 @@ private fun RBuilder.visionTree(props: ObjectTreeProps): Unit { //display as node if any child is visible if (obj is VisionGroup) { flexRow { - if (obj.children.keys.any { !it.body.startsWith("@") }) { + if (obj.children.any { !it.key.body.startsWith("@") }) { styledSpan { css { +TreeStyles.treeCaret @@ -82,9 +81,9 @@ private fun RBuilder.visionTree(props: ObjectTreeProps): Unit { css { +TreeStyles.tree } - obj.children.asSequence() - .filter { !it.first.toString().startsWith("@") } // ignore statics and other hidden children - .sortedBy { (it.second as? VisionGroup)?.children?.isEmpty() ?: true } // ignore empty groups + obj.children.entries + .filter { !it.key.toString().startsWith("@") } // ignore statics and other hidden children + .sortedBy { (it.value as? VisionGroup)?.isEmpty ?: true } // ignore empty groups .forEach { (childToken, child) -> styledDiv { css { @@ -108,14 +107,14 @@ private fun RBuilder.visionTree(props: ObjectTreeProps): Unit { } @JsExport -public val ObjectTree: FC = fc("ObjectTree") { props -> +public val ObjectTree: FunctionComponent = functionalComponent("ObjectTree") { props -> visionTree(props) } public fun RBuilder.visionTree( vision: Vision, selected: Name? = null, - clickCallback: (Name) -> Unit = {}, + clickCallback: (Name) -> Unit = {} ) { child(ObjectTree) { attrs { diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/createRoot.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/createRoot.kt deleted file mode 100644 index fec86770..00000000 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/createRoot.kt +++ /dev/null @@ -1,17 +0,0 @@ - -@file:JsModule("react-dom/client") -@file:JsNonModule - -package space.kscience.visionforge.react - -import org.w3c.dom.Element -import react.dom.client.Root -import react.dom.client.RootOptions - -/** - * Compatibility method to work with old browser API - */ -public external fun createRoot( - container: Element, - options: RootOptions = definedExternally, -): Root diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt deleted file mode 100644 index ae47fa65..00000000 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt +++ /dev/null @@ -1,10 +0,0 @@ -package space.kscience.visionforge.react - -import react.Props -import react.RBuilder -import react.createElement -import react.dom.client.Root - -public fun Root.render(block: RBuilder.() -> Unit) { - render(createElement(block)) -} \ No newline at end of file diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/layout.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/layout.kt index 11a13561..e8d928f5 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/layout.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/layout.kt @@ -6,13 +6,14 @@ import kotlinx.css.display import kotlinx.css.flexDirection import kotlinx.html.DIV import react.RBuilder +import react.ReactElement import styled.StyledDOMBuilder import styled.css import styled.styledDiv public inline fun RBuilder.flexColumn( block: StyledDOMBuilder
.() -> Unit -): Unit = styledDiv { +): ReactElement = styledDiv { css { display = Display.flex flexDirection = FlexDirection.column @@ -22,7 +23,7 @@ public inline fun RBuilder.flexColumn( public inline fun RBuilder.flexRow( block: StyledDOMBuilder
.() -> Unit -): Unit = styledDiv { +): ReactElement = styledDiv { css { display = Display.flex flexDirection = FlexDirection.row 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 bc6f1979..711710f6 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 @@ -7,158 +7,162 @@ import kotlinx.css.width import kotlinx.html.InputType import kotlinx.html.js.onChangeFunction import kotlinx.html.js.onKeyDownFunction -import kotlinx.html.org.w3c.dom.events.Event import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLSelectElement -import react.FC -import react.Props +import org.w3c.dom.events.Event +import react.* import react.dom.attrs import react.dom.option -import react.fc -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 import styled.styledInput import styled.styledSelect -import three.math.Color -public external interface ValueChooserProps : Props { +public external interface ValueChooserProps : RProps { public var descriptor: MetaDescriptor? - public var state: EditorPropertyState - public var value: Value? - public var onValueChange: (Value?) -> Unit + public var meta: ObservableMutableMeta + public var actual: Meta } @JsExport -public val StringValueChooser: FC = fc("StringValueChooser") { props -> - var value by useState(props.value?.string ?: "") - val keyDown: (Event) -> Unit = { event -> - if (event.type == "keydown" && event.asDynamic().key == "Enter") { - value = (event.target as HTMLInputElement).value - props.onValueChange(value.asValue()) +public val StringValueChooser: FunctionComponent = + functionalComponent("StringValueChooser") { props -> + var value by useState(props.actual.string ?: "") + val keyDown: (Event) -> Unit = { event -> + if (event.type == "keydown" && event.asDynamic().key == "Enter") { + value = (event.target as HTMLInputElement).value + props.meta.value = value.asValue() + } } - } - val handleChange: (Event) -> Unit = { - value = (it.target as HTMLInputElement).value - } - styledInput(type = InputType.text) { - css { - width = 100.pct + val handleChange: (Event) -> Unit = { + value = (it.target as HTMLInputElement).value } - attrs { - this.value = value - onKeyDownFunction = keyDown - onChangeFunction = handleChange - } - } -} - -@JsExport -public val BooleanValueChooser: FC = fc("BooleanValueChooser") { props -> - val handleChange: (Event) -> Unit = { - val newValue = (it.target as HTMLInputElement).checked - props.onValueChange(newValue.asValue()) - } - styledInput(type = InputType.checkBox) { - css { - width = 100.pct - } - attrs { - //this.attributes["indeterminate"] = (props.item == null).toString() - checked = props.value?.boolean ?: false - onChangeFunction = handleChange - } - } -} - -@JsExport -public val NumberValueChooser: FC = fc("NumberValueChooser") { props -> - var innerValue by useState(props.value?.string ?: "") - val keyDown: (Event) -> Unit = { event -> - if (event.type == "keydown" && event.asDynamic().key == "Enter") { - innerValue = (event.target as HTMLInputElement).value - val number = innerValue.toDoubleOrNull() - if (number == null) { - console.error("The input value $innerValue is not a number") - } else { - props.onValueChange(number.asValue()) + styledInput(type = InputType.text) { + css { + width = 100.pct + } + attrs { + this.value = value + onKeyDownFunction = keyDown + onChangeFunction = handleChange } } } - val handleChange: (Event) -> Unit = { - innerValue = (it.target as HTMLInputElement).value - } - styledInput(type = InputType.number) { - css { - width = 100.pct - } - attrs { - value = innerValue - onKeyDownFunction = keyDown - onChangeFunction = handleChange - props.descriptor?.attributes?.get("step").string?.let { - step = it - } - props.descriptor?.attributes?.get("min").string?.let { - min = it - } - props.descriptor?.attributes?.get("max").string?.let { - max = it - } - } - } -} @JsExport -public val ComboValueChooser: FC = fc("ComboValueChooser") { props -> - var selected by useState(props.value?.string ?: "") - val handleChange: (Event) -> Unit = { - selected = (it.target as HTMLSelectElement).value - props.onValueChange(selected.asValue()) - } - styledSelect { - css { - width = 100.pct +public val BooleanValueChooser: FunctionComponent = + functionalComponent("BooleanValueChooser") { props -> + val handleChange: (Event) -> Unit = { + val newValue = (it.target as HTMLInputElement).checked + props.meta.value = newValue.asValue() } - props.descriptor?.allowedValues?.forEach { - option { - +it.string + styledInput(type = InputType.checkBox) { + css { + width = 100.pct + } + attrs { + //this.attributes["indeterminate"] = (props.item == null).toString() + checked = props.actual.boolean ?: false + onChangeFunction = handleChange } } - attrs { - this.value = props.value?.string ?: "" - multiple = false - onChangeFunction = handleChange - } } -} @JsExport -public val ColorValueChooser: FC = fc("ColorValueChooser") { props -> - val handleChange: (Event) -> Unit = { - props.onValueChange((it.target as HTMLInputElement).value.asValue()) - } - styledInput(type = InputType.color) { - css { - width = 100.pct - margin(0.px) +public val NumberValueChooser: FunctionComponent = + functionalComponent("NumberValueChooser") { props -> + var innerValue by useState(props.actual.string ?: "") + val keyDown: (Event) -> Unit = { event -> + if (event.type == "keydown" && event.asDynamic().key == "Enter") { + innerValue = (event.target as HTMLInputElement).value + val number = innerValue.toDoubleOrNull() + if (number == null) { + console.error("The input value $innerValue is not a number") + } else { + props.meta.value = number.asValue() + } + } } - attrs { - this.value = props.value?.let { value -> - if (value.type == ValueType.NUMBER) Colors.rgbToString(value.int) - else "#" + Color(value.string).getHexString() - } ?: "#000000" - onChangeFunction = handleChange + val handleChange: (Event) -> Unit = { + innerValue = (it.target as HTMLInputElement).value + } + styledInput(type = InputType.number) { + css { + width = 100.pct + } + attrs { + value = innerValue + onKeyDownFunction = keyDown + onChangeFunction = handleChange + props.descriptor?.attributes?.get("step").string?.let { + step = it + } + props.descriptor?.attributes?.get("min").string?.let { + min = it + } + props.descriptor?.attributes?.get("max").string?.let { + max = it + } + } } } -} @JsExport -public val ValueChooser: FC = fc("ValueChooser") { props -> +public val ComboValueChooser: FunctionComponent = + functionalComponent("ComboValueChooser") { props -> + var selected by useState(props.actual.string ?: "") + val handleChange: (Event) -> Unit = { + selected = (it.target as HTMLSelectElement).value + props.meta.value = selected.asValue() + } + styledSelect { + css { + width = 100.pct + } + props.descriptor?.allowedValues?.forEach { + option { + +it.string + } + } + attrs { + this.value = props.actual.string ?: "" + multiple = false + onChangeFunction = handleChange + } + } + } + +@JsExport +public val ColorValueChooser: FunctionComponent = + functionalComponent("ColorValueChooser") { props -> + val handleChange: (Event) -> Unit = { + props.meta.value = (it.target as HTMLInputElement).value.asValue() + } + styledInput(type = InputType.color) { + css { + width = 100.pct + margin(0.px) + } + attrs { + this.value = props.actual.value?.let { value -> + if (value.type == ValueType.NUMBER) Colors.rgbToString(value.int) + else value.string + } ?: "#000000" + onChangeFunction = handleChange + } + } + } + +@JsExport +public val ValueChooser: FunctionComponent = functionalComponent("ValueChooser") { props -> val rawInput by useState(false) val descriptor = props.descriptor diff --git a/ui/ring/README.md b/ui/ring/README.md deleted file mode 100644 index 6cdcbb60..00000000 --- a/ui/ring/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module ring - - - diff --git a/ui/ring/build.gradle.kts b/ui/ring/build.gradle.kts index 8b4bf056..53dee008 100644 --- a/ui/ring/build.gradle.kts +++ b/ui/ring/build.gradle.kts @@ -1,17 +1,15 @@ plugins { - id("space.kscience.gradle.js") + id("ru.mipt.npm.gradle.js") } val dataforgeVersion: String by rootProject.extra kotlin{ - js(IR){ + js{ useCommonJs() browser { commonWebpackConfig { - cssSupport{ - enabled.set(false) - } + cssSupport.enabled = false } } } diff --git a/ui/ring/src/main/kotlin/ringui/Loader.kt b/ui/ring/src/main/kotlin/ringui/Loader.kt index b7bc63a9..c58d51c1 100644 --- a/ui/ring/src/main/kotlin/ringui/Loader.kt +++ b/ui/ring/src/main/kotlin/ringui/Loader.kt @@ -4,11 +4,10 @@ package ringui import react.ComponentClass -import react.PropsWithClassName - +import react.dom.WithClassName // https://github.com/JetBrains/ring-ui/blob/master/components/loader/loader.js -public external interface LoaderProps : PropsWithClassName { +public external interface LoaderProps : WithClassName { public var size: Number public var colors: Array public var message: String diff --git a/ui/ring/src/main/kotlin/ringui/LoaderScreen.kt b/ui/ring/src/main/kotlin/ringui/LoaderScreen.kt index d662ee2b..8d0bf578 100644 --- a/ui/ring/src/main/kotlin/ringui/LoaderScreen.kt +++ b/ui/ring/src/main/kotlin/ringui/LoaderScreen.kt @@ -4,10 +4,10 @@ package ringui import react.ComponentClass -import react.PropsWithClassName +import react.dom.WithClassName // https://github.com/JetBrains/ring-ui/blob/master/components/loader-screen/loader-screen.js -public external interface LoaderScreenProps : PropsWithClassName { +public external interface LoaderScreenProps : WithClassName { public var containerClassName: String public var message: String } diff --git a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt index 3b7133e9..e69b04c9 100644 --- a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt +++ b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt @@ -5,52 +5,47 @@ import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlinx.css.* import react.* -import react.dom.b import react.dom.div -import react.dom.p import react.dom.span import ringui.* -import space.kscience.dataforge.meta.get +import space.kscience.dataforge.context.Context import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.isEmpty import space.kscience.dataforge.names.length -import space.kscience.visionforge.* -import space.kscience.visionforge.react.* +import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionGroup +import space.kscience.visionforge.computeProperties +import space.kscience.visionforge.react.ThreeCanvasComponent +import space.kscience.visionforge.react.flexColumn +import space.kscience.visionforge.react.flexRow +import space.kscience.visionforge.react.propertyEditor import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.solidGroup import space.kscience.visionforge.solid.specifications.Canvas3DOptions import styled.css import styled.styledDiv -public external interface ThreeCanvasWithControlsProps : Props { - public var solids: Solids +public external interface ThreeCanvasWithControlsProps : RProps { + public var context: Context public var builderOfSolid: Deferred public var selected: Name? public var options: Canvas3DOptions? public var additionalTabs: Map Unit>? } -private val ThreeCanvasWithControlsProps.context get() = solids.context - public fun ThreeCanvasWithControlsProps.solid(block: SolidGroup.() -> Unit) { builderOfSolid = context.async { - solids.solidGroup(null, block) + SolidGroup(block) } } -public fun ThreeCanvasWithControlsProps.options(block: Canvas3DOptions.() -> Unit) { - options = Canvas3DOptions(block) -} - public fun ThreeCanvasWithControlsProps.tab(title: String, block: RBuilder.() -> Unit) { additionalTabs = (additionalTabs ?: emptyMap()) + (title to block) } -public fun RBuilder.nameCrumbs(name: Name?, link: (Name) -> Unit): Unit = styledDiv { +public fun RBuilder.nameCrumbs(name: Name?, link: (Name) -> Unit): ReactElement = styledDiv { div { Link { attrs { @@ -83,130 +78,108 @@ public fun RBuilder.nameCrumbs(name: Name?, link: (Name) -> Unit): Unit = styled } @JsExport -public val ThreeCanvasWithControls: FC = fc("ThreeViewWithControls") { props -> - var selected: Name? by useState { props.selected } - var solid: Solid? by useState(null) +public val ThreeCanvasWithControls: FunctionComponent = + functionalComponent("ThreeViewWithControls") { props -> + var selected by useState { props.selected } + var solid: Solid? by useState(null) - useEffect { - props.context.launch { - solid = props.builderOfSolid.await() - //ensure that the solid is properly rooted - if (solid?.parent == null) { - solid?.setAsRoot(props.context.visionManager) + useEffect { + props.context.launch { + solid = props.builderOfSolid.await() } } - } - val onSelect: (Name?) -> Unit = { - selected = it - } - - val options = useMemo(props.options) { - (props.options ?: Canvas3DOptions()).apply { - this.onSelect = onSelect + val onSelect: (Name?) -> Unit = { + selected = it } - } - val selectedVision: Vision? = useMemo(props.builderOfSolid, selected) { - selected?.let { - when { - it.isEmpty() -> solid - else -> (solid as? SolidGroup)?.get(it) + val options = useMemo(props.options) { + (props.options?: Canvas3DOptions()).apply { + this.onSelect = onSelect } } - } - - flexRow { - css { - height = 100.pct - width = 100.pct - flexWrap = FlexWrap.wrap - alignItems = Align.stretch - alignContent = Align.stretch + val selectedVision: Vision? = useMemo(props.builderOfSolid, selected) { + selected?.let { + when { + it.isEmpty() -> solid + else -> (solid as? VisionGroup)?.get(it) + } + } } - flexColumn { + + flexRow { css { height = 100.pct - minWidth = 600.px - flex(10.0, 1.0, FlexBasis("600px")) - position = Position.relative + width = 100.pct + flexWrap = FlexWrap.wrap + alignItems = Align.stretch + alignContent = Align.stretch } - if (solid == null) { - LoaderScreen { - attrs { - message = "Loading Three vision" - } + flexColumn { + css { + height = 100.pct + minWidth = 600.px + flex(10.0, 1.0, FlexBasis("600px")) + position = Position.relative } - } else { - child(ThreeCanvasComponent) { - attrs { - this.context = props.context - this.solid = solid - this.selected = selected - this.options = options - } - } - } - selectedVision?.let { vision -> - styledDiv { - css { - position = Position.absolute - top = 5.px - right = 5.px - width = 450.px - } - Island { - IslandHeader { - attrs { - border = true - } - nameCrumbs(selected) { selected = it } + if (solid == null) { + LoaderScreen { + attrs { + message = "Loading Three vision" } - IslandContent { - child(PropertyEditor) { + } + } else { + child(ThreeCanvasComponent) { + attrs { + this.context = props.context + this.solid = solid + this.selected = selected + this.options = options + } + } + } + + selectedVision?.let { vision -> + styledDiv { + css { + position = Position.absolute + top = 5.px + right = 5.px + width = 450.px + } + Island { + IslandHeader { attrs { - this.key = selected.toString() - this.meta = vision.properties.root() - this.updates = vision.properties.changes - this.descriptor = vision.descriptor - this.scope = props.context - this.getPropertyState = { name -> - if (vision.properties.own?.get(name) != null) { - EditorPropertyState.Defined - } else if (vision.properties.root()[name] != null) { - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - } + border = true } + nameCrumbs(selected) { selected = it } } - vision.styles.takeIf { it.isNotEmpty() }?.let { styles -> - p { - b { +"Styles: " } - +styles.joinToString(separator = ", ") - } + IslandContent { + propertyEditor( + ownProperties = vision.meta, + allProperties = vision.computeProperties(), + descriptor = vision.descriptor, + key = selected + ) } } } } } - } - flexColumn { - css { - padding(4.px) - minWidth = 400.px - height = 100.pct - overflowY = Overflow.auto - flex(1.0, 10.0, FlexBasis("300px")) + flexColumn { + css { + padding(4.px) + minWidth = 400.px + height = 100.pct + overflowY = Overflow.auto + flex(1.0, 10.0, FlexBasis("300px")) + } + ringThreeControls(options, solid, selected, onSelect, additionalTabs = props.additionalTabs) } - ringThreeControls(options, solid, selected, onSelect, additionalTabs = props.additionalTabs) } } -} diff --git a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt index 94259b2f..c01b5ae1 100644 --- a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt +++ b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt @@ -2,21 +2,19 @@ package space.kscience.visionforge.ring import kotlinx.coroutines.async import org.w3c.dom.Element +import react.child import space.kscience.dataforge.context.AbstractPlugin import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.boolean -import space.kscience.dataforge.meta.get import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.visionforge.ElementVisionRenderer import space.kscience.visionforge.Vision -import space.kscience.visionforge.react.render import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.specifications.Canvas3DOptions import space.kscience.visionforge.solid.three.ThreePlugin +import kotlin.reflect.KClass public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { public val three: ThreePlugin by require(ThreePlugin) @@ -26,17 +24,12 @@ public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { override fun rateVision(vision: Vision): Int = if (vision is Solid) ElementVisionRenderer.DEFAULT_RATING * 2 else ElementVisionRenderer.ZERO_RATING - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { - if(meta["controls.enabled"].boolean == false){ - three.render(element, name, vision, meta) - } else { - space.kscience.visionforge.react.createRoot(element).render { - child(ThreeCanvasWithControls) { - attrs { - this.solids = three.solids - this.options = Canvas3DOptions.read(meta) - this.builderOfSolid = context.async { vision as Solid } - } + override fun render(element: Element, vision: Vision, meta: Meta) { + react.dom.render(element) { + child(ThreeCanvasWithControls) { + attrs { + this.context = this@ThreeWithControlsPlugin.context + this.builderOfSolid = context.async { vision as Solid} } } } @@ -51,7 +44,7 @@ public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.threejs.withControls", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): ThreeWithControlsPlugin = ThreeWithControlsPlugin() + override val type: KClass = ThreeWithControlsPlugin::class + override fun invoke(meta: Meta, context: Context): ThreeWithControlsPlugin = ThreeWithControlsPlugin() } } \ No newline at end of file diff --git a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt index 83529d28..06f2a1c0 100644 --- a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt +++ b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt @@ -3,15 +3,17 @@ package space.kscience.visionforge.ring import org.w3c.dom.Element import react.RBuilder import react.dom.p +import react.dom.render import ringui.Island import ringui.SmartTabs import ringui.Tab import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.get import space.kscience.visionforge.Vision +import space.kscience.visionforge.computeProperties import space.kscience.visionforge.getStyle -import space.kscience.visionforge.react.* -import space.kscience.visionforge.root +import space.kscience.visionforge.react.flexColumn +import space.kscience.visionforge.react.metaViewer +import space.kscience.visionforge.react.propertyEditor import space.kscience.visionforge.solid.SolidReference import space.kscience.visionforge.styles @@ -28,25 +30,12 @@ public fun RBuilder.ringPropertyEditor( flexColumn { Island("Properties") { - child(PropertyEditor) { - attrs { - this.key = key?.toString() - this.meta = vision.properties.root() - this.updates = vision.properties.changes - this.descriptor = descriptor - this.scope = vision.manager?.context ?: error("Orphan vision could not be observed") - this.getPropertyState = {name-> - if(vision.properties.own?.get(name)!= null){ - EditorPropertyState.Defined - } else if(vision.properties.root()[name] != null){ - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - } - } - } + propertyEditor( + ownProperties = vision.meta, + allProperties = vision.computeProperties(), + descriptor = descriptor, + key = key + ) } if (styles.isNotEmpty()) { @@ -83,6 +72,6 @@ public fun RBuilder.ringPropertyEditor( public fun Element.ringPropertyEditor( item: Vision, descriptor: MetaDescriptor? = item.descriptor, -): Unit = createRoot(this).render { +): Unit = render(this) { ringPropertyEditor(item, descriptor = descriptor) } \ No newline at end of file diff --git a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt index d59b37b9..016ce4e0 100644 --- a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt +++ b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt @@ -1,25 +1,21 @@ package space.kscience.visionforge.ring -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope import kotlinx.css.BorderStyle import kotlinx.css.Color import kotlinx.css.padding import kotlinx.css.properties.border import kotlinx.css.px import kotlinx.html.js.onClickFunction -import kotlinx.html.org.w3c.dom.events.Event +import org.w3c.dom.events.Event import org.w3c.files.Blob import org.w3c.files.BlobPropertyBag -import react.FC -import react.Props -import react.RBuilder +import react.* import react.dom.attrs import react.dom.button -import react.fc import ringui.Island import ringui.SmartTabs import ringui.Tab +import space.kscience.dataforge.meta.withDefault import space.kscience.dataforge.names.Name import space.kscience.visionforge.Vision import space.kscience.visionforge.encodeToString @@ -39,8 +35,8 @@ internal fun saveData(event: Event, fileName: String, mimeType: String = "text/p fileSaver.saveAs(blob, fileName) } -internal fun RBuilder.canvasControls(options: Canvas3DOptions, vision: Vision?): Unit { - child(CanvasControls) { +internal fun RBuilder.canvasControls(options: Canvas3DOptions, vision: Vision?): ReactElement { + return child(CanvasControls) { attrs { this.options = options this.vision = vision @@ -48,13 +44,12 @@ internal fun RBuilder.canvasControls(options: Canvas3DOptions, vision: Vision?): } } -internal external interface CanvasControlsProps : Props { +internal external interface CanvasControlsProps : RProps { public var options: Canvas3DOptions public var vision: Vision? } -@OptIn(DelicateCoroutinesApi::class) -internal val CanvasControls: FC = fc("CanvasControls") { props -> +internal val CanvasControls: FunctionComponent = functionalComponent("CanvasControls") { props -> flexColumn { flexRow { css { @@ -77,8 +72,8 @@ internal val CanvasControls: FC = fc("CanvasControls") { pr } } propertyEditor( - scope = props.vision?.manager?.context ?: GlobalScope, - properties = props.options.meta, + ownProperties = props.options.meta, + allProperties = props.options.meta.withDefault(Canvas3DOptions.descriptor.defaultNode), descriptor = Canvas3DOptions.descriptor, expanded = false ) @@ -87,7 +82,7 @@ internal val CanvasControls: FC = fc("CanvasControls") { pr } -public external interface ThreeControlsProps : Props { +public external interface ThreeControlsProps : RProps { public var canvasOptions: Canvas3DOptions public var vision: Vision? public var selected: Name? @@ -96,7 +91,7 @@ public external interface ThreeControlsProps : Props { } @JsExport -public val ThreeControls: FC = fc { props -> +public val ThreeControls: FunctionComponent = functionalComponent { props -> SmartTabs("Tree") { props.vision?.let { Tab("Tree") { @@ -124,7 +119,7 @@ public fun RBuilder.ringThreeControls( selected: Name?, onSelect: (Name?) -> Unit = {}, additionalTabs: Map Unit>? = null -): Unit = child(ThreeControls) { +): ReactElement = child(ThreeControls) { attrs { this.canvasOptions = canvasOptions this.vision = vision diff --git a/visionforge-core/README.md b/visionforge-core/README.md deleted file mode 100644 index 2f9e6889..00000000 --- a/visionforge-core/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-core - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-core:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-core:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-core:0.2.0") -} -``` diff --git a/visionforge-core/api/visionforge-core.api b/visionforge-core/api/visionforge-core.api deleted file mode 100644 index f9099a99..00000000 --- a/visionforge-core/api/visionforge-core.api +++ /dev/null @@ -1,815 +0,0 @@ -public final class space/kscience/visionforge/Colors { - public static final field BLUE_KEY Ljava/lang/String; - public static final field GREEN_KEY Ljava/lang/String; - public static final field INSTANCE Lspace/kscience/visionforge/Colors; - public static final field RED_KEY Ljava/lang/String; - public static final field aliceblue I - public static final field antiquewhite I - public static final field aqua I - public static final field aquamarine I - public static final field azure I - public static final field beige I - public static final field bisque I - public static final field black I - public static final field blanchedalmond I - public static final field blue I - public static final field blueviolet I - public static final field brown I - public static final field burlywood I - public static final field cadetblue I - public static final field chartreuse I - public static final field chocolate I - public static final field coral I - public static final field cornflowerblue I - public static final field cornsilk I - public static final field crimson I - public static final field cyan I - public static final field darkblue I - public static final field darkcyan I - public static final field darkgoldenrod I - public static final field darkgray I - public static final field darkgreen I - public static final field darkgrey I - public static final field darkkhaki I - public static final field darkmagenta I - public static final field darkolivegreen I - public static final field darkorange I - public static final field darkorchid I - public static final field darkred I - public static final field darksalmon I - public static final field darkseagreen I - public static final field darkslateblue I - public static final field darkslategray I - public static final field darkslategrey I - public static final field darkturquoise I - public static final field darkviolet I - public static final field deeppink I - public static final field deepskyblue I - public static final field dimgray I - public static final field dimgrey I - public static final field dodgerblue I - public static final field firebrick I - public static final field floralwhite I - public static final field forestgreen I - public static final field fuchsia I - public static final field gainsboro I - public static final field ghostwhite I - public static final field gold I - public static final field goldenrod I - public static final field gray I - public static final field green I - public static final field greenyellow I - public static final field grey I - public static final field honeydew I - public static final field hotpink I - public static final field indianred I - public static final field indigo I - public static final field ivory I - public static final field khaki I - public static final field lavender I - public static final field lavenderblush I - public static final field lawngreen I - public static final field lemonchiffon I - public static final field lightblue I - public static final field lightcoral I - public static final field lightcyan I - public static final field lightgoldenrodyellow I - public static final field lightgray I - public static final field lightgreen I - public static final field lightgrey I - public static final field lightpink I - public static final field lightsalmon I - public static final field lightseagreen I - public static final field lightskyblue I - public static final field lightslategray I - public static final field lightslategrey I - public static final field lightsteelblue I - public static final field lightyellow I - public static final field lime I - public static final field limegreen I - public static final field linen I - public static final field magenta I - public static final field maroon I - public static final field mediumaquamarine I - public static final field mediumblue I - public static final field mediumorchid I - public static final field mediumpurple I - public static final field mediumseagreen I - public static final field mediumslateblue I - public static final field mediumspringgreen I - public static final field mediumturquoise I - public static final field mediumvioletred I - public static final field midnightblue I - public static final field mintcream I - public static final field mistyrose I - public static final field moccasin I - public static final field navajowhite I - public static final field navy I - public static final field oldlace I - public static final field olive I - public static final field olivedrab I - public static final field orange I - public static final field orangered I - public static final field orchid I - public static final field palegoldenrod I - public static final field palegreen I - public static final field paleturquoise I - public static final field palevioletred I - public static final field papayawhip I - public static final field peachpuff I - public static final field peru I - public static final field pink I - public static final field plum I - public static final field powderblue I - public static final field purple I - public static final field rebeccapurple I - public static final field red I - public static final field rosybrown I - public static final field royalblue I - public static final field saddlebrown I - public static final field salmon I - public static final field sandybrown I - public static final field seagreen I - public static final field seashell I - public static final field sienna I - public static final field silver I - public static final field skyblue I - public static final field slateblue I - public static final field slategray I - public static final field slategrey I - public static final field snow I - public static final field springgreen I - public static final field steelblue I - public static final field tan I - public static final field teal I - public static final field thistle I - public static final field tomato I - public static final field turquoise I - public static final field violet I - public static final field wheat I - public static final field white I - public static final field whitesmoke I - public static final field yellow I - public static final field yellowgreen I - public final fun fromMeta (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/String; - public final fun rgbToString (I)Ljava/lang/String; - public final fun rgbToString-8NGXxBw (BBB)Ljava/lang/String; -} - -public final class space/kscience/visionforge/ComputedVisionPropertiesKt { - public static final fun computeProperties (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/Meta; - public static synthetic fun computeProperties$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; - public static final fun computeProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/values/Value; - public static synthetic fun computeProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; - public static final fun computePropertyNode (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/Meta; - public static synthetic fun computePropertyNode$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; - public static final fun computePropertyValues (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/values/MutableValueProvider; - public static synthetic fun computePropertyValues$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/values/MutableValueProvider; -} - -public final class space/kscience/visionforge/HtmlExportKt { - public static final fun makeFile (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;)Ljava/nio/file/Path; - public static synthetic fun makeFile$default (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/nio/file/Path; - public static final fun show (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;)V - public static synthetic fun show$default (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;ILjava/lang/Object;)V -} - -public abstract interface class space/kscience/visionforge/MutableVisionGroup : space/kscience/visionforge/VisionContainerBuilder, space/kscience/visionforge/VisionGroup { - public abstract fun onStructureChanged (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V - public abstract fun removeStructureListener (Ljava/lang/Object;)V -} - -public class space/kscience/visionforge/SimpleVisionPropertyContainer : space/kscience/dataforge/meta/Configurable, space/kscience/visionforge/VisionPropertyContainer { - public fun (Lspace/kscience/dataforge/meta/ObservableMutableMeta;)V - public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; -} - -public final class space/kscience/visionforge/StyleReference { - public fun (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;)V - public final fun getName ()Ljava/lang/String; - public final fun getOwner ()Lspace/kscience/visionforge/VisionGroup; -} - -public final class space/kscience/visionforge/StyleReferenceKt { - public static final fun style (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadOnlyProperty; - public static final fun style (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/Specification;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadOnlyProperty; - public static synthetic fun style$default (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; - public static synthetic fun style$default (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/Specification;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; - public static final fun useStyle (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/StyleReference;)V -} - -public final class space/kscience/visionforge/StyleSheet { - public static final field Companion Lspace/kscience/visionforge/StyleSheet$Companion; - public static final synthetic fun box-impl (Lspace/kscience/visionforge/VisionGroup;)Lspace/kscience/visionforge/StyleSheet; - public static fun constructor-impl (Lspace/kscience/visionforge/VisionGroup;)Lspace/kscience/visionforge/VisionGroup; - public static final fun define-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V - public fun equals (Ljava/lang/Object;)Z - public static fun equals-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/Object;)Z - public static final fun equals-impl0 (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/visionforge/VisionGroup;)Z - public static final fun get-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; - public static final fun getItems-impl (Lspace/kscience/visionforge/VisionGroup;)Ljava/util/Map; - public fun hashCode ()I - public static fun hashCode-impl (Lspace/kscience/visionforge/VisionGroup;)I - public static final fun invoke-impl (Lspace/kscience/visionforge/VisionGroup;Lkotlin/jvm/functions/Function1;)V - public static final fun set-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public static final fun set-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V - public fun toString ()Ljava/lang/String; - public static fun toString-impl (Lspace/kscience/visionforge/VisionGroup;)Ljava/lang/String; - public final synthetic fun unbox-impl ()Lspace/kscience/visionforge/VisionGroup; -} - -public final class space/kscience/visionforge/StyleSheet$Companion { - public final fun getSTYLESHEET_KEY ()Lspace/kscience/dataforge/names/Name; -} - -public final class space/kscience/visionforge/StyleSheetKt { - public static final fun getStyle (Lspace/kscience/visionforge/Vision;Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; - public static final fun getStyleNodes (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;)Ljava/util/List; - public static final fun getStyleProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/values/Value; - public static final fun getStyleSheet (Lspace/kscience/visionforge/VisionGroup;)Lspace/kscience/visionforge/VisionGroup; - public static final fun getStyles (Lspace/kscience/visionforge/Vision;)Ljava/util/List; - public static final fun setStyles (Lspace/kscience/visionforge/Vision;Ljava/util/List;)V - public static final fun useStyle (Lspace/kscience/visionforge/Vision;Ljava/lang/String;)V -} - -public abstract interface class space/kscience/visionforge/Vision : space/kscience/dataforge/meta/Configurable, space/kscience/dataforge/meta/descriptors/Described { - public static final field Companion Lspace/kscience/visionforge/Vision$Companion; - public static final field TYPE Ljava/lang/String; - public abstract fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public fun getManager ()Lspace/kscience/visionforge/VisionManager; - public abstract fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public abstract fun getParent ()Lspace/kscience/visionforge/VisionGroup; - public abstract fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public static synthetic fun getProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; - public abstract fun invalidateProperty (Lspace/kscience/dataforge/names/Name;)V - public abstract fun setParent (Lspace/kscience/visionforge/VisionGroup;)V - public abstract fun update (Lspace/kscience/visionforge/VisionChange;)V -} - -public final class space/kscience/visionforge/Vision$Companion { - public static final field TYPE Ljava/lang/String; - public final fun getSTYLE_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getVISIBLE_KEY ()Lspace/kscience/dataforge/names/Name; -} - -public class space/kscience/visionforge/VisionBase : space/kscience/visionforge/Vision { - public static final field Companion Lspace/kscience/visionforge/VisionBase$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/MutableMeta;)V - public synthetic fun (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/MutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public final fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - protected final fun getOrCreateProperties ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getParent ()Lspace/kscience/visionforge/VisionGroup; - protected final fun getProperties ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public fun invalidateProperty (Lspace/kscience/dataforge/names/Name;)V - public fun setParent (Lspace/kscience/visionforge/VisionGroup;)V - protected final fun setProperties (Lspace/kscience/dataforge/meta/MutableMeta;)V - public fun update (Lspace/kscience/visionforge/VisionChange;)V - public static final fun write$Self (Lspace/kscience/visionforge/VisionBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/VisionBase$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/VisionBase$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionBase; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionBase;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionBase$Companion { - public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public final fun serializer ()Lkotlinx/serialization/KSerializer; - public final fun updateProperties (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V -} - -public abstract interface annotation class space/kscience/visionforge/VisionBuilder : java/lang/annotation/Annotation { -} - -public final class space/kscience/visionforge/VisionChange { - public static final field Companion Lspace/kscience/visionforge/VisionChange$Companion; - public fun ()V - public synthetic fun (IZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;)V - public synthetic fun (ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Z - public final fun component2 ()Lspace/kscience/visionforge/Vision; - public final fun component3 ()Lspace/kscience/dataforge/meta/Meta; - public final fun component4 ()Ljava/util/Map; - public final fun copy (ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;)Lspace/kscience/visionforge/VisionChange; - public static synthetic fun copy$default (Lspace/kscience/visionforge/VisionChange;ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;ILjava/lang/Object;)Lspace/kscience/visionforge/VisionChange; - public fun equals (Ljava/lang/Object;)Z - public final fun getChildren ()Ljava/util/Map; - public final fun getDelete ()Z - public final fun getProperties ()Lspace/kscience/dataforge/meta/Meta; - public final fun getVision ()Lspace/kscience/visionforge/Vision; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/VisionChange;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/VisionChange$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/VisionChange$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionChange; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionChange;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionChange$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionChangeBuilder : space/kscience/visionforge/VisionContainerBuilder { - public fun ()V - public final fun deepCopy ()Lspace/kscience/visionforge/VisionChange; - public final fun isEmpty ()Z - public final fun propertyChanged (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V - public fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V -} - -public final class space/kscience/visionforge/VisionChangeKt { - public static final fun VisionChange (Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/VisionChange; - public static final fun flowChanges-HG0u8IE (Lspace/kscience/visionforge/Vision;J)Lkotlinx/coroutines/flow/Flow; -} - -public abstract interface class space/kscience/visionforge/VisionContainer { - public abstract fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; -} - -public abstract interface class space/kscience/visionforge/VisionContainerBuilder { - public abstract fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V -} - -public final class space/kscience/visionforge/VisionDelegatesKt { - public static final fun numberProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZ)Lkotlin/properties/ReadWriteProperty; - public static final fun numberProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function0;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun numberProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun numberProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static final fun propertyValue (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZ)Lkotlin/properties/ReadWriteProperty; - public static final fun propertyValue (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun propertyValue$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun propertyValue$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; -} - -public final class space/kscience/visionforge/VisionDescriptorKt { - public static final fun getHidden (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Z - public static final fun getInherited (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Ljava/lang/Boolean; - public static final fun getInherited (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;)Ljava/lang/Boolean; - public static final fun getUsesStyles (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Ljava/lang/Boolean; - public static final fun getUsesStyles (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;)Ljava/lang/Boolean; - public static final fun getWidget (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/Meta; - public static final fun getWidget (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;)Lspace/kscience/dataforge/meta/Meta; - public static final fun getWidgetType (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Ljava/lang/String; - public static final fun getWidgetType (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;)Ljava/lang/String; - public static final fun hide (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;)V - public static final fun setInherited (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;Ljava/lang/Boolean;)V - public static final fun setUsesStyles (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;Ljava/lang/Boolean;)V - public static final fun setWidget (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;Lspace/kscience/dataforge/meta/Meta;)V - public static final fun setWidgetType (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;Ljava/lang/String;)V -} - -public abstract interface class space/kscience/visionforge/VisionGroup : space/kscience/dataforge/provider/Provider, space/kscience/visionforge/Vision, space/kscience/visionforge/VisionContainer { - public static final field Companion Lspace/kscience/visionforge/VisionGroup$Companion; - public static final field STYLE_TARGET Ljava/lang/String; - public fun content (Ljava/lang/String;)Ljava/util/Map; - public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; - public abstract fun getChildren ()Ljava/util/Map; - public fun getDefaultTarget ()Ljava/lang/String; -} - -public final class space/kscience/visionforge/VisionGroup$Companion { - public static final field STYLE_TARGET Ljava/lang/String; -} - -public class space/kscience/visionforge/VisionGroupBase : space/kscience/visionforge/VisionBase, space/kscience/visionforge/MutableVisionGroup { - public static final field Companion Lspace/kscience/visionforge/VisionGroupBase$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/util/Map;)V - public synthetic fun (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected fun addStatic (Lspace/kscience/visionforge/Vision;)V - protected final fun childrenChanged (Lspace/kscience/dataforge/names/Name;)V - protected fun createGroup ()Lspace/kscience/visionforge/VisionGroupBase; - public fun getChildren ()Ljava/util/Map; - protected final fun getChildrenInternal ()Ljava/util/Map; - public fun invalidateProperty (Lspace/kscience/dataforge/names/Name;)V - public fun onStructureChanged (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V - public fun removeStructureListener (Ljava/lang/Object;)V - public fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V - public fun update (Lspace/kscience/visionforge/VisionChange;)V - public static final fun write$Self (Lspace/kscience/visionforge/VisionGroupBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/VisionGroupBase$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/VisionGroupBase$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionGroupBase; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionGroupBase;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionGroupBase$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionGroupBaseKt { - public static final fun setAsRoot (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/VisionManager;)V -} - -public final class space/kscience/visionforge/VisionGroupKt { - public static final fun get (Lspace/kscience/visionforge/VisionContainer;Ljava/lang/String;)Lspace/kscience/visionforge/Vision; - public static final fun getStructureChanges (Lspace/kscience/visionforge/MutableVisionGroup;)Lkotlinx/coroutines/flow/Flow; - public static final fun isEmpty (Lspace/kscience/visionforge/VisionGroup;)Z - public static final fun iterator (Lspace/kscience/visionforge/VisionGroup;)Ljava/util/Iterator; - public static final fun removeAll (Lspace/kscience/visionforge/MutableVisionGroup;)V - public static final fun set (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lspace/kscience/visionforge/Vision;)V - public static final fun set (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/dataforge/names/NameToken;Lspace/kscience/visionforge/Vision;)V -} - -public final class space/kscience/visionforge/VisionKt { - public static final fun getPropertyChanges (Lspace/kscience/visionforge/Vision;)Lkotlinx/coroutines/flow/Flow; - public static final fun getProperty (Lspace/kscience/visionforge/Vision;Ljava/lang/String;ZZZ)Lspace/kscience/dataforge/values/Value; - public static synthetic fun getProperty$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;ZZZILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; - public static final fun getVisible (Lspace/kscience/visionforge/Vision;)Ljava/lang/Boolean; - public static final fun onPropertyChange (Lspace/kscience/visionforge/Vision;Lkotlin/jvm/functions/Function2;)V - public static final fun setProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Object;)V - public static final fun setPropertyNode (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Object;)V - public static final fun setVisible (Lspace/kscience/visionforge/Vision;Ljava/lang/Boolean;)V - public static final fun useProperty (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V - public static synthetic fun useProperty$default (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V -} - -public final class space/kscience/visionforge/VisionManager : space/kscience/dataforge/context/AbstractPlugin { - public static final field Companion Lspace/kscience/visionforge/VisionManager$Companion; - public static final field VISION_SERIALIZER_MODULE_TARGET Ljava/lang/String; - public fun (Lspace/kscience/dataforge/meta/Meta;)V - public final fun decodeFromJson (Lkotlinx/serialization/json/JsonElement;)Lspace/kscience/visionforge/Vision; - public final fun decodeFromMeta (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/visionforge/Vision; - public static synthetic fun decodeFromMeta$default (Lspace/kscience/visionforge/VisionManager;Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/visionforge/Vision; - public final fun decodeFromString (Ljava/lang/String;)Lspace/kscience/visionforge/Vision; - public final fun encodeToJsonElement (Lspace/kscience/visionforge/Vision;)Lkotlinx/serialization/json/JsonElement; - public final fun encodeToMeta (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/Meta; - public static synthetic fun encodeToMeta$default (Lspace/kscience/visionforge/VisionManager;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; - public final fun encodeToString (Lspace/kscience/visionforge/Vision;)Ljava/lang/String; - public final fun encodeToString (Lspace/kscience/visionforge/VisionChange;)Ljava/lang/String; - public final fun getJsonFormat ()Lkotlinx/serialization/json/Json; - public final fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; -} - -public final class space/kscience/visionforge/VisionManager$Companion : space/kscience/dataforge/context/PluginFactory { - public final fun getDefaultJson ()Lkotlinx/serialization/json/Json; - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/VisionManager; -} - -public final class space/kscience/visionforge/VisionManagerKt { - public static final fun encodeToString (Lspace/kscience/visionforge/Vision;)Ljava/lang/String; - public static final fun getVisionManager (Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/VisionManager; -} - -public abstract class space/kscience/visionforge/VisionPlugin : space/kscience/dataforge/context/AbstractPlugin { - public fun ()V - public fun (Lspace/kscience/dataforge/meta/Meta;)V - public synthetic fun (Lspace/kscience/dataforge/meta/Meta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun content (Ljava/lang/String;)Ljava/util/Map; - public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; - protected abstract fun getVisionSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; -} - -public abstract interface class space/kscience/visionforge/VisionPropertyContainer { - public abstract fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public abstract fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public static synthetic fun getProperty$default (Lspace/kscience/visionforge/VisionPropertyContainer;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; -} - -public final class space/kscience/visionforge/html/HeadersKt { - public static final fun importScriptHeader (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;Ljava/nio/file/Path;)Lkotlin/jvm/functions/Function1; - public static synthetic fun importScriptHeader$default (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;Ljava/nio/file/Path;ILjava/lang/Object;)Lkotlin/jvm/functions/Function1; -} - -public final class space/kscience/visionforge/html/HtmlFormFragment { - public final fun get (Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; - public final fun getFormBody ()Lkotlin/jvm/functions/Function1; - public final fun getValues ()Lspace/kscience/dataforge/meta/Meta; - public final fun getVision ()Lspace/kscience/visionforge/html/VisionOfHtmlForm; -} - -public final class space/kscience/visionforge/html/HtmlFragmentKt { - public static final fun fragment (Lkotlinx/html/FlowContent;Lkotlin/jvm/functions/Function1;)V - public static final fun fragment (Lkotlinx/html/TagConsumer;Lkotlin/jvm/functions/Function1;)V - public static final fun plus (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static final fun renderToString (Lkotlin/jvm/functions/Function1;)Ljava/lang/String; -} - -public final class space/kscience/visionforge/html/HtmlVisionRendererKt { - public static final fun HtmlVisionFragment (Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static final fun visionFragment (Lkotlinx/html/FlowContent;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ljava/util/Map; - public static final fun visionFragment (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ljava/util/Map; - public static synthetic fun visionFragment$default (Lkotlinx/html/FlowContent;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/Map; - public static synthetic fun visionFragment$default (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/Map; -} - -public final class space/kscience/visionforge/html/Page { - public static final field Companion Lspace/kscience/visionforge/html/Page$Companion; - public fun (Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)V - public synthetic fun (Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Lspace/kscience/dataforge/context/Context; - public final fun component2 ()Ljava/util/Map; - public final fun component3 ()Lkotlin/jvm/functions/Function1; - public final fun copy (Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/Page; - public static synthetic fun copy$default (Lspace/kscience/visionforge/html/Page;Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/Page; - public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Lkotlin/jvm/functions/Function1; - public final fun getContext ()Lspace/kscience/dataforge/context/Context; - public final fun getHeaders ()Ljava/util/Map; - public fun hashCode ()I - public final fun render (Lkotlinx/html/TagConsumer;)Ljava/lang/Object; - public fun toString ()Ljava/lang/String; -} - -public final class space/kscience/visionforge/html/Page$Companion { - public final fun scriptHeader (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static synthetic fun scriptHeader$default (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/jvm/functions/Function1; - public final fun styleSheetHeader (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static synthetic fun styleSheetHeader$default (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/jvm/functions/Function1; - public final fun title (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; -} - -public final class space/kscience/visionforge/html/ResourceLocation : java/lang/Enum { - public static final field EMBED Lspace/kscience/visionforge/html/ResourceLocation; - public static final field LOCAL Lspace/kscience/visionforge/html/ResourceLocation; - public static final field SYSTEM Lspace/kscience/visionforge/html/ResourceLocation; - public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/html/ResourceLocation; - public static fun values ()[Lspace/kscience/visionforge/html/ResourceLocation; -} - -public abstract interface annotation class space/kscience/visionforge/html/VisionDSL : java/lang/annotation/Annotation { -} - -public final class space/kscience/visionforge/html/VisionOfCheckbox : space/kscience/visionforge/html/VisionOfHtmlInput { - public static final field Companion Lspace/kscience/visionforge/html/VisionOfCheckbox$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getChecked ()Ljava/lang/Boolean; - public final fun getLabel ()Ljava/lang/String; - public final fun getName ()Ljava/lang/String; - public final fun setChecked (Ljava/lang/Boolean;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfCheckbox;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/html/VisionOfCheckbox$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfCheckbox$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfCheckbox; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfCheckbox;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfCheckbox$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfHtmlForm : space/kscience/visionforge/html/VisionOfHtmlInput { - public static final field Companion Lspace/kscience/visionforge/html/VisionOfHtmlForm$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;)V - public final fun getFormId ()Ljava/lang/String; - public final fun getValues ()Lspace/kscience/dataforge/meta/Meta; - public final fun setValues (Lspace/kscience/dataforge/meta/Meta;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfHtmlForm;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/html/VisionOfHtmlForm$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfHtmlForm$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfHtmlForm; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfHtmlForm;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfHtmlForm$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfHtmlFormKt { - public static final fun HtmlFormFragment (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/HtmlFormFragment; - public static synthetic fun HtmlFormFragment$default (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/HtmlFormFragment; - public static final fun formFragment (Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfHtmlForm; - public static synthetic fun formFragment$default (Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfHtmlForm; -} - -public abstract class space/kscience/visionforge/html/VisionOfHtmlInput : space/kscience/visionforge/VisionBase { - public static final field Companion Lspace/kscience/visionforge/html/VisionOfHtmlInput$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getDisabled ()Z - public final fun setDisabled (Z)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/html/VisionOfHtmlInput$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfNumberField : space/kscience/visionforge/html/VisionOfHtmlInput { - public static final field Companion Lspace/kscience/visionforge/html/VisionOfNumberField$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getLabel ()Ljava/lang/String; - public final fun getName ()Ljava/lang/String; - public final fun getValue ()Ljava/lang/Number; - public final fun setValue (Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfNumberField;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/html/VisionOfNumberField$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfNumberField$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfNumberField; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfNumberField;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfNumberField$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfRangeField : space/kscience/visionforge/html/VisionOfHtmlInput { - public static final field Companion Lspace/kscience/visionforge/html/VisionOfRangeField$Companion; - public fun (DDDLjava/lang/String;Ljava/lang/String;)V - public synthetic fun (DDDLjava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;DDDLjava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getLabel ()Ljava/lang/String; - public final fun getMax ()D - public final fun getMin ()D - public final fun getName ()Ljava/lang/String; - public final fun getStep ()D - public final fun getValue ()Ljava/lang/Number; - public final fun setValue (Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfRangeField;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/html/VisionOfRangeField$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfRangeField$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfRangeField; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfRangeField;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfRangeField$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfTextField : space/kscience/visionforge/html/VisionOfHtmlInput { - public static final field Companion Lspace/kscience/visionforge/html/VisionOfTextField$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getLabel ()Ljava/lang/String; - public final fun getName ()Ljava/lang/String; - public final fun getText ()Ljava/lang/String; - public final fun setText (Ljava/lang/String;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfTextField;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/html/VisionOfTextField$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfTextField$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfTextField; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfTextField;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOfTextField$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/html/VisionOutput { - public fun (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/names/Name;)V - public final fun getContext ()Lspace/kscience/dataforge/context/Context; - public final fun getMeta ()Lspace/kscience/dataforge/meta/Meta; - public final fun getName ()Lspace/kscience/dataforge/names/Name; - public final fun meta (Lkotlin/jvm/functions/Function1;)V - public final fun requirePlugin (Lspace/kscience/dataforge/context/PluginFactory;)V - public final fun setMeta (Lspace/kscience/dataforge/meta/Meta;)V -} - -public abstract class space/kscience/visionforge/html/VisionTagConsumer : kotlinx/html/TagConsumer { - public static final field AUTO_DATA_ATTRIBUTE Ljava/lang/String; - public static final field Companion Lspace/kscience/visionforge/html/VisionTagConsumer$Companion; - public static final field DEFAULT_ENDPOINT Ljava/lang/String; - public static final field DEFAULT_VISION_NAME Ljava/lang/String; - public static final field OUTPUT_CLASS Ljava/lang/String; - public static final field OUTPUT_CONNECT_ATTRIBUTE Ljava/lang/String; - public static final field OUTPUT_DATA_CLASS Ljava/lang/String; - public static final field OUTPUT_ENDPOINT_ATTRIBUTE Ljava/lang/String; - public static final field OUTPUT_FETCH_ATTRIBUTE Ljava/lang/String; - public static final field OUTPUT_META_CLASS Ljava/lang/String; - public static final field OUTPUT_NAME_ATTRIBUTE Ljava/lang/String; - public static final field OUTPUT_RENDERED Ljava/lang/String; - public fun (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;Ljava/lang/String;)V - public synthetic fun (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun finalize ()Ljava/lang/Object; - public final fun getContext ()Lspace/kscience/dataforge/context/Context; - public fun onTagAttributeChange (Lkotlinx/html/Tag;Ljava/lang/String;Ljava/lang/String;)V - public fun onTagComment (Ljava/lang/CharSequence;)V - public fun onTagContent (Ljava/lang/CharSequence;)V - public fun onTagContentEntity (Lkotlinx/html/Entities;)V - public fun onTagContentUnsafe (Lkotlin/jvm/functions/Function1;)V - public fun onTagEnd (Lkotlinx/html/Tag;)V - public fun onTagError (Lkotlinx/html/Tag;Ljava/lang/Throwable;)V - public fun onTagEvent (Lkotlinx/html/Tag;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public fun onTagStart (Lkotlinx/html/Tag;)V - protected fun processResult (Ljava/lang/Object;)V - protected abstract fun renderVision (Lkotlinx/html/DIV;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V - public fun resolveId (Lspace/kscience/dataforge/names/Name;)Ljava/lang/String; - public final fun vision (Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public final fun vision (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static synthetic fun vision$default (Lspace/kscience/visionforge/html/VisionTagConsumer;Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; -} - -public final class space/kscience/visionforge/html/VisionTagConsumer$Companion { -} - -public final class space/kscience/visionforge/visitor/CountDistinctKt { - public static final fun countDistinct (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun countDistinctBy (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class space/kscience/visionforge/visitor/DefaultVisionStatistics { - public fun (Lspace/kscience/dataforge/names/Name;Lkotlin/reflect/KClass;)V - public final fun component1 ()Lspace/kscience/dataforge/names/Name; - public final fun component2 ()Lkotlin/reflect/KClass; - public final fun copy (Lspace/kscience/dataforge/names/Name;Lkotlin/reflect/KClass;)Lspace/kscience/visionforge/visitor/DefaultVisionStatistics; - public static synthetic fun copy$default (Lspace/kscience/visionforge/visitor/DefaultVisionStatistics;Lspace/kscience/dataforge/names/Name;Lkotlin/reflect/KClass;ILjava/lang/Object;)Lspace/kscience/visionforge/visitor/DefaultVisionStatistics; - public fun equals (Ljava/lang/Object;)Z - public final fun getDepth ()I - public final fun getName ()Lspace/kscience/dataforge/names/Name; - public final fun getType ()Lkotlin/reflect/KClass; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class space/kscience/visionforge/visitor/StatisticsVisitorKt { - public static final fun flowStatistics (Lspace/kscience/visionforge/Vision;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun flowStatistics (Lspace/kscience/visionforge/Vision;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class space/kscience/visionforge/visitor/VisionVisitor { - public static final field Companion Lspace/kscience/visionforge/visitor/VisionVisitor$Companion; - public fun skip (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)Z - public abstract fun visit (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun visitChildren (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/VisionGroup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class space/kscience/visionforge/visitor/VisionVisitor$Companion { - public final fun visitTree (Lspace/kscience/visionforge/visitor/VisionVisitor;Lkotlinx/coroutines/CoroutineScope;Lspace/kscience/visionforge/Vision;)Lkotlinx/coroutines/Job; -} - diff --git a/visionforge-core/build.gradle.kts b/visionforge-core/build.gradle.kts index f2cac4c6..3af5c602 100644 --- a/visionforge-core/build.gradle.kts +++ b/visionforge-core/build.gradle.kts @@ -1,27 +1,26 @@ plugins { - id("space.kscience.gradle.mpp") + id("ru.mipt.npm.gradle.mpp") } val dataforgeVersion: String by rootProject.extra -kscience { - jvm() - js() - native() - useCoroutines() - dependencies { - api("space.kscience:dataforge-context:$dataforgeVersion") - api(spclibs.kotlinx.html) -// api("org.jetbrains.kotlin-wrappers:kotlin-css") - } - jsMain { - api("org.jetbrains.kotlin-wrappers:kotlin-extensions") - } - useSerialization { - json() - } +kscience{ + useSerialization() } -readme { - maturity = space.kscience.gradle.Maturity.DEVELOPMENT +kotlin { + sourceSets { + commonMain { + dependencies { + api("space.kscience:dataforge-context:$dataforgeVersion") + api("org.jetbrains.kotlinx:kotlinx-html:${ru.mipt.npm.gradle.KScienceVersions.htmlVersion}") + api("org.jetbrains.kotlin-wrappers:kotlin-css") + } + } + jsMain { + dependencies { + api("org.jetbrains.kotlin-wrappers:kotlin-extensions") + } + } + } } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt deleted file mode 100644 index e7df2198..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt +++ /dev/null @@ -1,30 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.meta.descriptors.MetaDescriptor - - -@Serializable -public abstract class AbstractVision : Vision { - - @Transient - override var parent: Vision? = null - - @SerialName("properties") - protected var propertiesInternal: MutableMeta? = null - - final override val properties: MutableVisionProperties by lazy { - object : AbstractVisionProperties(this) { - override var properties: MutableMeta? - get() = propertiesInternal - set(value) { - propertiesInternal = value - } - } - } - - override val descriptor: MetaDescriptor? get() = null -} \ No newline at end of file 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 ad4a4c0e..58be399e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Colors.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Colors.kt @@ -1,6 +1,11 @@ package space.kscience.visionforge -import space.kscience.dataforge.meta.* +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 kotlin.math.max /** diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/ComputedVisionProperties.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/ComputedVisionProperties.kt new file mode 100644 index 00000000..925eecfe --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/ComputedVisionProperties.kt @@ -0,0 +1,84 @@ +package space.kscience.visionforge + +import space.kscience.dataforge.meta.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.Name +import space.kscience.dataforge.names.NameToken +import space.kscience.dataforge.names.plus +import space.kscience.dataforge.values.MutableValueProvider +import space.kscience.dataforge.values.Value + +private class ComputedVisionProperties( + val vision: Vision, + val pathName: Name, + val visionDescriptor: MetaDescriptor, + val parentInheritFlag: Boolean?, + val parentStylesFlag: Boolean? +) : Meta { + + val descriptor: MetaDescriptor? by lazy { visionDescriptor[pathName] } + + override val items: Map + get() { + val metaKeys = vision.meta.getMeta(pathName)?.items?.keys ?: emptySet() + val descriptorKeys = descriptor?.children?.map { NameToken(it.key) } ?: emptySet() + val inheritFlag = descriptor?.inherited ?: parentInheritFlag + val stylesFlag = descriptor?.usesStyles ?: parentStylesFlag + return (metaKeys + descriptorKeys).associateWith { + ComputedVisionProperties( + vision, + pathName + it, + visionDescriptor, + inheritFlag, + stylesFlag + ) + } + } + + override val value: Value? + get() { + val inheritFlag = descriptor?.inherited ?: parentInheritFlag ?: false + val stylesFlag = descriptor?.usesStyles ?: parentStylesFlag ?: true + return vision.getPropertyValue(pathName, inheritFlag, stylesFlag, true) + } + + override fun toString(): String = Meta.toString(this) + override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta) + override fun hashCode(): Int = Meta.hashCode(this) +} + +/** + * Compute property node based on inheritance and style information from the descriptor + */ +public fun Vision.computeProperties(descriptor: MetaDescriptor? = this.descriptor): Meta = + if (descriptor == null) meta else ComputedVisionProperties(this, Name.EMPTY, descriptor, null, null) + +public fun Vision.computePropertyNode( + name: Name, + descriptor: MetaDescriptor? = this.descriptor +): Meta? = computeProperties(descriptor)[name] + +/** + * Compute the property based on the provided value descriptor. By default, use Vision own descriptor + */ +public fun Vision.computeProperty(name: Name, valueDescriptor: MetaDescriptor? = descriptor?.get(name)): Value? { + val inheritFlag = valueDescriptor?.inherited ?: false + val stylesFlag = valueDescriptor?.usesStyles ?: true + return getPropertyValue(name, inheritFlag, stylesFlag) +} + +/** + * Accessor to all vision properties + */ +public fun Vision.computePropertyValues( + descriptor: MetaDescriptor? = this.descriptor +): MutableValueProvider = object : MutableValueProvider { + override fun getValue(name: Name): Value? = computeProperty(name, descriptor?.get(name)) + + override fun setValue(name: Name, value: Value?) { + setProperty(name, value) + } +} + diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/JvmSynchronized.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/JvmSynchronized.kt deleted file mode 100644 index a6f8c374..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/JvmSynchronized.kt +++ /dev/null @@ -1,5 +0,0 @@ -package space.kscience.visionforge - -@OptIn(ExperimentalMultiplatform::class) -@OptionalExpectation -public expect annotation class JvmSynchronized() diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt index 62d898b8..d5dfac6e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt @@ -9,7 +9,7 @@ import kotlin.properties.ReadOnlyProperty /** * A reference to a style defined in a specific container */ -public class StyleReference(public val owner: Vision, public val name: String) +public class StyleReference(public val owner: VisionGroup, public val name: String) private tailrec fun styleIsDefined(vision: Vision, reference: StyleReference): Boolean = when { reference.owner === vision -> true @@ -18,14 +18,14 @@ private tailrec fun styleIsDefined(vision: Vision, reference: StyleReference): B } @VisionBuilder -public fun Vision.useStyle(reference: StyleReference, notify: Boolean = true) { +public fun Vision.useStyle(reference: StyleReference) { //check that style is defined in a parent //check(styleIsDefined(this, reference)) { "Style reference does not belong to a Vision parent" } - useStyle(reference.name, notify) + useStyle(reference.name) } @VisionBuilder -public fun Vision.style( +public fun VisionGroup.style( styleKey: String? = null, builder: MutableMeta.() -> Unit, ): ReadOnlyProperty = ReadOnlyProperty { _, property -> @@ -35,7 +35,7 @@ public fun Vision.style( } @VisionBuilder -public fun Vision.style( +public fun VisionGroup.style( spec: Specification, styleKey: String? = null, builder: T.() -> Unit, 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 7320839d..52deee3c 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt @@ -5,17 +5,20 @@ 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.Value +import space.kscience.dataforge.values.asValue +import space.kscience.dataforge.values.stringList import kotlin.jvm.JvmInline /** * A container for styles */ @JvmInline -public value class StyleSheet(private val owner: Vision) { +public value class StyleSheet(private val owner: VisionGroup) { - private val styleNode: Meta get() = owner.properties.getProperty(STYLESHEET_KEY) + private val styleNode: Meta? get() = owner.meta[STYLESHEET_KEY] - public val items: Map get() = styleNode.items + public val items: Map? get() = styleNode?.items public operator fun get(key: String): Meta? = owner.getStyle(key) @@ -23,7 +26,7 @@ public value class StyleSheet(private val owner: Vision) { * Define a style without notifying owner */ public fun define(key: String, style: Meta?) { - owner.properties.setProperty(STYLESHEET_KEY + key, style) + owner.meta.setMeta(STYLESHEET_KEY + key, style) } /** @@ -40,7 +43,7 @@ public value class StyleSheet(private val owner: Vision) { /** * Create and set a style */ - public fun update(key: String, builder: MutableMeta.() -> Unit) { + public operator fun set(key: String, builder: MutableMeta.() -> Unit) { val newStyle = get(key)?.toMutableMeta()?.apply(builder) ?: Meta(builder) set(key, newStyle.seal()) } @@ -56,48 +59,49 @@ internal fun Vision.styleChanged(key: String, oldStyle: Meta?, newStyle: Meta?) val tokens: Collection = ((oldStyle?.items?.keys ?: emptySet()) + (newStyle?.items?.keys ?: emptySet())) .map { it.asName() } - tokens.forEach { parent?.properties?.invalidate(it) } + tokens.forEach { parent?.invalidateProperty(it) } } - children?.forEach { _, vision -> - vision.styleChanged(key, oldStyle, newStyle) + if (this is VisionGroup) { + for (obj in this) { + obj.styleChanged(key, oldStyle, newStyle) + } } } + /** * List of names of styles applied to this object. Order matters. Not inherited. */ public var Vision.styles: List - get() = properties.own?.getValue(Vision.STYLE_KEY)?.stringList ?: emptyList() + get() = meta.getValue(Vision.STYLE_KEY)?.stringList ?: emptyList() set(value) { - properties.setValue(Vision.STYLE_KEY, value.map { it.asValue() }.asValue()) + meta.setValue(Vision.STYLE_KEY, value.map { it.asValue() }.asValue()) } /** * A stylesheet for this group and its descendants. Stylesheet is not applied directly, * but instead is just a repository for named configurations. */ -public val Vision.styleSheet: StyleSheet get() = StyleSheet(this) +public val VisionGroup.styleSheet: StyleSheet get() = StyleSheet(this) /** - * Add style name to the list of styles to be resolved later. - * The style with given name does not necessary exist at the moment. + * Add style name to the list of styles to be resolved later. The style with given name does not necessary exist at the moment. */ -public fun Vision.useStyle(name: String, notify: Boolean = true) { - val newStyle = properties.own?.get(Vision.STYLE_KEY)?.value?.list?.plus(name.asValue()) ?: listOf(name.asValue()) - properties.setValue(Vision.STYLE_KEY, newStyle.asValue(), notify) +public fun Vision.useStyle(name: String) { + styles = (meta.getMeta(Vision.STYLE_KEY)?.stringList ?: emptyList()) + name } /** - * Resolve a style with given name for given [Vision]. The style is not necessarily applied to this [Vision]. + * Find a style with given name for given [Vision]. The style is not necessary applied to this [Vision]. */ -public fun Vision.getStyle(name: String): Meta? = - properties.own?.getMeta(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name) +public tailrec fun Vision.getStyle(name: String): Meta? = + meta.getMeta(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name) /** * Resolve a property from all styles */ -public fun Vision.getStyleProperty(name: Name): Meta? = styles.firstNotNullOfOrNull { getStyle(it)?.get(name) } +public fun Vision.getStyleProperty(name: Name): Value? = styles.firstNotNullOfOrNull { getStyle(it)?.get(name)?.value } /** * Resolve an item in all style layers 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 ce5f588f..54e9261c 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt @@ -1,73 +1,147 @@ package space.kscience.visionforge -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import space.kscience.dataforge.meta.asValue -import space.kscience.dataforge.meta.boolean +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.launch +import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.Described import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.misc.Type import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties +import space.kscience.dataforge.names.startsWith +import space.kscience.dataforge.values.Value +import space.kscience.dataforge.values.asValue +import space.kscience.dataforge.values.boolean import space.kscience.visionforge.Vision.Companion.TYPE +import kotlin.reflect.KProperty1 /** * A root type for display hierarchy */ @Type(TYPE) -public interface Vision : Described { +public interface Vision : Described, Configurable { /** * The parent object of this one. If null, this one is a root. */ - public var parent: Vision? + public var parent: VisionGroup? /** * Owner [VisionManager]. Used to define coroutine scope a serialization */ public val manager: VisionManager? get() = parent?.manager + /** + * This Vision own properties (ignoring inheritance, styles and defaults + */ + override val meta: ObservableMutableMeta - public val properties: MutableVisionProperties + /** + * Get property value with given layer flags. + * @param inherit toggles parent node property lookup. Null means inference from descriptor. Default is false. + * @param includeStyles toggles inclusion of properties from styles. default is true + */ + public fun getPropertyValue( + name: Name, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true, + ): Value? + + + /** + * Notify all listeners that a property has been changed and should be invalidated + */ + public fun invalidateProperty(propertyName: Name) /** * Update this vision using a dif represented by [VisionChange]. */ - public fun update(change: VisionChange) { - change.properties?.let { - updateProperties(it, Name.EMPTY) - } - } + public fun update(change: VisionChange) override val descriptor: MetaDescriptor? public companion object { public const val TYPE: String = "vision" public val STYLE_KEY: Name = "@style".asName() - public const val STYLE_TARGET: String = "style" public val VISIBLE_KEY: Name = "visible".asName() } } /** - * Control visibility of the element + * Flow of property invalidation events. It does not contain property values after invalidation since it is not clear + * if it should include inherited properties etc. */ -public var Vision.visible: Boolean? - get() = properties.getValue(Vision.VISIBLE_KEY)?.boolean - set(value) { - properties.setValue(Vision.VISIBLE_KEY, value?.asValue()) +@OptIn(ExperimentalCoroutinesApi::class) +@DFExperimental +public val Vision.propertyChanges: Flow + get() = callbackFlow { + meta.onChange(this) { name -> + launch { + send(name) + } + } + awaitClose { + meta.removeListener(this) + } } /** - * Subscribe on property updates. The subscription is bound to the given scope and canceled when the scope is canceled + * Subscribe on property updates. The subscription is bound to the given [scope] and canceled when the scope is canceled */ -public fun Vision.onPropertyChange( - scope: CoroutineScope? = manager?.context, - callback: suspend (Name) -> Unit -): Job = properties.changes.onEach { - callback(it) -}.launchIn(scope ?: error("Orphan Vision can't observe properties")) \ No newline at end of file +public fun Vision.onPropertyChange(callback: Meta.(Name) -> Unit) { + meta.onChange(null, callback) +} + +/** + * Get [Vision] property using key as a String + */ +public fun Vision.getPropertyValue( + key: String, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true, +): Value? = getPropertyValue(Name.parse(key), inherit, includeStyles, includeDefaults) + +/** + * A convenient method to set property node or value. If Item is null, then node is removed, not a value + */ +public fun Vision.setProperty(name: Name, item: Any?) { + when (item) { + null -> meta.remove(name) + is Meta -> meta.setMeta(name, item) + is Value -> meta.setValue(name, item) + else -> meta.setValue(name, Value.of(item)) + } +} + +public fun Vision.setPropertyNode(key: String, item: Any?) { + setProperty(Name.parse(key), item) +} + +/** + * Control visibility of the element + */ +public var Vision.visible: Boolean? + get() = getPropertyValue(Vision.VISIBLE_KEY)?.boolean + set(value) = meta.setValue(Vision.VISIBLE_KEY, value?.asValue()) + + +public fun V.useProperty( + property: KProperty1, + owner: Any? = null, + callBack: V.(T) -> Unit, +) { + //Pass initial value. + callBack(property.get(this)) + meta.onChange(owner) { name -> + if (name.startsWith(property.name.asName())) { + callBack(property.get(this@useProperty)) + } + } +} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionBase.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionBase.kt new file mode 100644 index 00000000..74f173ae --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionBase.kt @@ -0,0 +1,178 @@ +package space.kscience.visionforge + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient +import space.kscience.dataforge.meta.Meta +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.value +import space.kscience.dataforge.meta.get +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.dataforge.names.* +import space.kscience.dataforge.values.Value +import space.kscience.dataforge.values.ValueType +import space.kscience.visionforge.Vision.Companion.STYLE_KEY +import kotlin.jvm.Synchronized + +internal data class MetaListener( + val owner: Any? = null, + val callback: Meta.(name: Name) -> Unit, +) + +/** + * A full base implementation for a [Vision] + * @param parent the parent object for this vision. Could ve set later. Not serialized. + */ +@Serializable +@SerialName("vision") +public open class VisionBase( + @Transient override var parent: VisionGroup? = null, +) : Vision { + + @Transient + protected open var properties: MutableMeta? = null + + @Synchronized + protected fun getOrCreateProperties(): MutableMeta { + if (properties == null) { + val newProperties = MutableMeta() + properties = newProperties + } + return properties!! + } + + @Transient + private val listeners: MutableList = mutableListOf() + + private inner class VisionProperties(val pathName: Name) : ObservableMutableMeta { + + override val items: Map + get() = properties?.get(pathName)?.items?.mapValues { entry -> + VisionProperties(pathName + entry.key) + } ?: emptyMap() + + override var value: Value? + get() = properties?.get(pathName)?.value + set(value) { + val oldValue = properties?.get(pathName)?.value + getOrCreateProperties().setValue(pathName, value) + if (oldValue != value) { + invalidate(Name.EMPTY) + } + } + + override fun getOrCreate(name: Name): ObservableMutableMeta = VisionProperties(pathName + name) + + override fun setMeta(name: Name, node: Meta?) { + getOrCreateProperties().setMeta(pathName + name, node) + invalidate(name) + } + + @DFExperimental + override fun attach(name: Name, node: ObservableMutableMeta) { + val ownProperties = getOrCreateProperties() + if (ownProperties is ObservableMutableMeta) { + ownProperties.attach(pathName + name, node) + } else { + ownProperties.setMeta(pathName + name, node) + node.onChange(this) { childName -> + ownProperties.setMeta(pathName + name + childName, this[childName]) + } + } + } + + override fun invalidate(name: Name) { + invalidateProperty(pathName + name) + } + + @Synchronized + override fun onChange(owner: Any?, callback: Meta.(name: Name) -> Unit) { + if (pathName.isEmpty()) { + listeners.add((MetaListener(owner, callback))) + } else { + listeners.add(MetaListener(owner) { name -> + if (name.startsWith(pathName)) { + (this@MetaListener[pathName] ?: Meta.EMPTY).callback(name.removeHeadOrNull(pathName)!!) + } + }) + } + } + + @Synchronized + override fun removeListener(owner: Any?) { + listeners.removeAll { it.owner === owner } + } + + override fun toString(): String = Meta.toString(this) + override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta) + override fun hashCode(): Int = Meta.hashCode(this) + } + + override val meta: ObservableMutableMeta get() = VisionProperties(Name.EMPTY) + + override fun getPropertyValue( + name: Name, + inherit: Boolean, + includeStyles: Boolean, + includeDefaults: Boolean, + ): Value? { + properties?.get(name)?.value?.let { return it } + if (includeStyles) { + getStyleProperty(name)?.let { return it } + } + if (inherit) { + parent?.getPropertyValue(name, inherit, includeStyles, includeDefaults)?.let { return it } + } + if (includeDefaults) { + descriptor?.defaultNode?.get(name)?.value.let { return it } + } + return null + } + + override val descriptor: MetaDescriptor? get() = null + + + override fun invalidateProperty(propertyName: Name) { + if (propertyName == STYLE_KEY) { + styles.mapNotNull { getStyle(it) }.asSequence() + .flatMap { it.items.asSequence() } + .distinctBy { it.key } + .forEach { + invalidateProperty(it.key.asName()) + } + } + listeners.forEach { it.callback(properties ?: Meta.EMPTY, propertyName) } + } + + override fun update(change: VisionChange) { + change.properties?.let { + updateProperties(Name.EMPTY, it) + } + } + + public companion object { + public val descriptor: MetaDescriptor = MetaDescriptor { + value(STYLE_KEY, ValueType.STRING) { + multiple = true + } + } + + public fun Vision.updateProperties(at: Name, item: Meta) { + meta.setValue(at, item.value) + item.items.forEach { (token, item) -> + updateProperties(at + token, item) + } + } + + } +} + +//fun VisualObject.findStyle(styleName: Name): Meta? { +// if (this is VisualGroup) { +// val style = resolveStyle(styleName) +// if (style != null) return style +// } +// return parent?.findStyle(styleName) +//} \ No newline at end of file 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 847368f3..c4f18712 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt @@ -5,195 +5,139 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.withLock import kotlinx.serialization.Serializable import space.kscience.dataforge.meta.* -import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.isEmpty import space.kscience.dataforge.names.plus +import space.kscience.dataforge.values.Null +import kotlin.jvm.Synchronized import kotlin.time.Duration /** - * Create a deep copy of given Vision without external connections. + * An update for a [Vision] or a [VisionGroup] */ -private fun Vision.deepCopy(manager: VisionManager): Vision { - if (this is NullVision) return NullVision +public class VisionChangeBuilder : VisionContainerBuilder { - //Assuming that unrooted visions are already isolated + private var reset: Boolean = false + private var vision: Vision? = null + private val propertyChange = MutableMeta() + private val children: HashMap = HashMap() + + public fun isEmpty(): Boolean = propertyChange.isEmpty() && propertyChange.isEmpty() && children.isEmpty() + + @Synchronized + private fun getOrPutChild(visionName: Name): VisionChangeBuilder = + children.getOrPut(visionName) { VisionChangeBuilder() } + + public fun propertyChanged(visionName: Name, propertyName: Name, item: Meta?) { + if (visionName == Name.EMPTY) { + //Write property removal as [Null] + propertyChange[propertyName] = (item ?: Meta(Null)) + } else { + getOrPutChild(visionName).propertyChanged(Name.EMPTY, propertyName, item) + } + } + + override fun set(name: Name?, child: Vision?) { + if (name == null) error("Static children are not allowed in VisionChange") + getOrPutChild(name).apply { + vision = child + reset = vision == null + } + } + + /** + * Isolate collected changes by creating detached copies of given visions + */ + public fun isolate(manager: VisionManager): VisionChange = VisionChange( + reset, + vision?.isolate(manager), + if (propertyChange.isEmpty()) null else propertyChange.seal(), + if (children.isEmpty()) null else children.mapValues { it.value.isolate(manager) } + ) +} + +private fun Vision.isolate(manager: VisionManager): Vision { //TODO replace by efficient deep copy val json = manager.encodeToJsonElement(this) return manager.decodeFromJson(json) } /** - * A vision used only in change propagation and showing that the target should be removed - */ -@Serializable -public object NullVision : Vision { - override var parent: Vision? - get() = null - set(_) { - error("Can't set parent for null vision") - } - - override val properties: MutableVisionProperties get() = error("Can't get properties of `NullVision`") - - override val descriptor: MetaDescriptor? = null -} - - -/** - * An update for a [Vision] - */ -public class VisionChangeBuilder : MutableVisionContainer { - - private var vision: Vision? = null - private var propertyChange = MutableMeta() - private val children: HashMap = HashMap() - - public operator fun get(name: Name): VisionChangeBuilder? = children[name] - - public fun isEmpty(): Boolean = propertyChange.isEmpty() && propertyChange.isEmpty() && children.isEmpty() - - @JvmSynchronized - private fun getOrPutChild(visionName: Name): VisionChangeBuilder = - children.getOrPut(visionName) { VisionChangeBuilder() } - - @JvmSynchronized - internal fun reset() { - vision = null - propertyChange = MutableMeta() - children.clear() - } - - public fun propertyChanged(visionName: Name, propertyName: Name, item: Meta?) { - if (visionName == Name.EMPTY) { - //Write property removal as [Null] - if (propertyName.isEmpty()) { - propertyChange = item?.toMutableMeta() ?: MutableMeta() - } else { - propertyChange[propertyName] = (item ?: Meta(Null)) - } - } else { - getOrPutChild(visionName).propertyChanged(Name.EMPTY, propertyName, item) - } - } - - override fun setChild(name: Name?, child: Vision?) { - if (name == null) error("Static children are not allowed in VisionChange") - getOrPutChild(name).apply { - vision = child ?: NullVision - } - } - - private fun build(visionManager: VisionManager): VisionChange = VisionChange( - vision, - if (propertyChange.isEmpty()) null else propertyChange, - if (children.isEmpty()) null else children.mapValues { it.value.build(visionManager) } - ) - - /** - * Isolate collected changes by creating detached copies of given visions - */ - public fun deepCopy(visionManager: VisionManager): VisionChange = VisionChange( - vision?.deepCopy(visionManager), - if (propertyChange.isEmpty()) null else propertyChange.seal(), - if (children.isEmpty()) null else children.mapValues { it.value.deepCopy(visionManager) } - ) - - /** - * Transform current change directly to Json string without protective copy - */ - public fun toJsonString(visionManager: VisionManager): String = visionManager.encodeToString( - build(visionManager) - ) -} - -/** - * @param vision a new value for vision content. If the Vision is to be removed should be [NullVision] + * @param delete flag showing that this vision child should be removed + * @param vision a new value for vision content * @param properties updated properties * @param children a map of children changed in ths [VisionChange]. If a child to be removed, set [delete] flag to true. */ @Serializable public data class VisionChange( + public val delete: Boolean = false, public val vision: Vision? = null, - public val properties: Meta? = null, + @Serializable(MetaSerializer::class) public val properties: Meta? = null, public val children: Map? = null, ) -public inline fun VisionManager.VisionChange(block: VisionChangeBuilder.() -> Unit): VisionChange = - VisionChangeBuilder().apply(block).deepCopy(this) +public inline fun VisionChange(manager: VisionManager, block: VisionChangeBuilder.() -> Unit): VisionChange = + VisionChangeBuilder().apply(block).isolate(manager) -/** - * Collect changes that are made to [source] to [collector] using [mutex] as a synchronization lock. - */ +@OptIn(DFExperimental::class) private fun CoroutineScope.collectChange( name: Name, source: Vision, - mutex: Mutex, - collector: VisionChangeBuilder, + collector: () -> VisionChangeBuilder, ) { //Collect properties change - source.properties.changes.onEach { propertyName -> - val newItem = source.properties.own?.get(propertyName) - collector.propertyChanged(name, propertyName, newItem) - }.launchIn(this) - - val children = source.children - //Subscribe for children changes - children?.forEach { token, child -> - collectChange(name + token, child, mutex, collector) + source.onPropertyChange { propertyName -> + val newItem = source.meta[propertyName] + collector().propertyChanged(name, propertyName, newItem) } - //Subscribe for structure change - children?.changes?.onEach { changedName -> - val after = children[changedName] - val fullName = name + changedName - if (after != null) { - collectChange(fullName, after, mutex, collector) + if (source is VisionGroup) { + //Subscribe for children changes + source.children.forEach { (token, child) -> + collectChange(name + token, child, collector) } - mutex.withLock { - collector.setChild(fullName, after) + + //Subscribe for structure change + if (source is MutableVisionGroup) { + source.structureChanges.onEach { changedName -> + val after = source[changedName] + val fullName = name + changedName + if (after != null) { + collectChange(fullName, after, collector) + } + collector()[fullName] = after + }.launchIn(this) } - }?.launchIn(this) + } } -/** - * Generate a flow of changes of this vision and its children - * - * @param sendInitial if true, send the initial vision state as first change - */ +@DFExperimental public fun Vision.flowChanges( + manager: VisionManager, collectionDuration: Duration, - sendInitial: Boolean = false, ): Flow = flow { - val manager = manager ?: error("Orphan vision could not collect changes") + + var collector = VisionChangeBuilder() coroutineScope { - val collector = VisionChangeBuilder() - val mutex = Mutex() - collectChange(Name.EMPTY, this@flowChanges, mutex, collector) + collectChange(Name.EMPTY, this@flowChanges) { collector } - if (sendInitial) { - //Send initial vision state - val initialChange = VisionChange(vision = deepCopy(manager)) - emit(initialChange) - } + //Send initial vision state + val initialChange = VisionChange(vision = isolate(manager)) + emit(initialChange) - while (true) { + while (currentCoroutineContext().isActive) { //Wait for changes to accumulate delay(collectionDuration) //Propagate updates only if something is changed if (!collector.isEmpty()) { - mutex.withLock { - //emit changes - emit(collector.deepCopy(manager)) - //Reset the collector - collector.reset() - } + //emit changes + emit(collector.isolate(manager)) + //Reset the collector + collector = VisionChangeBuilder() } } } diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt deleted file mode 100644 index 77f989f4..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt +++ /dev/null @@ -1,216 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.* -import kotlinx.coroutines.launch -import space.kscience.dataforge.names.* -import space.kscience.visionforge.VisionChildren.Companion.STATIC_TOKEN_BODY - -@DslMarker -public annotation class VisionBuilder - -public interface VisionContainer { - public fun getChild(name: Name): V? -} - -public interface MutableVisionContainer { - //TODO add documentation - public fun setChild(name: Name?, child: V?) -} - -/** - * A serializable representation of [Vision] children container - */ -public interface VisionChildren : VisionContainer { - public val parent: Vision? - - public val keys: Set - - public val values: Iterable get() = keys.map { get(it)!! } - - public val changes: Flow - - public operator fun get(token: NameToken): Vision? - - override fun getChild(name: Name): Vision? = when (name.length) { - 0 -> parent - 1 -> get(name.first()) - else -> get(name.first())?.children?.getChild(name.cutFirst()) - } - - public companion object { - public const val STATIC_TOKEN_BODY: String = "@static" - - public fun empty(owner: Vision): VisionChildren = object : VisionChildren { - override val parent: Vision get() = owner - override val keys: Set get() = emptySet() - override val changes: Flow get() = emptyFlow() - override fun get(token: NameToken): Vision? = null - } - } -} - -public operator fun VisionChildren.get(name: Name): Vision? = getChild(name) -public operator fun VisionChildren.get(name: String): Vision? = getChild(name) - - -public fun VisionChildren.isEmpty(): Boolean = keys.isEmpty() - -public inline fun VisionChildren.forEach(block: (NameToken, Vision) -> Unit) { - keys.forEach { block(it, get(it)!!) } -} - -public interface MutableVisionChildren : VisionChildren, MutableVisionContainer { - - public override val parent: MutableVisionGroup - - public operator fun set(token: NameToken, value: Vision?) - - override fun setChild(name: Name?, child: Vision?) { - when { - name == null -> { - if (child != null) { - static(child) - } - } - - name.isEmpty() -> error("Empty names are not allowed in VisionGroup::set") - name.length == 1 -> { - val token = name.tokens.first() - set(token, child) - } - - else -> { - val currentParent = get(name.first()) - if (currentParent != null && currentParent !is MutableVisionGroup) error("Can't assign a child to $currentParent") - val parent: MutableVisionGroup = currentParent as? MutableVisionGroup ?: parent.createGroup().also { - set(name.first(), it) - } - parent.children.setChild(name.cutFirst(), child) - } - } - } - - public fun clear() -} - -public operator fun MutableVisionChildren.set(name: Name?, vision: Vision?) { - setChild(name, vision) -} - -public operator fun MutableVisionChildren.set(name: String?, vision: Vision?) { - setChild(name, vision) -} - - -/** - * Add a static child. Statics could not be found by name, removed or replaced. Changing statics also do not trigger events. - */ -public fun MutableVisionChildren.static(child: Vision) { - set(NameToken(STATIC_TOKEN_BODY, index = child.hashCode().toString()), child) -} - -public fun VisionChildren.asSequence(): Sequence> = sequence { - keys.forEach { yield(it to get(it)!!) } -} - -public operator fun VisionChildren.iterator(): Iterator> = asSequence().iterator() - -public fun VisionContainer.getChild(str: String): V? = getChild(Name.parse(str)) - -public fun MutableVisionContainer.setChild( - str: String?, vision: V?, -): Unit = setChild(str?.parseAsName(), vision) - -internal abstract class VisionChildrenImpl( - override val parent: MutableVisionGroup, -) : MutableVisionChildren { - - private val updateJobs = HashMap() - - abstract var items: MutableMap? - - @JvmSynchronized - private fun buildItems(): MutableMap { - if (items == null) { - items = LinkedHashMap() - } - return items!! - } - - private val scope: CoroutineScope? get() = parent.manager?.context - - override val keys: Set get() = items?.keys ?: emptySet() - - override fun get(token: NameToken): Vision? = items?.get(token) - - private val _changes = MutableSharedFlow() - override val changes: SharedFlow get() = _changes - - private fun onChange(name: Name) { - scope?.launch { - _changes.emit(name) - } - } - - override operator fun set(token: NameToken, value: Vision?) { - //fast return if value equals existing - if (value == get(token)) return - - val currentUpdateJob = updateJobs[token] - if (currentUpdateJob != null) { - currentUpdateJob.cancel() - updateJobs.remove(token) - } - - if (value == null) { - items?.remove(token) - } else { - (items ?: buildItems())[token] = value - //check if parent already exists and is different from the current one - if (value.parent != null && value.parent != parent) error("Can't reassign parent Vision for $value") - //set parent - value.parent = parent - //start update jobs (only if the vision is rooted) - scope?.let { scope -> - val job = value.children?.changes?.onEach { - onChange(token + it) - }?.launchIn(scope) - if (job != null) { - updateJobs[token] = job - } - } - } - - onChange(token.asName()) - } - - override fun clear() { - items?.forEach { set(it.key, null) } -// if (!items.isNullOrEmpty()) { -// updateJobs.values.forEach { -// it.cancel() -// } -// updateJobs.clear() -// items?.clear() -// } - } -} -// -//internal object VisionChildrenContainerSerializer : KSerializer { -// private val mapSerializer = serializer>() -// -// override val descriptor: SerialDescriptor = mapSerializer.descriptor -// -// override fun deserialize(decoder: Decoder): MutableVisionChildren { -// val map = decoder.decodeSerializableValue(mapSerializer) -// return VisionChildrenImpl(map) -// } -// -// override fun serialize(encoder: Encoder, value: MutableVisionChildren) { -// val map = value.keys.associateWith { value[it]!! } -// encoder.encodeSerializableValue(mapSerializer, map) -// } -// -//} 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 8a651ffc..12fe243b 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt @@ -1,119 +1,109 @@ 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.parseAsName -import space.kscience.dataforge.names.plus -import space.kscience.visionforge.Vision.Companion.STYLE_KEY +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.launch +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.dataforge.names.* +import space.kscience.dataforge.provider.Provider +@DslMarker +public annotation class VisionBuilder -public interface VisionGroup : Vision { - public val children: VisionChildren +public interface VisionContainer { + public operator fun get(name: Name): V? } -public interface MutableVisionGroup : VisionGroup { - - override val children: MutableVisionChildren - - public fun createGroup(): MutableVisionGroup -} - -public val Vision.children: VisionChildren? get() = (this as? VisionGroup)?.children - /** - * A full base implementation for a [Vision] + * Represents a group of [Vision] instances */ -@Serializable -public abstract class AbstractVisionGroup : AbstractVision(), MutableVisionGroup { +public interface VisionGroup : Provider, Vision, VisionContainer { + /** + * A map of top level named children + */ + public val children: Map - override fun update(change: VisionChange) { - change.children?.forEach { (name, change) -> - when { - change.vision == NullVision -> children.setChild(name, null) - change.vision != null -> children.setChild(name, change.vision) - else -> children.getChild(name)?.update(change) - } - } - change.properties?.let { - updateProperties(it, Name.EMPTY) - } - } + override val defaultTarget: String get() = Vision.TYPE - @SerialName("children") - protected var childrenInternal: MutableMap? = null - - - init { - childrenInternal?.forEach { it.value.parent = this } - } - - override val children: MutableVisionChildren by lazy { - object : VisionChildrenImpl(this) { - override var items: MutableMap? - get() = this@AbstractVisionGroup.childrenInternal - set(value) { - this@AbstractVisionGroup.childrenInternal = value + /** + * A map of direct children for specific target + * (currently "visual" or "style") + */ + override fun content(target: String): Map = + when (target) { + Vision.TYPE -> children.flatMap { (key, value) -> + val res: Map = if (value is VisionGroup) { + value.content(target).mapKeys { key + it.key } + } else { + mapOf(key.asName() to value) } + res.entries + }.associate { it.toPair() } + STYLE_TARGET -> styleSheet.items?.mapKeys { it.key.asName() } ?: emptyMap() + else -> emptyMap() + } + + public override operator fun get(name: Name): Vision? { + return when { + name.isEmpty() -> this + name.length == 1 -> children[name.tokens.first()] + else -> (children[name.tokens.first()] as? VisionGroup)?.get(name.cutFirst()) } } - abstract override fun createGroup(): AbstractVisionGroup - public companion object { - public val descriptor: MetaDescriptor = MetaDescriptor { - value(STYLE_KEY, ValueType.STRING) { - multiple = true - } - } - - public fun Vision.updateProperties(item: Meta, name: Name = Name.EMPTY) { - properties.setValue(name, item.value) - item.items.forEach { (token, item) -> - updateProperties(item, name + token) - } - } - + public const val STYLE_TARGET: String = "style" } } /** - * A simple vision group that just holds children. Nothing else. + * Iterate over children of this group */ -@Serializable -@SerialName("vision.group") -public class SimpleVisionGroup : AbstractVisionGroup(), MutableVisionContainer { - override fun createGroup(): SimpleVisionGroup = SimpleVisionGroup() +public operator fun VisionGroup.iterator(): Iterator = children.values.iterator() - override fun setChild(name: Name?, child: Vision?) { - children.setChild(name, child) - } +public val VisionGroup.isEmpty: Boolean get() = this.children.isEmpty() + +public interface VisionContainerBuilder { + //TODO add documentation + public operator fun set(name: Name?, child: V?) +} + +/** + * Mutable version of [VisionGroup] + */ +public interface MutableVisionGroup : VisionGroup, VisionContainerBuilder { + public fun onStructureChanged(owner: Any?, block: VisionGroup.(Name) -> Unit) + + public fun removeStructureListener(owner: Any?) } -@VisionBuilder -public inline fun MutableVisionContainer.group( - name: Name? = null, - builder: SimpleVisionGroup.() -> Unit = {}, -): SimpleVisionGroup = SimpleVisionGroup().also { setChild(name, it) }.apply(builder) /** - * Define a group with given [name], attach it to this parent and return it. + * Flow structure changes of this group. Unconsumed changes are discarded */ -@VisionBuilder -public inline fun MutableVisionContainer.group( - name: String, - builder: SimpleVisionGroup.() -> Unit = {}, -): SimpleVisionGroup = group(name.parseAsName(), builder) +@OptIn(ExperimentalCoroutinesApi::class) +@DFExperimental +public val MutableVisionGroup.structureChanges: Flow + get() = callbackFlow { + meta.onChange(this) { name -> + launch { + send(name) + } + } + awaitClose { + removeStructureListener(this) + } + } -//fun VisualObject.findStyle(styleName: Name): Meta? { -// if (this is VisualGroup) { -// val style = resolveStyle(styleName) -// if (style != null) return style -// } -// return parent?.findStyle(styleName) -//} \ No newline at end of file + +public operator fun VisionContainer.get(str: String): V? = get(Name.parse(str)) + +public operator fun VisionContainerBuilder.set(token: NameToken, child: V?): Unit = + set(token.asName(), child) + +public operator fun VisionContainerBuilder.set(key: String?, child: V?): Unit = + set(key?.let(Name::parse), child) + +public fun MutableVisionGroup.removeAll(): Unit = children.keys.map { it.asName() }.forEach { this[it] = null } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt new file mode 100644 index 00000000..7280ae1f --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt @@ -0,0 +1,168 @@ +package space.kscience.visionforge + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient +import space.kscience.dataforge.names.* +import kotlin.jvm.Synchronized + +private class StructureChangeListener(val owner: Any?, val callback: VisionGroup.(Name) -> Unit) + +/** + * Abstract implementation of mutable group of [Vision] + * + * @param childrenInternal Internal mutable container for group children + */ +@Serializable +@SerialName("vision.group") +public open class VisionGroupBase( + @SerialName("children") protected val childrenInternal: MutableMap = LinkedHashMap(), +) : VisionBase(), MutableVisionGroup { + + /** + * A map of top level named children + */ + override val children: Map get() = childrenInternal + + init { + childrenInternal.forEach { (token, child) -> + if (child.parent != null && child.parent != this) error("Can't reassign existing parent for child $token") + child.parent = this + } + } + + override fun invalidateProperty(propertyName: Name) { + super.invalidateProperty(propertyName) + for (obj in this) { + obj.invalidateProperty(propertyName) + } + } + + @Transient + private val structureListeners = HashSet() + + @Synchronized + override fun onStructureChanged(owner: Any?, block: VisionGroup.(Name) -> Unit) { + structureListeners.add(StructureChangeListener(owner, block)) + } + + @Synchronized + override fun removeStructureListener(owner: Any?) { + structureListeners.removeAll { it.owner == owner } + } + + /** + * Propagate children change event upwards + */ + protected fun childrenChanged(name: Name) { + structureListeners.forEach { + it.callback(this, name) + } + } + + /** + * Add a static child. Statics could not be found by name, removed or replaced. Changing statics also do not trigger events. + */ + protected open fun addStatic(child: Vision): Unit { + attachChild(NameToken("@static", index = child.hashCode().toString()), child) + } + + /** + * Create a vision group of the same type as this vision group. Do not attach it. + */ + protected open fun createGroup(): VisionGroupBase = VisionGroupBase() + + /** + * Set parent for given child and attach it + */ + private fun attachChild(token: NameToken, child: Vision?) { + val before = children[token] + when { + child == null -> { + childrenInternal.remove(token) + } + child.parent == null -> { + child.parent = this + childrenInternal[token] = child + } + child.parent !== this -> { + error("Can't reassign existing parent for child $token") + } + } + if (before != child) { + childrenChanged(token.asName()) + if (child is MutableVisionGroup) { + child.onStructureChanged(this) { changedName -> + this@VisionGroupBase.childrenChanged(token + changedName) + } + } + } + } + + /** + * Recursively create a child group + */ + private fun createGroups(name: Name): VisionGroupBase { + return when { + name.isEmpty() -> error("Should be unreachable") + name.length == 1 -> { + val token = name.tokens.first() + when (val current = children[token]) { + null -> createGroup().also { child -> + attachChild(token, child) + } + is VisionGroupBase -> current + else -> error("Can't create group with name $name because it exists and not a group") + } + } + else -> createGroups(name.tokens.first().asName()).createGroups(name.cutFirst()) + } + } + + /** + * Add named or unnamed child to the group. If key is null the child is considered unnamed. Both key and value are not + * allowed to be null in the same time. If name is present and [child] is null, the appropriate element is removed. + */ + override fun set(name: Name?, child: Vision?): Unit { + when { + name == null -> { + if (child != null) { + addStatic(child) + } + } + name.isEmpty() -> error("Empty names are not allowed in VisionGroup::set") + name.length == 1 -> { + val token = name.tokens.first() + attachChild(token, child) + } + else -> { + //TODO add safety check + val parent = (get(name.cutLast()) as? MutableVisionGroup) ?: createGroups(name.cutLast()) + parent[name.tokens.last().asName()] = child + } + } + } + + override fun update(change: VisionChange) { + change.children?.forEach { (name, change) -> + when { + change.delete -> set(name, null) + change.vision != null -> set(name, change.vision) + else -> get(name)?.update(change) + } + } + super.update(change) + } +} + +/** + * Non-serializable root group used to propagate manager to its children + */ +internal class RootVisionGroup(override val manager: VisionManager) : VisionGroupBase() + +/** + * Designate this [VisionGroup] as a root group and assign a [VisionManager] as its parent + */ +public fun Vision.root(manager: VisionManager) { + parent = RootVisionGroup(manager) +} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt index e4ca1cdb..3f9bfaa8 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt @@ -1,6 +1,5 @@ package space.kscience.visionforge -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.PolymorphicSerializer import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonElement @@ -13,28 +12,25 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.toJson import space.kscience.dataforge.meta.toMeta import space.kscience.dataforge.names.Name -import space.kscience.visionforge.html.VisionOfCheckbox -import space.kscience.visionforge.html.VisionOfHtmlForm -import space.kscience.visionforge.html.VisionOfNumberField -import space.kscience.visionforge.html.VisionOfTextField +import kotlin.reflect.KClass -public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionContainer { +public class VisionManager(meta: Meta) : AbstractPlugin(meta) { override val tag: PluginTag get() = Companion.tag /** * Combined [SerializersModule] for all registered visions */ - public val serializersModule: SerializersModule by lazy { - SerializersModule { + public val serializersModule: SerializersModule + get() = SerializersModule { include(defaultSerialModule) context.gather(VISION_SERIALIZER_MODULE_TARGET).values.forEach { include(it) } } - } public val jsonFormat: Json get() = Json(defaultJson) { + encodeDefaults = false serializersModule = this@VisionManager.serializersModule } @@ -56,36 +52,28 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont public fun encodeToMeta(vision: Vision, descriptor: MetaDescriptor? = null): Meta = encodeToJsonElement(vision).toMeta(descriptor) - override fun setChild(name: Name?, child: Vision?) { - child?.setAsRoot(this) - } - public companion object : PluginFactory { override val tag: PluginTag = PluginTag(name = "vision", group = PluginTag.DATAFORGE_GROUP) + override val type: KClass = VisionManager::class public const val VISION_SERIALIZER_MODULE_TARGET: String = "visionSerializerModule" - override fun build(context: Context, meta: Meta): VisionManager = VisionManager(meta) + override fun invoke(meta: Meta, context: Context): VisionManager = VisionManager(meta) private val defaultSerialModule: SerializersModule = SerializersModule { polymorphic(Vision::class) { - defaultDeserializer { SimpleVisionGroup.serializer() } - subclass(NullVision.serializer()) - subclass(SimpleVisionGroup.serializer()) - subclass(VisionOfNumberField.serializer()) - subclass(VisionOfTextField.serializer()) - subclass(VisionOfCheckbox.serializer()) - subclass(VisionOfHtmlForm.serializer()) + default { VisionBase.serializer() } + subclass(VisionBase.serializer()) + subclass(VisionGroupBase.serializer()) } } - @OptIn(ExperimentalSerializationApi::class) public val defaultJson: Json = Json { serializersModule = defaultSerialModule prettyPrint = true useArrayPolymorphism = false + encodeDefaults = false ignoreUnknownKeys = true - explicitNulls = false } internal val visionSerializer: PolymorphicSerializer = PolymorphicSerializer(Vision::class) @@ -106,22 +94,7 @@ public abstract class VisionPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(met /** * Fetch a [VisionManager] from this plugin or create a child plugin with a [VisionManager] */ -public val Context.visionManager: VisionManager get() = request(VisionManager ) +public val Context.visionManager: VisionManager get() = fetch(VisionManager) public fun Vision.encodeToString(): String = - manager?.encodeToString(this) ?: error("Orphan vision could not be encoded") - -/** - * A root vision attached to [VisionManager] - */ -public class RootVision(override val manager: VisionManager) : AbstractVisionGroup() { - override fun createGroup(): SimpleVisionGroup = SimpleVisionGroup() -} - -/** - * Designate this [Vision] as a root and assign a [VisionManager] as its parent - */ -public fun Vision.setAsRoot(manager: VisionManager) { - if (parent != null) error("Vision $this already has a parent. It could not be set as root") - parent = RootVision(manager) -} \ No newline at end of file + manager?.encodeToString(this) ?: error("VisionManager not defined in Vision") \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt deleted file mode 100644 index 2fa88248..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt +++ /dev/null @@ -1,303 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.SharedFlow -import kotlinx.coroutines.launch -import kotlinx.serialization.Transient -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.names.* - -public interface VisionProperties { - - /** - * Raw Visions own properties without styles, defaults, etc. - */ - public val own: Meta? - - public val descriptor: MetaDescriptor? - - public fun getValue( - name: Name, - inherit: Boolean? = null, - includeStyles: Boolean? = null, - ): Value? - - /** - * Get property with given layer flags. - * @param inherit toggles parent node property lookup. Null means inference from descriptor. - * @param includeStyles toggles inclusion of properties from styles. - */ - public fun getProperty( - name: Name, - inherit: Boolean? = null, - includeStyles: Boolean? = null, - ): Meta - - public val changes: Flow - - /** - * Notify all listeners that a property has been changed and should be invalidated. - * This method does not check that the property has actually changed. - */ - public fun invalidate(propertyName: Name) -} - -public interface MutableVisionProperties : VisionProperties { - - override fun getProperty( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): MutableMeta = VisionPropertiesItem( - this, - name, - inherit, - includeStyles, - ) - - public fun setProperty( - name: Name, - node: Meta?, - notify: Boolean = true, - ) - - public fun setValue( - name: Name, - value: Value?, - notify: Boolean = true, - ) -} - -public fun MutableVisionProperties.remove(name: Name) { - setProperty(name, null) -} - -public fun MutableVisionProperties.remove(name: String) { - remove(name.parseAsName()) -} - -@VisionBuilder -public operator fun MutableVisionProperties.invoke(block: MutableMeta.() -> Unit) { - root(inherit = false, includeStyles = false).apply(block) -} - -private class VisionPropertiesItem( - val properties: MutableVisionProperties, - val nodeName: Name, - val inherit: Boolean? = null, - val useStyles: Boolean? = null, - val default: Meta? = null, -) : MutableMeta { - - val descriptor: MetaDescriptor? by lazy { properties.descriptor?.get(nodeName) } - - - override val items: Map - get() { - val metaKeys = properties.own?.getMeta(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 - val stylesFlag = descriptor?.usesStyles ?: useStyles - return (metaKeys + descriptorKeys + defaultKeys).associateWith { - VisionPropertiesItem( - properties, - nodeName + it, - inheritFlag, - stylesFlag, - default - ) - } - } - - override var value: Value? - get() { - val inheritFlag = descriptor?.inherited ?: inherit ?: false - val stylesFlag = descriptor?.usesStyles ?: useStyles ?: true - return properties.getValue(nodeName, inheritFlag, stylesFlag) ?: default?.getValue(nodeName) - } - set(value) { - properties.setValue(nodeName, value) - } - - override fun getOrCreate(name: Name): MutableMeta = VisionPropertiesItem( - properties, - nodeName + name, - inherit, - useStyles, - default - ) - - override fun setMeta(name: Name, node: Meta?) { - properties.setProperty(nodeName + name, node) - } - - override fun toString(): String = Meta.toString(this) - override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta) - override fun hashCode(): Int = Meta.hashCode(this) -} - -/** - * A base implementation of [MutableVisionProperties] - */ -public abstract class AbstractVisionProperties( - public val vision: Vision, -) : MutableVisionProperties { - override val descriptor: MetaDescriptor? get() = vision.descriptor - - protected abstract var properties: MutableMeta? - - override val own: Meta? get() = properties - - @JvmSynchronized - protected fun getOrCreateProperties(): MutableMeta { - if (properties == null) { - //TODO check performance issues - val newProperties = MutableMeta() - properties = newProperties - } - return properties!! - } - - private val descriptorCache = HashMap() - - override fun getValue( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): Value? { - own?.get(name)?.value?.let { return it } - - val descriptor = descriptor?.let { descriptor -> descriptorCache.getOrPut(name) { descriptor[name] } } - val stylesFlag = includeStyles ?: descriptor?.usesStyles ?: true - - if (stylesFlag) { - vision.getStyleProperty(name)?.value?.let { return it } - } - - val inheritFlag = inherit ?: descriptor?.inherited ?: false - if (inheritFlag) { - vision.parent?.properties?.getValue(name, inheritFlag, stylesFlag)?.let { return it } - } - return descriptor?.defaultValue - } - - override fun setProperty(name: Name, node: Meta?, notify: Boolean) { - //ignore if the value is the same as existing - if (own?.getMeta(name) == node) return - - if (name.isEmpty()) { - properties = node?.asMutableMeta() - } else if (node == null) { - properties?.setMeta(name, node) - } else { - getOrCreateProperties().setMeta(name, node) - } - if (notify) { - invalidate(name) - } - } - - override fun setValue(name: Name, value: Value?, notify: Boolean) { - //ignore if the value is the same as existing - if (own?.getValue(name) == value) return - - if (value == null) { - properties?.getMeta(name)?.value = null - } else { - getOrCreateProperties().setValue(name, value) - } - if (notify) { - invalidate(name) - } - } - - @Transient - protected val changesInternal: MutableSharedFlow = MutableSharedFlow() - override val changes: SharedFlow get() = changesInternal - - override fun invalidate(propertyName: Name) { - //send update signal - @OptIn(DelicateCoroutinesApi::class) - (vision.manager?.context ?: GlobalScope).launch { - changesInternal.emit(propertyName) - } - - //notify children if there are any - if (vision is VisionGroup) { - vision.children.values.forEach { - it.properties.invalidate(propertyName) - } - } - - // update styles - if (propertyName == Vision.STYLE_KEY) { - vision.styles.asSequence() - .mapNotNull { vision.getStyle(it) } - .flatMap { it.items.asSequence() } - .distinctBy { it.key } - .forEach { - invalidate(it.key.asName()) - } - } - } -} - -public fun VisionProperties.getValue( - name: String, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): Value? = getValue(name.parseAsName(), inherit, includeStyles) - -/** - * Get [Vision] property using key as a String - */ -public fun VisionProperties.getProperty( - name: String, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): Meta = getProperty(name.parseAsName(), inherit, includeStyles) - -/** - * The root property node with given inheritance and style flags - * @param inherit - inherit properties from the [Vision] parent. If null, infer from descriptor - * @param includeStyles - include style information. If null, infer from descriptor - */ -public fun MutableVisionProperties.root( - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): MutableMeta = getProperty(Name.EMPTY, inherit, includeStyles) - - -/** - * Get [Vision] property using key as a String - */ -public fun MutableVisionProperties.getProperty( - name: String, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): MutableMeta = getProperty(name.parseAsName(), inherit, includeStyles) - - -public operator fun MutableVisionProperties.set(name: Name, value: Number): Unit = - setValue(name, value.asValue()) - -public operator fun MutableVisionProperties.set(name: String, value: Number): Unit = - set(name.parseAsName(), value) - -public operator fun MutableVisionProperties.set(name: Name, value: Boolean): Unit = - setValue(name, value.asValue()) - -public operator fun MutableVisionProperties.set(name: String, value: Boolean): Unit = - set(name.parseAsName(), value) - -public operator fun MutableVisionProperties.set(name: Name, value: String): Unit = - setValue(name, value.asValue()) - -public operator fun MutableVisionProperties.set(name: String, value: String): Unit = - set(name.parseAsName(), value) \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionPropertyContainer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionPropertyContainer.kt new file mode 100644 index 00000000..fed474fc --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionPropertyContainer.kt @@ -0,0 +1,34 @@ +package space.kscience.visionforge + +import space.kscience.dataforge.meta.Configurable +import space.kscience.dataforge.meta.MutableMeta +import space.kscience.dataforge.meta.ObservableMutableMeta +import space.kscience.dataforge.meta.get +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.values.Value + +/** + * Property containers are used to create a symmetric behaviors for vision properties and style builders + */ +public interface VisionPropertyContainer { + + public val meta: MutableMeta + + public fun getPropertyValue( + name: Name, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true, + ): Value? +} + +public open class SimpleVisionPropertyContainer( + override val meta: ObservableMutableMeta, +) : VisionPropertyContainer, Configurable { + override fun getPropertyValue( + name: Name, + inherit: Boolean, + includeStyles: Boolean, + includeDefaults: Boolean + ): Value? = meta[name]?.value +} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt deleted file mode 100644 index c8f14ae3..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt +++ /dev/null @@ -1,55 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.Value -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.parseAsName -import space.kscience.dataforge.names.startsWith - -/** - * Create a flow of a specific property - */ -public fun Vision.flowProperty( - propertyName: Name, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): Flow = flow { - //Pass initial value. - emit(properties.getProperty(propertyName, inherit, includeStyles)) - properties.changes.collect { name -> - if (name.startsWith(propertyName)) { - emit(properties.getProperty(propertyName, inherit, includeStyles)) - } - } -} - -public fun Vision.flowProperty( - propertyName: String, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): Flow = flowProperty(propertyName.parseAsName(), inherit, includeStyles) - -/** - * Flow the value of specific property - */ -public fun Vision.flowPropertyValue( - propertyName: Name, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): Flow = flow { - //Pass initial value. - emit(properties.getValue(propertyName, inherit, includeStyles)) - properties.changes.collect { name -> - if (name.startsWith(propertyName)) { - emit(properties.getValue(propertyName, inherit, includeStyles)) - } - } -} - -public fun Vision.flowPropertyValue( - propertyName: String, - inherit: Boolean? = null, - includeStyles: Boolean? = null, -): Flow = flowPropertyValue(propertyName.parseAsName(), inherit, includeStyles) diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlFragment.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlFragment.kt deleted file mode 100644 index ec3f3605..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlFragment.kt +++ /dev/null @@ -1,31 +0,0 @@ -package space.kscience.visionforge.html - -import kotlinx.html.FlowContent -import kotlinx.html.TagConsumer -import kotlinx.html.stream.createHTML - -/** - * A standalone HTML fragment - */ -public fun interface HtmlFragment { - public fun TagConsumer<*>.append() -} - -/** - * Convenience method to append fragment to the given [consumer] - */ -public fun HtmlFragment.appendTo(consumer: TagConsumer<*>): Unit = consumer.append() - -/** - * Create a string from this [HtmlFragment] - */ -public fun HtmlFragment.renderToString(): String = createHTML().apply { append() }.finalize() - -public fun TagConsumer<*>.appendFragment(fragment: HtmlFragment): Unit = fragment.appendTo(this) - -public fun FlowContent.appendFragment(fragment: HtmlFragment): Unit = fragment.appendTo(consumer) - -public operator fun HtmlFragment.plus(other: HtmlFragment): HtmlFragment = HtmlFragment { - this@plus.appendTo(this) - other.appendTo(this) -} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionFragment.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionFragment.kt new file mode 100644 index 00000000..9be18263 --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionFragment.kt @@ -0,0 +1,23 @@ +package space.kscience.visionforge.html + +import kotlinx.html.FlowContent +import kotlinx.html.TagConsumer +import kotlinx.html.stream.createHTML +import space.kscience.dataforge.misc.DFExperimental + +public typealias HtmlFragment = TagConsumer<*>.() -> Unit + +public fun HtmlFragment.render(): String = createHTML().apply(this).finalize() + +public fun TagConsumer<*>.fragment(fragment: HtmlFragment) { + fragment() +} + +public fun FlowContent.fragment(fragment: HtmlFragment) { + fragment(consumer) +} + +public typealias HtmlVisionFragment = VisionTagConsumer<*>.() -> Unit + +@DFExperimental +public fun HtmlVisionFragment(content: VisionTagConsumer<*>.() -> Unit): HtmlVisionFragment = content \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt index c02b6e64..e45e4f08 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt @@ -2,105 +2,53 @@ package space.kscience.visionforge.html import kotlinx.html.* import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.NameToken -import space.kscience.dataforge.names.asName import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager -public fun interface HtmlVisionFragment{ - public fun VisionTagConsumer<*>.append() -} -public fun HtmlVisionFragment.appendTo(consumer: VisionTagConsumer<*>): Unit = consumer.append() - -/** - * Render a fragment in the given consumer and return a map of extracted visions - * @param context a context used to create a vision fragment - * @param embedData embed Vision initial state in the HTML - * @param fetchDataUrl fetch data after first render from given url - * @param updatesUrl receive push updates from the server at given url - * @param idPrefix a prefix to be used before vision ids - */ -public fun TagConsumer<*>.visionFragment( - visionManager: VisionManager, - embedData: Boolean = true, - fetchDataUrl: String? = null, - updatesUrl: String? = null, +public fun TagConsumer<*>.embedVisionFragment( + manager: VisionManager, idPrefix: String? = null, - onVisionRendered: (Name, Vision) -> Unit = { _, _ -> }, fragment: HtmlVisionFragment, -) { - - val collector: MutableMap> = mutableMapOf() - - val consumer = object : VisionTagConsumer(this@visionFragment, visionManager, idPrefix) { - - override fun TagConsumer.vision(name: Name?, buildOutput: VisionOutput.() -> Vision): T { - //Avoid re-creating cached visions - val actualName = name ?: NameToken( - DEFAULT_VISION_NAME, - buildOutput.hashCode().toUInt().toString() - ).asName() - - val (output, vision) = collector.getOrPut(actualName) { - val output = VisionOutput(context, actualName) - val vision = output.buildOutput() - onVisionRendered(actualName, vision) - output to vision - } - - return addVision(actualName, output.visionManager, vision, output.meta) - } - - override fun DIV.renderVision(manager: VisionManager, name: Name, vision: Vision, outputMeta: Meta) { - - val (_, actualVision) = collector.getOrPut(name) { - val output = VisionOutput(context, name) - onVisionRendered(name, vision) - output to vision - } - - - // Toggle update mode - updatesUrl?.let { - attributes[OUTPUT_CONNECT_ATTRIBUTE] = it - } - - fetchDataUrl?.let { - attributes[OUTPUT_FETCH_ATTRIBUTE] = it - } - - if (embedData) { - script { - type = "text/json" - attributes["class"] = OUTPUT_DATA_CLASS - unsafe { - +"\n${manager.encodeToString(actualVision)}\n" - } +): Map { + val visionMap = HashMap() + val consumer = object : VisionTagConsumer(this@embedVisionFragment, manager, idPrefix) { + override fun DIV.renderVision(name: Name, vision: Vision, outputMeta: Meta) { + visionMap[name] = vision + script { + type = "text/json" + attributes["class"] = OUTPUT_DATA_CLASS + unsafe { + +"\n${manager.encodeToString(vision)}\n" } } } } - - fragment.appendTo(consumer) + fragment(consumer) + return visionMap } -public fun FlowContent.visionFragment( - visionManager: VisionManager, - embedData: Boolean = true, - fetchDataUrl: String? = null, - updatesUrl: String? = null, - onVisionRendered: (Name, Vision) -> Unit = { _, _ -> }, +public fun FlowContent.embedVisionFragment( + manager: VisionManager, idPrefix: String? = null, - fragment: HtmlVisionFragment, -): Unit = consumer.visionFragment( - visionManager = visionManager, - embedData = embedData, - fetchDataUrl = fetchDataUrl, - updatesUrl = updatesUrl, - idPrefix = idPrefix, - onVisionRendered = onVisionRendered, - fragment = fragment -) \ No newline at end of file +): Map = consumer.embedVisionFragment(manager, idPrefix, fragment) + + +internal const val RENDER_FUNCTION_NAME = "renderAllVisionsById" + +@DFExperimental +public fun TagConsumer<*>.embedAndRenderVisionFragment(manager: VisionManager, id: Any, fragment: HtmlVisionFragment) { + div { + div { + this.id = id.toString() + embedVisionFragment(manager, fragment = fragment) + } + script { + type = "text/javascript" + unsafe { +"window.${RENDER_FUNCTION_NAME}(\"$id\");" } + } + } +} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/Page.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/Page.kt new file mode 100644 index 00000000..6e807e92 --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/Page.kt @@ -0,0 +1,36 @@ +package space.kscience.visionforge.html + +import kotlinx.html.* +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.visionforge.visionManager + +public data class Page( + public val context: Context, + public val title: String, + public val headers: Map, + public val content: HtmlVisionFragment, +) { + public fun render(root: TagConsumer): R = root.apply { + head { + meta { + charset = "utf-8" + headers.values.forEach { + fragment(it) + } + } + title(this@Page.title) + } + body { + embedVisionFragment(context.visionManager, fragment = content) + } + }.finalize() +} + + +@DFExperimental +public fun Context.page( + title: String = "VisionForge page", + vararg headers: Pair, + content: HtmlVisionFragment, +): Page = Page(this, title, mapOf(*headers), content) \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt deleted file mode 100644 index d9c0347d..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt +++ /dev/null @@ -1,26 +0,0 @@ -package space.kscience.visionforge.html - -import kotlinx.html.FORM -import kotlinx.html.TagConsumer -import kotlinx.html.form -import kotlinx.html.id -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.node - -@Serializable -@SerialName("html.form") -public class VisionOfHtmlForm( - public val formId: String, -) : VisionOfHtmlInput() { - public var values: Meta? by mutableProperties.node() -} - -public fun TagConsumer.bindForm( - visionOfForm: VisionOfHtmlForm, - builder: FORM.() -> Unit, -): R = form { - this.id = visionOfForm.formId - builder() -} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlInput.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlInput.kt deleted file mode 100644 index 3a818b08..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlInput.kt +++ /dev/null @@ -1,57 +0,0 @@ -package space.kscience.visionforge.html - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import space.kscience.dataforge.meta.boolean -import space.kscience.dataforge.meta.number -import space.kscience.dataforge.meta.string -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.* - -//TODO replace by something -internal val Vision.mutableProperties get() = properties.getProperty(Name.EMPTY, false, false) - -@Serializable -public abstract class VisionOfHtmlInput : AbstractVision() { - public var disabled: Boolean by mutableProperties.boolean { false } -} - -@Serializable -@SerialName("html.text") -public class VisionOfTextField( - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var text: String? by mutableProperties.string() -} - -@Serializable -@SerialName("html.checkbox") -public class VisionOfCheckbox( - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var checked: Boolean? by mutableProperties.boolean() -} - -@Serializable -@SerialName("html.number") -public class VisionOfNumberField( - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var value: Number? by mutableProperties.number() -} - -@Serializable -@SerialName("html.range") -public class VisionOfRangeField( - public val min: Double, - public val max: Double, - public val step: Double = 1.0, - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var value: Number? by mutableProperties.number() -} - diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionPage.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionPage.kt deleted file mode 100644 index 1ea216c5..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionPage.kt +++ /dev/null @@ -1,43 +0,0 @@ -package space.kscience.visionforge.html - -import kotlinx.html.* -import space.kscience.visionforge.VisionManager - -/** - * A structure representing a single page with Visions to be rendered. - * - * @param pageHeaders static headers for this page. - */ -public data class VisionPage( - public val visionManager: VisionManager, - public val pageHeaders: Map = emptyMap(), - public val content: HtmlVisionFragment, -) { - public companion object{ - /** - * Use a script with given [src] as a global header for all pages. - */ - public fun scriptHeader(src: String, block: SCRIPT.() -> Unit = {}): HtmlFragment = HtmlFragment{ - script { - type = "text/javascript" - this.src = src - block() - } - } - - /** - * Use css with the given stylesheet link as a global header for all pages. - */ - public fun styleSheetHeader(href: String, block: LINK.() -> Unit = {}): HtmlFragment = HtmlFragment{ - link { - rel = "stylesheet" - this.href = href - block() - } - } - - public fun title(title:String): HtmlFragment = HtmlFragment{ - title(title) - } - } -} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt index 99a8ea0d..035b6a6e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt @@ -1,22 +1,17 @@ package space.kscience.visionforge.html import kotlinx.html.* -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.MetaSerializer import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.isEmpty +import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.asName -import space.kscience.dataforge.names.parseAsName import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.html.VisionTagConsumer.Companion.DEFAULT_VISION_NAME -import space.kscience.visionforge.setAsRoot -import space.kscience.visionforge.visionManager +import space.kscience.visionforge.root import kotlin.collections.set @DslMarker @@ -25,26 +20,12 @@ public annotation class VisionDSL /** * A placeholder object to attach inline vision builders. */ +@DFExperimental @VisionDSL -public class VisionOutput @PublishedApi internal constructor(override val context: Context, public val name: Name): ContextAware { +public class VisionOutput @PublishedApi internal constructor(public val manager: VisionManager) { public var meta: Meta = Meta.EMPTY - private val requirements: MutableSet> = HashSet() - - public fun requirePlugin(factory: PluginFactory<*>) { - requirements.add(factory) - } - - public val visionManager: VisionManager - get() = if (requirements.all { req -> context.plugins.find(true) { it.tag == req.tag } != null }) { - context.visionManager - } else { - val newContext = context.buildContext(NameToken(DEFAULT_VISION_NAME, name.toString()).asName()) { - plugin(VisionManager) - requirements.forEach { plugin(it) } - } - newContext.visionManager - } + //TODO expose a way to define required plugins. public inline fun meta(block: MutableMeta.() -> Unit) { this.meta = Meta(block) @@ -57,87 +38,70 @@ public class VisionOutput @PublishedApi internal constructor(override val contex @VisionDSL public abstract class VisionTagConsumer( private val root: TagConsumer, - public val visionManager: VisionManager, + public val manager: VisionManager, private val idPrefix: String? = null, -) : TagConsumer by root, ContextAware { +) : TagConsumer by root { - override val context: Context get() = visionManager.context - - public open fun resolveId(name: Name): String = (idPrefix ?: "output") + "[$name]" + public open fun resolveId(name: Name): String = (idPrefix ?: "output:") + name.toString() /** * Render a vision inside the output fragment - * @param manager a [VisionManager] to be used in renderer * @param name name of the output container * @param vision an object to be rendered * @param outputMeta optional configuration for the output container */ - protected abstract fun DIV.renderVision(manager: VisionManager, name: Name, vision: Vision, outputMeta: Meta) + protected abstract fun DIV.renderVision(name: Name, vision: Vision, outputMeta: Meta) /** * Create a placeholder for a vision output with optional [Vision] in it * TODO with multi-receivers could be replaced by [VisionTagConsumer, TagConsumer] extension */ - protected fun TagConsumer.addVision( + public fun TagConsumer.vision( name: Name, - manager: VisionManager, - vision: Vision?, + vision: Vision? = null, outputMeta: Meta = Meta.EMPTY, - ): T = if (vision == null) div { - +"Empty Vision output" - } else div { + ): T = div { id = resolveId(name) classes = setOf(OUTPUT_CLASS) - if (vision.parent == null) { - vision.setAsRoot(manager) - } attributes[OUTPUT_NAME_ATTRIBUTE] = name.toString() - renderVision(manager, name, vision, outputMeta) if (!outputMeta.isEmpty()) { //Hard-code output configuration script { - type = "text/json" attributes["class"] = OUTPUT_META_CLASS unsafe { - +("\n" + manager.jsonFormat.encodeToString(MetaSerializer, outputMeta) + "\n") + +manager.jsonFormat.encodeToString(MetaSerializer, outputMeta) } } } + vision?.let { + renderVision(name, it, outputMeta) + } } - /** - * Insert a vision in this HTML. - * TODO replace by multi-receiver - */ - @VisionDSL - public open fun TagConsumer.vision( - name: Name? = null, - buildOutput: VisionOutput.() -> Vision, + @OptIn(DFExperimental::class) + public inline fun TagConsumer.vision( + name: Name, + visionProvider: VisionOutput.() -> Vision, ): T { - val actualName = name ?: NameToken(DEFAULT_VISION_NAME, buildOutput.hashCode().toUInt().toString()).asName() - val output = VisionOutput(context, actualName) - val vision = output.buildOutput() - return addVision(actualName, output.visionManager, vision, output.meta) + val output = VisionOutput(manager) + val vision = output.visionProvider() + vision.root(manager) + return vision(name, vision, output.meta) } /** * TODO to be replaced by multi-receiver */ + @OptIn(DFExperimental::class) @VisionDSL - public fun TagConsumer.vision( - name: String?, - buildOutput: VisionOutput.() -> Vision, - ): T = vision(name?.parseAsName(), buildOutput) + public inline fun TagConsumer.vision( + name: String = DEFAULT_VISION_NAME, + visionProvider: VisionOutput.() -> Vision, + ): T = vision(Name.parse(name), visionProvider) - @VisionDSL - public open fun TagConsumer.vision( + public fun TagConsumer.vision( vision: Vision, - name: Name? = null, - outputMeta: Meta = Meta.EMPTY, - ) { - val actualName = name ?: NameToken(DEFAULT_VISION_NAME, vision.hashCode().toUInt().toString()).asName() - addVision(actualName, context.visionManager, vision, outputMeta) - } + ): T = vision(NameToken("vision", vision.hashCode().toString()).asName(), vision) /** * Process the resulting object produced by [TagConsumer] @@ -146,7 +110,9 @@ public abstract class VisionTagConsumer( //do nothing by default } - override fun finalize(): R = root.finalize().also { processResult(it) } + override fun finalize(): R { + return root.finalize().also { processResult(it) } + } public companion object { public const val OUTPUT_CLASS: String = "visionforge-output" @@ -156,14 +122,10 @@ public abstract class VisionTagConsumer( public const val OUTPUT_FETCH_ATTRIBUTE: String = "data-output-fetch" public const val OUTPUT_CONNECT_ATTRIBUTE: String = "data-output-connect" - public const val OUTPUT_RENDERED: String = "data-output-rendered" - public const val OUTPUT_NAME_ATTRIBUTE: String = "data-output-name" public const val OUTPUT_ENDPOINT_ATTRIBUTE: String = "data-output-endpoint" public const val DEFAULT_ENDPOINT: String = "." - public const val AUTO_DATA_ATTRIBUTE: String = "@auto" - public const val DEFAULT_VISION_NAME: String = "vision" } } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt deleted file mode 100644 index 87312f6f..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt +++ /dev/null @@ -1,54 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName -import space.kscience.dataforge.names.parseAsName -import space.kscience.dataforge.names.startsWith -import kotlin.reflect.KProperty1 - - -/** - * Call [callback] on initial value of the property and then on all subsequent values after change - */ -public fun Vision.useProperty( - propertyName: Name, - inherit: Boolean? = null, - includeStyles: Boolean? = null, - scope: CoroutineScope? = manager?.context, - callback: (Meta) -> Unit, -): Job { - //Pass initial value. - callback(properties.getProperty(propertyName, inherit, includeStyles)) - return properties.changes.onEach { name -> - if (name.startsWith(propertyName)) { - callback(properties.getProperty(propertyName, inherit, includeStyles)) - } - }.launchIn(scope ?: error("Orphan Vision can't observe properties")) -} - -public fun Vision.useProperty( - propertyName: String, - inherit: Boolean? = null, - includeStyles: Boolean? = null, - scope: CoroutineScope? = manager?.context, - callback: (Meta) -> Unit, -): Job = useProperty(propertyName.parseAsName(), inherit, includeStyles, scope, callback) - -public fun V.useProperty( - property: KProperty1, - scope: CoroutineScope? = manager?.context, - callback: V.(T) -> Unit, -): Job { - //Pass initial value. - callback(property.get(this)) - return properties.changes.onEach { name -> - if (name.startsWith(property.name.asName())) { - callback(property.get(this@useProperty)) - } - }.launchIn(scope ?: error("Orphan Vision can't observe properties")) -} \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDelegates.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDelegates.kt new file mode 100644 index 00000000..999bbb45 --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDelegates.kt @@ -0,0 +1,91 @@ +package space.kscience.visionforge + +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.values.Value +import space.kscience.dataforge.values.number +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KProperty + +//public fun Vision.propertyNode( +// name: Name? = null, +// inherit: Boolean = false, +// includeStyles: Boolean = true, +// includeDefaults: Boolean = true, +//): ReadWriteProperty = object : ReadWriteProperty { +// override fun getValue(thisRef: Any?, property: KProperty<*>): Meta? = +// getProperty(name ?: Name.parse(property.name), inherit, includeStyles, includeDefaults) +// +// override fun setValue(thisRef: Any?, property: KProperty<*>, value: Meta?) { +// meta.setMeta(name ?: Name.parse(property.name), value) +// } +//} +// +//public fun Vision.propertyNode( +// converter: MetaConverter, +// name: Name? = null, +// inherit: Boolean = false, +// includeStyles: Boolean = true, +// includeDefaults: Boolean = true, +//): ReadWriteProperty = object : ReadWriteProperty { +// override fun getValue(thisRef: Any?, property: KProperty<*>): T? = getProperty( +// name ?: Name.parse(property.name), +// inherit, +// includeStyles, +// includeDefaults +// )?.let(converter::metaToObject) +// +// override fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) { +// meta.setMeta(name ?: Name.parse(property.name), value?.let(converter::objectToMeta)) +// } +//} + +public fun Vision.propertyValue( + name: Name? = null, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true, +): ReadWriteProperty = object : ReadWriteProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Value? = + getPropertyValue(name ?: Name.parse(property.name), inherit, includeStyles, includeDefaults) + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Value?) { + meta.setValue(name ?: Name.parse(property.name), value) + } +} + +public fun Vision.propertyValue( + name: Name? = null, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true, + setter: (T) -> Value? = { it?.let(Value::of) }, + getter: (Value?) -> T, +): ReadWriteProperty = object : ReadWriteProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): T = getPropertyValue( + name ?: Name.parse(property.name), + inherit, + includeStyles, + includeDefaults + ).let(getter) + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { + meta.setValue(name ?: Name.parse(property.name), value?.let(setter)) + } +} + +public fun Vision.numberProperty( + name: Name? = null, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true +): ReadWriteProperty = propertyValue(name, inherit, includeStyles, includeDefaults) { it?.number } + +public fun Vision.numberProperty( + name: Name? = null, + inherit: Boolean = false, + includeStyles: Boolean = true, + includeDefaults: Boolean = true, + default: () -> Number +): ReadWriteProperty = propertyValue(name, inherit, includeStyles, includeDefaults) { + it?.number ?: default() +} \ No newline at end of file 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 66ee43e0..15ef9229 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDescriptor.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visionDescriptor.kt @@ -2,7 +2,7 @@ package space.kscience.visionforge import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.* -import space.kscience.dataforge.meta.set +import space.kscience.dataforge.values.asValue private const val INHERITED_DESCRIPTOR_ATTRIBUTE = "inherited" private const val STYLE_DESCRIPTOR_ATTRIBUTE = "useStyles" diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/StatisticsVisitor.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/StatisticsVisitor.kt index 5b989274..0a60c3c0 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/StatisticsVisitor.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/StatisticsVisitor.kt @@ -1,5 +1,6 @@ package space.kscience.visionforge.visitor +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow @@ -10,6 +11,7 @@ import space.kscience.visionforge.Vision import kotlin.reflect.KClass +@OptIn(ExperimentalCoroutinesApi::class) public suspend fun Vision.flowStatistics(statistics: (Name, Vision) -> T): Flow = callbackFlow { val visitor = object : VisionVisitor { override suspend fun visit(name: Name, vision: Vision){ diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/VisionVisitor.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/VisionVisitor.kt index 4ceab3d9..0533dc4e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/VisionVisitor.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/visitor/VisionVisitor.kt @@ -6,8 +6,7 @@ import kotlinx.coroutines.launch import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.plus import space.kscience.visionforge.Vision -import space.kscience.visionforge.children -import space.kscience.visionforge.forEach +import space.kscience.visionforge.VisionGroup public interface VisionVisitor { /** @@ -20,30 +19,30 @@ public interface VisionVisitor { /** * Rearrange children of given group */ - public suspend fun visitChildren(name: Name, group: Vision) { + public suspend fun visitChildren(name: Name, group: VisionGroup) { //Do nothing by default } public fun skip(name: Name, vision: Vision): Boolean = false - public companion object { + public companion object{ private fun CoroutineScope.visitTreeAsync( visionVisitor: VisionVisitor, name: Name, - vision: Vision, + vision: Vision ): Job = launch { if (visionVisitor.skip(name, vision)) return@launch visionVisitor.visit(name, vision) + if (vision is VisionGroup) { + visionVisitor.visitChildren(name, vision) - visionVisitor.visitChildren(name, vision) - - vision.children?.forEach { token, child -> - visitTreeAsync(visionVisitor, name + token, child) + for ((token, child) in vision.children) { + visitTreeAsync(visionVisitor, name + token, child) + } } } - /** * Recursively visit this [Vision] and all children */ diff --git a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt index eaea0a4e..3572dd42 100644 --- a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt +++ b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt @@ -3,10 +3,15 @@ package space.kscience.visionforge.html import kotlinx.html.* import kotlinx.html.stream.createHTML import space.kscience.dataforge.context.Global +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.configure +import space.kscience.dataforge.meta.set import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name -import space.kscience.visionforge.* +import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionBase +import space.kscience.visionforge.VisionManager import kotlin.collections.set import kotlin.test.Test @@ -18,24 +23,24 @@ fun FlowContent.renderVisionFragment( fragment: HtmlVisionFragment, ): Map { val visionMap = HashMap() - val consumer = object : VisionTagConsumer(consumer, Global.visionManager, idPrefix) { - override fun DIV.renderVision(manager: VisionManager, name: Name, vision: Vision, outputMeta: Meta) { + val consumer = object : VisionTagConsumer(consumer, Global.fetch(VisionManager), idPrefix) { + override fun DIV.renderVision(name: Name, vision: Vision, outputMeta: Meta) { visionMap[name] = vision renderer(name, vision, outputMeta) } } - fragment.appendTo(consumer) + fragment(consumer) return visionMap } -@DFExperimental -private fun VisionOutput.base(block: VisionGroup.() -> Unit) = context.visionManager.group().apply(block) - @DFExperimental class HtmlTagTest { - val fragment = HtmlVisionFragment{ + fun VisionOutput.base(block: VisionBase.() -> Unit) = + VisionBase().apply(block) + + val fragment: HtmlVisionFragment = { div { h1 { +"Head" } vision("ddd") { @@ -43,8 +48,10 @@ class HtmlTagTest { "metaProperty" put 87 } base { - properties["myProp"] = 82 - properties["otherProp"] = false + configure { + set("myProp", 82) + set("otherProp", false) + } } } } @@ -54,7 +61,7 @@ class HtmlTagTest { div { h2 { +"Properties" } ul { - vision.properties.own?.items?.forEach { + (vision as? VisionBase)?.meta?.items?.forEach { li { a { +it.key.toString() } p { +it.value.toString() } 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 e9a0685e..40b4c96e 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,127 +1,44 @@ package space.kscience.visionforge.meta -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.take -import kotlinx.coroutines.flow.toList -import kotlinx.coroutines.launch -import kotlinx.coroutines.test.runTest -import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.* -import space.kscience.visionforge.* +import space.kscience.dataforge.values.asValue +import space.kscience.visionforge.VisionBase import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals -import kotlin.time.Duration.Companion.milliseconds - - -private class TestScheme : Scheme() { - var ddd by int() - - companion object : SchemeSpec(::TestScheme) -} - -@OptIn(ExperimentalCoroutinesApi::class) -internal class VisionPropertyTest { - - private val manager = Global.request(VisionManager) +class VisionPropertyTest { @Test - fun testPropertyWrite() { - val vision = manager.group() - vision.properties["fff"] = 2 - vision.properties["fff.ddd"] = false + fun testPropertyWrite(){ + val vision = VisionBase() + vision.meta["fff"] = 2 + vision.meta["fff.ddd"] = false - assertEquals(2, vision.properties.getValue("fff")?.int) - assertEquals(false, vision.properties.getValue("fff.ddd")?.boolean) + assertEquals(2, vision.meta["fff"]?.int) + assertEquals(false, vision.meta["fff.ddd"]?.boolean) } @Test - fun testPropertyEdit() { - val vision = manager.group() - vision.properties.getProperty("fff.ddd").apply { + fun testPropertyEdit(){ + val vision = VisionBase() + vision.meta.getOrCreate("fff.ddd").apply { value = 2.asValue() } - assertEquals(2, vision.properties.getValue("fff.ddd")?.int) - assertNotEquals(true, vision.properties.getValue("fff.ddd")?.boolean) + assertEquals(2, vision.meta["fff.ddd"]?.int) + assertNotEquals(true, vision.meta["fff.ddd"]?.boolean) + } + + internal class TestScheme: Scheme(){ + var ddd by int() + companion object: SchemeSpec(::TestScheme) } @Test - fun testPropertyUpdate() { - val vision = manager.group() - vision.properties.getProperty("fff").updateWith(TestScheme) { + fun testPropertyUpdate(){ + val vision = VisionBase() + vision.meta.getOrCreate("fff").updateWith(TestScheme){ ddd = 2 } - assertEquals(2, vision.properties.getValue("fff.ddd")?.int) - } - - @Test - fun testChildrenPropertyPropagation() = runTest(timeout = 200.milliseconds) { - val group = Global.request(VisionManager).group { - properties { - "test" put 11 - } - group("child") { - properties { - "test" put 22 - } - } - } - - val child = group.children["child"]!! - - val deferred: CompletableDeferred = CompletableDeferred() - - var callCounter = 0 - - val subscription = child.useProperty("test", inherit = true) { - deferred.complete(it.value) - callCounter++ - } - - assertEquals(22, deferred.await()?.int) - assertEquals(1, callCounter) - - child.properties.remove("test") - - assertEquals(11, child.properties.getProperty("test", inherit = true).int) -// assertEquals(11, deferred.await()?.int) -// assertEquals(2, callCounter) - subscription.cancel() - } - - @Test - fun testChildrenPropertyFlow() = runTest(timeout = 200.milliseconds) { - val group = Global.request(VisionManager).group { - - properties { - "test" put 11 - } - - group("child") { - properties { - "test" put 22 - } - } - - } - - val child = group.children["child"]!! - - launch { - val list = child.flowPropertyValue("test", inherit = true).take(3).map { it?.int }.toList() - assertEquals(22, list.first()) - //assertEquals(11, list[1]) //a race - assertEquals(33, list.last()) - } - - //wait for subscription to be created - delay(5) - - child.properties.remove("test") - group.properties["test"] = 33 + assertEquals(2, vision.meta["fff.ddd"]?.int) } } \ No newline at end of file diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt index 85ead127..5e1e2470 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt @@ -2,7 +2,7 @@ package space.kscience.visionforge import kotlinx.browser.document import kotlinx.coroutines.CoroutineScope -import org.w3c.dom.Document +import kotlinx.dom.hasClass import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext @@ -36,7 +36,7 @@ public interface Application: CoroutineScope { * Starting point for an application. * @param state Initial state between Hot Module Replacement (HMR). */ - public fun start(document: Document, state: Map) + public fun start(state: Map) /** * Ending point for an application. @@ -46,13 +46,17 @@ public interface Application: CoroutineScope { } public fun startApplication(builder: () -> Application) { - fun start(document: Document, state: dynamic): Application{ - val application = builder() + fun start(state: dynamic): Application? { + return if (document.body?.hasClass("application") == true) { + val application = builder() - @Suppress("UnsafeCastFromDynamic") - application.start(document, state?.appState ?: emptyMap()) + @Suppress("UnsafeCastFromDynamic") + application.start(state?.appState ?: emptyMap()) - return application + application + } else { + null + } } var application: Application? = null @@ -69,9 +73,9 @@ public fun startApplication(builder: () -> Application) { } if (document.body != null) { - application = start(document, state) + application = start(state) } else { application = null - document.addEventListener("DOMContentLoaded", { application = start(document, state) }) + document.addEventListener("DOMContentLoaded", { application = start(state) }) } } \ No newline at end of file diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt deleted file mode 100644 index 75ec785a..00000000 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt +++ /dev/null @@ -1,74 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.dom.clear -import kotlinx.html.TagConsumer -import kotlinx.html.dom.append -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.InternalSerializationApi -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.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 -import kotlin.reflect.KClass -import kotlin.reflect.cast - -/** - * A browser renderer for a [Vision]. - */ -@Type(ElementVisionRenderer.TYPE) -public interface ElementVisionRenderer : Named { - - /** - * Give a [vision] integer rating based on this renderer capabilities. [ZERO_RATING] or negative values means that this renderer - * can't process a vision. The value of [DEFAULT_RATING] used for default renderer. Specialized renderers could specify - * higher value in order to "steal" rendering job - */ - public fun rateVision(vision: Vision): Int - - /** - * Display the [vision] inside a given [element] replacing its current content. - * @param meta additional parameters for rendering container - */ - public fun render(element: Element, name: Name, vision: Vision, meta: Meta = Meta.EMPTY) - - public companion object { - public const val TYPE: String = "elementVisionRenderer" - public const val ZERO_RATING: Int = 0 - public const val DEFAULT_RATING: Int = 10 - } -} - -/** - * A browser renderer for element of given type - */ -public class SingleTypeVisionRenderer( - public val kClass: KClass, - private val acceptRating: Int = ElementVisionRenderer.DEFAULT_RATING, - private val renderFunction: TagConsumer.(name: Name, vision: T, meta: Meta) -> Unit, -) : ElementVisionRenderer { - - @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class) - override val name: Name - get() = kClass.serializerOrNull()?.descriptor?.serialName?.parseAsName() - ?: kClass.toString().asName() - - override fun rateVision(vision: Vision): Int = - if (vision::class == kClass) acceptRating else ElementVisionRenderer.ZERO_RATING - - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { - element.clear() - element.append { - renderFunction(name, kClass.cast(vision), meta) - } - } -} - -public inline fun ElementVisionRenderer( - acceptRating: Int = ElementVisionRenderer.DEFAULT_RATING, - noinline renderFunction: TagConsumer.(name: Name, vision: T, meta: Meta) -> Unit, -): ElementVisionRenderer = SingleTypeVisionRenderer(T::class, acceptRating, renderFunction) diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt index c9146efd..017c615d 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt @@ -3,37 +3,30 @@ package space.kscience.visionforge import kotlinx.browser.document import kotlinx.browser.window import kotlinx.coroutines.Job -import kotlinx.coroutines.delay -import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.withLock +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import org.w3c.dom.* import org.w3c.dom.url.URL import space.kscience.dataforge.context.* import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.MetaSerializer -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.int -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.parseAsName +import space.kscience.visionforge.html.RENDER_FUNCTION_NAME import space.kscience.visionforge.html.VisionTagConsumer import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_CONNECT_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_ENDPOINT_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_FETCH_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_NAME_ATTRIBUTE -import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_RENDERED -import kotlin.time.Duration.Companion.milliseconds +import kotlin.reflect.KClass +import kotlin.time.Duration -/** - * A Kotlin-browser plugin that renders visions based on provided renderers and governs communication with the server. - */ public class VisionClient : AbstractPlugin() { override val tag: PluginTag get() = Companion.tag private val visionManager: VisionManager by require(VisionManager) + //private val visionMap = HashMap() + /** - * Up-going tree traversal in search for endpoint attribute. If element is null, return window URL + * Up-going tree traversal in search for endpoint attribute */ private fun resolveEndpoint(element: Element?): String { if (element == null) return window.location.href @@ -46,116 +39,88 @@ public class VisionClient : AbstractPlugin() { return attribute?.value } - internal val renderers by lazy { context.gather(ElementVisionRenderer.TYPE).values } + private fun getRenderers() = context.gather(ElementVisionRenderer.TYPE).values - private fun findRendererFor(vision: Vision): ElementVisionRenderer? = renderers.mapNotNull { - val rating = it.rateVision(vision) - if (rating > 0) { - rating to it - } else { - null - } - }.maxByOrNull { it.first }?.second + private fun findRendererFor(vision: Vision): ElementVisionRenderer? { + return getRenderers().mapNotNull { + val rating = it.rateVision(vision) + if (rating > 0) { + rating to it + } else { + null + } + }.maxByOrNull { it.first }?.second + } private fun Element.getEmbeddedData(className: String): String? = getElementsByClassName(className)[0]?.innerHTML private fun Element.getFlag(attribute: String): Boolean = attributes[attribute]?.value != null - private val mutex = Mutex() + private fun renderVision(name: String, element: Element, vision: Vision?, outputMeta: Meta) { + if (vision != null) { + val renderer = findRendererFor(vision) ?: error("Could nof find renderer for $vision") + renderer.render(element, vision, outputMeta) - private val changeCollector = VisionChangeBuilder() - - /** - * Communicate vision property changed from rendering engine to model - */ - public fun visionPropertyChanged(visionName: Name, propertyName: Name, item: Meta?) { - context.launch { - mutex.withLock { - changeCollector.propertyChanged(visionName, propertyName, item) - } - } - } - -// public fun visionChanged(name: Name?, child: Vision?) { -// changeCollector.setChild(name, child) -// } - - private fun renderVision(element: Element, name: Name, vision: Vision, outputMeta: Meta) { - vision.setAsRoot(visionManager) - val renderer = findRendererFor(vision) ?: error("Could not find renderer for ${vision::class}") - renderer.render(element, name, vision, outputMeta) - } - - private fun startVisionUpdate(element: Element, name: Name, vision: Vision?, outputMeta: Meta) { - element.attributes[OUTPUT_CONNECT_ATTRIBUTE]?.let { attr -> - val wsUrl = if (attr.value.isBlank() || attr.value == VisionTagConsumer.AUTO_DATA_ATTRIBUTE) { - val endpoint = resolveEndpoint(element) - logger.info { "Vision server is resolved to $endpoint" } - URL(endpoint).apply { - pathname += "/ws" - } - } else { - URL(attr.value) - }.apply { - protocol = "ws" - searchParams.append("name", name.toString()) - } - - logger.info { "Updating vision data from $wsUrl" } - - //Individual websocket for this element - WebSocket(wsUrl.toString()).apply { - onmessage = { messageEvent -> - val stringData: String? = messageEvent.data as? String - if (stringData != null) { - val change: VisionChange = visionManager.jsonFormat.decodeFromString( - VisionChange.serializer(), - stringData - ) - - // If change contains root vision replacement, do it - change.vision?.let { vision -> - renderVision(element, name, vision, outputMeta) - } - - logger.debug { "Got update $change for output with name $name" } - if (vision == null) error("Can't update vision because it is not loaded.") - vision.update(change) - } else { - logger.error { "WebSocket message data is not a string" } + element.attributes[OUTPUT_CONNECT_ATTRIBUTE]?.let { attr -> + val wsUrl = if (attr.value.isBlank() || attr.value == "auto") { + val endpoint = resolveEndpoint(element) + logger.info { "Vision server is resolved to $endpoint" } + URL(endpoint).apply { + pathname += "/ws" } + } else { + URL(attr.value) + }.apply { + protocol = "ws" + searchParams.append("name", name) } + logger.info { "Updating vision data from $wsUrl" } - //Backward change propagation - var feedbackJob: Job? = null + //Individual websocket for this element + WebSocket(wsUrl.toString()).apply { + onmessage = { messageEvent -> + val stringData: String? = messageEvent.data as? String + if (stringData != null) { + val change: VisionChange = visionManager.jsonFormat.decodeFromString( + VisionChange.serializer(), + stringData + ) - //Feedback changes aggregation time in milliseconds - val feedbackAggregationTime = meta["aggregationTime"]?.int ?: 300 - - onopen = { - feedbackJob = visionManager.context.launch { - while (isActive) { - delay(feedbackAggregationTime.milliseconds) - val change = changeCollector[name] ?: continue - if (!change.isEmpty()) { - mutex.withLock { - send(change.toJsonString(visionManager)) - change.reset() - } + if (change.vision != null) { + renderer.render(element, vision, outputMeta) } + + logger.debug { "Got update $change for output with name $name" } + vision.update(change) + } else { + console.error("WebSocket message data is not a string") } } - logger.info { "WebSocket update channel established for output '$name'" } - } - onclose = { - feedbackJob?.cancel() - logger.info { "WebSocket update channel closed for output '$name'" } - } - onerror = { - feedbackJob?.cancel() - logger.error { "WebSocket update channel error for output '$name'" } + + //Backward change propagation + var feedbackJob: Job? = null + + onopen = { + feedbackJob = vision.flowChanges( + visionManager, + Duration.Companion.milliseconds(300) + ).onEach { change -> + send(visionManager.encodeToString(change)) + }.launchIn(visionManager.context) + + console.info("WebSocket update channel established for output '$name'") + } + + onclose = { + feedbackJob?.cancel() + console.info("WebSocket update channel closed for output '$name'") + } + onerror = { + feedbackJob?.cancel() + console.error("WebSocket update channel error for output '$name'") + } } } } @@ -165,37 +130,38 @@ public class VisionClient : AbstractPlugin() { * Fetch from server and render a vision, described in a given with [VisionTagConsumer.OUTPUT_CLASS] class. */ public fun renderVisionIn(element: Element) { + val name = resolveName(element) ?: error("The element is not a vision output") + logger.info { "Found DF output with name $name" } if (!element.classList.contains(VisionTagConsumer.OUTPUT_CLASS)) error("The element $element is not an output element") - val name = resolveName(element)?.parseAsName() ?: error("The element is not a vision output") - if (element.attributes[OUTPUT_RENDERED]?.value == "true") { - logger.info { "VF output in element $element is already rendered" } - return - } else { - logger.info { "Rendering VF output with name $name" } - } val outputMeta = element.getEmbeddedData(VisionTagConsumer.OUTPUT_META_CLASS)?.let { - VisionManager.defaultJson.decodeFromString(MetaSerializer, it).also { - logger.info { "Output meta for $name: $it" } - } + VisionManager.defaultJson.decodeFromString(MetaSerializer, it) } ?: Meta.EMPTY + //Trying to render embedded vision + val embeddedVision = element.getEmbeddedData(VisionTagConsumer.OUTPUT_DATA_CLASS)?.let { + visionManager.decodeFromString(it) + } + when { - // fetch data if the path is provided + embeddedVision != null -> { + logger.info { "Found embedded vision for output with name $name" } + renderVision(name, element, embeddedVision, outputMeta) + } element.attributes[OUTPUT_FETCH_ATTRIBUTE] != null -> { val attr = element.attributes[OUTPUT_FETCH_ATTRIBUTE]!! - val fetchUrl = if (attr.value.isBlank() || attr.value == VisionTagConsumer.AUTO_DATA_ATTRIBUTE) { + val fetchUrl = if (attr.value.isBlank() || attr.value == "auto") { val endpoint = resolveEndpoint(element) logger.info { "Vision server is resolved to $endpoint" } URL(endpoint).apply { - pathname += "/data" + pathname += "/vision" } } else { URL(attr.value) }.apply { - searchParams.append("name", name.toString()) + searchParams.append("name", name) } logger.info { "Fetching vision data from $fetchUrl" } @@ -203,69 +169,30 @@ public class VisionClient : AbstractPlugin() { if (response.ok) { response.text().then { text -> val vision = visionManager.decodeFromString(text) - renderVision(element, name, vision, outputMeta) - startVisionUpdate(element, name, vision, outputMeta) + renderVision(name, element, vision, outputMeta) } } else { logger.error { "Failed to fetch initial vision state from $fetchUrl" } } } } - - // use embedded data if it is available - element.getElementsByClassName(VisionTagConsumer.OUTPUT_DATA_CLASS).length > 0 -> { - //Getting embedded vision data - val embeddedVision = element.getEmbeddedData(VisionTagConsumer.OUTPUT_DATA_CLASS)!!.let { - visionManager.decodeFromString(it) - } - logger.info { "Found embedded vision for output with name $name" } - renderVision(element, name, embeddedVision, outputMeta) - startVisionUpdate(element, name, embeddedVision, outputMeta) - } - - //Try to load vision via websocket - element.attributes[OUTPUT_CONNECT_ATTRIBUTE] != null -> { - startVisionUpdate(element, name, null, outputMeta) - } - else -> error("No embedded vision data / fetch url for $name") } - element.setAttribute(OUTPUT_RENDERED, "true") } - override fun content(target: String): Map = if (target == ElementVisionRenderer.TYPE) { - listOf( - numberVisionRenderer(this), - textVisionRenderer(this), - formVisionRenderer(this) - ).associateByName() - } else super.content(target) - public companion object : PluginFactory { - override fun build(context: Context, meta: Meta): VisionClient = VisionClient() - override val tag: PluginTag = PluginTag(name = "vision.client.js", group = PluginTag.DATAFORGE_GROUP) + override fun invoke(meta: Meta, context: Context): VisionClient = VisionClient() + + override val tag: PluginTag = PluginTag(name = "vision.client", group = PluginTag.DATAFORGE_GROUP) + + override val type: KClass = VisionClient::class } } -public fun VisionClient.visionPropertyChanged(visionName: Name, propertyName: String, item: Meta?) { - visionPropertyChanged(visionName, propertyName.parseAsName(true), item) -} - -public fun VisionClient.visionPropertyChanged(visionName: Name, propertyName: String, item: Number) { - visionPropertyChanged(visionName, propertyName.parseAsName(true), Meta(item)) -} - -public fun VisionClient.visionPropertyChanged(visionName: Name, propertyName: String, item: String) { - visionPropertyChanged(visionName, propertyName.parseAsName(true), Meta(item)) -} - -public fun VisionClient.visionPropertyChanged(visionName: Name, propertyName: String, item: Boolean) { - visionPropertyChanged(visionName, propertyName.parseAsName(true), Meta(item)) -} private fun whenDocumentLoaded(block: Document.() -> Unit): Unit { - if (document.body != null) { + if (document.readyState == DocumentReadyState.COMPLETE) { block(document) } else { document.addEventListener("DOMContentLoaded", { block(document) }) @@ -277,7 +204,7 @@ private fun whenDocumentLoaded(block: Document.() -> Unit): Unit { */ public fun VisionClient.renderAllVisionsIn(element: Element) { val elements = element.getElementsByClassName(VisionTagConsumer.OUTPUT_CLASS) - logger.info { "Finished search for outputs. Found ${elements.length} items" } + console.info("Finished search for outputs. Found ${elements.length} items") elements.asList().forEach { child -> renderVisionIn(child) } @@ -286,12 +213,12 @@ public fun VisionClient.renderAllVisionsIn(element: Element) { /** * Render all visions in an element with a given [id] */ -public fun VisionClient.renderAllVisionsById(document: Document, id: String): Unit { - val element = document.getElementById(id) +public fun VisionClient.renderAllVisionsById(id: String): Unit = whenDocumentLoaded { + val element = getElementById(id) if (element != null) { renderAllVisionsIn(element) } else { - logger.warn { "Element with id $id not found" } + console.warn("Element with id $id not found") } } @@ -304,36 +231,14 @@ public fun VisionClient.renderAllVisions(): Unit = whenDocumentLoaded { renderAllVisionsIn(element) } -public class VisionClientApplication(public val context: Context) : Application { - private val client = context.request(VisionClient) - - override fun start(document: Document, state: Map) { - context.logger.info { - "Starting VisionClient with renderers: ${ - client.renderers.joinToString( - prefix = "\n\t", - separator = "\n\t" - ) { it.name.toString() } - }" - } - val element = document.body ?: error("Document does not have a body") - client.renderAllVisionsIn(element) - } -} - - /** * Create a vision client context and render all visions on the page. */ public fun runVisionClient(contextBuilder: ContextBuilder.() -> Unit) { - Global.logger.info { "Starting VisionForge context" } + console.info("Starting VisionForge context") + val context = Context("VisionForge", contextBuilder) + val visionClient = context.fetch(VisionClient) + window.asDynamic()[RENDER_FUNCTION_NAME] = visionClient::renderAllVisionsById - val context = Context("VisionForge") { - plugin(VisionClient) - contextBuilder() - } - - startApplication { - VisionClientApplication(context) - } + visionClient.renderAllVisions() } \ No newline at end of file diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/elementOutput.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/elementOutput.kt new file mode 100644 index 00000000..f85fdabb --- /dev/null +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/elementOutput.kt @@ -0,0 +1,27 @@ +package space.kscience.visionforge + +import org.w3c.dom.Element +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.misc.Type + +@Type(ElementVisionRenderer.TYPE) +public interface ElementVisionRenderer { + + /** + * Give a [vision] integer rating based on this renderer capabilities. [ZERO_RATING] or negative values means that this renderer + * can't process a vision. The value of [DEFAULT_RATING] used for default renderer. Specialized renderers could specify + * higher value in order to "steal" rendering job + */ + public fun rateVision(vision: Vision): Int + + /** + * Display the [vision] inside a given [element] replacing its current content + */ + public fun render(element: Element, vision: Vision, meta: Meta = Meta.EMPTY) + + public companion object { + public const val TYPE: String = "elementVisionRenderer" + public const val ZERO_RATING: Int = 0 + public const val DEFAULT_RATING: Int = 10 + } +} \ No newline at end of file diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/inputRenderers.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/inputRenderers.kt deleted file mode 100644 index 390058ea..00000000 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/inputRenderers.kt +++ /dev/null @@ -1,113 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.browser.document -import kotlinx.html.InputType -import kotlinx.html.js.input -import kotlinx.html.js.label -import kotlinx.html.js.onChangeFunction -import org.w3c.dom.HTMLFormElement -import org.w3c.dom.HTMLInputElement -import org.w3c.dom.get -import org.w3c.xhr.FormData -import space.kscience.dataforge.context.debug -import space.kscience.dataforge.context.logger -import space.kscience.dataforge.meta.DynamicMeta -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.toMap -import space.kscience.dataforge.meta.valueSequence -import space.kscience.visionforge.html.VisionOfHtmlForm -import space.kscience.visionforge.html.VisionOfNumberField -import space.kscience.visionforge.html.VisionOfTextField - -internal fun textVisionRenderer( - client: VisionClient, -): ElementVisionRenderer = ElementVisionRenderer { name, vision, _ -> - val fieldName = vision.name ?: "input[${vision.hashCode().toUInt()}]" - vision.label?.let { - label { - htmlFor = fieldName - +it - } - } - input { - type = InputType.text - this.name = fieldName - vision.useProperty(VisionOfTextField::text) { - value = it ?: "" - } - onChangeFunction = { - client.visionPropertyChanged(name, VisionOfTextField::text.name, value) - } - } -} - -internal fun numberVisionRenderer( - client: VisionClient, -): ElementVisionRenderer = ElementVisionRenderer { name, vision, _ -> - val fieldName = vision.name ?: "input[${vision.hashCode().toUInt()}]" - vision.label?.let { - label { - htmlFor = fieldName - +it - } - } - input { - type = InputType.text - this.name = fieldName - vision.useProperty(VisionOfNumberField::value) { - value = it?.toDouble() ?: 0.0 - } - onChangeFunction = { - client.visionPropertyChanged(name, VisionOfNumberField::value.name, value) - } - } -} - -internal fun FormData.toMeta(): Meta { - @Suppress("UNUSED_VARIABLE") val formData = this - //val res = js("Object.fromEntries(formData);") - val `object` = js("{}") - //language=JavaScript - js( - """ - formData.forEach(function(value, key){ - // Reflect.has in favor of: object.hasOwnProperty(key) - if(!Reflect.has(object, key)){ - object[key] = value; - return; - } - if(!Array.isArray(object[key])){ - object[key] = [object[key]]; - } - object[key].push(value); - }); - """ - ) - return DynamicMeta(`object`) -} - -internal fun formVisionRenderer( - client: VisionClient, -): ElementVisionRenderer = ElementVisionRenderer { name, vision, _ -> - - val form = document.getElementById(vision.formId) as? HTMLFormElement - ?: error("An element with id = '${vision.formId} is not a form") - - client.logger.debug{"Adding hooks to form with id = '$vision.formId'"} - - vision.useProperty(VisionOfHtmlForm::values) { values -> - client.logger.debug{"Updating form '${vision.formId}' with values $values"} - val inputs = form.getElementsByTagName("input") - values?.valueSequence()?.forEach { (token, value) -> - (inputs[token.toString()] as? HTMLInputElement)?.value = value.toString() - } - } - - form.onsubmit = { event -> - event.preventDefault() - val formData = FormData(form).toMeta() - client.visionPropertyChanged(name, VisionOfHtmlForm::values.name, formData) - console.info("Sent: ${formData.toMap()}") - false - } -} \ No newline at end of file diff --git a/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt b/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt deleted file mode 100644 index 58bd2b09..00000000 --- a/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package space.kscience.visionforge - -import org.w3c.xhr.FormData -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.int -import space.kscience.dataforge.meta.stringList -import kotlin.test.Test -import kotlin.test.assertEquals - -class FormTest { - @Test - fun testFormConversion() { - val fd = FormData() - fd.append("a", "22") - fd.append("b", "1") - fd.append("b", "2") - val meta = fd.toMeta() - assertEquals(22, meta["a"].int) - assertEquals(listOf("1","2"), meta["b"]?.stringList) - } - -} \ No newline at end of file diff --git a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/JvmSynchronized.kt b/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/JvmSynchronized.kt deleted file mode 100644 index fc8fed09..00000000 --- a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/JvmSynchronized.kt +++ /dev/null @@ -1,3 +0,0 @@ -package space.kscience.visionforge - -public actual typealias JvmSynchronized = Synchronized \ No newline at end of file diff --git a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/HtmlVisionContext.kt b/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/HtmlVisionContext.kt deleted file mode 100644 index 3796d436..00000000 --- a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/HtmlVisionContext.kt +++ /dev/null @@ -1,95 +0,0 @@ -package space.kscience.visionforge.html - -import kotlinx.html.* -import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MetaSerializer -import space.kscience.dataforge.meta.isEmpty -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.NameToken -import space.kscience.dataforge.names.asName -import space.kscience.dataforge.names.parseAsName -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.html.VisionTagConsumer.Companion.DEFAULT_VISION_NAME -import space.kscience.visionforge.setAsRoot -import space.kscience.visionforge.visionManager - -/** - * Rendering context for visions in HTML - */ -public interface HtmlVisionContext : ContextAware { - - /** - * Generate div id for vision div tag - */ - public fun generateId(name: Name): String = "vision[$name]" - - /** - * Render vision at given [DIV] - */ - public fun DIV.renderVision(name: Name, vision: Vision, outputMeta: Meta) -} - - -public typealias HtmlVisionContextFragment = context(HtmlVisionContext) TagConsumer<*>.() -> Unit - -//context(HtmlVisionContext) -//public fun HtmlVisionFragment( -// content: TagConsumer<*>.() -> Unit, -//): HtmlVisionFragment = HtmlVisionFragment { } - -context(HtmlVisionContext) -private fun TagConsumer.vision( - visionManager: VisionManager, - name: Name, - vision: Vision, - outputMeta: Meta = Meta.EMPTY, -): T = div { - id = generateId(name) - classes = setOf(VisionTagConsumer.OUTPUT_CLASS) - vision.setAsRoot(visionManager) - attributes[VisionTagConsumer.OUTPUT_NAME_ATTRIBUTE] = name.toString() - if (!outputMeta.isEmpty()) { - //Hard-code output configuration - script { - attributes["class"] = VisionTagConsumer.OUTPUT_META_CLASS - unsafe { - +visionManager.jsonFormat.encodeToString(MetaSerializer, outputMeta) - } - } - } - renderVision(name, vision, outputMeta) -} - -context(HtmlVisionContext) -private fun TagConsumer.vision( - name: Name, - vision: Vision, - outputMeta: Meta = Meta.EMPTY, -): T = vision(context.visionManager, name, vision, outputMeta) - -/** - * Insert a vision in this HTML. - */ -context(HtmlVisionContext) -@VisionDSL -public fun TagConsumer.vision( - name: Name? = null, - visionProvider: VisionOutput.() -> Vision, -): T { - val actualName = name ?: NameToken(DEFAULT_VISION_NAME, visionProvider.hashCode().toUInt().toString()).asName() - val output = VisionOutput(context, actualName) - val vision = output.visionProvider() - return vision(output.visionManager, actualName, vision, output.meta) -} - -/** - * Insert a vision in this HTML. - */ -context(HtmlVisionContext) -@VisionDSL -public fun TagConsumer.vision( - name: String?, - visionProvider: VisionOutput.() -> Vision, -): T = vision(name?.parseAsName(), visionProvider) \ No newline at end of file diff --git a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/headers.kt b/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/headers.kt index bf880e84..ffe35cc7 100644 --- a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/headers.kt +++ b/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/headers.kt @@ -4,10 +4,13 @@ import kotlinx.html.link import kotlinx.html.script import kotlinx.html.unsafe import org.slf4j.LoggerFactory +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.visionforge.VisionManager import java.nio.file.Files import java.nio.file.Path import java.nio.file.StandardOpenOption import java.security.MessageDigest +import kotlin.io.path.ExperimentalPathApi import kotlin.io.path.readText @@ -45,14 +48,15 @@ private fun ByteArray.toHexString() = asUByteArray().joinToString("") { it.toStr * Check if the asset exists in given local location and put it there if it does not * @param */ -internal fun checkOrStoreFile(htmlPath: Path, filePath: Path, resource: String, classLoader: ClassLoader): Path { +@OptIn(ExperimentalPathApi::class) +internal fun checkOrStoreFile(htmlPath: Path, filePath: Path, resource: String): Path { val logger = LoggerFactory.getLogger("") logger.info("Resolving or storing resource file $resource") val fullPath = htmlPath.resolveSibling(filePath).toAbsolutePath().resolve(resource) logger.debug("Full path to resource file $resource: $fullPath") - val bytes = classLoader.getResourceAsStream(resource)?.readAllBytes() + val bytes = VisionManager.Companion::class.java.getResourceAsStream("/$resource")?.readAllBytes() ?: error("Resource $resource not found on classpath") val md = MessageDigest.getInstance("MD5") @@ -63,20 +67,8 @@ internal fun checkOrStoreFile(htmlPath: Path, filePath: Path, resource: String, if (!skip) { logger.debug("File $fullPath does not exist or wrong checksum. Writing file") Files.createDirectories(fullPath.parent) - Files.write( - fullPath, - bytes, - StandardOpenOption.CREATE, - StandardOpenOption.TRUNCATE_EXISTING, - StandardOpenOption.WRITE - ) - Files.write( - md5File, - checksum.encodeToByteArray(), - StandardOpenOption.CREATE, - StandardOpenOption.TRUNCATE_EXISTING, - StandardOpenOption.WRITE - ) + Files.write(fullPath, bytes, StandardOpenOption.CREATE, StandardOpenOption.WRITE) + Files.write(md5File, checksum.encodeToByteArray(), StandardOpenOption.CREATE, StandardOpenOption.WRITE) } return if (htmlPath.isAbsolute && fullPath.startsWith(htmlPath.parent)) { @@ -91,18 +83,18 @@ internal fun checkOrStoreFile(htmlPath: Path, filePath: Path, resource: String, */ internal fun fileScriptHeader( path: Path, -): HtmlFragment = HtmlFragment{ +): HtmlFragment = { script { type = "text/javascript" src = path.toString() } } -internal fun embedScriptHeader(resource: String, classLoader: ClassLoader): HtmlFragment = HtmlFragment{ +internal fun embedScriptHeader(resource: String): HtmlFragment = { script { type = "text/javascript" unsafe { - val bytes = classLoader.getResourceAsStream(resource)!!.readAllBytes() + val bytes = VisionManager::class.java.getResourceAsStream("/$resource")!!.readAllBytes() +bytes.toString(Charsets.UTF_8) } } @@ -112,9 +104,8 @@ internal fun fileCssHeader( basePath: Path, cssPath: Path, resource: String, - classLoader: ClassLoader, -): HtmlFragment = HtmlFragment{ - val relativePath = checkOrStoreFile(basePath, cssPath, resource, classLoader) +): HtmlFragment = { + val relativePath = checkOrStoreFile(basePath, cssPath, resource) link { rel = "stylesheet" href = relativePath.toString() @@ -122,32 +113,29 @@ internal fun fileCssHeader( } /** - * Make a script header from a resource file, automatically copying file to appropriate location + * Make a script header, automatically copying file to appropriate location */ -public fun VisionPage.Companion.importScriptHeader( +@DFExperimental +public fun scriptHeader( scriptResource: String, resourceLocation: ResourceLocation, htmlPath: Path? = null, - classLoader: ClassLoader = Thread.currentThread().contextClassLoader, ): HtmlFragment { val targetPath = when (resourceLocation) { ResourceLocation.LOCAL -> checkOrStoreFile( htmlPath ?: Path.of("."), Path.of(VISIONFORGE_ASSETS_PATH), - scriptResource, - classLoader + scriptResource ) - ResourceLocation.SYSTEM -> checkOrStoreFile( Path.of("."), Path.of(System.getProperty("user.home")).resolve(VISIONFORGE_ASSETS_PATH), - scriptResource, classLoader + scriptResource ) - ResourceLocation.EMBED -> null } return if (targetPath == null) { - embedScriptHeader(scriptResource, classLoader) + embedScriptHeader(scriptResource) } else { fileScriptHeader(targetPath) } diff --git a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/htmlExport.kt b/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/htmlExport.kt index e45dd9b5..63f405c3 100644 --- a/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/htmlExport.kt +++ b/visionforge-core/src/jvmMain/kotlin/space/kscience/visionforge/html/htmlExport.kt @@ -1,12 +1,9 @@ -package space.kscience.visionforge.html +package space.kscience.visionforge -import kotlinx.html.body -import kotlinx.html.head -import kotlinx.html.meta import kotlinx.html.stream.createHTML -import space.kscience.dataforge.context.Global import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.visionManager +import space.kscience.visionforge.html.HtmlFragment +import space.kscience.visionforge.html.Page import java.awt.Desktop import java.nio.file.Files import java.nio.file.Path @@ -57,41 +54,26 @@ import java.nio.file.Path // } //} -/** - * Export a [VisionPage] to a file - * - * @param fileHeaders additional file system specific headers. - */ @DFExperimental -public fun VisionPage.makeFile( +public fun Page.makeFile( path: Path?, - fileHeaders: ((Path) -> Map)? = null, + defaultHeaders: ((Path) -> Map)? = null, ): Path { - val actualFile = path ?: Files.createTempFile("tempPlot", ".html") + val actualFile = path?.let { + Path.of(System.getProperty("user.home")).resolve(path) + } ?: Files.createTempFile("tempPlot", ".html") - val actualDefaultHeaders = fileHeaders?.invoke(actualFile) - val actualHeaders = if (actualDefaultHeaders == null) pageHeaders else actualDefaultHeaders + pageHeaders + val actualDefaultHeaders = defaultHeaders?.invoke(actualFile) + val actualPage = if (actualDefaultHeaders == null) this else copy(headers = actualDefaultHeaders + headers) - val htmlString = createHTML().apply { - head { - meta { - charset = "utf-8" - } - actualHeaders.values.forEach { - appendFragment(it) - } - } - body { - visionFragment(Global.visionManager, fragment = content) - } - }.finalize() + val htmlString = actualPage.render(createHTML()) Files.writeString(actualFile, htmlString) return actualFile } @DFExperimental -public fun VisionPage.show(path: Path? = null) { +public fun Page.show(path: Path? = null) { val actualPath = makeFile(path) Desktop.getDesktop().browse(actualPath.toFile().toURI()) } \ No newline at end of file diff --git a/visionforge-fx/README.md b/visionforge-fx/README.md deleted file mode 100644 index 2cef5e81..00000000 --- a/visionforge-fx/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-fx - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-fx:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-fx:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-fx:0.2.0") -} -``` diff --git a/visionforge-fx/build.gradle.kts b/visionforge-fx/build.gradle.kts index 464c7af3..7b522fc4 100644 --- a/visionforge-fx/build.gradle.kts +++ b/visionforge-fx/build.gradle.kts @@ -1,12 +1,12 @@ plugins { - id("space.kscience.gradle.jvm") + id("ru.mipt.npm.gradle.jvm") } val dataforgeVersion: String by rootProject.extra val fxVersion: String by rootProject.extra kscience{ - useFx(space.kscience.gradle.FXModule.CONTROLS, version = fxVersion) + useFx(ru.mipt.npm.gradle.FXModule.CONTROLS, version = fxVersion) } dependencies { @@ -15,12 +15,8 @@ dependencies { api("org.fxyz3d:fxyz3d:0.5.4") { exclude(module = "slf4j-simple") } - api("org.jetbrains.kotlinx:kotlinx-coroutines-javafx:${space.kscience.gradle.KScienceVersions.coroutinesVersion}") + api("org.jetbrains.kotlinx:kotlinx-coroutines-javafx:${ru.mipt.npm.gradle.KScienceVersions.coroutinesVersion}") implementation("eu.mihosoft.vrl.jcsg:jcsg:0.5.7") { exclude(module = "slf4j-simple") } -} - -readme{ - maturity = space.kscience.gradle.Maturity.PROTOTYPE } \ No newline at end of file diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt index 4edc4f13..d8210a13 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt @@ -52,12 +52,12 @@ public class FXPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(meta) { while (!FX.initialized.get()) { if (Thread.interrupted()) { - error("Interrupted application start") + throw RuntimeException("Interrupted application start") } } Platform.setImplicitExit(false) } else { - error("FX Application not defined") + throw RuntimeException("FX Application not defined") } } } @@ -95,9 +95,8 @@ public class FXPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(meta) { public companion object : PluginFactory { override val type: KClass = FXPlugin::class override val tag: PluginTag = PluginTag("vis.fx", group = PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): FXPlugin = FXPlugin(meta) - + override fun invoke(meta: Meta, context: Context): FXPlugin = + FXPlugin(meta) } } 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 1161d5bf..442c299f 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,9 +3,13 @@ package space.kscience.visionforge.editor import javafx.scene.control.ColorPicker import javafx.scene.paint.Color import org.slf4j.LoggerFactory -import space.kscience.dataforge.meta.* +import space.kscience.dataforge.meta.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 a4c4e583..a99599ee 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,10 +8,14 @@ package space.kscience.visionforge.editor import javafx.collections.FXCollections import javafx.scene.control.ComboBox import javafx.util.StringConverter -import space.kscience.dataforge.meta.* +import space.kscience.dataforge.meta.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 8c3d2584..7d8e71b2 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,10 +5,14 @@ import javafx.beans.binding.BooleanBinding import javafx.beans.binding.ListBinding import javafx.beans.binding.ObjectBinding import javafx.collections.ObservableList -import space.kscience.dataforge.meta.* +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.ObservableMeta +import space.kscience.dataforge.meta.boolean 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 144b018e..4563ade5 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.meta.string +import space.kscience.dataforge.values.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 fd86ec72..9a1840ce 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,10 +9,11 @@ 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.* +import space.kscience.dataforge.meta.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 c6d654f5..a4e72871 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.meta.Value +import space.kscience.dataforge.values.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 ea43547c..d4ce7bb5 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.* @@ -71,31 +71,35 @@ public interface ValueChooser { public companion object { - private fun findWidgetByType(context: Context, type: String): Factory? = when (Name.parse(type)) { - TextValueChooser.name -> TextValueChooser - ColorValueChooser.name -> ColorValueChooser - ComboBoxValueChooser.name -> ComboBoxValueChooser - else -> null//context.provideByType(type)//Search for additional factories in the plugin + private fun findWidgetByType(context: Context, type: String): Factory? { + return when (Name.parse(type)) { + TextValueChooser.name -> TextValueChooser + ColorValueChooser.name -> ColorValueChooser + ComboBoxValueChooser.name -> ComboBoxValueChooser + else -> null//context.provideByType(type)//Search for additional factories in the plugin + } } - private fun build(context: Context, descriptor: MetaDescriptor?): ValueChooser = if (descriptor == null) { - TextValueChooser(); - } else { - val widgetType = descriptor.widgetType - val chooser: ValueChooser = when { - widgetType != null -> { - findWidgetByType( - context, - widgetType - )?.invoke( - descriptor.widget - ) ?: TextValueChooser() + private fun build(context: Context, descriptor: MetaDescriptor?): ValueChooser { + return if (descriptor == null) { + TextValueChooser(); + } else { + val widgetType = descriptor.widgetType + val chooser: ValueChooser = when { + widgetType != null -> { + findWidgetByType( + context, + widgetType + )?.invoke( + descriptor.widget + ) ?: TextValueChooser() + } + !descriptor.allowedValues.isNullOrEmpty() -> ComboBoxValueChooser() + else -> TextValueChooser() } - !descriptor.allowedValues.isNullOrEmpty() -> ComboBoxValueChooser() - else -> TextValueChooser() + chooser.descriptor = descriptor + chooser } - chooser.descriptor = descriptor - chooser } public fun build( 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 a9adae8f..e9b61886 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 0fcc45f3..bf1033ba 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 @@ -6,11 +6,12 @@ import javafx.scene.Node import javafx.scene.Parent import javafx.scene.layout.VBox import space.kscience.dataforge.meta.MutableMeta +import space.kscience.dataforge.meta.ObservableMutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.names.Name import space.kscience.visionforge.Vision +import space.kscience.visionforge.computeProperties import space.kscience.visionforge.getStyle -import space.kscience.visionforge.root import space.kscience.visionforge.styles import tornadofx.* @@ -20,8 +21,8 @@ public class VisionEditorFragment : Fragment() { public var vision: Vision? by visionProperty public val descriptorProperty: SimpleObjectProperty = SimpleObjectProperty() - private val configProperty: Binding = visionProperty.objectBinding { vision -> - vision?.properties?.root() + private val configProperty: Binding = visionProperty.objectBinding { vision -> + vision?.meta } private val configEditorProperty: Binding = configProperty.objectBinding(descriptorProperty) { @@ -29,7 +30,7 @@ public class VisionEditorFragment : Fragment() { val node:FXMetaModel = FXMetaModel( meta, vision?.descriptor, - vision?.properties?.root(), + vision?.computeProperties(), Name.EMPTY, "Vision properties" ) diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionTreeFragment.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionTreeFragment.kt index c0c1dfa4..335b5a69 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionTreeFragment.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/editor/VisionTreeFragment.kt @@ -5,17 +5,17 @@ import javafx.scene.control.SelectionMode import javafx.scene.control.TreeItem import javafx.scene.layout.VBox import space.kscience.visionforge.Vision -import space.kscience.visionforge.solid.SolidGroup +import space.kscience.visionforge.VisionGroup import tornadofx.* private fun toTreeItem(vision: Vision, title: String): TreeItem> { return object : TreeItem>(title to vision) { init { - if (vision is SolidGroup) { + if (vision is VisionGroup) { //lazy populate the tree expandedProperty().onChange { expanded -> if (expanded && children.isEmpty()) { - children.setAll(vision.items.map { + children.setAll(vision.children.map { toTreeItem(it.value, it.key.toString()) }) } @@ -24,7 +24,7 @@ private fun toTreeItem(vision: Vision, title: String): TreeItem, FX3DFactory<*>>() private val compositeFactory = FXCompositeFactory(this) private val referenceFactory = FXReferenceFactory(this) @@ -45,13 +44,12 @@ public class FX3DPlugin : AbstractPlugin() { } public fun buildNode(obj: Solid): Node { - val binding = VisionFXBinding(this, obj) + val binding = VisualObjectFXBinding(this, obj) return when (obj) { - is SolidReference -> referenceFactory(obj, binding) + is SolidReferenceGroup -> referenceFactory(obj, binding) is SolidGroup -> { - Group(obj.items.mapNotNull { (token, obj) -> + Group(obj.children.mapNotNull { (token, obj) -> (obj as? Solid)?.let { - logger.info { token.toString() } buildNode(it).apply { properties["name"] = token.toString() } @@ -76,7 +74,7 @@ public class FX3DPlugin : AbstractPlugin() { is PolyLine -> PolyLine3D( obj.points.map { Point3D(it.x, it.y, it.z) }, obj.thickness.toFloat(), - obj.properties.getProperty(SolidMaterial.MATERIAL_COLOR_KEY).color() + obj.computePropertyNode(SolidMaterial.MATERIAL_COLOR_KEY)?.color() ).apply { this.meshView.cullFace = CullFace.FRONT } @@ -97,8 +95,6 @@ public class FX3DPlugin : AbstractPlugin() { scaleYProperty().bind(binding[Solid.Y_SCALE_KEY].float(obj.scaleY.toFloat())) scaleZProperty().bind(binding[Solid.Z_SCALE_KEY].float(obj.scaleZ.toFloat())) - if(obj.quaternion!= null) TODO("Quaternion support not implemented") - val rotateX = Rotate(0.0, Rotate.X_AXIS).apply { angleProperty().bind(binding[Solid.X_ROTATION_KEY].float(obj.rotationX.toFloat()).multiply(180.0 / PI)) } @@ -139,8 +135,7 @@ public class FX3DPlugin : AbstractPlugin() { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.fx3D", PluginTag.DATAFORGE_GROUP) override val type: KClass = FX3DPlugin::class - - override fun build(context: Context, meta: Meta): FX3DPlugin = FX3DPlugin() + override fun invoke(meta: Meta, context: Context): FX3DPlugin = FX3DPlugin() } } @@ -152,7 +147,7 @@ public interface FX3DFactory { public val type: KClass - public operator fun invoke(obj: T, binding: VisionFXBinding): Node + public operator fun invoke(obj: T, binding: VisualObjectFXBinding): Node public companion object { public const val TYPE: String = "fx3DFactory" diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXCompositeFactory.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXCompositeFactory.kt index 2e07527a..1cdcf914 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXCompositeFactory.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXCompositeFactory.kt @@ -42,13 +42,13 @@ public class FXCompositeFactory(public val plugin: FX3DPlugin) : FX3DFactory get() = Composite::class - override fun invoke(obj: Composite, binding: VisionFXBinding): Node { + override fun invoke(obj: Composite, binding: VisualObjectFXBinding): Node { val first = plugin.buildNode(obj.first) as? MeshView ?: error("Can't build node") val second = plugin.buildNode(obj.second) as? MeshView ?: error("Can't build node") val firstCSG = first.toCSG() val secondCSG = second.toCSG() val resultCSG = when (obj.compositeType) { - CompositeType.GROUP, CompositeType.UNION -> firstCSG.union(secondCSG) + CompositeType.SUM, CompositeType.UNION -> firstCSG.union(secondCSG) CompositeType.INTERSECT -> firstCSG.intersect(secondCSG) CompositeType.SUBTRACT -> firstCSG.difference(secondCSG) } diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXConvexFactory.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXConvexFactory.kt index ddb342b0..7bc44207 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXConvexFactory.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXConvexFactory.kt @@ -10,7 +10,7 @@ import kotlin.reflect.KClass public object FXConvexFactory : FX3DFactory { override val type: KClass get() = Convex::class - override fun invoke(obj: Convex, binding: VisionFXBinding): Node { + override fun invoke(obj: Convex, binding: VisualObjectFXBinding): Node { val hull = HullUtil.hull( obj.points.map { Vector3d.xyz(it.x.toDouble(), it.y.toDouble(), it.z.toDouble()) }, PropertyStorage() 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 81bbad5b..ca5e6583 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,7 +3,13 @@ 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.* +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.visionforge.Colors import space.kscience.visionforge.solid.FXMaterials.GREY diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXReferenceFactory.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXReferenceFactory.kt index a75771cb..af00f7c5 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXReferenceFactory.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXReferenceFactory.kt @@ -8,23 +8,20 @@ import space.kscience.dataforge.names.firstOrNull import space.kscience.dataforge.names.isEmpty import space.kscience.visionforge.Vision import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.solid.SolidReference.Companion.REFERENCE_CHILD_PROPERTY_PREFIX import kotlin.reflect.KClass -public class FXReferenceFactory(public val plugin: FX3DPlugin) : FX3DFactory { - override val type: KClass get() = SolidReference::class +public class FXReferenceFactory(public val plugin: FX3DPlugin) : FX3DFactory { + override val type: KClass get() = SolidReferenceGroup::class - override fun invoke(obj: SolidReference, binding: VisionFXBinding): Node { + override fun invoke(obj: SolidReferenceGroup, binding: VisualObjectFXBinding): Node { val prototype = obj.prototype val node = plugin.buildNode(prototype) - obj.onPropertyChange { name -> - if (name.firstOrNull()?.body == REFERENCE_CHILD_PROPERTY_PREFIX) { - val childName = name.firstOrNull()?.index?.let(Name::parse) - ?: error("Wrong syntax for reference child property: '$name'") + obj.onPropertyChange { name-> + if (name.firstOrNull()?.body == SolidReferenceGroup.REFERENCE_CHILD_PROPERTY_PREFIX) { + val childName = name.firstOrNull()?.index?.let(Name::parse) ?: error("Wrong syntax for reference child property: '$name'") val propertyName = name.cutFirst() - val referenceChild = - obj.children.getChild(childName) ?: error("Reference child with name '$childName' not found") + val referenceChild = obj[childName] ?: error("Reference child with name '$childName' not found") val child = node.findChild(childName) ?: error("Object child with name '$childName' not found") child.updateProperty(referenceChild, propertyName) } diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXShapeFactory.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXShapeFactory.kt index d4d58db1..116075ce 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXShapeFactory.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FXShapeFactory.kt @@ -11,7 +11,7 @@ import kotlin.reflect.KClass public object FXShapeFactory : FX3DFactory { override val type: KClass get() = GeometrySolid::class - override fun invoke(obj: GeometrySolid, binding: VisionFXBinding): MeshView { + override fun invoke(obj: GeometrySolid, binding: VisualObjectFXBinding): MeshView { val mesh = FXGeometryBuilder().apply { obj.toGeometry(this) }.build() return MeshView(mesh) } diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/OrbitControls.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/OrbitControls.kt index 9c4ab664..2fe573e0 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/OrbitControls.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/OrbitControls.kt @@ -17,7 +17,7 @@ import kotlin.math.PI import kotlin.math.cos import kotlin.math.max import kotlin.math.sin -import space.kscience.visionforge.solid.specifications.CameraScheme as CameraSpec +import space.kscience.visionforge.solid.specifications.Camera as CameraSpec public class OrbitControls internal constructor(camera: Camera, canvas: SubScene, spec: CameraSpec) { diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisionFXBinding.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt similarity index 88% rename from visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisionFXBinding.kt rename to visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt index cc4f3637..607913d7 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisionFXBinding.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/VisualObjectFXBinding.kt @@ -5,14 +5,16 @@ 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.computePropertyNode import space.kscience.visionforge.onPropertyChange import tornadofx.* /** * A caching binding collection for [Vision] properties */ -public class VisionFXBinding(public val fx: FX3DPlugin, public val obj: Vision) { +public class VisualObjectFXBinding(public val fx: FX3DPlugin, public val obj: Vision) { private val bindings = HashMap>() init { @@ -34,7 +36,7 @@ public class VisionFXBinding(public val fx: FX3DPlugin, public val obj: Vision) public operator fun get(key: Name): ObjectBinding { return bindings.getOrPut(key) { object : ObjectBinding() { - override fun computeValue(): Meta = obj.properties.getProperty(key) + override fun computeValue(): Meta? = obj.computePropertyNode(key) } } } @@ -56,5 +58,4 @@ 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/README.md b/visionforge-gdml/README.md deleted file mode 100644 index 135a369e..00000000 --- a/visionforge-gdml/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-gdml - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-gdml:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-gdml:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-gdml:0.2.0") -} -``` diff --git a/visionforge-gdml/api/visionforge-gdml.api b/visionforge-gdml/api/visionforge-gdml.api deleted file mode 100644 index 1a73d170..00000000 --- a/visionforge-gdml/api/visionforge-gdml.api +++ /dev/null @@ -1,49 +0,0 @@ -public final class space/kscience/visionforge/gdml/GdmlJVMKt { - public static final fun gdml (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/nio/file/Path;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)V - public static synthetic fun gdml$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/nio/file/Path;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V -} - -public final class space/kscience/visionforge/gdml/GdmlLoaderKt { - public static final fun gdml (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static final fun gdml (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/gdml/Gdml;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public static synthetic fun gdml$default (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/gdml/Gdml;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public static final fun toVision (Lspace/kscience/gdml/Gdml;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static synthetic fun toVision$default (Lspace/kscience/gdml/Gdml;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; -} - -public final class space/kscience/visionforge/gdml/GdmlLoaderOptions { - public static final field Companion Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Companion; - public fun ()V - public final fun configure (Lkotlin/jvm/functions/Function4;)V - public final fun getAUnit ()Lspace/kscience/gdml/AUnit; - public final fun getConfigurePaint ()Lkotlin/jvm/functions/Function3; - public final fun getConfigureSolid ()Lkotlin/jvm/functions/Function4; - public final fun getLUnit ()Lspace/kscience/gdml/LUnit; - public final fun getSolidAction ()Lkotlin/jvm/functions/Function1; - public final fun getVolumeAction ()Lkotlin/jvm/functions/Function1; - public final fun paint (Lkotlin/jvm/functions/Function3;)V - public final fun registerAndUseStyle (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public final fun setAUnit (Lspace/kscience/gdml/AUnit;)V - public final fun setLUnit (Lspace/kscience/gdml/LUnit;)V - public final fun setSolidAction (Lkotlin/jvm/functions/Function1;)V - public final fun setVolumeAction (Lkotlin/jvm/functions/Function1;)V - public final fun transparent (Lspace/kscience/visionforge/solid/Solid;)V -} - -public final class space/kscience/visionforge/gdml/GdmlLoaderOptions$Action : java/lang/Enum { - public static final field ADD Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; - public static final field PROTOTYPE Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; - public static final field REJECT Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; - public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; - public static fun values ()[Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; -} - -public final class space/kscience/visionforge/gdml/GdmlLoaderOptions$Companion { - public final fun randomColor (Lspace/kscience/gdml/GdmlMaterial;)I -} - -public final class space/kscience/visionforge/gdml/MarkLayersKt { - public static final fun markLayers (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/util/List;)V - public static synthetic fun markLayers$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/util/List;ILjava/lang/Object;)V -} - diff --git a/visionforge-gdml/build.gradle.kts b/visionforge-gdml/build.gradle.kts index 6dd3042a..aa40405a 100644 --- a/visionforge-gdml/build.gradle.kts +++ b/visionforge-gdml/build.gradle.kts @@ -1,17 +1,21 @@ plugins { - id("space.kscience.gradle.mpp") + kotlin("multiplatform") + id("ru.mipt.npm.gradle.mpp") } -kscience { - jvm() - js { - binaries.library() +kotlin { + sourceSets { + val commonMain by getting { + dependencies { + api(project(":visionforge-solid")) + api("space.kscience:gdml:0.4.0") + } + } } - dependencies { - api(projects.visionforgeSolid) - api("space.kscience:gdml:0.4.0") - } - dependencies(jvmTest) { - implementation(spclibs.logback.classic) - } -} \ No newline at end of file +} + +//tasks{ +// val jsBrowserWebpack by getting(KotlinWebpack::class) { +// sourceMaps = false +// } +//} \ No newline at end of file diff --git a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/GdmlLoaderOptions.kt b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/GdmlLoaderOptions.kt deleted file mode 100644 index 2d3c18c9..00000000 --- a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/GdmlLoaderOptions.kt +++ /dev/null @@ -1,95 +0,0 @@ -package space.kscience.visionforge.gdml - -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MutableMeta -import space.kscience.dataforge.names.Name -import space.kscience.gdml.* -import space.kscience.visionforge.solid.* -import space.kscience.visionforge.useStyle -import kotlin.random.Random - -public class GdmlLoaderOptions { - - public enum class Action { - ADD, - REJECT, - PROTOTYPE - } - - public var lUnit: LUnit = LUnit.MM - public var aUnit: AUnit = AUnit.RADIAN - - public var solidAction: (GdmlSolid) -> Action = { Action.PROTOTYPE } - public var volumeAction: (GdmlGroup) -> Action = { Action.PROTOTYPE } - - internal val styleCache = HashMap() - - public fun Solid.registerAndUseStyle(name: String, builder: MutableMeta.() -> Unit) { - styleCache.getOrPut(Name.parse(name)) { - Meta(builder) - } - useStyle(name, false) - } - - public fun Solid.transparent() { - registerAndUseStyle("transparent") { - SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 - "edges.enabled" put true - } - } - - /** - * Configure paint for given solid with given [GdmlMaterial] - */ - public var configurePaint: SolidMaterial.(material: GdmlMaterial, solid: GdmlSolid) -> Unit = - { material, _ -> color(randomColor(material)) } - private set - - public fun paint(block: SolidMaterial.(material: GdmlMaterial, solid: GdmlSolid) -> Unit) { - configurePaint = block - } - - /** - * Configure given solid - */ - public var configureSolid: Solid.(parent: GdmlVolume, solid: GdmlSolid, material: GdmlMaterial) -> Unit = - { parent, solid, material -> - val styleName = "materials.${material.name}" - - if (parent.physVolumes.isNotEmpty()) transparent() - - registerAndUseStyle(styleName) { - val vfMaterial = SolidMaterial().apply { - configurePaint(material, solid) - } - SolidMaterial.MATERIAL_KEY put vfMaterial.toMeta() - "Gdml.material" put material.name - } - } - private set - - public fun solids(block: Solid.(parent: GdmlVolume, solid: GdmlSolid, material: GdmlMaterial) -> Unit) { - val oldConfigure = configureSolid - configureSolid = { parent: GdmlVolume, solid: GdmlSolid, material: GdmlMaterial -> - oldConfigure(parent, solid, material) - block(parent, solid, material) - } - } - - - public var light: LightSource? = AmbientLightSource() - - public companion object { - private val random: Random = Random(222) - - private val colorCache = HashMap() - - /** - * Use random color and cache it based on the material. Meaning that colors are random, but always the same for the - * same material. - */ - public fun randomColor(material: GdmlMaterial): Int { - return colorCache.getOrPut(material) { random.nextInt(16777216) } - } - } -} \ No newline at end of file diff --git a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/GdmlTransformer.kt similarity index 70% rename from visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt rename to visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/GdmlTransformer.kt index 0c81d258..284d80cf 100644 --- a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/gdmlLoader.kt +++ b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/GdmlTransformer.kt @@ -1,17 +1,20 @@ package space.kscience.visionforge.gdml +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus import space.kscience.gdml.* -import space.kscience.kmath.geometry.RotationOrder import space.kscience.visionforge.* import space.kscience.visionforge.html.VisionOutput import space.kscience.visionforge.solid.* +import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_KEY import kotlin.math.cos import kotlin.math.sin +import kotlin.random.Random private val solidsName = "solids".asName() private val volumesName = "volumes".asName() @@ -22,19 +25,103 @@ private inline operator fun Number.times(d: Double) = toDouble() * d @Suppress("NOTHING_TO_INLINE") private inline operator fun Number.times(f: Float) = toFloat() * f -private class GdmlLoader(val settings: GdmlLoaderOptions) { +public class GdmlTransformer { + + public enum class Action { + ADD, + REJECT, + PROTOTYPE + } + + public var lUnit: LUnit = LUnit.MM + public var aUnit: AUnit = AUnit.RADIAN + + public var solidAction: (GdmlSolid) -> Action = { Action.PROTOTYPE } + public var volumeAction: (GdmlGroup) -> Action = { Action.PROTOTYPE } + + internal val styleCache = HashMap() + + public fun Solid.registerAndUseStyle(name: String, builder: MutableMeta.() -> Unit) { + styleCache.getOrPut(Name.parse(name)) { + Meta(builder) + } + useStyle(name) + } + + public fun Solid.transparent() { + registerAndUseStyle("transparent") { + SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 + "edges.enabled" put true + } + } + + /** + * Configure paint for given solid with given [GdmlMaterial] + */ + public var configurePaint: SolidMaterial.(material: GdmlMaterial, solid: GdmlSolid) -> Unit = + { material, _ -> color(randomColor(material)) } + private set + + public fun paint(block: SolidMaterial.(material: GdmlMaterial, solid: GdmlSolid) -> Unit) { + configurePaint = block + } + + /** + * Configure given solid + */ + public var configureSolid: Solid.(parent: GdmlVolume, solid: GdmlSolid, material: GdmlMaterial) -> Unit = + { parent, solid, material -> + val styleName = "materials.${material.name}" + + if (parent.physVolumes.isNotEmpty()) transparent() + + registerAndUseStyle(styleName) { + val vfMaterial = SolidMaterial().apply { + configurePaint(material, solid) + } + MATERIAL_KEY put vfMaterial.toMeta() + "Gdml.material" put material.name + } + } + private set + + public fun configure(block: Solid.(parent: GdmlVolume, solid: GdmlSolid, material: GdmlMaterial) -> Unit) { + val oldConfigure = configureSolid + configureSolid = { parent: GdmlVolume, solid: GdmlSolid, material: GdmlMaterial -> + oldConfigure(parent, solid, material) + block(parent, solid, material) + } + } + + + public companion object { + private val random: Random = Random(222) + + private val colorCache = HashMap() + + /** + * Use random color and cache it based on the material. Meaning that colors are random, but always the same for the + * same material. + */ + public fun randomColor(material: GdmlMaterial): Int { + return colorCache.getOrPut(material) { random.nextInt(16777216) } + } + } +} + +private class GdmlTransformerEnv(val settings: GdmlTransformer) { //private val materialCache = HashMap() /** * A special group for local templates */ - private val templates = SolidGroup() + private val proto = SolidGroup() - private val solids = templates.solidGroup(solidsName) { - edges(false) + private val solids = proto.group(solidsName) { + setPropertyNode("edges.enabled", false) } - private val referenceStore = HashMap>() + private val referenceStore = HashMap>() fun Solid.configureSolid(root: Gdml, parent: GdmlVolume, solid: GdmlSolid) { val material = parent.materialref.resolve(root) ?: GdmlElement(parent.materialref.ref) @@ -45,9 +132,9 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { } } - private fun proxySolid(root: Gdml, group: SolidGroup, solid: GdmlSolid, name: String): SolidReference { + private fun proxySolid(root: Gdml, group: SolidGroup, solid: GdmlSolid, name: String): SolidReferenceGroup { val templateName = solidsName + name - if (templates[templateName] == null) { + if (proto[templateName] == null) { solids.addSolid(root, solid, name) } val ref = group.ref(templateName, name) @@ -60,10 +147,10 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { group: SolidGroup, physVolume: GdmlPhysVolume, volume: GdmlGroup, - ): SolidReference { + ): SolidReferenceGroup { val templateName = volumesName + volume.name.asName() - if (templates[templateName] == null) { - templates.setChild(templateName, volume(root, volume)) + if (proto[templateName] == null) { + proto[templateName] = volume(root, volume) } val ref = group.ref(templateName, physVolume.name).withPosition(root, physVolume) referenceStore.getOrPut(templateName) { ArrayList() }.add(ref) @@ -140,7 +227,6 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { angle = solid.deltaphi * aScale, name = name ) - is GdmlCone -> if (solid.rmin1.toDouble() == 0.0 && solid.rmin2.toDouble() == 0.0) { cone( bottomRadius = solid.rmax1 * lScale, @@ -162,7 +248,6 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { name = name ) } - is GdmlXtru -> extruded(name) { shape { solid.vertices.forEach { @@ -178,7 +263,6 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { ) } } - is GdmlScaledSolid -> { //Add solid with modified scale val innerSolid: GdmlSolid = solid.solidref.resolve(root) @@ -190,7 +274,6 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { scaleZ = solid.scale.z.toFloat() } } - is GdmlSphere -> sphereLayer( outerRadius = solid.rmax * lScale, innerRadius = solid.rmin * lScale, @@ -200,16 +283,15 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { thetaStart = solid.starttheta * aScale, name = name, ) - is GdmlOrb -> sphere(solid.r * lScale, name = name) is GdmlPolyhedra -> extruded(name) { //getting the radius of first require(solid.planes.size > 1) { "The polyhedron geometry requires at least two planes" } val baseRadius = solid.planes.first().rmax * lScale shape { - (0.. @@ -217,17 +299,16 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { layer(plane.z * lScale, scale = plane.rmax * lScale / baseRadius) } } - is GdmlBoolSolid -> { val first: GdmlSolid = solid.first.resolve(root) ?: error("") val second: GdmlSolid = solid.second.resolve(root) ?: error("") val type: CompositeType = when (solid) { - is GdmlUnion -> CompositeType.UNION // dumb sum for better performance + is GdmlUnion -> CompositeType.SUM // dumb sum for better performance is GdmlSubtraction -> CompositeType.SUBTRACT is GdmlIntersection -> CompositeType.INTERSECT } - return smartComposite(type, name) { + return composite(type, name) { addSolid(root, first).withPosition( solid.resolveFirstPosition(root), solid.resolveFirstRotation(root), @@ -242,24 +323,22 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { } } - is GdmlTrapezoid -> { val dxBottom = solid.x1.toDouble() / 2 val dxTop = solid.x2.toDouble() / 2 val dyBottom = solid.y1.toDouble() / 2 val dyTop = solid.y2.toDouble() / 2 val dz = solid.z.toDouble() / 2 - val node1 = Float32Vector3D(-dxBottom, -dyBottom, -dz) - val node2 = Float32Vector3D(dxBottom, -dyBottom, -dz) - val node3 = Float32Vector3D(dxBottom, dyBottom, -dz) - val node4 = Float32Vector3D(-dxBottom, dyBottom, -dz) - val node5 = Float32Vector3D(-dxTop, -dyTop, dz) - val node6 = Float32Vector3D(dxTop, -dyTop, dz) - val node7 = Float32Vector3D(dxTop, dyTop, dz) - val node8 = Float32Vector3D(-dxTop, dyTop, dz) + val node1 = Point3D(-dxBottom, -dyBottom, -dz) + val node2 = Point3D(dxBottom, -dyBottom, -dz) + val node3 = Point3D(dxBottom, dyBottom, -dz) + val node4 = Point3D(-dxBottom, dyBottom, -dz) + val node5 = Point3D(-dxTop, -dyTop, dz) + val node6 = Point3D(dxTop, -dyTop, dz) + val node7 = Point3D(dxTop, dyTop, dz) + val node8 = Point3D(-dxTop, dyTop, dz) hexagon(node1, node2, node3, node4, node5, node6, node7, node8, name) } - is GdmlEllipsoid -> TODO("Renderer for $solid not supported yet") is GdmlElTube -> TODO("Renderer for $solid not supported yet") is GdmlElCone -> TODO("Renderer for $solid not supported yet") @@ -277,15 +356,13 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { ): Solid? { require(name != "") { "Can't use empty solid name. Use null instead." } return when (settings.solidAction(solid)) { - GdmlLoaderOptions.Action.ADD -> { + GdmlTransformer.Action.ADD -> { addSolid(root, solid, name) } - - GdmlLoaderOptions.Action.PROTOTYPE -> { + GdmlTransformer.Action.PROTOTYPE -> { proxySolid(root, this, solid, name ?: solid.name) } - - GdmlLoaderOptions.Action.REJECT -> { + GdmlTransformer.Action.REJECT -> { //ignore null } @@ -311,16 +388,14 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { } when (settings.volumeAction(volume)) { - GdmlLoaderOptions.Action.ADD -> { + GdmlTransformer.Action.ADD -> { val group: SolidGroup = volume(root, volume) - this.setChild(physVolume.name, group.withPosition(root, physVolume)) + this[physVolume.name] = group.withPosition(root, physVolume) } - - GdmlLoaderOptions.Action.PROTOTYPE -> { + GdmlTransformer.Action.PROTOTYPE -> { proxyVolume(root, this, physVolume, volume) } - - GdmlLoaderOptions.Action.REJECT -> { + GdmlTransformer.Action.REJECT -> { //ignore } } @@ -334,7 +409,7 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { ?: error("Volume with ref ${divisionVolume.volumeref.ref} could not be resolved") //TODO add divisions - children.static(volume(root, volume)) + set(null, volume(root, volume)) } private fun volume( @@ -352,7 +427,6 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { when (val vol: GdmlPlacement? = group.placement) { is GdmlPhysVolume -> addPhysicalVolume(root, vol) is GdmlDivisionVolume -> addDivisionVolume(root, vol) - else -> {} } } @@ -361,50 +435,46 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) { } } - fun transform(root: Gdml): SolidGroup { - val rootSolid = volume(root, root.world.resolve(root) ?: error("GDML root is not resolved")) - - val rootStyle by rootSolid.style("gdml") { + private fun finalize(final: SolidGroup): SolidGroup { + val rootStyle by final.style("gdml") { Solid.ROTATION_ORDER_KEY put RotationOrder.ZXY } + final.useStyle(rootStyle) - rootSolid.useStyle(rootStyle, false) - - rootSolid.prototypes { - templates.items.forEach { (token, item) -> + final.prototypes { + proto.children.forEach { (token, item) -> item.parent = null - setChild(token.asName(), item as? Solid) + set(token.asName(), item as? Solid) } } settings.styleCache.forEach { - rootSolid.styleSheet { + final.styleSheet { define(it.key.toString(), it.value) } } - return rootSolid + return final } + + fun transform(root: Gdml): SolidGroup = + finalize(volume(root, root.world.resolve(root) ?: error("GDML root is not resolved"))) } -public fun Gdml.toVision(block: GdmlLoaderOptions.() -> Unit = {}): SolidGroup { - val settings = GdmlLoaderOptions().apply(block) - return GdmlLoader(settings).transform(this).also { - it.children["light"] = settings.light - } +public fun Gdml.toVision(block: GdmlTransformer.() -> Unit = {}): SolidGroup { + val settings = GdmlTransformer().apply(block) + val context = GdmlTransformerEnv(settings) + return context.transform(this) } /** * Append Gdml node to the group */ -public fun SolidGroup.gdml(gdml: Gdml, key: String? = null, transformer: GdmlLoaderOptions.() -> Unit = {}) { - val vision = gdml.toVision(transformer) +public fun SolidGroup.gdml(gdml: Gdml, key: String? = null, transformer: GdmlTransformer.() -> Unit = {}) { + val visual = gdml.toVision(transformer) //println(Visual3DPlugin.json.stringify(VisualGroup3D.serializer(), visual)) - children.setChild(key, vision) + set(key, visual) } @VisionBuilder @DFExperimental -public inline fun VisionOutput.gdml(block: Gdml.() -> Unit): SolidGroup { - requirePlugin(Solids) - return Gdml(block).toVision() -} \ No newline at end of file +public inline fun VisionOutput.gdml(block: Gdml.() -> Unit): SolidGroup = Gdml(block).toVision() \ No newline at end of file diff --git a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt index 7af53964..befc69bb 100644 --- a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt +++ b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt @@ -1,15 +1,15 @@ package space.kscience.visionforge.gdml -import space.kscience.dataforge.context.Global import space.kscience.dataforge.context.info import space.kscience.dataforge.context.logger import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.length import space.kscience.dataforge.names.plus +import space.kscience.visionforge.VisionGroup import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.SolidReference +import space.kscience.visionforge.solid.SolidReferenceGroup import space.kscience.visionforge.solid.layer @@ -23,15 +23,15 @@ private class VisionCounterTree( var selfCount = 1 val children: Map by lazy { - (vision as? SolidGroup)?.items?.mapValues { (key, vision) -> - if (vision is SolidReference) { - prototypes.getOrPut(vision.prototypeName) { - VisionCounterTree(vision.prototypeName, vision.prototype, prototypes) + (vision as? VisionGroup)?.children?.mapValues { (key, vision) -> + if (vision is SolidReferenceGroup) { + prototypes.getOrPut(vision.refName) { + VisionCounterTree(vision.refName, vision.prototype, prototypes) }.apply { selfCount += 1 } } else { - VisionCounterTree(name + key, vision, prototypes) + VisionCounterTree(name + key, vision as Solid, prototypes) } } ?: emptyMap() } @@ -51,10 +51,10 @@ private fun VisionCounterTree.topToBottom(): Sequence = seque } public fun SolidGroup.markLayers(thresholds: List = listOf(500, 1000, 20000, 50000)) { - val logger = manager?.context?.logger ?: Global.logger + val logger = manager?.context?.logger val counterTree = VisionCounterTree(Name.EMPTY, this, hashMapOf()) val totalCount = counterTree.childrenCount - if (totalCount > (thresholds.firstOrNull() ?: 0)) { + if (totalCount > thresholds.firstOrNull() ?: 0) { val allNodes = counterTree.topToBottom().distinct().toMutableList() //println("tree construction finished") allNodes.sortWith( @@ -77,7 +77,7 @@ public fun SolidGroup.markLayers(thresholds: List = listOf(500, 1000, 20000 node.vision.layer = layerIndex remaining -= node.selfCount * (node.children.size + 1) - logger.run { + logger?.apply { if (node.selfCount > 1) { info { "Prototype with name ${node.name} moved to layer $layerIndex. $remaining nodes remains" } } else { diff --git a/visionforge-gdml/src/commonTest/kotlin/TestCubes.kt b/visionforge-gdml/src/commonTest/kotlin/TestCubes.kt index aa262c45..0ca76fd1 100644 --- a/visionforge-gdml/src/commonTest/kotlin/TestCubes.kt +++ b/visionforge-gdml/src/commonTest/kotlin/TestCubes.kt @@ -4,7 +4,7 @@ import space.kscience.dataforge.context.Context import space.kscience.dataforge.names.Name import space.kscience.gdml.* import space.kscience.visionforge.Vision -import space.kscience.visionforge.getChild +import space.kscience.visionforge.get import space.kscience.visionforge.solid.* import space.kscience.visionforge.visionManager import kotlin.test.Test @@ -21,12 +21,12 @@ class TestCubes { @Test fun testCubesDirect() { - val vision: SolidGroup = cubes.toVision() + val vision = cubes.toVision() // println(Solids.encodeToString(vision)) val smallBoxPrototype = vision.getPrototype(Name.parse("solids.smallBox")) as? Box assertNotNull(smallBoxPrototype) assertEquals(30.0, smallBoxPrototype.xSize.toDouble()) - val smallBoxVision = vision.children.getChild("composite-111.smallBox")?.prototype as? Box + val smallBoxVision = vision["composite-111.smallBox"]?.unref as? Box assertNotNull(smallBoxVision) assertEquals(30.0, smallBoxVision.xSize.toDouble()) } @@ -55,7 +55,7 @@ class TestCubes { assertNotNull(this.prototype) } if (this is SolidGroup) { - items.forEach { + children.forEach { it.value.checkPrototypes() } } diff --git a/visionforge-gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/gdmlJVM.kt b/visionforge-gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/gdmlJVM.kt index ed854100..b67e231e 100644 --- a/visionforge-gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/gdmlJVM.kt +++ b/visionforge-gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/gdmlJVM.kt @@ -9,7 +9,7 @@ public fun SolidGroup.gdml( file: Path, key: String = "", usePreprocessor: Boolean = false, - transformer: GdmlLoaderOptions.() -> Unit = {}, + transformer: GdmlTransformer.() -> Unit = {}, ) { val gdml = Gdml.decodeFromFile(file, usePreprocessor) gdml(gdml, key, transformer) diff --git a/visionforge-jupyter/README.md b/visionforge-jupyter/README.md deleted file mode 100644 index 433d3042..00000000 --- a/visionforge-jupyter/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module jupyter - -Common visionforge jupyter module - diff --git a/visionforge-jupyter/build.gradle.kts b/visionforge-jupyter/build.gradle.kts deleted file mode 100644 index 49943631..00000000 --- a/visionforge-jupyter/build.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -description = "Common visionforge jupyter module" - -kscience { - useKtor() - jvm() - js() - jupyterLibrary() - dependencies { - api(projects.visionforgeCore) - } - dependencies(jvmMain){ - api("io.ktor:ktor-server-cio-jvm") - api("io.ktor:ktor-server-websockets-jvm") - api("io.ktor:ktor-server-cors-jvm") - api(projects.visionforgeServer) - } -} - - -readme { - maturity = space.kscience.gradle.Maturity.EXPERIMENTAL -} \ No newline at end of file diff --git a/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt b/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt deleted file mode 100644 index 7f06c6ac..00000000 --- a/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt +++ /dev/null @@ -1,50 +0,0 @@ -package space.kscience.visionforge.jupyter - -import kotlinx.browser.window -import org.w3c.dom.Document -import org.w3c.dom.Element -import space.kscience.dataforge.context.AbstractPlugin -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.PluginFactory -import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.meta.Meta -import space.kscience.visionforge.VisionClient -import space.kscience.visionforge.renderAllVisions -import space.kscience.visionforge.renderAllVisionsById -import space.kscience.visionforge.renderAllVisionsIn - -@JsExport -public class VFNotebookClient : AbstractPlugin() { - private val client by require(VisionClient) - - public fun renderAllVisionsIn(element: Element) { - client.renderAllVisionsIn(element) - } - - public fun renderAllVisionsById(document: Document, id: String) { - client.renderAllVisionsById(document, id) - } - - public fun renderAllVisions() { - client.renderAllVisions() - } - - - init { - console.info("Loading VisionForge global hooks") - //register VisionForge in the browser window - window.parent.asDynamic().vf = this - window.parent.asDynamic().VisionForge = this - } - - @Suppress("NON_EXPORTABLE_TYPE") - override val tag: PluginTag get() = Companion.tag - - @Suppress("NON_EXPORTABLE_TYPE") - public companion object : PluginFactory { - override fun build(context: Context, meta: Meta): VFNotebookClient = VFNotebookClient() - - override val tag: PluginTag = PluginTag(name = "vision.notebook", group = PluginTag.DATAFORGE_GROUP) - } - -} \ No newline at end of file diff --git a/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt b/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt deleted file mode 100644 index 49d5fe23..00000000 --- a/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt +++ /dev/null @@ -1,177 +0,0 @@ -package space.kscience.visionforge.jupyter - -import io.ktor.http.URLProtocol -import io.ktor.server.application.install -import io.ktor.server.cio.CIO -import io.ktor.server.engine.ApplicationEngine -import io.ktor.server.engine.embeddedServer -import io.ktor.server.util.url -import io.ktor.server.websocket.WebSockets -import kotlinx.coroutines.CoroutineScope -import kotlinx.html.* -import kotlinx.html.stream.createHTML -import org.jetbrains.kotlinx.jupyter.api.* -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.context.info -import space.kscience.dataforge.context.logger -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.html.HtmlVisionFragment -import space.kscience.visionforge.html.visionFragment -import space.kscience.visionforge.server.VisionRoute -import space.kscience.visionforge.server.serveVisionData -import kotlin.coroutines.CoroutineContext -import kotlin.random.Random -import kotlin.random.nextUInt - - -@Suppress("FunctionName") -internal inline fun HTML(isolated: Boolean = false, block: TagConsumer<*>.() -> Unit): MimeTypedResult = - HTML(createHTML().apply(block).finalize(), isolated) - -internal fun KotlinKernelHost.displayHtml(block: TagConsumer<*>.() -> Unit) { - display(HTML(false, block), null) -} - -public enum class VisionForgeCompatibility { - JUPYTER, - JUPYTER_LAB, - DATALORE, - IDEA -} - -/** - * A handler class that includes a server and common utilities - */ -@Suppress("ExtractKtorModule") -public class VisionForge( - public val visionManager: VisionManager, - public val notebook: Notebook, - meta: Meta = Meta.EMPTY, -) : ContextAware, CoroutineScope { - - override val context: Context get() = visionManager.context - - public val configuration: ObservableMutableMeta = meta.toMutableMeta() - - private var counter = 0 - - private var engine: ApplicationEngine? = null - - override val coroutineContext: CoroutineContext get() = context.coroutineContext - - - public fun isServerRunning(): Boolean = engine != null - - public fun getProperty(name: String): TypedMeta<*>? = configuration[name] ?: context.properties[name] - - internal fun startServer( - kernel: KotlinKernelHost, - host: String = getProperty("visionforge.host").string ?: "localhost", - port: Int = getProperty("visionforge.port").int ?: VisionRoute.DEFAULT_PORT, - ) { - engine?.let { - kernel.displayHtml { - p { - style = "color: red;" - +"Stopping current VisionForge server" - } - } - it.stop(1000, 2000) - } - - //val connector: EngineConnectorConfig = EngineConnectorConfig(host, port) - - - engine = context.embeddedServer(CIO, port, host) { - install(WebSockets) - }.start(false) - - kernel.displayHtml { - p { - style = "color: blue;" - +"Starting VisionForge server on port $port" - } - } - } - - internal fun stopServer(kernel: KotlinKernelHost) { - engine?.apply { - logger.info { "Stopping VisionForge server" } - stop(1000, 2000) - engine = null - } - - kernel.displayHtml { - p { - style = "color: red;" - +"VisionForge server stopped" - } - } - } - - internal fun TagConsumer<*>.renderScriptForId(id: String) { - script { - type = "text/javascript" - //language=JavaScript - unsafe { +"parent.VisionForge.renderAllVisionsById(document, \"$id\");" } - } - } - - - public fun produceHtml( - isolated: Boolean? = null, - fragment: HtmlVisionFragment, - ): MimeTypedResult { - val iframeIsolation = isolated ?: when (notebook.jupyterClientType) { - JupyterClientType.DATALORE, JupyterClientType.JUPYTER_NOTEBOOK -> true - else -> false - } - return HTML( - iframeIsolation - ) { - val id = "fragment[${fragment.hashCode()}/${Random.nextUInt()}]" - div { - this.id = id - val engine = engine - if (engine != null) { - //if server exist, serve dynamically - //server.serveVisionsFromFragment(consumer, "content-${counter++}", fragment) - val cellRoute = "content-${counter++}" - - val collector: MutableMap = mutableMapOf() - - val url = engine.environment.connectors.first().let { - url { - protocol = URLProtocol.WS - host = it.host - port = it.port - pathSegments = listOf(cellRoute, "ws") - } - } - - engine.application.serveVisionData(VisionRoute(cellRoute, visionManager), collector) - - visionFragment( - visionManager, - embedData = true, - updatesUrl = url, - onVisionRendered = { name, vision -> collector[name] = vision }, - fragment = fragment - ) - } else { - //if not, use static rendering - visionFragment(visionManager, fragment = fragment) - } - } - renderScriptForId(id) - } - } - - public fun form(builder: FORM.() -> Unit): HtmlFormFragment = - HtmlFormFragment("form[${counter++}]", builder = builder) -} - diff --git a/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt b/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt deleted file mode 100644 index afc2ecc2..00000000 --- a/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt +++ /dev/null @@ -1,133 +0,0 @@ -package space.kscience.visionforge.jupyter - -import kotlinx.html.* -import org.jetbrains.kotlinx.jupyter.api.KotlinKernelHost -import org.jetbrains.kotlinx.jupyter.api.MimeTypedResult -import org.jetbrains.kotlinx.jupyter.api.declare -import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.html.* -import kotlin.random.Random -import kotlin.random.nextUInt - -/** - * A base class for different Jupyter VF integrations - */ -@DFExperimental -public abstract class VisionForgeIntegration( - public val visionManager: VisionManager, -) : JupyterIntegration(), ContextAware { - - override val context: Context get() = visionManager.context - - protected abstract fun Builder.afterLoaded(vf: VisionForge) - - final override fun Builder.onLoaded() { - - val vf: VisionForge = VisionForge(visionManager, notebook) - - onLoaded { - val kernel: KotlinKernelHost = this - declare("VisionForge" to vf, "vf" to vf) - vf.startServer(kernel) - vf.configuration.onChange(this) { name -> - if (name.toString() == "visionforge.port") { - kernel.displayHtml { - p { +"Property 'visionforge.port' changed. Restarting server" } - } - vf.startServer(kernel) - } - } - } - - - onShutdown { - vf.stopServer(this) - } - - import( - "kotlinx.html.*", - "space.kscience.visionforge.html.*", - "space.kscience.visionforge.jupyter.*" - ) -// -// render { fragment -> -// HTML(fragment.renderToString()) -// } -// -// render { fragment -> -// handler.produceHtml(fragment = fragment) -// } - - render { vision -> - vf.produceHtml { - vision(vision) - } - } - - render { page -> - HTML(true) { - head { - meta { - charset = "utf-8" - } - page.pageHeaders.values.forEach { - appendFragment(it) - } - } - body { - val id = "fragment[${page.hashCode()}/${Random.nextUInt()}]" - div { - this.id = id - visionFragment(visionManager, fragment = page.content) - } - with(vf) { - renderScriptForId(id) - } - } - } - } - - render { fragment -> - vf.produceHtml { - if (!vf.isServerRunning()) { - p { - style = "color: red;" - +"The server is not running. Forms are not interactive. Start server with `VisionForge.startServer()." - } - } - appendFragment(fragment.formBody) - vision(fragment.vision) - } - } - - afterLoaded(vf) - } -} - - -/** - * Create a fragment without a head to be embedded in the page - */ -@Suppress("UnusedReceiverParameter") -public fun VisionForge.html(body: TagConsumer<*>.() -> Unit): MimeTypedResult = HTML(false, body) - - -/** - * Create a fragment without a head to be embedded in the page - */ -public fun VisionForge.fragment(body: VisionTagConsumer<*>.() -> Unit): MimeTypedResult = produceHtml(false, body) - - -/** - * Create a standalone page in the notebook - */ -public fun VisionForge.page( - pageHeaders: Map = emptyMap(), - body: VisionTagConsumer<*>.() -> Unit, -): VisionPage = VisionPage(visionManager, pageHeaders, body) - diff --git a/visionforge-jupyter/src/jvmMain/kotlin/forms.kt b/visionforge-jupyter/src/jvmMain/kotlin/forms.kt deleted file mode 100644 index fe072887..00000000 --- a/visionforge-jupyter/src/jvmMain/kotlin/forms.kt +++ /dev/null @@ -1,34 +0,0 @@ -package space.kscience.visionforge.jupyter - -import kotlinx.html.FORM -import kotlinx.html.form -import kotlinx.html.id -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.get -import space.kscience.visionforge.html.HtmlFragment -import space.kscience.visionforge.html.VisionOfHtmlForm - -public class HtmlFormFragment internal constructor( - public val vision: VisionOfHtmlForm, - public val formBody: HtmlFragment, -) { - public val values: Meta? get() = vision.values - public operator fun get(valueName: String): Meta? = values?.get(valueName) -} - -/** - * Top level function to create a form - */ -public fun HtmlFormFragment(id: String? = null, builder: FORM.() -> Unit): HtmlFormFragment { - val realId = id ?: "form[${builder.hashCode().toUInt()}]" - return HtmlFormFragment(VisionOfHtmlForm(realId)) { - form { - this.id = realId - builder() - } - } -} - - -public fun VisionForge.form(id: String? = null, builder: FORM.() -> Unit): HtmlFormFragment = - HtmlFormFragment(id, builder) \ No newline at end of file diff --git a/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts b/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts deleted file mode 100644 index e6fd162b..00000000 --- a/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts +++ /dev/null @@ -1,42 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -description = "Jupyter api artifact including all common modules" - -kscience { - fullStack( - "js/visionforge-jupyter-common.js", - jsConfig = { useCommonJs() } - ) { - commonWebpackConfig { - sourceMaps = false - cssSupport { - enabled.set(false) - } - } - } - - dependencies { - api(projects.visionforgeSolid) - api(projects.visionforgePlotly) - api(projects.visionforgeTables) - api(projects.visionforgeMarkdown) - api(projects.visionforgeJupyter) - } - - jvmMain { - api(projects.visionforgeGdml) - } - - jsMain { - implementation(projects.ui.ring) - implementation(projects.visionforgeThreejs) - } - - jupyterLibrary("space.kscience.visionforge.jupyter.JupyterCommonIntegration") -} - -readme { - maturity = space.kscience.gradle.Maturity.EXPERIMENTAL -} \ No newline at end of file diff --git a/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt b/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt deleted file mode 100644 index e5fb4edd..00000000 --- a/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt +++ /dev/null @@ -1,17 +0,0 @@ -package space.kscience.visionforge.gdml.jupyter - -import space.kscience.visionforge.jupyter.VFNotebookClient -import space.kscience.visionforge.markup.MarkupPlugin -import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.ring.ThreeWithControlsPlugin -import space.kscience.visionforge.runVisionClient -import space.kscience.visionforge.tables.TableVisionJsPlugin - -public fun main(): Unit = runVisionClient { - plugin(ThreeWithControlsPlugin) - plugin(PlotlyPlugin) - plugin(MarkupPlugin) - plugin(TableVisionJsPlugin) - plugin(VFNotebookClient) -} - diff --git a/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt b/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt deleted file mode 100644 index 6200bd5d..00000000 --- a/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt +++ /dev/null @@ -1,90 +0,0 @@ -package space.kscience.visionforge.jupyter - -import kotlinx.html.* -import org.jetbrains.kotlinx.jupyter.api.libraries.resources -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.misc.DFExperimental -import space.kscience.gdml.Gdml -import space.kscience.plotly.Plot -import space.kscience.plotly.PlotlyPage -import space.kscience.plotly.StaticPlotlyRenderer -import space.kscience.tables.* -import space.kscience.visionforge.gdml.toVision -import space.kscience.visionforge.html.HtmlFragment -import space.kscience.visionforge.html.VisionPage -import space.kscience.visionforge.markup.MarkupPlugin -import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.plotly.asVision -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.tables.TableVisionPlugin -import space.kscience.visionforge.tables.toVision -import space.kscience.visionforge.visionManager - - -@DFExperimental -public class JupyterCommonIntegration : VisionForgeIntegration(CONTEXT.visionManager) { - - override fun Builder.afterLoaded(vf: VisionForge) { - - resources { - js("visionforge-common") { - classPath("js/visionforge-jupyter-common.js") - } - } - - import( - "space.kscience.gdml.*", - "space.kscience.visionforge.solid.*", - "space.kscience.tables.*", - "space.kscience.dataforge.meta.*", - "space.kscience.plotly.*", - "space.kscience.plotly.models.*", - "space.kscience.visionforge.plotly.plotly" - ) - - render { gdmlModel -> - vf.produceHtml { - vision { gdmlModel.toVision() } - } - } - - render> { table -> - vf.produceHtml { - vision { table.toVision() } - } - } - - render { plot -> - vf.produceHtml { - vision { plot.asVision() } - } - } - - - render { plotlyPage -> - val headers = plotlyPage.headers.associate { plotlyFragment -> - plotlyFragment.hashCode().toString(16) to HtmlFragment { - plotlyFragment.visit(this) - } - - } - VisionPage(visionManager, headers) { - div{ - p { +"Plotly page renderer is not recommended in VisionForge, use `vf.page{}`" } - } - div { - plotlyPage.fragment.render.invoke(this, StaticPlotlyRenderer) - } - } - } - } - - public companion object { - private val CONTEXT: Context = Context("Jupyter-common") { - plugin(Solids) - plugin(PlotlyPlugin) - plugin(TableVisionPlugin) - plugin(MarkupPlugin) - } - } -} diff --git a/visionforge-jupyter/visionforge-jupyter-common/webpack.config.d/01.ring.js b/visionforge-jupyter/visionforge-jupyter-common/webpack.config.d/01.ring.js deleted file mode 100644 index cfb15cb8..00000000 --- a/visionforge-jupyter/visionforge-jupyter-common/webpack.config.d/01.ring.js +++ /dev/null @@ -1,24 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; - -const path = require('path'); - -config.module.rules.push(...ringConfig.module.rules) - -config.module.rules.push( - { - test: /\.css$/, - exclude: [ - path.resolve(__dirname, "../../node_modules/@jetbrains/ring-ui") - ], - use: [ - { - loader: 'style-loader', - options: {} - }, - { - loader: 'css-loader', - options: {} - } - ] - } -) \ No newline at end of file diff --git a/visionforge-markdown/README.md b/visionforge-markdown/README.md deleted file mode 100644 index f43c742b..00000000 --- a/visionforge-markdown/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-markdown - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-markdown:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-markdown:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-markdown:0.2.0") -} -``` diff --git a/visionforge-markdown/api/visionforge-markdown.api b/visionforge-markdown/api/visionforge-markdown.api deleted file mode 100644 index 08028532..00000000 --- a/visionforge-markdown/api/visionforge-markdown.api +++ /dev/null @@ -1,40 +0,0 @@ -public final class space/kscience/visionforge/markup/MarkdownKt { - public static final fun markdown (Lkotlinx/html/TagConsumer;Lorg/intellij/markdown/flavours/MarkdownFlavourDescriptor;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; - public static synthetic fun markdown$default (Lkotlinx/html/TagConsumer;Lorg/intellij/markdown/flavours/MarkdownFlavourDescriptor;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Ljava/lang/Object; -} - -public final class space/kscience/visionforge/markup/VisionOfMarkup : space/kscience/visionforge/VisionBase { - public static final field COMMONMARK_FORMAT Ljava/lang/String; - public static final field Companion Lspace/kscience/visionforge/markup/VisionOfMarkup$Companion; - public static final field GFM_FORMAT Ljava/lang/String; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getContent ()Ljava/lang/String; - public final fun getFormat ()Ljava/lang/String; - public final fun setContent (Ljava/lang/String;)V - public static final fun write$Self (Lspace/kscience/visionforge/markup/VisionOfMarkup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/markup/VisionOfMarkup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/markup/VisionOfMarkup$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/markup/VisionOfMarkup; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/markup/VisionOfMarkup;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/markup/VisionOfMarkup$Companion { - public final fun getCONTENT_PROPERTY_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/markup/VisionOfMarkupKt { - public static final fun content (Lspace/kscience/visionforge/markup/VisionOfMarkup;Lkotlin/jvm/functions/Function0;)V -} - diff --git a/visionforge-markdown/build.gradle.kts b/visionforge-markdown/build.gradle.kts index 36559a09..210e4ee8 100644 --- a/visionforge-markdown/build.gradle.kts +++ b/visionforge-markdown/build.gradle.kts @@ -1,18 +1,44 @@ plugins { - id("space.kscience.gradle.mpp") + id("ru.mipt.npm.gradle.mpp") } -val markdownVersion = "0.4.1" +val markdownVersion = "0.2.4" kscience { - jvm() - js { - binaries.library() - } - dependencies { - api(projects.visionforgeCore) - api("org.jetbrains:markdown:$markdownVersion") - api("org.jetbrains:annotations:24.0.0") - } useSerialization() +} + +kotlin { + js { + //binaries.library() + binaries.executable() + browser { + webpackTask { + outputFileName = "js/visionforge-markdown.js" + } + } + } + + jvm { + val processResourcesTaskName = + compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME] + .processResourcesTaskName + } + + + val jsBrowserDistribution by tasks.getting + + tasks.getByName("jvmProcessResources") { + dependsOn(jsBrowserDistribution) + from(jsBrowserDistribution) + } + + sourceSets { + commonMain { + dependencies { + api(project(":visionforge-core")) + api("org.jetbrains:markdown:$markdownVersion") + } + } + } } \ No newline at end of file diff --git a/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt b/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt deleted file mode 100644 index 3508ba8b..00000000 --- a/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt +++ /dev/null @@ -1,8 +0,0 @@ -package space.kscience.visionforge.markup - -import space.kscience.dataforge.context.PluginFactory -import space.kscience.visionforge.VisionPlugin - -public expect class MarkupPlugin: VisionPlugin{ - public companion object : PluginFactory -} \ No newline at end of file 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 f3e255df..a5ec3fa0 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 @@ -5,24 +5,25 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.polymorphic import kotlinx.serialization.modules.subclass +import space.kscience.dataforge.meta.MutableMeta 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.VisionBuilder -import space.kscience.visionforge.html.VisionOutput -import space.kscience.visionforge.root +import space.kscience.visionforge.VisionBase @Serializable @SerialName("vision.markup") public class VisionOfMarkup( - public val format: String = COMMONMARK_FORMAT, -) : AbstractVision() { + public val format: String = COMMONMARK_FORMAT +) : VisionBase() { + + //FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix + protected override var properties: MutableMeta? = null //TODO add templates - public var content: String? by properties.root().string(CONTENT_PROPERTY_KEY) + public var content: String? by meta.string(CONTENT_PROPERTY_KEY) public companion object { public val CONTENT_PROPERTY_KEY: Name = "content".asName() @@ -40,16 +41,4 @@ internal val markupSerializersModule = SerializersModule { polymorphic(Vision::class) { subclass(VisionOfMarkup.serializer()) } -} - -/** - * Embed a dynamic markdown block in a vision - */ -@VisionBuilder -public inline fun VisionOutput.markdown( - format: String = VisionOfMarkup.COMMONMARK_FORMAT, - block: VisionOfMarkup.() -> Unit, -): VisionOfMarkup { - requirePlugin(MarkupPlugin) - return VisionOfMarkup(format).apply(block) } \ No newline at end of file diff --git a/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt b/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt index aad66f3f..4d7a1060 100644 --- a/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt +++ b/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt @@ -11,13 +11,12 @@ import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName import space.kscience.visionforge.* import space.kscience.visionforge.markup.VisionOfMarkup.Companion.COMMONMARK_FORMAT import space.kscience.visionforge.markup.VisionOfMarkup.Companion.GFM_FORMAT +import kotlin.reflect.KClass -public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { +public class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { public val visionClient: VisionClient by require(VisionClient) override val tag: PluginTag get() = Companion.tag override val visionSerializersModule: SerializersModule get() = markupSerializersModule @@ -27,7 +26,7 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { else -> ElementVisionRenderer.ZERO_RATING } - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { + override fun render(element: Element, vision: Vision, meta: Meta) { require(vision is VisionOfMarkup) { "The vision is not a markup vision" } val div = document.createElement("div") val flavour = when (vision.format) { @@ -45,15 +44,9 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { element.append(div) } - override fun content(target: String): Map = when (target) { - ElementVisionRenderer.TYPE -> mapOf("markup".asName() to this) - else -> super.content(target) - } - - public actual companion object : PluginFactory { - override val tag: PluginTag = PluginTag("vision.markup.js", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() - + public companion object : PluginFactory { + override val tag: PluginTag = PluginTag("vision.markup", PluginTag.DATAFORGE_GROUP) + override val type: KClass = MarkupPlugin::class + override fun invoke(meta: Meta, context: Context): MarkupPlugin = MarkupPlugin() } } \ No newline at end of file diff --git a/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt b/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt deleted file mode 100644 index ce094ee9..00000000 --- a/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt +++ /dev/null @@ -1,26 +0,0 @@ -package space.kscience.visionforge.markup - -import kotlinx.serialization.modules.SerializersModule -import org.intellij.lang.annotations.Language -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.PluginFactory -import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.meta.Meta -import space.kscience.visionforge.VisionPlugin - -public actual class MarkupPlugin : VisionPlugin() { - override val visionSerializersModule: SerializersModule get() = markupSerializersModule - - override val tag: PluginTag get() = Companion.tag - - public actual companion object : PluginFactory { - override val tag: PluginTag = PluginTag("vision.markup.jvm", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() - - } -} - -public fun VisionOfMarkup.content(@Language("markdown") text: String) { - content = text -} \ No newline at end of file diff --git a/visionforge-plotly/README.md b/visionforge-plotly/README.md deleted file mode 100644 index f8a03891..00000000 --- a/visionforge-plotly/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-plotly - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-plotly:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-plotly:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-plotly:0.2.0") -} -``` diff --git a/visionforge-plotly/api/visionforge-plotly.api b/visionforge-plotly/api/visionforge-plotly.api deleted file mode 100644 index 273f3123..00000000 --- a/visionforge-plotly/api/visionforge-plotly.api +++ /dev/null @@ -1,42 +0,0 @@ -public final class space/kscience/visionforge/plotly/PlotlyPlugin : space/kscience/visionforge/VisionPlugin { - public static final field Companion Lspace/kscience/visionforge/plotly/PlotlyPlugin$Companion; - public fun ()V - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; -} - -public final class space/kscience/visionforge/plotly/PlotlyPlugin$Companion : space/kscience/dataforge/context/PluginFactory { - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/plotly/PlotlyPlugin; -} - -public final class space/kscience/visionforge/plotly/VisionOfPlotly : space/kscience/visionforge/VisionBase { - public static final field Companion Lspace/kscience/visionforge/plotly/VisionOfPlotly$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/plotly/Plot;)V - public final fun getPlot ()Lspace/kscience/plotly/Plot; - public static final fun write$Self (Lspace/kscience/visionforge/plotly/VisionOfPlotly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/plotly/VisionOfPlotly$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/plotly/VisionOfPlotly$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/plotly/VisionOfPlotly;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/plotly/VisionOfPlotly$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/plotly/VisionOfPlotlyKt { - public static final fun asVision (Lspace/kscience/plotly/Plot;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; - public static final fun plotly (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; -} - diff --git a/visionforge-plotly/build.gradle.kts b/visionforge-plotly/build.gradle.kts index 8b0a99d1..b0b5a9c2 100644 --- a/visionforge-plotly/build.gradle.kts +++ b/visionforge-plotly/build.gradle.kts @@ -1,17 +1,37 @@ plugins { - id("space.kscience.gradle.mpp") + id("ru.mipt.npm.gradle.mpp") } -val plotlyVersion = "0.5.3" +val plotlyVersion = "0.5.0" kscience { - jvm() - js { - binaries.library() - } - dependencies { - api(projects.visionforgeCore) - api("space.kscience:plotlykt-core:${plotlyVersion}") - } useSerialization() +} + +kotlin { + js { + //binaries.library() + binaries.executable() + browser { + webpackTask { + this.outputFileName = "js/visionforge-three.js" + } + } + } + + val jsBrowserDistribution by tasks.getting + + tasks.getByName("jvmProcessResources") { + dependsOn(jsBrowserDistribution) + from(jsBrowserDistribution) + } + + sourceSets { + commonMain { + dependencies { + api(project(":visionforge-core")) + api("space.kscience:plotlykt-core:${plotlyVersion}") + } + } + } } \ No newline at end of file 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 f92e7d4d..99df2e84 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 @@ -1,98 +1,29 @@ package space.kscience.visionforge.plotly -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.emptyFlow -import kotlinx.coroutines.launch import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.misc.DFExperimental -import space.kscience.dataforge.names.Name import space.kscience.plotly.Plot import space.kscience.plotly.Plotly -import space.kscience.plotly.PlotlyConfig -import space.kscience.visionforge.MutableVisionProperties -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionBuilder +import space.kscience.visionforge.VisionBase import space.kscience.visionforge.html.VisionOutput @Serializable @SerialName("vision.plotly") -public class VisionOfPlotly private constructor( - @Serializable(MutableMetaSerializer::class) public val meta: MutableMeta, -) : Vision { - public constructor(plot: Plot) : this(plot.meta) - - public val plot: Plot get() = Plot(meta.asObservable()) - - @Transient - override var parent: Vision? = null - - @Transient - override val properties: MutableVisionProperties = object : MutableVisionProperties { - override fun setProperty(name: Name, node: Meta?, notify: Boolean) { - meta.setMeta(name, node) - } - - override fun setValue(name: Name, value: Value?, notify: Boolean) { - meta.setValue(name, value) - } - - override val own: Meta get() = meta - - override val descriptor: MetaDescriptor? get() = this@VisionOfPlotly.descriptor - - override fun getProperty( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): MutableMeta = meta.getMeta(name) ?: MutableMeta() - - override fun getValue( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): Value? = meta.getValue(name) - - override val changes: Flow = if (meta is ObservableMeta) { - callbackFlow { - meta.onChange(this) { - launch { - send(it) - } - } - awaitClose { - meta.removeListener(this) - } - } - } else emptyFlow() - - - override fun invalidate(propertyName: Name) { - // Do nothing - } +public class VisionOfPlotly private constructor() : VisionBase() { + //FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix + override var properties: MutableMeta? = null + public constructor(plot: Plot) : this() { + properties = plot.meta } - - - override val descriptor: MetaDescriptor? = null // TODO add descriptor for Plot + public val plot: Plot get() = Plot(meta) } public fun Plot.asVision(): VisionOfPlotly = VisionOfPlotly(this) -/** - * Embed a dynamic plotly plot in a vision - */ -@VisionBuilder +@DFExperimental public inline fun VisionOutput.plotly( - config: PlotlyConfig = PlotlyConfig(), block: Plot.() -> Unit, -): VisionOfPlotly { - requirePlugin(PlotlyPlugin) - meta = config.meta - return VisionOfPlotly(Plotly.plot(block)) -} \ No newline at end of file +): VisionOfPlotly = VisionOfPlotly(Plotly.plot(block)) \ No newline at end of file diff --git a/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt b/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt deleted file mode 100644 index 7634e73d..00000000 --- a/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package space.kscience.visionforge.plotly - -import space.kscience.plotly.Plotly -import space.kscience.plotly.scatter -import kotlin.test.Test -import kotlin.test.assertTrue - -class VisionOfPlotlyTest { - @Test - fun conversion(){ - val plot = Plotly.plot { - scatter { - x(1,2,3) - y(1,2,3) - } - } - val vision = VisionOfPlotly(plot) -// println(vision.plot.toJsonString()) -// println(vision.plot.data.toJsonString()) - assertTrue { vision.plot.data.first().x.doubles.size == 3} - } -} \ No newline at end of file diff --git a/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt b/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt index 91518f34..e0cea767 100644 --- a/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt +++ b/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt @@ -14,6 +14,7 @@ import space.kscience.visionforge.ElementVisionRenderer import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionClient import space.kscience.visionforge.VisionPlugin +import kotlin.reflect.KClass public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { public val visionClient: VisionClient by require(VisionClient) @@ -27,21 +28,24 @@ public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { else -> ElementVisionRenderer.ZERO_RATING } - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { + override fun render(element: Element, vision: Vision, meta: Meta) { val plot = (vision as? VisionOfPlotly)?.plot ?: error("VisionOfPlotly expected but ${vision::class} found") val config = PlotlyConfig.read(meta) - element.plot(config, plot) +// println(plot.meta) +// println(plot.data[0].toMeta()) + element.plot(plot, config) } - override fun content(target: String): Map = when (target) { - ElementVisionRenderer.TYPE -> mapOf("plotly".asName() to this) - else -> super.content(target) + override fun content(target: String): Map { + return when (target) { + ElementVisionRenderer.TYPE -> mapOf("plotly".asName() to this) + else -> super.content(target) + } } public actual companion object : PluginFactory { - override val tag: PluginTag = PluginTag("vision.plotly.js", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() - + override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP) + override val type: KClass = PlotlyPlugin::class + override fun invoke(meta: Meta, context: Context): PlotlyPlugin = PlotlyPlugin() } } \ No newline at end of file diff --git a/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyHeaders.kt b/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyHeaders.kt new file mode 100644 index 00000000..8c986125 --- /dev/null +++ b/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyHeaders.kt @@ -0,0 +1,22 @@ +package space.kscience.visionforge.plotly + +//internal val plotlyScriptLocation = "js/visionforge-three.js" +// +///** +// * A header that stores/embeds plotly bundle and registers plotly renderer in the frontend +// */ +//@OptIn(DFExperimental::class) +//public fun plotlyHeader(location: ResourceLocation, filePath: Path? = null): HtmlFragment = { +// scriptHeader( +// plotlyScriptLocation, +// resourceLocation = location, +// htmlPath = filePath +// ).invoke(this) +// script { +// type = "text/javascript" +// unsafe { +// //language=JavaScript +// +"space.kscience.visionforge.plotly.loadPlotly()" +// } +// } +//} diff --git a/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt b/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt index b9a8d373..21522664 100644 --- a/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt +++ b/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt @@ -2,12 +2,14 @@ package space.kscience.visionforge.plotly import kotlinx.serialization.modules.SerializersModule import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.Plugin import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.visionforge.VisionPlugin +import kotlin.reflect.KClass -public actual class PlotlyPlugin : VisionPlugin() { +public actual class PlotlyPlugin : VisionPlugin(), Plugin { override val tag: PluginTag get() = Companion.tag @@ -15,8 +17,7 @@ public actual class PlotlyPlugin : VisionPlugin() { public actual companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() - + override val type: KClass = PlotlyPlugin::class + override fun invoke(meta: Meta, context: Context): PlotlyPlugin = PlotlyPlugin() } } \ No newline at end of file diff --git a/visionforge-server/README.md b/visionforge-server/README.md deleted file mode 100644 index 0ac4c198..00000000 --- a/visionforge-server/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-server - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-server:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-server:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-server:0.2.0") -} -``` diff --git a/visionforge-server/api/visionforge-server.api b/visionforge-server/api/visionforge-server.api deleted file mode 100644 index 3446765b..00000000 --- a/visionforge-server/api/visionforge-server.api +++ /dev/null @@ -1,36 +0,0 @@ -public final class space/kscience/visionforge/server/VisionServer : space/kscience/dataforge/meta/Configurable { - public static final field Companion Lspace/kscience/visionforge/server/VisionServer$Companion; - public static final field DEFAULT_PAGE Ljava/lang/String; - public static final field DEFAULT_PORT I - public final fun getApplication ()Lio/ktor/application/Application; - public final fun getCacheFragments ()Z - public final fun getDataEmbed ()Z - public final fun getDataFetch ()Z - public final fun getDataUpdate ()Z - public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public final fun getUpdateInterval ()J - public final fun page (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V - public static synthetic fun page$default (Lspace/kscience/visionforge/server/VisionServer;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public final fun serveVisions (Ljava/lang/String;Ljava/util/Map;)V - public final fun serveVisionsFromFragment (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String; - public final fun setCacheFragments (Z)V - public final fun setDataEmbed (Z)V - public final fun setDataFetch (Z)V - public final fun setDataUpdate (Z)V - public final fun setUpdateInterval (J)V -} - -public final class space/kscience/visionforge/server/VisionServer$Companion { - public final fun getUPDATE_INTERVAL_KEY ()Lspace/kscience/dataforge/names/Name; -} - -public final class space/kscience/visionforge/server/VisionServerKt { - public static final fun close (Lio/ktor/server/engine/ApplicationEngine;)V - public static final fun openInBrowser (Lio/ktor/server/engine/ApplicationEngine;)V - public static final fun serve (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;ILkotlin/jvm/functions/Function1;)Lio/ktor/server/engine/ApplicationEngine; - public static synthetic fun serve$default (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lio/ktor/server/engine/ApplicationEngine; - public static final fun visionServer (Lio/ktor/application/Application;Lspace/kscience/visionforge/VisionManager;Lio/ktor/http/Url;Ljava/lang/String;)Lspace/kscience/visionforge/server/VisionServer; - public static synthetic fun visionServer$default (Lio/ktor/application/Application;Lspace/kscience/visionforge/VisionManager;Lio/ktor/http/Url;Ljava/lang/String;ILjava/lang/Object;)Lspace/kscience/visionforge/server/VisionServer; -} - diff --git a/visionforge-server/build.gradle.kts b/visionforge-server/build.gradle.kts index 59034dd1..18fda1cf 100644 --- a/visionforge-server/build.gradle.kts +++ b/visionforge-server/build.gradle.kts @@ -1,15 +1,13 @@ plugins { - id("space.kscience.gradle.jvm") + id("ru.mipt.npm.gradle.jvm") } -kscience{ - useKtor() - dependencies { - api(projects.visionforgeCore) - api("io.ktor:ktor-server-host-common") - api("io.ktor:ktor-server-html-builder") - api("io.ktor:ktor-server-websockets") - api("io.ktor:ktor-server-cors") - } -} +val ktorVersion = ru.mipt.npm.gradle.KScienceVersions.ktorVersion +dependencies { + api(project(":visionforge-core")) + api("io.ktor:ktor-server-cio:$ktorVersion") + //api("io.ktor:ktor-server-netty:$ktorVersion") + api("io.ktor:ktor-html-builder:$ktorVersion") + api("io.ktor:ktor-websockets:$ktorVersion") +} \ No newline at end of file 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 deleted file mode 100644 index 61952497..00000000 --- a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt +++ /dev/null @@ -1,230 +0,0 @@ -package space.kscience.visionforge.server - -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.engine.* -import io.ktor.server.html.* -import io.ktor.server.http.content.* -import io.ktor.server.plugins.* -import io.ktor.server.plugins.cors.routing.* -import io.ktor.server.request.* -import io.ktor.server.response.* -import io.ktor.server.routing.* -import io.ktor.server.util.* -import io.ktor.server.websocket.* -import io.ktor.util.pipeline.* -import io.ktor.websocket.* -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import kotlinx.html.* -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionChange -import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.flowChanges -import space.kscience.visionforge.html.* -import kotlin.time.Duration.Companion.milliseconds - - -public class VisionRoute( - public val route: String, - public val visionManager: VisionManager, - override val meta: ObservableMutableMeta = MutableMeta(), -) : Configurable, ContextAware { - - public enum class Mode { - /** - * Embed the initial state of the vision inside its html tag. - */ - EMBED, - - /** - * Fetch data on vision load. Do not embed data. - */ - FETCH, - - /** - * Connect to server to get pushes. The address of the server is embedded in the tag. - */ - UPDATE - } - - override val context: Context get() = visionManager.context - - /** - * Update the minimal interval between updates in milliseconds (if there are no updates, push will not happen - */ - public var updateInterval: Long by meta.long(300, key = UPDATE_INTERVAL_KEY) - - public var dataMode: Mode by meta.enum(Mode.UPDATE) - - public companion object { - public const val DEFAULT_PORT: Int = 7777 - public const val DEFAULT_PAGE: String = "/" - public val UPDATE_INTERVAL_KEY: Name = Name.parse("update.interval") - } -} - - -/** - * Serve visions in a given [route] without providing a page template. - * [visions] could be changed during the service. - */ -public fun Application.serveVisionData( - configuration: VisionRoute, - resolveVision: (Name) -> Vision?, -) { - require(WebSockets) - routing { - route(configuration.route) { - install(CORS) { - anyHost() - } - application.log.info("Serving visions at ${configuration.route}") - - //Update websocket - webSocket("ws") { - val name: String = call.request.queryParameters.getOrFail("name") - application.log.debug("Opened server socket for $name") - val vision: Vision = resolveVision(Name.parse(name)) ?: error("Vision with id='$name' not registered") - - launch { - for (frame in incoming) { - val data = frame.data.decodeToString() - application.log.debug("Received update for $name: \n$data") - val change = configuration.visionManager.jsonFormat.decodeFromString( - VisionChange.serializer(), data - ) - vision.update(change) - } - } - - try { - withContext(configuration.context.coroutineContext) { - vision.flowChanges(configuration.updateInterval.milliseconds).onEach { update -> - val json = configuration.visionManager.jsonFormat.encodeToString( - VisionChange.serializer(), - update - ) - application.log.debug("Sending update for $name: \n$json") - outgoing.send(Frame.Text(json)) - }.collect() - } - } catch (t: Throwable) { - this.application.log.info("WebSocket update channel for $name is closed with exception: $t") - } - } - //Plots in their json representation - get("data") { - val name: String = call.request.queryParameters.getOrFail("name") - - val vision: Vision? = resolveVision(Name.parse(name)) - if (vision == null) { - call.respond(HttpStatusCode.NotFound, "Vision with name '$name' not found") - } else { - call.respondText( - configuration.visionManager.encodeToString(vision), - contentType = ContentType.Application.Json, - status = HttpStatusCode.OK - ) - } - } - } - } -} - -public fun Application.serveVisionData( - configuration: VisionRoute, - data: Map, -): Unit = serveVisionData(configuration) { data[it] } - -/** - * Serve a page, potentially containing any number of visions at a given [route] with given [header]. - */ -public fun Application.visionPage( - route: String, - configuration: VisionRoute, - headers: Collection, - connector: EngineConnectorConfig? = null, - visionFragment: HtmlVisionFragment, -) { - require(WebSockets) - - val collector: MutableMap = mutableMapOf() - - //serve data - serveVisionData(configuration, collector) - - //filled pages - routing { - get(route) { - val host = connector?.host ?: call.request.host() - val port = connector?.port ?: call.request.port() - call.respondHtml { - head { - meta { - charset = "utf-8" - } - headers.forEach { headerContent -> - headerContent.appendTo(consumer) - } - } - body { - //Load the fragment and remember all loaded visions - visionFragment( - visionManager = configuration.visionManager, - embedData = configuration.dataMode == VisionRoute.Mode.EMBED, - fetchDataUrl = if (configuration.dataMode != VisionRoute.Mode.EMBED) { - url { - this.host = host - this.port = port - path(route, "data") - } - } else null, - updatesUrl = if (configuration.dataMode == VisionRoute.Mode.UPDATE) { - url { - protocol = URLProtocol.WS - this.host = host - this.port = port - path(route, "ws") - } - } else null, - onVisionRendered = { name, vision -> collector[name] = vision }, - fragment = visionFragment - ) - } - } - } - } -} - -public fun Application.visionPage( - visionManager: VisionManager, - vararg headers: HtmlFragment, - route: String = "/", - connector: EngineConnectorConfig? = null, - configurationBuilder: VisionRoute.() -> Unit = {}, - visionFragment: HtmlVisionFragment, -) { - val configuration = VisionRoute(route, visionManager).apply(configurationBuilder) - visionPage(route, configuration, listOf(*headers), connector, visionFragment) -} - -/** - * Render given [VisionPage] at server - */ -public fun Application.visionPage( - page: VisionPage, - route: String = "/", - connector: EngineConnectorConfig? = null, - configurationBuilder: VisionRoute.() -> Unit = {}, -) { - val configuration = VisionRoute(route, page.visionManager).apply(configurationBuilder) - visionPage(route, configuration, page.pageHeaders.values, connector, visionFragment = page.content) -} - diff --git a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/applicationExtensions.kt b/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/applicationExtensions.kt deleted file mode 100644 index 81f6e3e7..00000000 --- a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/applicationExtensions.kt +++ /dev/null @@ -1,39 +0,0 @@ -package space.kscience.visionforge.server - -import io.ktor.server.application.ApplicationCall -import io.ktor.server.application.Plugin -import io.ktor.server.application.install -import io.ktor.server.application.pluginOrNull -import io.ktor.server.engine.ApplicationEngine -import io.ktor.server.engine.EngineConnectorBuilder -import io.ktor.server.engine.EngineConnectorConfig -import io.ktor.util.pipeline.Pipeline -import java.awt.Desktop -import java.net.URI - - -public fun

, B : Any, F : Any> P.require( - plugin: Plugin, -): F = pluginOrNull(plugin) ?: install(plugin) - - -/** - * Connect to a given Ktor server using browser - */ -public fun ApplicationEngine.openInBrowser() { - val connector = environment.connectors.first() - val host = if (connector.host == "0.0.0.0") "127.0.0.1" else connector.host - val uri = URI("http", null, host, connector.port, null, null, null) - Desktop.getDesktop().browse(uri) -} - -/** - * Stop the server with default timeouts - */ -public fun ApplicationEngine.close(): Unit = stop(1000, 5000) - - -public fun EngineConnectorConfig(host: String, port: Int): EngineConnectorConfig = EngineConnectorBuilder().apply { - this.host = host - this.port = port -} \ No newline at end of file diff --git a/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt b/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt new file mode 100644 index 00000000..46cb2e66 --- /dev/null +++ b/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt @@ -0,0 +1,306 @@ +package space.kscience.visionforge.three.server + +import io.ktor.application.* +import io.ktor.features.CORS +import io.ktor.features.CallLogging +import io.ktor.html.respondHtml +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.http.cio.websocket.Frame +import io.ktor.http.content.resources +import io.ktor.http.content.static +import io.ktor.http.withCharset +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.* +import io.ktor.server.cio.CIO +import io.ktor.server.engine.ApplicationEngine +import io.ktor.server.engine.embeddedServer +import io.ktor.websocket.WebSockets +import io.ktor.websocket.webSocket +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.channels.consumeEach +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import kotlinx.html.* +import kotlinx.html.stream.createHTML +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.meta.* +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.dataforge.names.Name +import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionChange +import space.kscience.visionforge.VisionManager +import space.kscience.visionforge.flowChanges +import space.kscience.visionforge.html.HtmlFragment +import space.kscience.visionforge.html.HtmlVisionFragment +import space.kscience.visionforge.html.VisionTagConsumer +import space.kscience.visionforge.html.fragment +import space.kscience.visionforge.three.server.VisionServer.Companion.DEFAULT_PAGE +import java.awt.Desktop +import java.net.URI +import kotlin.collections.set +import kotlin.time.Duration + + +/** + * A ktor plugin container with given [routing] + */ +public class VisionServer internal constructor( + private val visionManager: VisionManager, + private val application: Application, + private val rootRoute: String, +) : Configurable, CoroutineScope by application { + override val meta: ObservableMutableMeta = MutableMeta() + public var updateInterval: Long by meta.long(300, key = UPDATE_INTERVAL_KEY) + public var cacheFragments: Boolean by meta.boolean(true) + public var dataEmbed: Boolean by meta.boolean(true, Name.parse("data.embed")) + public var dataFetch: Boolean by meta.boolean(false, Name.parse("data.fetch")) + public var dataConnect: Boolean by meta.boolean(true, Name.parse("data.connect")) + + /** + * a list of headers that should be applied to all pages + */ + private val globalHeaders: ArrayList = ArrayList() + + public fun header(block: TagConsumer<*>.() -> Unit) { + globalHeaders.add(block) + } + + private fun HTML.buildPage( + visionFragment: HtmlVisionFragment, + title: String, + headers: List, + ): Map { + val visionMap = HashMap() + + val consumer = object : VisionTagConsumer(consumer, visionManager) { + override fun DIV.renderVision(name: Name, vision: Vision, outputMeta: Meta) { + visionMap[name] = vision + // Toggle update mode + if (dataConnect) { + attributes[OUTPUT_CONNECT_ATTRIBUTE] = "auto" + } + + if (dataFetch) { + attributes[OUTPUT_FETCH_ATTRIBUTE] = "auto" + } + + if (dataEmbed) { + script { + type = "text/json" + attributes["class"] = OUTPUT_DATA_CLASS + unsafe { + +"\n${visionManager.encodeToString(vision)}\n" + } + } + } + } + } + + head { + meta { + charset = "utf-8" + (globalHeaders + headers).forEach { + fragment(it) + } + } + title(title) + } + body { + //Load the fragment and remember all loaded visions + visionFragment(consumer) + } + + return visionMap + } + + /** + * Server a map of visions without providing explicit html page for them + */ + @OptIn(DFExperimental::class) + public fun serveVisions(route: Route, visions: Map): Unit = route { + application.log.info("Serving visions $visions at $route") + + //Update websocket + webSocket("ws") { + val name: String = call.request.queryParameters["name"] + ?: error("Vision name is not defined in parameters") + + application.log.debug("Opened server socket for $name") + val vision: Vision = visions[Name.parse(name)] ?: error("Plot with id='$name' not registered") + + launch { + incoming.consumeEach { + val change = visionManager.jsonFormat.decodeFromString( + VisionChange.serializer(), it.data.decodeToString() + ) + vision.update(change) + } + } + + try { + withContext(visionManager.context.coroutineContext) { + vision.flowChanges(visionManager, Duration.milliseconds(updateInterval)).collect { update -> + val json = visionManager.jsonFormat.encodeToString( + VisionChange.serializer(), + update + ) + outgoing.send(Frame.Text(json)) + } + } + } catch (t: Throwable) { + application.log.info("WebSocket update channel for $name is closed with exception: $t") + } + } + //Plots in their json representation + get("vision") { + val name: String = call.request.queryParameters["name"] + ?: error("Vision name is not defined in parameters") + + val vision: Vision? = visions[Name.parse(name)] + if (vision == null) { + call.respond(HttpStatusCode.NotFound, "Vision with name '$name' not found") + } else { + call.respondText( + visionManager.encodeToString(vision), + contentType = ContentType.Application.Json, + status = HttpStatusCode.OK + ) + } + } + } + + /** + * Serv visions in a given [route] without providing a page template + */ + public fun serveVisions(route: String, visions: Map): Unit { + application.routing { + route(rootRoute) { + route(route) { + serveVisions(this, visions) + } + } + } + } + + /** + * Serve a page, potentially containing any number of visions at a given [route] with given [headers]. + * + */ + public fun page( + route: String = DEFAULT_PAGE, + title: String = "VisionForge server page '$route'", + headers: List = emptyList(), + visionFragment: HtmlVisionFragment, + ) { + val visions = HashMap() + + val cachedHtml: String? = if (cacheFragments) { + //Create and cache page html and map of visions + createHTML(true).html { + visions.putAll(buildPage(visionFragment, title, headers)) + } + } else { + null + } + + application.routing { + route(rootRoute) { + route(route) { + serveVisions(this, visions) + //filled pages + get { + if (cachedHtml == null) { + //re-create html and vision list on each call + call.respondHtml { + visions.clear() + visions.putAll(buildPage(visionFragment, title, headers)) + } + } else { + //Use cached html + call.respondText(cachedHtml, ContentType.Text.Html.withCharset(Charsets.UTF_8)) + } + } + } + } + } + } + + public companion object { + public const val DEFAULT_PAGE: String = "/" + public val UPDATE_INTERVAL_KEY: Name = Name.parse("update.interval") + } +} + +/** + * Use a script with given [src] as a global header for all pages. + */ +public inline fun VisionServer.useScript(src: String, crossinline block: SCRIPT.() -> Unit = {}) { + header { + script { + type = "text/javascript" + this.src = src + block() + } + } +} + +public inline fun VisionServer.useCss(href: String, crossinline block: LINK.() -> Unit = {}) { + header { + link { + rel = "stylesheet" + this.href = href + block() + } + } +} + +/** + * Attach plotly application to given server + */ +public fun Application.visionServer(context: Context, route: String = DEFAULT_PAGE): VisionServer { + if (featureOrNull(WebSockets) == null) { + install(WebSockets) + } + + if (featureOrNull(CORS) == null) { + install(CORS) { + anyHost() + } + } + + if (featureOrNull(CallLogging) == null) { + install(CallLogging) + } + + val visionManager = context.fetch(VisionManager) + + routing { + route(route) { + static { + resources() + } + } + } + + return VisionServer(visionManager, this, route) +} + +public fun VisionManager.serve( + host: String = "localhost", + port: Int = 7777, + block: VisionServer.() -> Unit, +): ApplicationEngine = context.embeddedServer(CIO, port, host) { + visionServer(context).apply(block) +}.start() + +public fun ApplicationEngine.show() { + val connector = environment.connectors.first() + val uri = URI("http", null, connector.host, connector.port, null, null, null) + Desktop.getDesktop().browse(uri) +} + +public fun ApplicationEngine.close(): Unit = stop(1000, 5000) \ No newline at end of file diff --git a/visionforge-solid/README.md b/visionforge-solid/README.md deleted file mode 100644 index cbf4073b..00000000 --- a/visionforge-solid/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-solid - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-solid:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-solid:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-solid:0.2.0") -} -``` diff --git a/visionforge-solid/api/visionforge-solid.api b/visionforge-solid/api/visionforge-solid.api deleted file mode 100644 index c763e3c8..00000000 --- a/visionforge-solid/api/visionforge-solid.api +++ /dev/null @@ -1,996 +0,0 @@ -public final class space/kscience/visionforge/solid/Box : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/Hexagon { - public static final field Companion Lspace/kscience/visionforge/solid/Box$Companion; - public fun (FFF)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun getNode1 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode2 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode3 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode4 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode5 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode6 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode7 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode8 ()Lspace/kscience/visionforge/solid/Point3D; - public final fun getXSize ()F - public final fun getYSize ()F - public final fun getZSize ()F - public static final fun write$Self (Lspace/kscience/visionforge/solid/Box;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Box$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Box$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Box; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Box;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Box$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ColorAccessor : space/kscience/dataforge/values/MutableValueProvider { - public fun (Lspace/kscience/dataforge/values/MutableValueProvider;Lspace/kscience/dataforge/names/Name;)V - public final fun getValue ()Lspace/kscience/dataforge/values/Value; - public fun getValue (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/values/Value; - public fun setValue (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/values/Value;)V - public final fun setValue (Lspace/kscience/dataforge/values/Value;)V -} - -public final class space/kscience/visionforge/solid/ColorAccessorKt { - public static final fun clear (Lspace/kscience/visionforge/solid/ColorAccessor;)V - public static final fun getString (Lspace/kscience/visionforge/solid/ColorAccessor;)Ljava/lang/String; - public static final fun invoke (Lspace/kscience/visionforge/solid/ColorAccessor;I)V - public static final fun invoke (Lspace/kscience/visionforge/solid/ColorAccessor;Ljava/lang/String;)V - public static final fun invoke-SGtJIdY (Lspace/kscience/visionforge/solid/ColorAccessor;BBB)V - public static final fun setString (Lspace/kscience/visionforge/solid/ColorAccessor;Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/solid/Composite : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { - public static final field Companion Lspace/kscience/visionforge/solid/Composite$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lspace/kscience/visionforge/solid/CompositeType;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Solid;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/visionforge/solid/CompositeType;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Solid;)V - public final fun getCompositeType ()Lspace/kscience/visionforge/solid/CompositeType; - public final fun getFirst ()Lspace/kscience/visionforge/solid/Solid; - public final fun getSecond ()Lspace/kscience/visionforge/solid/Solid; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Composite;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Composite$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Composite$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Composite; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Composite;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Composite$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/CompositeKt { - public static final fun composite (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun composite$default (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; - public static final fun intersect (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun intersect$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; - public static final fun smartComposite (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Solid; - public static synthetic fun smartComposite$default (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Solid; - public static final fun subtract (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun subtract$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; - public static final fun union (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun union$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; -} - -public final class space/kscience/visionforge/solid/CompositeType : java/lang/Enum { - public static final field GROUP Lspace/kscience/visionforge/solid/CompositeType; - public static final field INTERSECT Lspace/kscience/visionforge/solid/CompositeType; - public static final field SUBTRACT Lspace/kscience/visionforge/solid/CompositeType; - public static final field UNION Lspace/kscience/visionforge/solid/CompositeType; - public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/solid/CompositeType; - public static fun values ()[Lspace/kscience/visionforge/solid/CompositeType; -} - -public final class space/kscience/visionforge/solid/ConeSegment : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { - public static final field Companion Lspace/kscience/visionforge/solid/ConeSegment$Companion; - public fun (FFFFF)V - public synthetic fun (FFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getAngle ()F - public final fun getBottomRadius ()F - public final fun getHeight ()F - public final fun getStartAngle ()F - public final fun getTopRadius ()F - public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/ConeSegment;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/ConeSegment$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/ConeSegment$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/ConeSegment; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/ConeSegment;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ConeSegment$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ConeSegmentKt { - public static final fun cone (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSegment; - public static synthetic fun cone$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSegment; - public static final fun cylinder (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSegment; - public static synthetic fun cylinder$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSegment; -} - -public final class space/kscience/visionforge/solid/ConeSurface : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer, space/kscience/visionforge/solid/GeometrySolid { - public static final field Companion Lspace/kscience/visionforge/solid/ConeSurface$Companion; - public fun (FFFFFFF)V - public synthetic fun (FFFFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getAngle ()F - public final fun getBottomInnerRadius ()F - public final fun getBottomRadius ()F - public final fun getHeight ()F - public final fun getStartAngle ()F - public final fun getTopInnerRadius ()F - public final fun getTopRadius ()F - public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/ConeSurface;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/ConeSurface$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/ConeSurface$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/ConeSurface; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/ConeSurface;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ConeSurface$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ConeSurfaceKt { - public static final fun coneSurface (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSurface; - public static synthetic fun coneSurface$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSurface; - public static final fun tube (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSurface; - public static synthetic fun tube$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSurface; -} - -public final class space/kscience/visionforge/solid/Convex : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { - public static final field Companion Lspace/kscience/visionforge/solid/Convex$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/util/List;)V - public final fun getPoints ()Ljava/util/List; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Convex;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Convex$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Convex$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Convex; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Convex;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Convex$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ConvexBuilder { - public fun ()V - public final fun build ()Lspace/kscience/visionforge/solid/Convex; - public final fun point (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)V -} - -public final class space/kscience/visionforge/solid/ConvexKt { - public static final fun convex (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Convex; - public static synthetic fun convex$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Convex; -} - -public final class space/kscience/visionforge/solid/ExtrudeBuilder : space/kscience/visionforge/SimpleVisionPropertyContainer { - public fun ()V - public fun (Ljava/util/List;Ljava/util/List;Lspace/kscience/dataforge/meta/ObservableMutableMeta;)V - public synthetic fun (Ljava/util/List;Ljava/util/List;Lspace/kscience/dataforge/meta/ObservableMutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getLayers ()Ljava/util/List; - public final fun getShape ()Ljava/util/List; - public final fun layer (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)V - public static synthetic fun layer$default (Lspace/kscience/visionforge/solid/ExtrudeBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Object;)V - public final fun setLayers (Ljava/util/List;)V - public final fun setShape (Ljava/util/List;)V - public final fun shape (Lkotlin/jvm/functions/Function1;)V -} - -public final class space/kscience/visionforge/solid/Extruded : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer, space/kscience/visionforge/solid/GeometrySolid { - public static final field Companion Lspace/kscience/visionforge/solid/Extruded$Companion; - public static final field TYPE Ljava/lang/String; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/List;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/util/List;Ljava/util/List;)V - public final fun getLayers ()Ljava/util/List; - public final fun getShape ()Ljava/util/List; - public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/Extruded;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Extruded$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Extruded$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Extruded; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Extruded;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Extruded$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/ExtrudedKt { - public static final fun extruded (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Extruded; - public static synthetic fun extruded$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Extruded; - public static final fun polygon (Lspace/kscience/visionforge/solid/Shape2DBuilder;ILjava/lang/Number;)V -} - -public final class space/kscience/visionforge/solid/GenericHexagon : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/Hexagon { - public static final field Companion Lspace/kscience/visionforge/solid/GenericHexagon$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)V - public fun getNode1 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode2 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode3 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode4 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode5 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode6 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode7 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode8 ()Lspace/kscience/visionforge/solid/Point3D; - public static final fun write$Self (Lspace/kscience/visionforge/solid/GenericHexagon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/GenericHexagon$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/GenericHexagon$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/GenericHexagon; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/GenericHexagon;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/GenericHexagon$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract interface class space/kscience/visionforge/solid/GeometryBuilder { - public abstract fun build ()Ljava/lang/Object; - public abstract fun face (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;)V - public static synthetic fun face$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V -} - -public final class space/kscience/visionforge/solid/GeometryBuilderKt { - public static final fun cap (Lspace/kscience/visionforge/solid/GeometryBuilder;Ljava/util/List;Lspace/kscience/visionforge/solid/Point3D;)V - public static synthetic fun cap$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Ljava/util/List;Lspace/kscience/visionforge/solid/Point3D;ILjava/lang/Object;)V - public static final fun face4 (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;)V - public static synthetic fun face4$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V -} - -public final class space/kscience/visionforge/solid/GeometryKt { - public static final field PI2 F - public static final fun Point2D (Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Point2D; - public static final fun Point3D (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun cross (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun minus (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun normalizeInPlace (Lspace/kscience/visionforge/solid/MutablePoint3D;)V - public static final fun plus (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun toMeta (Lspace/kscience/visionforge/solid/Point2D;)Lspace/kscience/dataforge/meta/Meta; - public static final fun toMeta (Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/dataforge/meta/Meta; - public static final fun unaryMinus (Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; -} - -public abstract interface class space/kscience/visionforge/solid/GeometrySolid : space/kscience/visionforge/solid/Solid { - public abstract fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V -} - -public abstract interface class space/kscience/visionforge/solid/Hexagon : space/kscience/visionforge/solid/GeometrySolid { - public abstract fun getNode1 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode2 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode3 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode4 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode5 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode6 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode7 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode8 ()Lspace/kscience/visionforge/solid/Point3D; - public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V -} - -public final class space/kscience/visionforge/solid/HexagonKt { - public static final fun box (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Box; - public static synthetic fun box$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Box; - public static final fun hexagon (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Hexagon; - public static synthetic fun hexagon$default (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Hexagon; -} - -public final class space/kscience/visionforge/solid/Layer { - public static final field Companion Lspace/kscience/visionforge/solid/Layer$Companion; - public fun (FFFF)V - public synthetic fun (IFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun component1 ()F - public final fun component2 ()F - public final fun component3 ()F - public final fun component4 ()F - public final fun copy (FFFF)Lspace/kscience/visionforge/solid/Layer; - public static synthetic fun copy$default (Lspace/kscience/visionforge/solid/Layer;FFFFILjava/lang/Object;)Lspace/kscience/visionforge/solid/Layer; - public fun equals (Ljava/lang/Object;)Z - public final fun getScale ()F - public final fun getX ()F - public final fun getY ()F - public final fun getZ ()F - public fun hashCode ()I - public final fun setScale (F)V - public final fun setX (F)V - public final fun setY (F)V - public final fun setZ (F)V - public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Layer;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Layer$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Layer$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Layer; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Layer;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Layer$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract interface class space/kscience/visionforge/solid/MutablePoint3D : space/kscience/visionforge/solid/Point3D { - public abstract fun getX ()F - public abstract fun getY ()F - public abstract fun getZ ()F - public abstract fun setX (F)V - public abstract fun setY (F)V - public abstract fun setZ (F)V -} - -public final class space/kscience/visionforge/solid/Point2D { - public static final field Companion Lspace/kscience/visionforge/solid/Point2D$Companion; - public fun (FF)V - public synthetic fun (IFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun component1 ()F - public final fun component2 ()F - public final fun copy (FF)Lspace/kscience/visionforge/solid/Point2D; - public static synthetic fun copy$default (Lspace/kscience/visionforge/solid/Point2D;FFILjava/lang/Object;)Lspace/kscience/visionforge/solid/Point2D; - public fun equals (Ljava/lang/Object;)Z - public final fun getX ()F - public final fun getY ()F - public fun hashCode ()I - public final fun setX (F)V - public final fun setY (F)V - public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Point2D;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Point2D$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Point2D$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Point2D; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Point2D;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Point2D$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract interface class space/kscience/visionforge/solid/Point3D { - public static final field Companion Lspace/kscience/visionforge/solid/Point3D$Companion; - public abstract fun getX ()F - public abstract fun getY ()F - public abstract fun getZ ()F -} - -public final class space/kscience/visionforge/solid/Point3D$Companion { - public final fun getONE ()Lspace/kscience/visionforge/solid/Point3D; - public final fun getZERO ()Lspace/kscience/visionforge/solid/Point3D; -} - -public final class space/kscience/visionforge/solid/PolyLine : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { - public static final field Companion Lspace/kscience/visionforge/solid/PolyLine$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/util/List;)V - public final fun getPoints ()Ljava/util/List; - public final fun getThickness ()Ljava/lang/Number; - public final fun setThickness (Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/PolyLine;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/PolyLine$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/PolyLine$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/PolyLine; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/PolyLine;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/PolyLine$Companion { - public final fun getTHICKNESS_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/PolyLineKt { - public static final fun polyline (Lspace/kscience/visionforge/VisionContainerBuilder;[Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/PolyLine; - public static synthetic fun polyline$default (Lspace/kscience/visionforge/VisionContainerBuilder;[Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/PolyLine; -} - -public abstract interface class space/kscience/visionforge/solid/PrototypeHolder { - public abstract fun getPrototype (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/Solid; - public abstract fun prototypes (Lkotlin/jvm/functions/Function1;)V -} - -public final class space/kscience/visionforge/solid/Quaternion { - public static final synthetic fun box-impl ([D)Lspace/kscience/visionforge/solid/Quaternion; - public static fun constructor-impl ([D)[D - public fun equals (Ljava/lang/Object;)Z - public static fun equals-impl ([DLjava/lang/Object;)Z - public static final fun equals-impl0 ([D[D)Z - public final fun getValues ()[D - public fun hashCode ()I - public static fun hashCode-impl ([D)I - public fun toString ()Ljava/lang/String; - public static fun toString-impl ([D)Ljava/lang/String; - public final synthetic fun unbox-impl ()[D -} - -public final class space/kscience/visionforge/solid/QuaternionKt { - public static final fun component1-VMqeIco ([D)D - public static final fun component2-VMqeIco ([D)D - public static final fun component3-VMqeIco ([D)D - public static final fun component4-VMqeIco ([D)D -} - -public final class space/kscience/visionforge/solid/RotationOrder : java/lang/Enum { - public static final field XYZ Lspace/kscience/visionforge/solid/RotationOrder; - public static final field XZY Lspace/kscience/visionforge/solid/RotationOrder; - public static final field YXZ Lspace/kscience/visionforge/solid/RotationOrder; - public static final field YZX Lspace/kscience/visionforge/solid/RotationOrder; - public static final field ZXY Lspace/kscience/visionforge/solid/RotationOrder; - public static final field ZYX Lspace/kscience/visionforge/solid/RotationOrder; - public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/solid/RotationOrder; - public static fun values ()[Lspace/kscience/visionforge/solid/RotationOrder; -} - -public final class space/kscience/visionforge/solid/Shape2DBuilder { - public static final field Companion Lspace/kscience/visionforge/solid/Shape2DBuilder$Companion; - public fun ()V - public synthetic fun (ILjava/util/ArrayList;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/util/ArrayList;)V - public synthetic fun (Ljava/util/ArrayList;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Ljava/util/List; - public final fun point (Ljava/lang/Number;Ljava/lang/Number;)V - public final fun to (Ljava/lang/Number;Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/Shape2DBuilder;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Shape2DBuilder$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Shape2DBuilder$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Shape2DBuilder; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Shape2DBuilder;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Shape2DBuilder$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public abstract interface class space/kscience/visionforge/solid/Solid : space/kscience/visionforge/Vision { - public static final field Companion Lspace/kscience/visionforge/solid/Solid$Companion; - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; -} - -public final class space/kscience/visionforge/solid/Solid$Companion { - public final fun getDETAIL_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public final fun getGEOMETRY_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getIGNORE_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getLAYER_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getPOSITION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getROTATION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getROTATION_ORDER_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getSCALE_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getX_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getX_POSITION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getX_ROTATION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getX_SCALE_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getY_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getY_POSITION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getY_ROTATION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getY_SCALE_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getZ_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getZ_POSITION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getZ_ROTATION_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getZ_SCALE_KEY ()Lspace/kscience/dataforge/names/Name; -} - -public class space/kscience/visionforge/solid/SolidBase : space/kscience/visionforge/VisionBase, space/kscience/visionforge/solid/Solid { - public static final field Companion Lspace/kscience/visionforge/solid/SolidBase$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/SolidBase$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidBase$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidBase; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SolidBase;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidBase$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidGroup : space/kscience/visionforge/VisionGroupBase, space/kscience/visionforge/solid/PrototypeHolder, space/kscience/visionforge/solid/Solid { - public static final field Companion Lspace/kscience/visionforge/solid/SolidGroup$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public synthetic fun createGroup ()Lspace/kscience/visionforge/VisionGroupBase; - public fun getChildren ()Ljava/util/Map; - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public fun getPrototype (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/Solid; - public fun prototypes (Lkotlin/jvm/functions/Function1;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidGroup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/SolidGroup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidGroup$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidGroup; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SolidGroup;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidGroup$Companion { - public final fun getPROTOTYPES_TOKEN ()Lspace/kscience/dataforge/names/NameToken; - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidGroupKt { - public static final fun SolidGroup (Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static final fun group (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static final fun group (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static synthetic fun group$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; - public static synthetic fun group$default (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; -} - -public final class space/kscience/visionforge/solid/SolidKt { - public static final fun getDetail (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Integer; - public static final fun getIgnore (Lspace/kscience/visionforge/Vision;)Ljava/lang/Boolean; - public static final fun getLayer (Lspace/kscience/visionforge/solid/Solid;)I - public static final fun getPosition (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun getRotation (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun getRotationOrder (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/RotationOrder; - public static final fun getRotationX (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getRotationY (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getRotationZ (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getScale (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun getScaleX (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getScaleY (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getScaleZ (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getX (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getY (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getZ (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun setDetail (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Integer;)V - public static final fun setIgnore (Lspace/kscience/visionforge/Vision;Ljava/lang/Boolean;)V - public static final fun setLayer (Lspace/kscience/visionforge/solid/Solid;I)V - public static final fun setPosition (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Point3D;)V - public static final fun setRotation (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Point3D;)V - public static final fun setRotationOrder (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/RotationOrder;)V - public static final fun setRotationX (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setRotationY (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setRotationZ (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setScale (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Point3D;)V - public static final fun setScaleX (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setScaleY (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setScaleZ (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setX (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setY (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setZ (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V -} - -public final class space/kscience/visionforge/solid/SolidLabel : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { - public static final field Companion Lspace/kscience/visionforge/solid/SolidLabel$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;DLjava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;DLjava/lang/String;)V - public final fun getFontFamily ()Ljava/lang/String; - public final fun getFontSize ()D - public final fun getText ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidLabel;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/SolidLabel$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidLabel$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidLabel; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SolidLabel;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidLabel$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidLabelKt { - public static final fun label (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidLabel; - public static synthetic fun label$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidLabel; -} - -public final class space/kscience/visionforge/solid/SolidMaterial : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/SolidMaterial$Companion; - public fun ()V - public final fun getColor ()Lspace/kscience/visionforge/solid/ColorAccessor; - public final fun getEmissiveColor ()Lspace/kscience/visionforge/solid/ColorAccessor; - public final fun getOpacity ()F - public final fun getSpecularColor ()Lspace/kscience/visionforge/solid/ColorAccessor; - public final fun getWireframe ()Z - public final fun setOpacity (F)V - public final fun setWireframe (Z)V -} - -public final class space/kscience/visionforge/solid/SolidMaterial$Companion : space/kscience/dataforge/meta/SchemeSpec { - public final fun getCOLOR_KEY ()Lspace/kscience/dataforge/names/Name; - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public final fun getMATERIAL_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getMATERIAL_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getMATERIAL_OPACITY_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getMATERIAL_SPECULAR_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getMATERIAL_WIREFRAME_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getOPACITY_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getSPECULAR_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; - public final fun getWIREFRAME_KEY ()Lspace/kscience/dataforge/names/Name; -} - -public final class space/kscience/visionforge/solid/SolidMaterialKt { - public static final fun getColor (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/ColorAccessor; - public static final fun getMaterial (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/SolidMaterial; - public static final fun getOpacity (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun material (Lspace/kscience/visionforge/solid/Solid;Lkotlin/jvm/functions/Function1;)V - public static final fun setMaterial (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/SolidMaterial;)V - public static final fun setOpacity (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V -} - -public abstract interface class space/kscience/visionforge/solid/SolidReference : space/kscience/visionforge/VisionGroup { - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public abstract fun getPrototype ()Lspace/kscience/visionforge/solid/Solid; -} - -public final class space/kscience/visionforge/solid/SolidReferenceGroup : space/kscience/visionforge/VisionBase, space/kscience/visionforge/VisionGroup, space/kscience/visionforge/solid/Solid, space/kscience/visionforge/solid/SolidReference { - public static final field Companion Lspace/kscience/visionforge/solid/SolidReferenceGroup$Companion; - public static final field REFERENCE_CHILD_PROPERTY_PREFIX Ljava/lang/String; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lspace/kscience/dataforge/names/Name;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/dataforge/names/Name;)V - public fun getChildren ()Ljava/util/Map; - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public fun getPrototype ()Lspace/kscience/visionforge/solid/Solid; - public final fun getRefName ()Lspace/kscience/dataforge/names/Name; - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidReferenceGroup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/SolidReferenceGroup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidReferenceGroup$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SolidReferenceGroup;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidReferenceGroup$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SolidReferenceKt { - public static final fun getUnref (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/solid/Solid; - public static final fun newRef (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/PrototypeHolder;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static synthetic fun newRef$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/PrototypeHolder;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static final fun ref (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Ljava/lang/String;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static final fun ref (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static synthetic fun ref$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static synthetic fun ref$default (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; -} - -public final class space/kscience/visionforge/solid/Solids : space/kscience/visionforge/VisionPlugin { - public static final field Companion Lspace/kscience/visionforge/solid/Solids$Companion; - public fun (Lspace/kscience/dataforge/meta/Meta;)V - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; -} - -public final class space/kscience/visionforge/solid/Solids$Companion : space/kscience/dataforge/context/PluginFactory { - public final fun decodeFromString (Ljava/lang/String;)Lspace/kscience/visionforge/solid/Solid; - public final fun encodeToString (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/String; - public final fun getSerializersModuleForSolids ()Lkotlinx/serialization/modules/SerializersModule; - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/solid/Solids; -} - -public final class space/kscience/visionforge/solid/SolidsKt { - public static final fun solid (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; -} - -public final class space/kscience/visionforge/solid/Sphere : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer, space/kscience/visionforge/solid/GeometrySolid { - public static final field Companion Lspace/kscience/visionforge/solid/Sphere$Companion; - public fun (FFFFF)V - public synthetic fun (FFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getPhi ()F - public final fun getPhiStart ()F - public final fun getRadius ()F - public final fun getTheta ()F - public final fun getThetaStart ()F - public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/Sphere;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/Sphere$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Sphere$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Sphere; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Sphere;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Sphere$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SphereKt { - public static final fun sphere (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Sphere; - public static synthetic fun sphere$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Sphere; -} - -public final class space/kscience/visionforge/solid/SphereLayer : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { - public static final field Companion Lspace/kscience/visionforge/solid/SphereLayer$Companion; - public fun (FFFFFF)V - public synthetic fun (FFFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getInnerRadius ()F - public final fun getOuterRadius ()F - public final fun getPhi ()F - public final fun getPhiStart ()F - public final fun getTheta ()F - public final fun getThetaStart ()F - public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/SphereLayer;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/solid/SphereLayer$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SphereLayer$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SphereLayer; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SphereLayer;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SphereLayer$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/SphereLayerKt { - public static final fun sphereLayer (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SphereLayer; - public static synthetic fun sphereLayer$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SphereLayer; -} - -public final class space/kscience/visionforge/solid/specifications/Axes : space/kscience/dataforge/meta/Scheme { - public static final field AXIS_SIZE D - public static final field AXIS_WIDTH D - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Axes$Companion; - public fun ()V - public final fun getSize ()D - public final fun getVisible ()Z - public final fun getWidth ()D - public final fun setSize (D)V - public final fun setVisible (Z)V - public final fun setWidth (D)V -} - -public final class space/kscience/visionforge/solid/specifications/Axes$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; -} - -public final class space/kscience/visionforge/solid/specifications/Camera : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Camera$Companion; - public static final field FAR_CLIP D - public static final field FIELD_OF_VIEW I - public static final field INITIAL_AZIMUTH D - public static final field INITIAL_DISTANCE D - public static final field INITIAL_LATITUDE D - public static final field NEAR_CLIP D - public fun ()V - public final fun getAzimuth ()D - public final fun getDistance ()D - public final fun getFarClip ()D - public final fun getFov ()I - public final fun getLatitude ()D - public final fun getNearClip ()D - public final fun setAzimuth (D)V - public final fun setDistance (D)V - public final fun setFarClip (D)V - public final fun setFov (I)V - public final fun setLatitude (D)V - public final fun setNearClip (D)V -} - -public final class space/kscience/visionforge/solid/specifications/Camera$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; -} - -public final class space/kscience/visionforge/solid/specifications/CameraKt { - public static final fun getZenith (Lspace/kscience/visionforge/solid/specifications/Camera;)D -} - -public final class space/kscience/visionforge/solid/specifications/Canvas3DOptions : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Canvas3DOptions$Companion; - public fun ()V - public final fun getAxes ()Lspace/kscience/visionforge/solid/specifications/Axes; - public final fun getCamera ()Lspace/kscience/visionforge/solid/specifications/Camera; - public final fun getClipping ()Lspace/kscience/visionforge/solid/specifications/Clipping; - public final fun getControls ()Lspace/kscience/visionforge/solid/specifications/Controls; - public final fun getLayers ()Ljava/util/List; - public final fun getLight ()Lspace/kscience/visionforge/solid/specifications/Light; - public final fun getOnSelect ()Lkotlin/jvm/functions/Function1; - public final fun getSize ()Lspace/kscience/visionforge/solid/specifications/CanvasSize; - public final fun setAxes (Lspace/kscience/visionforge/solid/specifications/Axes;)V - public final fun setCamera (Lspace/kscience/visionforge/solid/specifications/Camera;)V - public final fun setClipping (Lspace/kscience/visionforge/solid/specifications/Clipping;)V - public final fun setControls (Lspace/kscience/visionforge/solid/specifications/Controls;)V - public final fun setLayers (Ljava/util/List;)V - public final fun setLight (Lspace/kscience/visionforge/solid/specifications/Light;)V - public final fun setOnSelect (Lkotlin/jvm/functions/Function1;)V - public final fun setSize (Lspace/kscience/visionforge/solid/specifications/CanvasSize;)V -} - -public final class space/kscience/visionforge/solid/specifications/Canvas3DOptions$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; -} - -public final class space/kscience/visionforge/solid/specifications/Canvas3DOptionsKt { - public static final fun computeHeight (Lspace/kscience/visionforge/solid/specifications/CanvasSize;Ljava/lang/Number;)I - public static final fun computeWidth (Lspace/kscience/visionforge/solid/specifications/CanvasSize;Ljava/lang/Number;)I -} - -public final class space/kscience/visionforge/solid/specifications/CanvasSize : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/CanvasSize$Companion; - public fun ()V - public final fun getMaxHeight ()Ljava/lang/Number; - public final fun getMaxSize ()I - public final fun getMaxWith ()Ljava/lang/Number; - public final fun getMinHeight ()Ljava/lang/Number; - public final fun getMinSize ()I - public final fun getMinWith ()Ljava/lang/Number; - public final fun setMaxHeight (Ljava/lang/Number;)V - public final fun setMaxSize (I)V - public final fun setMaxWith (Ljava/lang/Number;)V - public final fun setMinHeight (Ljava/lang/Number;)V - public final fun setMinSize (I)V - public final fun setMinWith (Ljava/lang/Number;)V -} - -public final class space/kscience/visionforge/solid/specifications/CanvasSize$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; -} - -public final class space/kscience/visionforge/solid/specifications/Clipping : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Clipping$Companion; - public fun ()V - public final fun getX ()Ljava/lang/Double; - public final fun getY ()Ljava/lang/Double; - public final fun getZ ()Ljava/lang/Double; - public final fun setX (Ljava/lang/Double;)V - public final fun setY (Ljava/lang/Double;)V - public final fun setZ (Ljava/lang/Double;)V -} - -public final class space/kscience/visionforge/solid/specifications/Clipping$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; -} - -public final class space/kscience/visionforge/solid/specifications/Controls : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Controls$Companion; - public fun ()V -} - -public final class space/kscience/visionforge/solid/specifications/Controls$Companion : space/kscience/dataforge/meta/SchemeSpec { -} - -public final class space/kscience/visionforge/solid/specifications/Light : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Light$Companion; - public fun ()V -} - -public final class space/kscience/visionforge/solid/specifications/Light$Companion : space/kscience/dataforge/meta/SchemeSpec { -} - -public abstract class space/kscience/visionforge/solid/transform/VisualTreeTransform { - public fun ()V - protected abstract fun clone (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/Vision; - public final fun invoke (Lspace/kscience/visionforge/Vision;Z)Lspace/kscience/visionforge/Vision; - public static synthetic fun invoke$default (Lspace/kscience/visionforge/solid/transform/VisualTreeTransform;Lspace/kscience/visionforge/Vision;ZILjava/lang/Object;)Lspace/kscience/visionforge/Vision; - protected abstract fun transformInPlace (Lspace/kscience/visionforge/Vision;)V -} - -public final class space/kscience/visionforge/solid/transform/VisualTreeTransformKt { - public static final fun transform (Lspace/kscience/visionforge/Vision;[Lspace/kscience/visionforge/solid/transform/VisualTreeTransform;)Lspace/kscience/visionforge/Vision; - public static final fun transformInPlace (Lspace/kscience/visionforge/Vision;[Lspace/kscience/visionforge/solid/transform/VisualTreeTransform;)V -} - diff --git a/visionforge-solid/build.gradle.kts b/visionforge-solid/build.gradle.kts index f87cef77..8b0b1dc2 100644 --- a/visionforge-solid/build.gradle.kts +++ b/visionforge-solid/build.gradle.kts @@ -1,26 +1,17 @@ plugins { - id("space.kscience.gradle.mpp") + id("ru.mipt.npm.gradle.mpp") } -val kmathVersion = "0.3.1" - -kscience { - jvm() - js() - native() - useSerialization { - json() - } - useCoroutines() - dependencies { - api("space.kscience:kmath-geometry:0.3.1") - api(projects.visionforgeCore) - } - dependencies(jvmTest) { - implementation(spclibs.logback.classic) - } +kscience{ + useSerialization() } -readme { - maturity = space.kscience.gradle.Maturity.DEVELOPMENT +kotlin { + sourceSets { + commonMain { + dependencies { + api(project(":visionforge-core")) + } + } + } } \ No newline at end of file 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 60789027..57f868f2 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,19 +1,15 @@ 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 -import space.kscience.visionforge.root -import kotlin.properties.ReadOnlyProperty @VisionBuilder public class ColorAccessor( private val provider: MutableValueProvider, - private val colorKey: Name, + private val colorKey: Name ) : MutableValueProvider { public var value: Value? get() = provider.getValue(colorKey) @@ -28,14 +24,8 @@ public class ColorAccessor( } } -public fun Vision.colorProperty( - propertyName: Name? = null, -): ReadOnlyProperty = ReadOnlyProperty { _, property -> - ColorAccessor(properties.root(true), propertyName ?: property.name.asName()) -} - public var ColorAccessor?.string: String? - get() = this?.value?.let { if (it == Null) null else it.string } + get() = this?.value?.let { if(it == Null) null else it.string } set(value) { this?.value = value?.asValue() } 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 7c6ab3ec..9debf612 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 @@ -2,11 +2,13 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.* +import space.kscience.dataforge.meta.update +import space.kscience.visionforge.VisionBuilder +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set public enum class CompositeType { - GROUP, // Dumb sum of meshes + SUM, // Dumb sum of meshes UNION, //CSG union INTERSECT, SUBTRACT @@ -18,66 +20,49 @@ public class Composite( public val compositeType: CompositeType, public val first: Solid, public val second: Solid, -) : SolidBase() +) : SolidBase(), Solid @VisionBuilder -public inline fun MutableVisionContainer.composite( +public inline fun VisionContainerBuilder.composite( type: CompositeType, name: String? = null, - @VisionBuilder builder: SolidGroup.() -> Unit, + builder: SolidGroup.() -> Unit, ): Composite { val group = SolidGroup().apply(builder) - val children = group.items.values.toList() - if (children.size != 2) { - error("Composite requires exactly two children, but found ${children.size}") - } + val children = group.children.values.filterIsInstance() + if (children.size != 2) error("Composite requires exactly two children") val res = Composite(type, children[0], children[1]) - res.properties.setProperty(Name.EMPTY, group.properties.own) + res.meta.update(group.meta) - setChild(name, res) + if (group.position != null) { + res.position = group.position + } + if (group.rotation != null) { + res.rotation = group.rotation + } + if (group.scale != null) { + res.scale = group.scale + } + + set(name, res) return res } -/** - * A smart form of [Composite] that in case of [CompositeType.GROUP] creates a static group instead - */ @VisionBuilder -public fun SolidGroup.smartComposite( - type: CompositeType, +public inline fun VisionContainerBuilder.union( name: String? = null, - @VisionBuilder builder: SolidGroup.() -> Unit, -): Solid = if (type == CompositeType.GROUP) { - val group = SolidGroup().apply(builder) - if (name == null && group.properties.own == null) { - //append directly to group if no properties are defined - group.items.forEach { (_, value) -> - value.parent = null - children.static(value) - } - this - } else { - children.setChild(name, group) - group - } -} else { - children.composite(type, name, builder) -} - -@VisionBuilder -public inline fun MutableVisionContainer.union( - name: String? = null, - builder: SolidGroup.() -> Unit, + builder: SolidGroup.() -> Unit ): Composite = composite(CompositeType.UNION, name, builder = builder) @VisionBuilder -public inline fun MutableVisionContainer.subtract( +public inline fun VisionContainerBuilder.subtract( name: String? = null, - builder: SolidGroup.() -> Unit, + builder: SolidGroup.() -> Unit ): Composite = composite(CompositeType.SUBTRACT, name, builder = builder) @VisionBuilder -public inline fun MutableVisionContainer.intersect( +public inline fun VisionContainerBuilder.intersect( name: String? = null, builder: SolidGroup.() -> Unit, ): Composite = composite(CompositeType.INTERSECT, name, builder = builder) \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSegment.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSegment.kt index 7b2679cd..560ec496 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSegment.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSegment.kt @@ -2,9 +2,9 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set import kotlin.math.cos import kotlin.math.sin @@ -18,84 +18,79 @@ public class ConeSegment( public val bottomRadius: Float, public val height: Float, public val topRadius: Float, - public val phiStart: Float = 0f, - public val phi: Float = PI2, -) : SolidBase(), GeometrySolid { - - - init { - require(bottomRadius > 0) { "Cone segment bottom radius must be positive" } - require(height > 0) { "Cone segment height must be positive" } - require(topRadius >= 0) { "Cone segment top radius must be non-negative" } - //require(startAngle >= 0) - require(phi in (0f..(PI2))) - } + public val startAngle: Float = 0f, + public val angle: Float = PI2 +) : SolidBase(), GeometrySolid { override fun toGeometry(geometryBuilder: GeometryBuilder) { val segments = detail ?: 32 - require(segments >= 4) { "The number of segments in cone is too small" } - val angleStep = phi / (segments - 1) + require(segments >= 4) { "The number of segments in cone segment is too small" } + val angleStep = angle / (segments - 1) - fun shape(r: Float, z: Float): List = (0 until segments).map { i -> - Float32Vector3D(r * cos(phiStart + angleStep * i), r * sin(phiStart + angleStep * i), z) + fun shape(r: Float, z: Float): List { + return (0 until segments).map { i -> + Point3D(r * cos(startAngle + angleStep * i), r * sin(startAngle + angleStep * i), z) + } } geometryBuilder.apply { //creating shape in x-y plane with z = 0 - val bottomPoints = shape(bottomRadius, -height / 2) - val topPoints = shape(topRadius, height / 2) + val bottomOuterPoints = shape(topRadius, -height / 2) + val upperOuterPoints = shape(bottomRadius, height / 2) //outer face - for (it in 1 until segments) { - face4(bottomPoints[it - 1], bottomPoints[it], topPoints[it], topPoints[it - 1]) + (1 until segments).forEach { + face4(bottomOuterPoints[it - 1], bottomOuterPoints[it], upperOuterPoints[it], upperOuterPoints[it - 1]) } - if (phi == PI2) { - face4(bottomPoints.last(), bottomPoints[0], topPoints[0], topPoints.last()) + if (angle == PI2) { + face4(bottomOuterPoints.last(), bottomOuterPoints[0], upperOuterPoints[0], upperOuterPoints.last()) } - val zeroBottom = Float32Vector3D(0f, 0f, -height / 2) - val zeroTop = Float32Vector3D(0f, 0f, +height / 2) - for (it in 1 until segments) { - face(bottomPoints[it - 1], zeroBottom, bottomPoints[it]) - face(topPoints[it - 1], topPoints[it], zeroTop) + + val zeroBottom = Point3D(0f, 0f, 0f) + val zeroTop = Point3D(0f, 0f, height) + (1 until segments).forEach { + face(bottomOuterPoints[it - 1], zeroBottom, bottomOuterPoints[it]) + face(upperOuterPoints[it - 1], upperOuterPoints[it], zeroTop) } - if (phi == PI2) { - face(bottomPoints.last(), zeroBottom, bottomPoints[0]) - face(topPoints.last(), topPoints[0], zeroTop) + if (angle == PI2) { + face(bottomOuterPoints.last(), zeroBottom, bottomOuterPoints[0]) + face(upperOuterPoints.last(), upperOuterPoints[0], zeroTop) } else { - face4(zeroTop, zeroBottom, bottomPoints[0], topPoints[0]) - face4(zeroTop, zeroBottom, bottomPoints.last(), topPoints.last()) + face4(zeroTop, zeroBottom, bottomOuterPoints[0], upperOuterPoints[0]) + face4(zeroTop, zeroBottom, bottomOuterPoints.last(), upperOuterPoints.last()) } } } + } @VisionBuilder -public inline fun MutableVisionContainer.cylinder( +public inline fun VisionContainerBuilder.cylinder( r: Number, height: Number, name: String? = null, - block: ConeSegment.() -> Unit = {}, + block: ConeSegment.() -> Unit = {} ): ConeSegment = ConeSegment( r.toFloat(), height.toFloat(), r.toFloat() -).apply(block).also { setChild(name, it) } +).apply(block).also { set(name, it) } @VisionBuilder -public inline fun MutableVisionContainer.cone( +public inline fun VisionContainerBuilder.cone( bottomRadius: Number, height: Number, upperRadius: Number = 0.0, startAngle: Number = 0f, angle: Number = PI2, name: String? = null, - block: ConeSegment.() -> Unit = {}, + block: ConeSegment.() -> Unit = {} ): ConeSegment = ConeSegment( bottomRadius.toFloat(), height.toFloat(), topRadius = upperRadius.toFloat(), - phiStart = startAngle.toFloat(), - phi = angle.toFloat() -).apply(block).also { setChild(name, it) } \ No newline at end of file + startAngle = startAngle.toFloat(), + angle = angle.toFloat() +).apply(block).also { set(name, it) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSurface.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSurface.kt index 8ce9ba8c..a9c5622b 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSurface.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/ConeSurface.kt @@ -2,9 +2,9 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set import kotlin.math.PI import kotlin.math.cos import kotlin.math.sin @@ -21,25 +21,27 @@ public class ConeSurface( public val height: Float, public val topRadius: Float, public val topInnerRadius: Float, - public val phiStart: Float = 0f, - public val phi: Float = PI2, -) : SolidBase(), GeometrySolid { + public val startAngle: Float = 0f, + public val angle: Float = PI2, +) : SolidBase(), GeometrySolid { init { require(bottomRadius > 0) { "Cone surface bottom radius must be positive" } require(height > 0) { "Cone surface height must be positive" } require(bottomInnerRadius >= 0) { "Cone surface bottom inner radius must be non-negative" } //require(startAngle >= 0) - require(phi in (0f..(PI2))) + require(angle in (0f..(PI2))) } override fun toGeometry(geometryBuilder: GeometryBuilder) { val segments = detail ?: 32 require(segments >= 4) { "The number of segments in tube is too small" } - val angleStep = phi / (segments - 1) + val angleStep = angle / (segments - 1) - fun shape(r: Float, z: Float): List = (0 until segments).map { i -> - Float32Vector3D(r * cos(phiStart + angleStep * i), r * sin(phiStart + angleStep * i), z) + fun shape(r: Float, z: Float): List { + return (0 until segments).map { i -> + Point3D(r * cos(startAngle + angleStep * i), r * sin(startAngle + angleStep * i), z) + } } geometryBuilder.apply { @@ -48,21 +50,21 @@ public class ConeSurface( val bottomOuterPoints = shape(bottomRadius, -height / 2) val topOuterPoints = shape(topRadius, height / 2) //outer face - for (it in 1 until segments) { + (1 until segments).forEach { face4(bottomOuterPoints[it - 1], bottomOuterPoints[it], topOuterPoints[it], topOuterPoints[it - 1]) } - if (phi == PI2) { + if (angle == PI2) { face4(bottomOuterPoints.last(), bottomOuterPoints[0], topOuterPoints[0], topOuterPoints.last()) } if (bottomInnerRadius == 0f) { - val zeroBottom = Float32Vector3D(0f, 0f, -height / 2) - val zeroTop = Float32Vector3D(0f, 0f, height / 2) + val zeroBottom = Point3D(0f, 0f, 0f) + val zeroTop = Point3D(0f, 0f, height) (1 until segments).forEach { face(bottomOuterPoints[it - 1], zeroBottom, bottomOuterPoints[it]) face(topOuterPoints[it - 1], topOuterPoints[it], zeroTop) } - if (phi == PI2) { + if (angle == PI2) { face(bottomOuterPoints.last(), zeroBottom, bottomOuterPoints[0]) face(topOuterPoints.last(), topOuterPoints[0], zeroTop) } else { @@ -96,7 +98,7 @@ public class ConeSurface( topOuterPoints[it] ) } - if (phi == PI2) { + if (angle == PI2) { face4(bottomInnerPoints[0], bottomInnerPoints.last(), topInnerPoints.last(), topInnerPoints[0]) face4( bottomInnerPoints.last(), @@ -121,7 +123,7 @@ public class ConeSurface( @VisionBuilder -public inline fun MutableVisionContainer.tube( +public inline fun VisionContainerBuilder.tube( radius: Number, height: Number, innerRadius: Number, @@ -135,12 +137,12 @@ public inline fun MutableVisionContainer.tube( height = height.toFloat(), topRadius = radius.toFloat(), topInnerRadius = innerRadius.toFloat(), - phiStart = startAngle.toFloat(), - phi = angle.toFloat() -).apply(block).also { setChild(name, it) } + startAngle = startAngle.toFloat(), + angle = angle.toFloat() +).apply(block).also { set(name, it) } @VisionBuilder -public inline fun MutableVisionContainer.coneSurface( +public inline fun VisionContainerBuilder.coneSurface( bottomOuterRadius: Number, bottomInnerRadius: Number, height: Number, @@ -156,6 +158,6 @@ public inline fun MutableVisionContainer.coneSurface( height = height.toFloat(), topRadius = topOuterRadius.toFloat(), topInnerRadius = topInnerRadius.toFloat(), - phiStart = startAngle.toFloat(), - phi = angle.toFloat() -).apply(block).also { setChild(name, it) } \ No newline at end of file + startAngle = startAngle.toFloat(), + angle = angle.toFloat() +).apply(block).also { set(name, it) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Convex.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Convex.kt index 4fa174ac..2d242391 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Convex.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Convex.kt @@ -2,23 +2,21 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set @Serializable @SerialName("solid.convex") -public class Convex(public val points: List) : SolidBase() +public class Convex(public val points: List) : SolidBase(), Solid -public inline fun MutableVisionContainer.convex( - name: String? = null, - action: ConvexBuilder.() -> Unit = {}, -): Convex = ConvexBuilder().apply(action).build().also { setChild(name, it) } +public inline fun VisionContainerBuilder.convex(name: String? = null, action: ConvexBuilder.() -> Unit = {}): Convex = + ConvexBuilder().apply(action).build().also { set(name, it) } public class ConvexBuilder { - private val points = ArrayList() + private val points = ArrayList() public fun point(x: Number, y: Number, z: Number) { - points.add(Float32Vector3D(x, y, z)) + points.add(Point3D(x, y, z)) } public fun build(): Convex { 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 014db562..30ecb575 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 @@ -3,26 +3,25 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import space.kscience.dataforge.meta.MutableMeta -import space.kscience.dataforge.names.Name -import space.kscience.kmath.geometry.component1 -import space.kscience.kmath.geometry.component2 -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.dataforge.meta.ObservableMutableMeta +import space.kscience.dataforge.meta.configure +import space.kscience.visionforge.* import kotlin.math.PI import kotlin.math.cos import kotlin.math.sin -public typealias Shape2D = List +public typealias Shape2D = List @Serializable -public class Shape2DBuilder(private val points: ArrayList = ArrayList()) { +public class Shape2DBuilder(private val points: ArrayList = ArrayList()) { public fun point(x: Number, y: Number) { - points.add(Float32Vector2D(x, y)) + points.add(Point2D(x, y)) } + public infix fun Number.to(y: Number): Unit = point(this, y) + public fun build(): Shape2D = points } @@ -40,9 +39,9 @@ public data class Layer(var x: Float, var y: Float, var z: Float, var scale: Flo @Serializable @SerialName("solid.extrude") public class Extruded( - public val shape: List, - public val layers: List, -) : SolidBase(), GeometrySolid { + public val shape: List, + public val layers: List +) : SolidBase(), GeometrySolid, VisionPropertyContainer { override fun toGeometry(geometryBuilder: GeometryBuilder) { val shape: Shape2D = shape @@ -52,23 +51,23 @@ public class Extruded( /** * Expand the shape for specific layers */ - val layers: List> = layers.map { layer -> + val layers: List> = layers.map { layer -> shape.map { (x, y) -> val newX = layer.x + x * layer.scale val newY = layer.y + y * layer.scale - Float32Vector3D(newX, newY, layer.z) + Point3D(newX, newY, layer.z) } } if (layers.size < 2) error("Extruded shape requires more than one layer") var lowerLayer = layers.first() - var upperLayer: List + var upperLayer: List for (i in (1 until layers.size)) { upperLayer = layers[i] for (j in (0 until shape.size - 1)) { - //counterclockwise + //counter clockwise geometryBuilder.face4( lowerLayer[j], lowerLayer[j + 1], @@ -96,10 +95,12 @@ public class Extruded( } public class ExtrudeBuilder( - public var shape: List = emptyList(), + public var shape: List = emptyList(), + public var layers: MutableList = ArrayList(), - public val properties: MutableMeta = MutableMeta(), -) { + + config: ObservableMutableMeta = MutableMeta() +) : SimpleVisionPropertyContainer(config) { public fun shape(block: Shape2DBuilder.() -> Unit) { this.shape = Shape2DBuilder().apply(block).build() } @@ -109,12 +110,12 @@ public class ExtrudeBuilder( } internal fun build(): Extruded = Extruded(shape, layers).apply { - this.properties.setProperty(Name.EMPTY, this@ExtrudeBuilder.properties) + configure(this@ExtrudeBuilder.meta) } } @VisionBuilder -public fun MutableVisionContainer.extruded( +public fun VisionContainerBuilder.extruded( name: String? = null, - action: ExtrudeBuilder.() -> Unit = {}, -): Extruded = ExtrudeBuilder().apply(action).build().also { setChild(name, it) } \ No newline at end of file + action: ExtrudeBuilder.() -> Unit = {} +): Extruded = ExtrudeBuilder().apply(action).build().also { set(name, it) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Float32Euclidean2DSpace.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Float32Euclidean2DSpace.kt deleted file mode 100644 index b9a2fdba..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Float32Euclidean2DSpace.kt +++ /dev/null @@ -1,71 +0,0 @@ -package space.kscience.visionforge.solid - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import space.kscience.kmath.geometry.GeometrySpace -import space.kscience.kmath.geometry.Vector2D -import space.kscience.kmath.operations.ScaleOperations -import kotlin.math.pow -import kotlin.math.sqrt - -@Serializable(Float32Euclidean2DSpace.VectorSerializer::class) -public interface Float32Vector2D: Vector2D - - -public object Float32Euclidean2DSpace : - GeometrySpace, - ScaleOperations { - - @Serializable - @SerialName("Float32Vector2D") - private data class Vector2DImpl( - override val x: Float, - override val y: Float, - ) : Float32Vector2D - - public object VectorSerializer : KSerializer { - private val proxySerializer = Vector2DImpl.serializer() - override val descriptor: SerialDescriptor get() = proxySerializer.descriptor - - override fun deserialize(decoder: Decoder): Float32Vector2D = decoder.decodeSerializableValue(proxySerializer) - - override fun serialize(encoder: Encoder, value: Float32Vector2D) { - val vector = value as? Vector2DImpl ?: Vector2DImpl(value.x, value.y) - encoder.encodeSerializableValue(proxySerializer, vector) - } - } - - public fun vector(x: Float, y: Float): Float32Vector2D = - Vector2DImpl(x, y) - - public fun vector(x: Number, y: Number): Float32Vector2D = - vector(x.toFloat(), y.toFloat()) - - override val zero: Float32Vector2D by lazy { vector(0f, 0f) } - - override fun norm(arg: Float32Vector2D): Double = sqrt(arg.x.pow(2) + arg.y.pow(2)).toDouble() - - public fun Float32Vector2D.norm(): Double = norm(this) - - override fun Float32Vector2D.unaryMinus(): Float32Vector2D = vector(-x, -y) - - override fun Float32Vector2D.distanceTo(other: Float32Vector2D): Double = (this - other).norm() - - override fun add(left: Float32Vector2D, right: Float32Vector2D): Float32Vector2D = - vector(left.x + right.x, left.y + right.y) - - override fun scale(a: Float32Vector2D, value: Double): Float32Vector2D = - vector(a.x * value, a.y * value) - - override fun Float32Vector2D.dot(other: Float32Vector2D): Double = - (x * other.x + y * other.y).toDouble() - - public val xAxis: Float32Vector2D = vector(1.0, 0.0) - public val yAxis: Float32Vector2D = vector(0.0, 1.0) -} - -public fun Float32Vector2D(x: Number, y: Number): Float32Vector2D = Float32Euclidean2DSpace.vector(x, y) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Float32Euclidean3DSpace.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Float32Euclidean3DSpace.kt deleted file mode 100644 index 04b3df35..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Float32Euclidean3DSpace.kt +++ /dev/null @@ -1,113 +0,0 @@ -package space.kscience.visionforge.solid - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import space.kscience.kmath.geometry.GeometrySpace -import space.kscience.kmath.geometry.Vector3D -import space.kscience.kmath.operations.ScaleOperations -import kotlin.math.pow -import kotlin.math.sqrt - -@Serializable(Float32Euclidean3DSpace.VectorSerializer::class) -public interface Float32Vector3D: Vector3D - - -public object Float32Euclidean3DSpace : - GeometrySpace, - ScaleOperations{ - - @Serializable - @SerialName("Float32Vector3D") - private data class Vector3DImpl( - override val x: Float, - override val y: Float, - override val z: Float, - ) : Float32Vector3D - - public object VectorSerializer : KSerializer { - private val proxySerializer = Vector3DImpl.serializer() - override val descriptor: SerialDescriptor get() = proxySerializer.descriptor - - override fun deserialize(decoder: Decoder): Float32Vector3D = decoder.decodeSerializableValue(proxySerializer) - - override fun serialize(encoder: Encoder, value: Float32Vector3D) { - val vector = value as? Vector3DImpl ?: Vector3DImpl(value.x, value.y, value.z) - encoder.encodeSerializableValue(proxySerializer, vector) - } - } - - public fun vector(x: Float, y: Float, z: Float): Float32Vector3D = - Vector3DImpl(x, y, z) - - public fun vector(x: Number, y: Number, z: Number): Float32Vector3D = - vector(x.toFloat(), y.toFloat(), z.toFloat()) - - override val zero: Float32Vector3D by lazy { vector(0.0, 0.0, 0.0) } - - override fun norm(arg: Float32Vector3D): Double = sqrt(arg.x.pow(2) + arg.y.pow(2) + arg.z.pow(2)).toDouble() - - public fun Float32Vector3D.norm(): Double = norm(this) - - override fun Float32Vector3D.unaryMinus(): Float32Vector3D = vector(-x, -y, -z) - - override fun Float32Vector3D.distanceTo(other: Float32Vector3D): Double = (this - other).norm() - - override fun add(left: Float32Vector3D, right: Float32Vector3D): Float32Vector3D = - vector(left.x + right.x, left.y + right.y, left.z + right.z) - - override fun scale(a: Float32Vector3D, value: Double): Float32Vector3D = - vector(a.x * value, a.y * value, a.z * value) - - override fun Float32Vector3D.dot(other: Float32Vector3D): Double = - (x * other.x + y * other.y + z * other.z).toDouble() - - private fun leviCivita(i: Int, j: Int, k: Int): Int = when { - // even permutation - i == 0 && j == 1 && k == 2 -> 1 - i == 1 && j == 2 && k == 0 -> 1 - i == 2 && j == 0 && k == 1 -> 1 - // odd permutations - i == 2 && j == 1 && k == 0 -> -1 - i == 0 && j == 2 && k == 1 -> -1 - i == 1 && j == 0 && k == 2 -> -1 - - else -> 0 - } - - /** - * Compute vector product of [first] and [second]. The basis is assumed to be right-handed. - */ - public fun vectorProduct( - first: Float32Vector3D, - second: Float32Vector3D, - ): Float32Vector3D { - var x = 0.0 - var y = 0.0 - var z = 0.0 - - for (j in (0..2)) { - for (k in (0..2)) { - x += leviCivita(0, j, k) * first[j] * second[k] - y += leviCivita(1, j, k) * first[j] * second[k] - z += leviCivita(2, j, k) * first[j] * second[k] - } - } - - return vector(x, y, z) - } - - /** - * Vector product in a right-handed basis - */ - public infix fun Float32Vector3D.cross(other: Float32Vector3D): Float32Vector3D = vectorProduct(this, other) - - public val xAxis: Float32Vector3D = vector(1.0, 0.0, 0.0) - public val yAxis: Float32Vector3D = vector(0.0, 1.0, 0.0) - public val zAxis: Float32Vector3D = vector(0.0, 0.0, 1.0) -} - -public fun Float32Vector3D(x: Number, y: Number, z: Number): Float32Vector3D = Float32Euclidean3DSpace.vector(x,y,z) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/GeometryBuilder.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/GeometryBuilder.kt index ab24f8ce..3cfc5da9 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/GeometryBuilder.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/GeometryBuilder.kt @@ -13,17 +13,17 @@ public interface GeometryBuilder { * @param normal optional external normal to the face * @param meta optional additional platform-specific parameters like color or texture index */ - public fun face(vertex1: Float32Vector3D, vertex2: Float32Vector3D, vertex3: Float32Vector3D, normal: Float32Vector3D? = null, meta: Meta = Meta.EMPTY) + public fun face(vertex1: Point3D, vertex2: Point3D, vertex3: Point3D, normal: Point3D? = null, meta: Meta = Meta.EMPTY) public fun build(): T } public fun GeometryBuilder<*>.face4( - vertex1: Float32Vector3D, - vertex2: Float32Vector3D, - vertex3: Float32Vector3D, - vertex4: Float32Vector3D, - normal: Float32Vector3D? = null, + vertex1: Point3D, + vertex2: Point3D, + vertex3: Point3D, + vertex4: Point3D, + normal: Point3D? = null, meta: Meta = Meta.EMPTY ) { face(vertex1, vertex2, vertex3, normal, meta) @@ -37,9 +37,9 @@ public interface GeometrySolid : Solid { public fun toGeometry(geometryBuilder: GeometryBuilder) } -public fun GeometryBuilder.cap(shape: List, normal: Float32Vector3D? = null) { +public fun GeometryBuilder.cap(shape: List, normal: Point3D? = null) { //FIXME won't work for non-convex shapes - val center = Float32Vector3D( + val center = Point3D( shape.map { it.x }.average(), shape.map { it.y }.average(), shape.map { it.z }.average() diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Hexagon.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Hexagon.kt index 12e661eb..baced452 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Hexagon.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Hexagon.kt @@ -2,19 +2,19 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set public interface Hexagon : GeometrySolid { - public val node1: Float32Vector3D - public val node2: Float32Vector3D - public val node3: Float32Vector3D - public val node4: Float32Vector3D - public val node5: Float32Vector3D - public val node6: Float32Vector3D - public val node7: Float32Vector3D - public val node8: Float32Vector3D + public val node1: Point3D + public val node2: Point3D + public val node3: Point3D + public val node4: Point3D + public val node5: Point3D + public val node6: Point3D + public val node7: Point3D + public val node8: Point3D override fun toGeometry(geometryBuilder: GeometryBuilder) { geometryBuilder.face4(node1, node4, node3, node2) @@ -35,54 +35,54 @@ public class Box( public val xSize: Float, public val ySize: Float, public val zSize: Float, -) : SolidBase(), Hexagon { +) : SolidBase(), Hexagon { private inline val dx get() = xSize / 2 private inline val dy get() = ySize / 2 private inline val dz get() = zSize / 2 - override val node1: Float32Vector3D get() = Float32Vector3D(-dx, -dy, -dz) - override val node2: Float32Vector3D get() = Float32Vector3D(dx, -dy, -dz) - override val node3: Float32Vector3D get() = Float32Vector3D(dx, dy, -dz) - override val node4: Float32Vector3D get() = Float32Vector3D(-dx, dy, -dz) - override val node5: Float32Vector3D get() = Float32Vector3D(-dx, -dy, dz) - override val node6: Float32Vector3D get() = Float32Vector3D(dx, -dy, dz) - override val node7: Float32Vector3D get() = Float32Vector3D(dx, dy, dz) - override val node8: Float32Vector3D get() = Float32Vector3D(-dx, dy, dz) + override val node1: Point3D get() = Point3D(-dx, -dy, -dz) + override val node2: Point3D get() = Point3D(dx, -dy, -dz) + override val node3: Point3D get() = Point3D(dx, dy, -dz) + override val node4: Point3D get() = Point3D(-dx, dy, -dz) + override val node5: Point3D get() = Point3D(-dx, -dy, dz) + override val node6: Point3D get() = Point3D(dx, -dy, dz) + override val node7: Point3D get() = Point3D(dx, dy, dz) + override val node8: Point3D get() = Point3D(-dx, dy, dz) } @VisionBuilder -public inline fun MutableVisionContainer.box( +public inline fun VisionContainerBuilder.box( xSize: Number, ySize: Number, zSize: Number, name: String? = null, - block: Box.() -> Unit = {}, -): Box = Box(xSize.toFloat(), ySize.toFloat(), zSize.toFloat()).apply(block).also { setChild(name, it) } + action: Box.() -> Unit = {}, +): Box = Box(xSize.toFloat(), ySize.toFloat(), zSize.toFloat()).apply(action).also { set(name, it) } @Serializable @SerialName("solid.hexagon") public class GenericHexagon( - override val node1: Float32Vector3D, - override val node2: Float32Vector3D, - override val node3: Float32Vector3D, - override val node4: Float32Vector3D, - override val node5: Float32Vector3D, - override val node6: Float32Vector3D, - override val node7: Float32Vector3D, - override val node8: Float32Vector3D, -) : SolidBase(), Hexagon + override val node1: Point3D, + override val node2: Point3D, + override val node3: Point3D, + override val node4: Point3D, + override val node5: Point3D, + override val node6: Point3D, + override val node7: Point3D, + override val node8: Point3D, +) : SolidBase(), Hexagon @VisionBuilder -public inline fun MutableVisionContainer.hexagon( - node1: Float32Vector3D, - node2: Float32Vector3D, - node3: Float32Vector3D, - node4: Float32Vector3D, - node5: Float32Vector3D, - node6: Float32Vector3D, - node7: Float32Vector3D, - node8: Float32Vector3D, +public inline fun VisionContainerBuilder.hexagon( + node1: Point3D, + node2: Point3D, + node3: Point3D, + node4: Point3D, + node5: Point3D, + node6: Point3D, + node7: Point3D, + node8: Point3D, name: String? = null, action: Hexagon.() -> Unit = {}, -): Hexagon = GenericHexagon(node1, node2, node3, node4, node5, node6, node7, node8).apply(action).also { setChild(name, it) } \ No newline at end of file +): Hexagon = GenericHexagon(node1, node2, node3, node4, node5, node6, node7, node8).apply(action).also { set(name, it) } \ No newline at end of file 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 deleted file mode 100644 index 6064e6ed..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/LightSource.kt +++ /dev/null @@ -1,75 +0,0 @@ -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.names.Name -import space.kscience.dataforge.names.asName -import space.kscience.visionforge.* - -@Serializable -public abstract class LightSource : SolidBase() { - override val descriptor: MetaDescriptor get() = LightSource.descriptor - - public val color: ColorAccessor by colorProperty(SolidMaterial.COLOR_KEY) - public var intensity: Number by properties.root(includeStyles = false).number(INTENSITY_KEY) { 1.0 } - - public companion object { - public val INTENSITY_KEY: Name = "intensity".asName() - - public val descriptor: MetaDescriptor by lazy { - MetaDescriptor { - value(Vision.VISIBLE_KEY, ValueType.BOOLEAN) { - inherited = false - default(true) - } - - value(LightSource::color.name, ValueType.STRING, ValueType.NUMBER) { - inherited = false - widgetType = "color" - default(Colors.white) - } - - value(LightSource::intensity.name, ValueType.NUMBER) { - inherited = false - default(1.0) - } - - node(Solid.POSITION_KEY) { - hide() - } - } - } - } -} - -@Serializable -@SerialName("solid.light.ambient") -public class AmbientLightSource : LightSource() - -@VisionBuilder -public fun MutableVisionContainer.ambientLight( - name: String? = "@ambientLight", - block: AmbientLightSource.() -> Unit = {}, -): AmbientLightSource = AmbientLightSource().apply(block).also { setChild(name, it) } - -@Serializable -@SerialName("solid.light.point") -public class PointLightSource : LightSource() - - -@VisionBuilder -public fun MutableVisionContainer.pointLight( - x: Number, - y: Number, - z: Number, - name: String? = null, - block: PointLightSource.() -> Unit = {}, -): PointLightSource = PointLightSource().apply(block).also { - it.position = Float32Vector3D(x, y, z) - setChild(name, it) -} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/MiscSolid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/MiscSolid.kt deleted file mode 100644 index f83f6cb9..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/MiscSolid.kt +++ /dev/null @@ -1,26 +0,0 @@ -package space.kscience.visionforge.solid - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild - -public abstract class MiscSolid: SolidBase() - -@Serializable -@SerialName("solid.axes") -public class AxesSolid(public val size: Double): MiscSolid(){ - public companion object{ - public const val AXES_NAME: String = "@xes" - } -} - -@VisionBuilder -public fun MutableVisionContainer.axes( - size: Number, - name: String = "@axes", - block: AxesSolid.() -> Unit = {}, -): AxesSolid = AxesSolid(size.toDouble()).apply(block).also { - setChild(name, it) -} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/PolyLine.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/PolyLine.kt index 1681f44a..d8aa937c 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/PolyLine.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/PolyLine.kt @@ -2,27 +2,31 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.dataforge.meta.number -import space.kscience.visionforge.MutableVisionContainer +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.asName +import space.kscience.dataforge.names.plus import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.root -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.numberProperty +import space.kscience.visionforge.set @Serializable @SerialName("solid.line") -public class PolyLine(public val points: List) : SolidBase() { +public class PolyLine(public val points: List) : SolidBase(), Solid { //var lineType by string() - public var thickness: Number by properties.root(inherit = false, includeStyles = true).number { DEFAULT_THICKNESS } + public var thickness: Number by numberProperty(name = SolidMaterial.MATERIAL_KEY + THICKNESS_KEY) { 1.0 } + public companion object { - public const val DEFAULT_THICKNESS: Double = 1.0 + public val THICKNESS_KEY: Name = "thickness".asName() } + } @VisionBuilder -public fun MutableVisionContainer.polyline( - vararg points: Float32Vector3D, +public fun VisionContainerBuilder.polyline( + vararg points: Point3D, name: String? = null, action: PolyLine.() -> Unit = {}, -): PolyLine = PolyLine(points.toList()).apply(action).also { setChild(name, it) } \ No newline at end of file +): PolyLine = PolyLine(points.toList()).apply(action).also { set(name, it) } \ No newline at end of file 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 8b719b54..39ed06ac 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,16 +1,11 @@ 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.descriptors.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus -import space.kscience.kmath.complex.Quaternion -import space.kscience.kmath.complex.QuaternionField -import space.kscience.kmath.geometry.* +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 @@ -35,7 +30,7 @@ import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty /** - * Interface for a [Vision] representing a 3D object + * Interface for 3-dimensional [Vision] */ public interface Solid : Vision { @@ -116,35 +111,44 @@ public interface Solid : Vision { * Get the layer number this solid belongs to. Return 0 if layer is not defined. */ public var Solid.layer: Int - get() = properties.getValue(LAYER_KEY, inherit = true)?.int ?: 0 + get() = getPropertyValue(LAYER_KEY, inherit = true)?.int ?: 0 set(value) { - properties[LAYER_KEY] = value + setProperty(LAYER_KEY, value) } // Common properties +public enum class RotationOrder { + XYZ, + YZX, + ZXY, + XZY, + YXZ, + ZYX +} + /** * Rotation order */ public var Solid.rotationOrder: RotationOrder - get() = properties.getValue(Solid.ROTATION_ORDER_KEY)?.enum() ?: RotationOrder.XYZ - set(value) = properties.setValue(Solid.ROTATION_ORDER_KEY, value.name.asValue()) + get() = getPropertyValue(Solid.ROTATION_ORDER_KEY)?.enum() ?: RotationOrder.XYZ + set(value) = meta.setValue(Solid.ROTATION_ORDER_KEY, value.name.asValue()) /** * Preferred number of polygons for displaying the object. If not defined, uses shape or renderer default. Not inherited */ public var Solid.detail: Int? - get() = properties.getValue(DETAIL_KEY, inherit = false)?.int - set(value) = properties.setValue(DETAIL_KEY, value?.asValue()) + get() = getPropertyValue(DETAIL_KEY, false)?.int + set(value) = meta.setValue(DETAIL_KEY, value?.asValue()) /** * If this property is true, the object will be ignored on render. * Property is not inherited. */ public var Vision.ignore: Boolean? - get() = properties.getValue(IGNORE_KEY, inherit = false, includeStyles = false)?.boolean - set(value) = properties.setValue(IGNORE_KEY, value?.asValue()) + get() = getPropertyValue(IGNORE_KEY, false)?.boolean + set(value) = meta.setValue(IGNORE_KEY, value?.asValue()) //var VisualObject.selected: Boolean? // get() = getProperty(SELECTED_KEY).boolean @@ -153,47 +157,39 @@ public var Vision.ignore: Boolean? internal fun float(name: Name, default: Number): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Solid, property: KProperty<*>): Number { - return thisRef.properties.getValue(name)?.number ?: default + return thisRef.meta.getMeta(name)?.number ?: default } override fun setValue(thisRef: Solid, property: KProperty<*>, value: Number) { - thisRef.properties.setValue(name, value.asValue()) + thisRef.setProperty(name, value) } } -internal fun point( - name: Name, - defaultX: Float, - defaultY: Float = defaultX, - defaultZ: Float = defaultX, -): ReadWriteProperty = - object : ReadWriteProperty { - override fun getValue(thisRef: Solid, property: KProperty<*>): Float32Vector3D? { - val item = thisRef.properties.own?.get(name) ?: return null - //using dynamic property accessor because values could change - return object : Float32Vector3D { - override val x: Float get() = item[X_KEY]?.float ?: defaultX - override val y: Float get() = item[Y_KEY]?.float ?: defaultY - override val z: Float get() = item[Z_KEY]?.float ?: defaultZ - - override fun toString(): String = item.toString() +internal fun point(name: Name, default: Float): ReadWriteProperty = + object : ReadWriteProperty { + override fun getValue(thisRef: Solid, property: KProperty<*>): Point3D? { + val item = thisRef.meta.getMeta(name) ?: return null + return object : Point3D { + override val x: Float get() = item[X_KEY]?.float ?: default + override val y: Float get() = item[Y_KEY]?.float ?: default + override val z: Float get() = item[Z_KEY]?.float ?: default } } - override fun setValue(thisRef: Solid, property: KProperty<*>, value: Float32Vector3D?) { + override fun setValue(thisRef: Solid, property: KProperty<*>, value: Point3D?) { if (value == null) { - thisRef.properties.setProperty(name, null) + thisRef.meta.setMeta(name, null) } else { - thisRef.properties[name + X_KEY] = value.x - thisRef.properties[name + Y_KEY] = value.y - thisRef.properties[name + Z_KEY] = value.z + thisRef.setProperty(name + X_KEY, value.x) + thisRef.setProperty(name + Y_KEY, value.y) + thisRef.setProperty(name + Z_KEY, value.z) } } } -public var Solid.position: Float32Vector3D? by point(POSITION_KEY, 0f) -public var Solid.rotation: Float32Vector3D? by point(ROTATION_KEY, 0f) -public var Solid.scale: Float32Vector3D? by point(SCALE_KEY, 1f) +public var Solid.position: Point3D? by point(POSITION_KEY, 0f) +public var Solid.rotation: Point3D? by point(ROTATION_KEY, 0f) +public var Solid.scale: Point3D? by point(SCALE_KEY, 1f) public var Solid.x: Number by float(X_POSITION_KEY, 0f) public var Solid.y: Number by float(Y_POSITION_KEY, 0f) @@ -203,49 +199,6 @@ public var Solid.rotationX: Number by float(X_ROTATION_KEY, 0f) public var Solid.rotationY: Number by float(Y_ROTATION_KEY, 0f) public var Solid.rotationZ: Number by float(Z_ROTATION_KEY, 0f) -/** - * Raw quaternion value defined in properties - */ -public var Solid.quaternionValue: Quaternion? - get() = properties.getValue(ROTATION_KEY)?.list?.let { - require(it.size == 4) { "Quaternion must be a number array of 4 elements" } - Quaternion(it[0].float, it[1].float, it[2].float, it[3].float) - } - set(value) { - properties.setValue( - ROTATION_KEY, - value?.let { - ListValue( - value.w, - value.x, - value.y, - value.z - ) - } - ) - } - -/** - * Quaternion value including information from euler angles - */ -public var Solid.quaternion: Quaternion - get() = quaternionValue ?: Quaternion.fromEuler( - rotationX.radians, - rotationY.radians, - rotationZ.radians, - rotationOrder - ) - set(value) { - quaternionValue = value - } - public var Solid.scaleX: Number by float(X_SCALE_KEY, 1f) public var Solid.scaleY: Number by float(Y_SCALE_KEY, 1f) -public var Solid.scaleZ: Number by float(Z_SCALE_KEY, 1f) - -/** - * Add rotation with given [angle] relative to given [axis] - */ -public fun Solid.rotate(angle: Angle, axis: DoubleVector3D): Unit = with(QuaternionField) { - quaternion = Quaternion.fromRotation(angle, axis)*quaternion -} \ No newline at end of file +public var Solid.scaleZ: Number by float(Z_SCALE_KEY, 1f) \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidBase.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidBase.kt index 7aef3f82..021079d3 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidBase.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidBase.kt @@ -2,11 +2,15 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.visionforge.AbstractVision +import space.kscience.visionforge.VisionBase @Serializable @SerialName("solid") -public open class SolidBase : AbstractVision(), Solid { +public open class SolidBase : VisionBase(), Solid { + //FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix + override var properties: MutableMeta? = null + override val descriptor: MetaDescriptor get() = Solid.descriptor } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidGroup.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidGroup.kt index d36057d3..3f49df5e 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidGroup.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidGroup.kt @@ -2,25 +2,21 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken -import space.kscience.dataforge.names.parseAsName -import space.kscience.visionforge.AbstractVisionGroup -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.MutableVisionGroup -import space.kscience.visionforge.VisionBuilder - +import space.kscience.visionforge.* /** * A container with prototype support */ public interface PrototypeHolder { /** - * Build or update the prototype tree + * Build or update prototype tree */ @VisionBuilder - public fun prototypes(builder: MutableVisionContainer.() -> Unit) + public fun prototypes(builder: VisionContainerBuilder.() -> Unit) /** * Resolve a prototype from this container. Should never return a ref. @@ -28,30 +24,23 @@ public interface PrototypeHolder { public fun getPrototype(name: Name): Solid? } - /** - * A [Solid] group with additional accessor methods + * Represents 3-dimensional Visual Group + * @param prototypes is a container for templates visible inside this group */ @Serializable @SerialName("group.solid") -public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, MutableVisionGroup, - MutableVisionContainer { +public class SolidGroup : VisionGroupBase(), Solid, PrototypeHolder { - public val items: Map - get() = children.keys.mapNotNull { - val value = children[it] as? Solid ?: return@mapNotNull null - it to value - }.toMap() + //FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix + override var properties: MutableMeta? = null - /** - * Get a child solid with given relative [name] if it exists - */ - public operator fun get(name: Name): Solid? = children.getChild(name) as? Solid + override val children: Map get() = super.childrenInternal.filter { it.key != PROTOTYPES_TOKEN } - private var prototypes: SolidGroup? - get() = items[PROTOTYPES_TOKEN] as? SolidGroup + private var prototypes: MutableVisionGroup? + get() = childrenInternal[PROTOTYPES_TOKEN] as? MutableVisionGroup set(value) { - children[PROTOTYPES_TOKEN] = value + set(PROTOTYPES_TOKEN, value) } @@ -59,27 +48,25 @@ public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, Mutable /** * Get a prototype redirecting the request to the parent if prototype is not found. - * If a prototype is a ref, then it is unfolded automatically. + * If prototype is a ref, then it is unfolded automatically. */ override fun getPrototype(name: Name): Solid? = - prototypes?.get(name)?.prototype ?: (parent as? PrototypeHolder)?.getPrototype(name) + prototypes?.get(name)?.unref ?: (parent as? PrototypeHolder)?.getPrototype(name) /** * Create or edit prototype node as a group */ - override fun prototypes(builder: MutableVisionContainer.() -> Unit): Unit { - (prototypes ?: SolidGroup().also { prototypes = it }).children.run(builder) + override fun prototypes(builder: VisionContainerBuilder.() -> Unit): Unit { + (prototypes ?: SolidGroup().also { + prototypes = it + }).run(builder) } override fun createGroup(): SolidGroup = SolidGroup() -// -// override fun update(change: VisionChange) { -// updatePosition(change.properties) -// super.update(change) -// } - override fun setChild(name: Name?, child: Solid?) { - children.setChild(name, child) + override fun update(change: VisionChange) { + updatePosition(change.properties) + super.update(change) } public companion object { @@ -87,25 +74,20 @@ public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, Mutable } } -public operator fun SolidGroup.get(name:String): Solid? = get(name.parseAsName()) +@Suppress("FunctionName") +public fun SolidGroup(block: SolidGroup.() -> Unit): SolidGroup { + return SolidGroup().apply(block) +} @VisionBuilder -public inline fun MutableVisionContainer.solidGroup( +public fun VisionContainerBuilder.group( name: Name? = null, - builder: SolidGroup.() -> Unit = {}, -): SolidGroup = SolidGroup().also { setChild(name, it) }.apply(builder) -//root first, update later + action: SolidGroup.() -> Unit = {}, +): SolidGroup = SolidGroup().apply(action).also { set(name, it) } /** * Define a group with given [name], attach it to this parent and return it. */ @VisionBuilder -public inline fun MutableVisionContainer.solidGroup( - name: String, - action: SolidGroup.() -> Unit = {}, -): SolidGroup = solidGroup(name.parseAsName(), action) - -/** - * Create a [SolidGroup] using given configuration [block] - */ -public inline fun SolidGroup(block: SolidGroup.() -> Unit): SolidGroup = SolidGroup().apply(block) \ No newline at end of file +public fun VisionContainerBuilder.group(name: String, action: SolidGroup.() -> Unit = {}): SolidGroup = + SolidGroup().apply(action).also { set(name, it) } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidLabel.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidLabel.kt index 2e59c1f8..3e725d0d 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidLabel.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidLabel.kt @@ -2,9 +2,9 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set @Serializable @SerialName("solid.label") @@ -12,13 +12,13 @@ public class SolidLabel( public val text: String, public val fontSize: Double, public val fontFamily: String, -) : SolidBase() +) : SolidBase(), Solid @VisionBuilder -public fun MutableVisionContainer.label( +public fun VisionContainerBuilder.label( text: String, fontSize: Number = 20, fontFamily: String = "Arial", name: String? = null, action: SolidLabel.() -> Unit = {}, -): SolidLabel = SolidLabel(text, fontSize.toDouble(), fontFamily).apply(action).also { setChild(name, it) } \ No newline at end of file +): SolidLabel = SolidLabel(text, fontSize.toDouble(), fontFamily).apply(action).also { set(name, it) } \ No newline at end of file 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 df720e6c..fa5b0d76 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,10 +3,12 @@ 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.visionforge.* import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_KEY @@ -25,7 +27,7 @@ public class SolidMaterial : Scheme() { */ public val specularColor: ColorAccessor = ColorAccessor(meta, SPECULAR_COLOR_KEY) - public val emissiveColor: ColorAccessor = ColorAccessor(meta, EMISSIVE_COLOR_KEY) + public val emissiveColor: ColorAccessor = ColorAccessor(meta, "emissiveColor".asName()) /** * Opacity @@ -41,33 +43,19 @@ public class SolidMaterial : Scheme() { public val MATERIAL_KEY: Name = "material".asName() public val COLOR_KEY: Name = "color".asName() - public val TYPE_KEY: Name = "type".asName() + public val MATERIAL_COLOR_KEY: Name = MATERIAL_KEY + COLOR_KEY public val SPECULAR_COLOR_KEY: Name = "specularColor".asName() - public val EMISSIVE_COLOR_KEY: Name = "emissiveColor".asName() + public val MATERIAL_SPECULAR_COLOR_KEY: Name = MATERIAL_KEY + SPECULAR_COLOR_KEY public val OPACITY_KEY: Name = "opacity".asName() public val MATERIAL_OPACITY_KEY: Name = MATERIAL_KEY + OPACITY_KEY public val WIREFRAME_KEY: Name = "wireframe".asName() - public val MATERIAL_COLOR_KEY: Name = MATERIAL_KEY + COLOR_KEY - public val MATERIAL_EMISSIVE_COLOR_KEY: Name = MATERIAL_KEY + EMISSIVE_COLOR_KEY - public val MATERIAL_SPECULAR_COLOR_KEY: Name = MATERIAL_KEY + SPECULAR_COLOR_KEY public val MATERIAL_WIREFRAME_KEY: Name = MATERIAL_KEY + WIREFRAME_KEY - public val EDGES_KEY: Name = "edges".asName() - public val ENABLED_KEY: Name = "enabled".asName() - public val EDGES_ENABLED_KEY: Name = EDGES_KEY + ENABLED_KEY - public val EDGES_MATERIAL_KEY: Name = EDGES_KEY + MATERIAL_KEY - public override val descriptor: MetaDescriptor by lazy { //must be lazy to avoid initialization bug MetaDescriptor { inherited = true - value(TYPE_KEY, ValueType.STRING){ - inherited = true - allowedValues = listOf("default".asValue(), "simple".asValue()) - default("default") - } - value(COLOR_KEY, ValueType.STRING, ValueType.NUMBER) { inherited = true widgetType = "color" @@ -79,12 +67,6 @@ public class SolidMaterial : Scheme() { hide() } - value(EMISSIVE_COLOR_KEY, ValueType.STRING, ValueType.NUMBER) { - inherited = true - widgetType = "color" - hide() - } - value(OPACITY_KEY, ValueType.NUMBER) { inherited = true default(1.0) @@ -104,26 +86,19 @@ public class SolidMaterial : Scheme() { } public val Solid.color: ColorAccessor - get() = ColorAccessor(properties.root(true), MATERIAL_COLOR_KEY) + get() = ColorAccessor(computePropertyValues(), MATERIAL_COLOR_KEY) public var Solid.material: SolidMaterial? - get() = SolidMaterial.read(properties.getProperty(MATERIAL_KEY)) - set(value) = properties.setProperty(MATERIAL_KEY, value?.meta) + get() = computePropertyNode(MATERIAL_KEY)?.let { SolidMaterial.read(it) } + set(value) = meta.setMeta(MATERIAL_KEY, value?.meta) @VisionBuilder public fun Solid.material(builder: SolidMaterial.() -> Unit) { - properties.getProperty(MATERIAL_KEY).updateWith(SolidMaterial, builder) + meta.getOrCreate(MATERIAL_KEY).updateWith(SolidMaterial, builder) } public var Solid.opacity: Number? - get() = properties.getValue(MATERIAL_OPACITY_KEY, inherit = true)?.number + get() = getPropertyValue(MATERIAL_OPACITY_KEY, inherit = true)?.number set(value) { - properties.setValue(MATERIAL_OPACITY_KEY, value?.asValue()) - } - - -@VisionBuilder -public fun Solid.edges(enabled: Boolean = true, block: SolidMaterial.() -> Unit = {}) { - properties[SolidMaterial.EDGES_ENABLED_KEY] = enabled - SolidMaterial.write(properties.getProperty(SolidMaterial.EDGES_MATERIAL_KEY)).apply(block) -} \ No newline at end of file + meta.setValue(MATERIAL_OPACITY_KEY, value?.asValue()) + } \ 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 2770a7aa..d2080924 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 @@ -1,348 +1,178 @@ package space.kscience.visionforge.solid -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.emptyFlow -import kotlinx.coroutines.flow.filter -import kotlinx.coroutines.launch import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient -import space.kscience.dataforge.meta.* +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.get +import space.kscience.dataforge.meta.get 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 + + +public interface SolidReference : VisionGroup { + /** + * The prototype for this reference. + */ + public val prototype: Solid + + override fun getPropertyValue( + name: Name, + inherit: Boolean, + includeStyles: Boolean, + includeDefaults: Boolean + ): Value? { + meta[name]?.value?.let { return it } + if (includeStyles) { + getStyleProperty(name)?.let { return it } + } + prototype.getPropertyValue(name, inherit, includeStyles, includeDefaults)?.let { return it } + if (inherit) { + parent?.getPropertyValue(name, inherit, includeStyles, includeDefaults)?.let { return it } + } + return null + } +} /** * Get a vision prototype if it is a [SolidReference] or vision itself if it is not. * Unref is recursive, so it always returns a non-reference. */ -public val Vision.prototype: Solid +public val Vision.unref: Solid get() = when (this) { - is SolidReference -> prototype.prototype - is SolidReferenceChild -> prototype.prototype + is SolidReference -> prototype.unref is Solid -> this else -> error("This Vision is neither Solid nor SolidReference") } +private fun childToken(childName: Name): NameToken = + NameToken(SolidReferenceGroup.REFERENCE_CHILD_PROPERTY_PREFIX, childName.toString()) + +private fun childPropertyName(childName: Name, propertyName: Name): Name = + childToken(childName) + propertyName + +/** + * A reference [Solid] to reuse a template object + */ @Serializable @SerialName("solid.ref") -public class SolidReference( - @SerialName("prototype") public val prototypeName: Name, -) : VisionGroup, Solid { +public class SolidReferenceGroup( + public val refName: Name, +) : VisionBase(), SolidReference, VisionGroup, Solid { - @Transient - override var parent: Vision? = null + override var properties: MutableMeta? = null /** - * The prototype for this reference. + * Recursively search for defined template in the parent */ - public val prototype: Solid by lazy { - //Recursively search for defined template in the parent - if (parent == null) error("No parent is present for SolidReference") + override val prototype: Solid by lazy { + if (parent == null) error("No parent is present for SolidReferenceGroup") if (parent !is PrototypeHolder) error("Parent does not hold prototypes") - (parent as? PrototypeHolder)?.getPrototype(prototypeName) - ?: error("Prototype with name $prototypeName not found") + (parent as? PrototypeHolder)?.getPrototype(refName) ?: error("Prototype with name $refName not found") } + + override val children: Map + get() = (prototype as? VisionGroup)?.children + ?.filter { it.key != SolidGroup.PROTOTYPES_TOKEN } + ?.mapValues { + ReferenceChild(this, it.key.asName()) + } ?: emptyMap() + + override fun getPropertyValue( + name: Name, + inherit: Boolean, + includeStyles: Boolean, + includeDefaults: Boolean + ): Value? = super.getPropertyValue(name, inherit, includeStyles, includeDefaults) + override val descriptor: MetaDescriptor get() = prototype.descriptor - @SerialName("properties") - private var propertiesInternal: MutableMeta? = null - override val properties: MutableVisionProperties by lazy { - object : AbstractVisionProperties(this) { - override var properties: MutableMeta? - get() = propertiesInternal - set(value) { - propertiesInternal = value - } + /** + * A ProxyChild is created temporarily only to interact with properties, it does not store any values + * (properties are stored in external cache) and created and destroyed on-demand). + */ + private class ReferenceChild( + val owner: SolidReferenceGroup, + private val refName: Name + ) : SolidReference, VisionGroup, Solid { - override fun getValue(name: Name, inherit: Boolean?, includeStyles: Boolean?): Value? { - if (name == Vision.STYLE_KEY) { - return buildList { - properties?.getValue(Vision.STYLE_KEY)?.list?.forEach { - add(it) - } - prototype.styles.forEach { - add(it.asValue()) - } - }.distinct().asValue() - } - //1. resolve own properties - properties?.getValue(name)?.let { return it } - - val descriptor = descriptor?.get(name) - val inheritFlag = inherit ?: descriptor?.inherited ?: false - val stylesFlag = includeStyles ?: descriptor?.usesStyles ?: true - - //2. Resolve prototype onw properties - prototype.properties.own?.getValue(name)?.let { return it } - - if (stylesFlag) { - //3. own styles - own?.getValue(Vision.STYLE_KEY)?.list?.forEach { styleName -> - getStyle(styleName.string)?.getValue(name)?.let { return it } - } - //4. prototype styles - prototype.getStyleProperty(name)?.value?.let { return it } - } - - if (inheritFlag) { - //5. own inheritance - parent?.properties?.getValue(name, inheritFlag, includeStyles)?.let { return it } - //6. prototype inheritance - prototype.parent?.properties?.getValue(name, inheritFlag, includeStyles)?.let { return it } - } - - return descriptor?.defaultValue - } - - - override fun invalidate(propertyName: Name) { - //send update signal - @OptIn(DelicateCoroutinesApi::class) - (manager?.context ?: GlobalScope).launch { - changesInternal.emit(propertyName) - } - - // update styles - if (propertyName == Vision.STYLE_KEY) { - styles.asSequence() - .mapNotNull { getStyle(it) } - .flatMap { it.items.asSequence() } - .distinctBy { it.key } - .forEach { - invalidate(it.key.asName()) - } - } + override val prototype: Solid by lazy { + if (refName.isEmpty()) { + owner.prototype + } else { + val proto = (owner.prototype as? VisionGroup)?.get(refName) + ?: error("Prototype with name $refName not found in SolidReferenceGroup ${owner.refName}") + proto as? Solid ?: error("Prototype with name $refName is ${proto::class} but expected Solid") +// proto.unref as? Solid +// ?: error("Prototype with name $refName is ${proto::class} but expected Solid") } } + + override val meta: ObservableMutableMeta by lazy { + owner.meta.getOrCreate(childToken(refName).asName()) + } + + override val children: Map + get() = (prototype as? VisionGroup)?.children + ?.filter { it.key != SolidGroup.PROTOTYPES_TOKEN } + ?.mapValues { (key, _) -> + ReferenceChild(owner, refName + key.asName()) + } ?: emptyMap() + + override var parent: VisionGroup? + get() { + val parentName = refName.cutLast() + return if (parentName.isEmpty()) owner else ReferenceChild(owner, parentName) + } + set(_) { + error("Setting a parent for a reference child is not possible") + } + + override fun invalidateProperty(propertyName: Name) { + owner.invalidateProperty(childPropertyName(refName, propertyName)) + } + + override fun update(change: VisionChange) { + change.properties?.let { + updateProperties(Name.EMPTY, it) + } + } + + override val descriptor: MetaDescriptor get() = prototype.descriptor + } - override val children: VisionChildren - get() = object : VisionChildren { - override val parent: Vision get() = this@SolidReference - - override val keys: Set get() = prototype.children?.keys ?: emptySet() - - override val changes: Flow get() = emptyFlow() - - override fun get(token: NameToken): SolidReferenceChild? { - if (token !in (prototype.children?.keys ?: emptySet())) return null - return SolidReferenceChild(this@SolidReference, this@SolidReference, token.asName()) - } - } - public companion object { public const val REFERENCE_CHILD_PROPERTY_PREFIX: String = "@child" } } -/** - * @param childName A name of reference child relative to prototype root - */ -internal class SolidReferenceChild( - val owner: SolidReference, - override var parent: Vision?, - val childName: Name, -) : Solid, VisionGroup { - - val prototype: Solid - get() = owner.prototype.children?.getChild(childName) as? Solid - ?: error("Prototype with name $childName not found") - - override val descriptor: MetaDescriptor get() = prototype.descriptor - - @Transient - override val properties: MutableVisionProperties = object : MutableVisionProperties { - override val descriptor: MetaDescriptor get() = this@SolidReferenceChild.descriptor - - override val own: MutableMeta by lazy { owner.properties.getProperty(childToken(childName).asName()) } - - override fun getValue( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): Value? = own.getValue(name) ?: prototype.properties.getValue(name, inherit, includeStyles) - - override fun setProperty(name: Name, node: Meta?, notify: Boolean) { - own.setMeta(name, node) - } - - override fun setValue(name: Name, value: Value?, notify: Boolean) { - own.setValue(name, value) - } - - override val changes: Flow get() = owner.properties.changes.filter { it.startsWith(childToken(childName)) } - - override fun invalidate(propertyName: Name) { - owner.properties.invalidate(childPropertyName(childName, propertyName)) - } - } - - override fun update(change: VisionChange) { - change.children?.forEach { (name, change) -> - when { - change.vision == NullVision -> error("Deleting children inside ref is not allowed.") - change.vision != null -> error("Updating content of the ref is not allowed") - else -> children.getChild(name)?.update(change) - } - } - change.properties?.let { - updateProperties(it, Name.EMPTY) - } - } - - - override val children: VisionChildren = object : VisionChildren { - override val parent: Vision get() = this@SolidReferenceChild - - override val keys: Set get() = prototype.children?.keys ?: emptySet() - - override val changes: Flow get() = emptyFlow() - - override fun get(token: NameToken): SolidReferenceChild? { - if (token !in (prototype.children?.keys ?: emptySet())) return null - return SolidReferenceChild(this@SolidReferenceChild.owner, this@SolidReferenceChild, childName + token) - } - } - - companion object { - - private fun childToken(childName: Name): NameToken = - NameToken(REFERENCE_CHILD_PROPERTY_PREFIX, childName.toString()) - - private fun childPropertyName(childName: Name, propertyName: Name): Name = - childToken(childName) + propertyName - - } -} - /** * Create ref for existing prototype */ -public fun MutableVisionContainer.ref( +public fun SolidGroup.ref( templateName: Name, - name: Name? = null, -): SolidReference = SolidReference(templateName).also { setChild(name, it) } - -public fun MutableVisionContainer.ref( - templateName: Name, - name: String, -): SolidReference = ref(templateName, name.parseAsName()) + name: String? = null, +): SolidReferenceGroup = SolidReferenceGroup(templateName).also { set(name, it) } /** - * Add new [SolidReference] wrapping given object and automatically adding it to the prototypes. + * Add new [SolidReferenceGroup] wrapping given object and automatically adding it to the prototypes */ -public fun SolidGroup.newRef( - name: String?, +public fun SolidGroup.ref( + name: String, obj: Solid, - prototypeHolder: SolidGroup = this, - prototypeName: Name = Name.parse(name ?: obj.toString()), -): SolidReference { - val existing = prototypeHolder.getPrototype(prototypeName) + templateName: Name = Name.parse(name), +): SolidReferenceGroup { + val existing = getPrototype(templateName) if (existing == null) { - prototypeHolder.prototypes { - setChild(prototypeName, obj) + prototypes { + this[templateName] = obj } } else if (existing != obj) { error("Can't add different prototype on top of existing one") } - return children.ref(prototypeName, name?.parseAsName()) + return this@ref.ref(templateName, name) } - - -// -// -///** -// * A reference [Solid] to reuse a template object -// */ -//@Serializable -//@SerialName("solid.ref") -//public class SolidReferenceGroup( -// public val refName: Name, -//) : VisionGroup(), SolidReference, VisionGroup, Solid { -// -// /** -// * Recursively search for defined template in the parent -// */ -// override val prototype: Solid by lazy { -// if (parent == null) error("No parent is present for SolidReferenceGroup") -// if (parent !is PrototypeHolder) error("Parent does not hold prototypes") -// (parent as? PrototypeHolder)?.getPrototype(refName) ?: error("Prototype with name $refName not found") -// } -// -// override val items: Map> -// get() = (prototype as? VisionGroup<*>)?.items -// ?.filter { it.key != SolidGroup.PROTOTYPES_TOKEN } -// ?.mapValues { -// VisionGroupItem.Node(ReferenceChild(this, it.key.asName())) -// } ?: emptyMap() -// -// override val descriptor: MetaDescriptor get() = prototype.descriptor -// -// -// /** -// * A ProxyChild is created temporarily only to interact with properties, it does not store any values -// * (properties are stored in external cache) and created and destroyed on-demand). -// */ -// private class ReferenceChild( -// val owner: SolidReferenceGroup, -// private val refName: Name, -// ) : SolidReference, VisionGroup, Solid { -// -// override val prototype: Solid by lazy { -// if (refName.isEmpty()) { -// owner.prototype -// } else { -// val proto = (owner.prototype).children.get(refName) -// ?: error("Prototype with name $refName not found in SolidReferenceGroup ${owner.refName}") -// proto as? Solid ?: error("Prototype with name $refName is ${proto::class} but expected Solid") -//// proto.unref as? Solid -//// ?: error("Prototype with name $refName is ${proto::class} but expected Solid") -// } -// } -// -// override val meta: ObservableMutableMeta by lazy { -// owner.meta.getOrCreate(childToken(refName).asName()) -// } -// -// override val items: Map> -// get() = (prototype as? VisionGroup<*>)?.items -// ?.filter { it.key != SolidGroup.PROTOTYPES_TOKEN } -// ?.mapValues { (key, _) -> -// VisionGroupItem.Node(ReferenceChild(owner, refName + key.asName())) -// } ?: emptyMap() -// -// override var parent: VisionGroup<*>? -// get() { -// val parentName = refName.cutLast() -// return if (parentName.isEmpty()) owner else ReferenceChild(owner, parentName) -// } -// set(_) { -// error("Setting a parent for a reference child is not possible") -// } -// -// override fun invalidateProperty(propertyName: Name) { -// owner.invalidateProperty(childPropertyName(refName, propertyName)) -// } -// -// override fun update(change: VisionChange) { -// change.properties?.let { -// updateProperties(it, Name.EMPTY) -// } -// } -// -// override val descriptor: MetaDescriptor get() = prototype.descriptor -// -// } -// -// public companion object { -// public const val REFERENCE_CHILD_PROPERTY_PREFIX: String = "@child" -// } -//} diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt index 1477c2a0..ca83f00f 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt @@ -6,34 +6,28 @@ import kotlinx.serialization.modules.PolymorphicModuleBuilder import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.polymorphic import kotlinx.serialization.modules.subclass -import kotlinx.serialization.serializer import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.names.Name +import space.kscience.dataforge.misc.DFExperimental import space.kscience.visionforge.* import space.kscience.visionforge.html.VisionOutput -import space.kscience.visionforge.solid.specifications.Canvas3DOptions +import kotlin.reflect.KClass -public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer { +public class Solids(meta: Meta) : VisionPlugin(meta) { override val tag: PluginTag get() = Companion.tag - override val visionSerializersModule: SerializersModule get() = serializersModuleForSolids - override fun setChild(name: Name?, child: Solid?) { - child?.setAsRoot(visionManager) - } - public companion object : PluginFactory { override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): Solids = Solids(meta) + override val type: KClass = Solids::class + override fun invoke(meta: Meta, context: Context): Solids = Solids(meta) private fun PolymorphicModuleBuilder.solids() { subclass(SolidGroup.serializer()) - subclass(SolidReference.serializer()) + subclass(SolidReferenceGroup.serializer()) subclass(Composite.serializer()) subclass(Box.serializer()) subclass(GenericHexagon.serializer()) @@ -44,23 +38,17 @@ public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer()) } + default { SolidBase.serializer() } solids() } } @@ -75,26 +63,10 @@ public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer Unit): SolidGroup { - requirePlugin(Solids) - options?.let { - meta = options.meta - } - return SolidGroup().apply(block).apply { - if (children.values.none { it is LightSource }) { - ambientLight() - } - } -} - -@VisionBuilder -public inline fun VisionOutput.solid(options: Canvas3DOptions.() -> Unit, block: SolidGroup.() -> Unit): SolidGroup = - solid(Canvas3DOptions(options), block) +@DFExperimental +public inline fun VisionOutput.solid(block: SolidGroup.() -> Unit): SolidGroup = + SolidGroup().apply(block) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Sphere.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Sphere.kt index 224e8bba..bae8d83d 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Sphere.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Sphere.kt @@ -2,9 +2,10 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.VisionPropertyContainer +import space.kscience.visionforge.set import kotlin.math.PI import kotlin.math.cos import kotlin.math.sin @@ -16,16 +17,16 @@ public class Sphere( public val phiStart: Float = 0f, public val phi: Float = PI2, public val thetaStart: Float = 0f, - public val theta: Float = PI.toFloat(), -) : SolidBase(), GeometrySolid { + public val theta: Float = PI .toFloat(), +) : SolidBase(), GeometrySolid, VisionPropertyContainer { override fun toGeometry(geometryBuilder: GeometryBuilder) { - fun point3dFromSphCoord(r: Float, theta: Float, phi: Float): Float32Vector3D { + fun point3DfromSphCoord(r: Float, theta: Float, phi: Float): Point3D { // This transformation matches three.js sphere implementation val y = r * cos(theta) val z = r * sin(theta) * sin(phi) val x = -r * sin(theta) * cos(phi) - return Float32Vector3D(x, y, z) + return Point3D(x, y, z) } val segments = this.detail ?: 32 @@ -38,10 +39,10 @@ public class Sphere( for (j in 0 until segments) { // phi iteration val phi1 = phiStart + j * phiStep val phi2 = phi1 + phiStep - val point1 = point3dFromSphCoord(radius, theta1, phi1) - val point2 = point3dFromSphCoord(radius, theta1, phi2) - val point3 = point3dFromSphCoord(radius, theta2, phi2) - val point4 = point3dFromSphCoord(radius, theta2, phi1) + val point1 = point3DfromSphCoord(radius, theta1, phi1) + val point2 = point3DfromSphCoord(radius, theta1, phi2) + val point3 = point3DfromSphCoord(radius, theta2, phi2) + val point4 = point3DfromSphCoord(radius, theta2, phi1) geometryBuilder.apply { // 1-2-3-4 gives the same face but with opposite orientation face4(point1, point4, point3, point2) @@ -52,10 +53,10 @@ public class Sphere( } @VisionBuilder -public inline fun MutableVisionContainer.sphere( +public inline fun VisionContainerBuilder.sphere( radius: Number, name: String? = null, action: Sphere.() -> Unit = {}, ): Sphere = Sphere( radius.toFloat(), -).apply(action).also { setChild(name, it) } \ No newline at end of file +).apply(action).also { set(name, it) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SphereLayer.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SphereLayer.kt index fa025df2..05149e2e 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SphereLayer.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SphereLayer.kt @@ -2,9 +2,9 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild +import space.kscience.visionforge.VisionContainerBuilder +import space.kscience.visionforge.set import kotlin.math.PI import kotlin.math.cos import kotlin.math.sin @@ -21,18 +21,18 @@ public class SphereLayer( public val phi: Float = PI2, public val thetaStart: Float = 0f, public val theta: Float = PI.toFloat(), -) : SolidBase(), GeometrySolid { +) : SolidBase(), GeometrySolid { override fun toGeometry(geometryBuilder: GeometryBuilder): Unit = geometryBuilder.run { require(outerRadius > 0) { "Outer radius must be positive" } require(innerRadius >= 0) { "inner radius must be non-negative" } - fun point3dFromSphCoord(r: Float, theta: Float, phi: Float): Float32Vector3D { + fun point3DfromSphCoord(r: Float, theta: Float, phi: Float): Point3D { // This transformation matches three.js sphere implementation val y = r * cos(theta) val z = r * sin(theta) * sin(phi) val x = -r * sin(theta) * cos(phi) - return Float32Vector3D(x, y, z) + return Point3D(x, y, z) } val segments = detail ?: 32 @@ -46,17 +46,17 @@ public class SphereLayer( val phi1 = phiStart + j * phiStep val phi2 = phi1 + phiStep //outer points - val outerPoint1 = point3dFromSphCoord(outerRadius, theta1, phi1) - val outerPoint2 = point3dFromSphCoord(outerRadius, theta1, phi2) - val outerPoint3 = point3dFromSphCoord(outerRadius, theta2, phi2) - val outerPoint4 = point3dFromSphCoord(outerRadius, theta2, phi1) + val outerPoint1 = point3DfromSphCoord(outerRadius, theta1, phi1) + val outerPoint2 = point3DfromSphCoord(outerRadius, theta1, phi2) + val outerPoint3 = point3DfromSphCoord(outerRadius, theta2, phi2) + val outerPoint4 = point3DfromSphCoord(outerRadius, theta2, phi1) // 1-2-3-4 gives the same face but with opposite orientation face4(outerPoint1, outerPoint4, outerPoint3, outerPoint2) if (innerRadius > 0) { - val innerPoint1 = point3dFromSphCoord(innerRadius, theta1, phi1) - val innerPoint2 = point3dFromSphCoord(innerRadius, theta1, phi2) - val innerPoint3 = point3dFromSphCoord(innerRadius, theta2, phi2) - val innerPoint4 = point3dFromSphCoord(innerRadius, theta2, phi1) + val innerPoint1 = point3DfromSphCoord(innerRadius, theta1, phi1) + val innerPoint2 = point3DfromSphCoord(innerRadius, theta1, phi2) + val innerPoint3 = point3DfromSphCoord(innerRadius, theta2, phi2) + val innerPoint4 = point3DfromSphCoord(innerRadius, theta2, phi1) face4(innerPoint1, innerPoint2, innerPoint3, innerPoint4) //the cup if (i == segments - 1 && theta != PI.toFloat() && innerRadius != outerRadius) { @@ -69,7 +69,7 @@ public class SphereLayer( } @VisionBuilder -public inline fun MutableVisionContainer.sphereLayer( +public inline fun VisionContainerBuilder.sphereLayer( outerRadius: Number, innerRadius: Number, phiStart: Number = 0f, @@ -85,4 +85,4 @@ public inline fun MutableVisionContainer.sphereLayer( phi.toFloat(), thetaStart.toFloat(), theta.toFloat() -).apply(action).also { setChild(name, it) } \ No newline at end of file +).apply(action).also { set(name, it) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/StlSolid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/StlSolid.kt deleted file mode 100644 index b9d9d835..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/StlSolid.kt +++ /dev/null @@ -1,25 +0,0 @@ -package space.kscience.visionforge.solid - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import space.kscience.visionforge.MutableVisionContainer -import space.kscience.visionforge.VisionBuilder -import space.kscience.visionforge.setChild - - -public sealed class StlSolid: SolidBase() - -@Serializable -@SerialName("solid.stl.url") -public class StlUrlSolid(public val url: String) : StlSolid() - -@Serializable -@SerialName("solid.stl.binary") -public class StlBinarySolid(public val data: ByteArray) : StlSolid() - -@VisionBuilder -public inline fun MutableVisionContainer.stl( - url: String, - name: String? = null, - action: StlSolid.() -> Unit = {}, -): StlSolid = StlUrlSolid(url).apply(action).also { setChild(name, it) } \ No newline at end of file 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..31611dc9 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 @@ -1,62 +1,121 @@ package space.kscience.visionforge.solid -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MetaProvider -import space.kscience.dataforge.meta.float -import space.kscience.dataforge.meta.get +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import space.kscience.dataforge.meta.* import space.kscience.visionforge.solid.Solid.Companion.X_KEY import space.kscience.visionforge.solid.Solid.Companion.Y_KEY import space.kscience.visionforge.solid.Solid.Companion.Z_KEY import kotlin.math.PI +import kotlin.math.pow +import kotlin.math.sqrt public const val PI2: Float = 2 * PI.toFloat() -public fun Float32Vector2D.toMeta(): Meta = Meta { +@Serializable +public data class Point2D(public var x: Float, public var y: Float) + +public fun Point2D(x: Number, y: Number): Point2D = Point2D(x.toFloat(), y.toFloat()) + +public fun Point2D.toMeta(): Meta = Meta { X_KEY put x Y_KEY put y } -internal fun Meta.toVector2D(): Float32Vector2D = - Float32Vector2D(this["x"].float ?: 0f, this["y"].float ?: 0f) +internal fun Meta.point2D(): Point2D = Point2D(this["x"].float ?: 0f, this["y"].float ?: 0f) -//@Suppress("SERIALIZER_TYPE_INCOMPATIBLE") -//@Serializable(Point3DSerializer::class) -//public interface MutablePoint3D : Float32Vector3D { -// override var x: Float -// override var y: Float -// override var z: Float -//} -// -// -//public fun MutablePoint3D.normalizeInPlace() { -// val norm = sqrt(x.pow(2) + y.pow(2) + z.pow(2)) -// x /= norm -// y /= norm -// z /= norm -//} +@Serializable(Point3DSerializer::class) +public interface Point3D { + public val x: Float + public val y: Float + public val z: Float -internal fun MetaProvider.point3D(default: Float = 0f) = Float32Euclidean3DSpace.vector( - getMeta(X_KEY).float ?: default, - getMeta(Y_KEY).float ?: default, - getMeta(Z_KEY).float ?: default + public companion object { + public val ZERO: Point3D = Point3D(0.0, 0.0, 0.0) + public val ONE: Point3D = Point3D(1.0, 1.0, 1.0) + } +} + +@Serializable(Point3DSerializer::class) +public interface MutablePoint3D : Point3D { + override var x: Float + override var y: Float + override var z: Float +} + +@Serializable +private class Point3DImpl(override var x: Float, override var y: Float, override var z: Float) : MutablePoint3D + +internal object Point3DSerializer : KSerializer { + + override val descriptor: SerialDescriptor = Point3DImpl.serializer().descriptor + + + override fun deserialize(decoder: Decoder): Point3D = decoder.decodeSerializableValue(Point3DImpl.serializer()) + + override fun serialize(encoder: Encoder, value: Point3D) { + val impl: Point3DImpl = (value as? Point3DImpl) ?: Point3DImpl(value.x, value.y, value.z) + encoder.encodeSerializableValue(Point3DImpl.serializer(), impl) + } +} + +public fun Point3D(x: Number, y: Number, z: Number): Point3D = Point3DImpl(x.toFloat(), y.toFloat(), z.toFloat()) + +public operator fun Point3D.plus(other: Point3D): Point3D = Point3D( + this.x + other.x, + this.y + other.y, + this.z + other.z ) +public operator fun Point3D.minus(other: Point3D): Point3D = Point3D( + this.x - other.x, + this.y - other.y, + this.z - other.z +) -public fun Float32Vector3D.toMeta(): Meta = Meta { +public operator fun Point3D.unaryMinus(): Point3D = Point3D( + -x, + -y, + -z +) + +public infix fun Point3D.cross(other: Point3D): Point3D = Point3D( + y * other.z - z * other.y, + z * other.x - x * other.z, + x * other.y - y * other.x +) + +public fun MutablePoint3D.normalizeInPlace() { + val norm = sqrt(x.pow(2) + y.pow(2) + z.pow(2)) + x /= norm + y /= norm + z /= norm +} + +internal fun MetaProvider.point3D(default: Float = 0f) = object : Point3D { + override val x: Float by float(default) + override val y: Float by float(default) + override val z: Float by float(default) +} + +public fun Point3D.toMeta(): Meta = Meta { X_KEY put x Y_KEY put y Z_KEY put z } -internal fun Meta.toVector3D(default: Float = 0f) = Float32Vector3D( - this[X_KEY].float ?: default, - this[Y_KEY].float ?: default, - this[Z_KEY].float ?: default +internal fun Meta.toVector(default: Float = 0f) = Point3D( + this[Solid.X_KEY].float ?: default, + this[Solid.Y_KEY].float ?: default, + this[Solid.Z_KEY].float ?: default ) -//internal fun Solid.updatePosition(meta: Meta?) { -// meta?.get(Solid.POSITION_KEY)?.toVector()?.let { position = it } -// meta?.get(Solid.ROTATION_KEY)?.toVector()?.let { rotation = it } -// meta?.get(Solid.SCALE_KEY)?.toVector(1f)?.let { scale = it } -//} \ No newline at end of file +internal fun Solid.updatePosition(meta: Meta?) { + meta?.get(Solid.POSITION_KEY)?.toVector()?.let { position = it } + meta?.get(Solid.ROTATION_KEY)?.toVector()?.let { rotation = it } + meta?.get(Solid.SCALE_KEY)?.toVector(1f)?.let { scale = it } +} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/AxesScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Axes.kt similarity index 74% rename from visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/AxesScheme.kt rename to visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Axes.kt index 0ed9126e..485cc8bd 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/AxesScheme.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Axes.kt @@ -7,26 +7,24 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.value import space.kscience.dataforge.meta.double -@Deprecated("Use separate axes object instead") -public class AxesScheme : Scheme() { +public class Axes : Scheme() { public var visible: Boolean by boolean(false) public var size: Double by double(AXIS_SIZE) public var width: Double by double(AXIS_WIDTH) - @Suppress("DEPRECATION") - public companion object : SchemeSpec(::AxesScheme) { + public companion object : SchemeSpec(::Axes) { public const val AXIS_SIZE: Double = 1000.0 public const val AXIS_WIDTH: Double = 3.0 override val descriptor: MetaDescriptor by lazy { MetaDescriptor { - value(AxesScheme::visible){ + value(Axes::visible){ default(false) } - value(AxesScheme::size){ + value(Axes::size){ default(AXIS_SIZE) } - value(AxesScheme::width){ + value(Axes::width){ default(AXIS_WIDTH) } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/CameraScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Camera.kt similarity index 77% rename from visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/CameraScheme.kt rename to visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Camera.kt index f884bc1e..b8cb05d4 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/CameraScheme.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Camera.kt @@ -8,7 +8,7 @@ import space.kscience.dataforge.meta.double import space.kscience.dataforge.meta.int import kotlin.math.PI -public class CameraScheme : Scheme() { +public class Camera : Scheme() { public var fov: Int by int(FIELD_OF_VIEW) //var aspect by double(1.0) @@ -19,7 +19,7 @@ public class CameraScheme : Scheme() { public var azimuth: Double by double(INITIAL_AZIMUTH) public var latitude: Double by double(INITIAL_LATITUDE) - public companion object : SchemeSpec(::CameraScheme) { + public companion object : SchemeSpec(::Camera) { public const val INITIAL_DISTANCE: Double = 300.0 public const val INITIAL_AZIMUTH: Double = 0.0 public const val INITIAL_LATITUDE: Double = PI / 6 @@ -29,22 +29,22 @@ public class CameraScheme : Scheme() { override val descriptor: MetaDescriptor by lazy { MetaDescriptor { - value(CameraScheme::fov) { + value(Camera::fov) { default(FIELD_OF_VIEW) } - value(CameraScheme::nearClip) { + value(Camera::nearClip) { default(NEAR_CLIP) } - value(CameraScheme::farClip) { + value(Camera::farClip) { default(FAR_CLIP) } - value(CameraScheme::distance) { + value(Camera::distance) { default(INITIAL_DISTANCE) } - value(CameraScheme::azimuth) { + value(Camera::azimuth) { default(INITIAL_AZIMUTH) } - value(CameraScheme::latitude) { + value(Camera::latitude) { default(INITIAL_LATITUDE) } } @@ -52,4 +52,4 @@ public class CameraScheme : Scheme() { } } -public val CameraScheme.zenith: Double get() = PI / 2 - latitude \ No newline at end of file +public val Camera.zenith: Double get() = PI / 2 - latitude \ No newline at end of file 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 b24c9b75..4a819ff7 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,39 +4,42 @@ 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.visionforge.hide import space.kscience.visionforge.widgetType +public class Clipping : Scheme() { + public var x: Double? by double() + public var y: Double? by double() + public var z: Double? by double() -public object Clipping : SchemeSpec(::PointScheme) { - override val descriptor: MetaDescriptor = MetaDescriptor { - value(PointScheme::x) { - widgetType = "range" - attributes["min"] = 0.0 - attributes["max"] = 1.0 - attributes["step"] = 0.01 - default(1.0) - } - value(PointScheme::y) { - widgetType = "range" - attributes["min"] = 0.0 - attributes["max"] = 1.0 - attributes["step"] = 0.01 - default(1.0) - } - value(PointScheme::z) { - widgetType = "range" - attributes["min"] = 0.0 - attributes["max"] = 1.0 - attributes["step"] = 0.01 - default(1.0) + public companion object : SchemeSpec(::Clipping) { + override val descriptor: MetaDescriptor = MetaDescriptor { + value(Clipping::x) { + widgetType = "range" + attributes["min"] = 0.0 + attributes["max"] = 1.0 + attributes["step"] = 0.01 + default(1.0) + } + value(Clipping::y) { + widgetType = "range" + attributes["min"] = 0.0 + attributes["max"] = 1.0 + attributes["step"] = 0.01 + default(1.0) + } + value(Clipping::z) { + widgetType = "range" + attributes["min"] = 0.0 + attributes["max"] = 1.0 + attributes["step"] = 0.01 + default(1.0) + } } } } - public class CanvasSize : Scheme() { public var minSize: Int by int(400) public var minWith: Number by number { minSize } @@ -59,16 +62,16 @@ public class CanvasSize : Scheme() { } public class Canvas3DOptions : Scheme() { - @Suppress("DEPRECATION") - public var axes: AxesScheme by spec(AxesScheme) - public var camera: CameraScheme by spec(CameraScheme) - public var controls: ControlsScheme by spec(ControlsScheme) + public var axes: Axes by spec(Axes) + public var light: Light by spec(Light) + public var camera: Camera by spec(Camera) + public var controls: Controls by spec(Controls) public var size: CanvasSize by spec(CanvasSize) public var layers: List by numberList(0) - public var clipping: PointScheme by spec(Clipping) + public var clipping: Clipping by spec(Clipping) public var onSelect: ((Name?) -> Unit)? = null @@ -76,8 +79,7 @@ public class Canvas3DOptions : Scheme() { public companion object : SchemeSpec(::Canvas3DOptions) { override val descriptor: MetaDescriptor by lazy { MetaDescriptor { - @Suppress("DEPRECATION") - scheme(Canvas3DOptions::axes, AxesScheme) + scheme(Canvas3DOptions::axes, Axes) value(Canvas3DOptions::layers) { multiple = true @@ -88,11 +90,15 @@ public class Canvas3DOptions : Scheme() { scheme(Canvas3DOptions::clipping, Clipping) - scheme(Canvas3DOptions::camera, CameraScheme) { + scheme(Canvas3DOptions::light, Light){ hide() } - scheme(Canvas3DOptions::controls, ControlsScheme) { + scheme(Canvas3DOptions::camera, Camera) { + hide() + } + + scheme(Canvas3DOptions::controls, Controls) { hide() } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/ControlsScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Controls.kt similarity index 56% rename from visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/ControlsScheme.kt rename to visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Controls.kt index 5e68f37c..ee8ebb9d 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/ControlsScheme.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Controls.kt @@ -4,6 +4,6 @@ import space.kscience.dataforge.meta.Scheme import space.kscience.dataforge.meta.SchemeSpec -public class ControlsScheme : Scheme() { - public companion object : SchemeSpec(::ControlsScheme) +public class Controls : Scheme() { + public companion object : SchemeSpec(::Controls) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Light.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Light.kt new file mode 100644 index 00000000..39b79466 --- /dev/null +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Light.kt @@ -0,0 +1,8 @@ +package space.kscience.visionforge.solid.specifications + +import space.kscience.dataforge.meta.Scheme +import space.kscience.dataforge.meta.SchemeSpec + +public class Light : Scheme() { + public companion object : SchemeSpec(::Light) +} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/PointScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/PointScheme.kt deleted file mode 100644 index 33b8c180..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/PointScheme.kt +++ /dev/null @@ -1,19 +0,0 @@ -package space.kscience.visionforge.solid.specifications - -import space.kscience.dataforge.meta.Scheme -import space.kscience.dataforge.meta.SchemeSpec -import space.kscience.dataforge.meta.double - -public class PointScheme: Scheme(){ - public var x: Double? by double() - public var y: Double? by double() - public var z: Double? by double() - - public companion object: SchemeSpec(::PointScheme) -} - -public operator fun PointScheme.invoke(x: Number?, y: Number?, z: Number?){ - this.x = x?.toDouble() - this.y = y?.toDouble() - this.z = z?.toDouble() -} \ No newline at end of file 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 d2667e76..39aadbf1 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 @@ -1,25 +1,31 @@ package space.kscience.visionforge.solid.transform +import space.kscience.dataforge.meta.configure +import space.kscience.dataforge.meta.update import space.kscience.dataforge.misc.DFExperimental -import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.kmath.complex.QuaternionField -import space.kscience.visionforge.root +import space.kscience.visionforge.* import space.kscience.visionforge.solid.* private operator fun Number.plus(other: Number) = toFloat() + other.toFloat() private operator fun Number.times(other: Number) = toFloat() * other.toFloat() @DFExperimental -internal fun Solid.updateFrom(other: Solid): Solid { - x += other.x - y += other.y - z += other.y - quaternion = with(QuaternionField) { other.quaternion * quaternion } - scaleX *= other.scaleX - scaleY *= other.scaleY - scaleZ *= other.scaleZ - properties.setProperty(Name.EMPTY, other.properties.root()) +internal fun Vision.updateFrom(other: Vision): Vision { + if (this is Solid && other is Solid) { + x += other.x + y += other.y + z += other.y + rotationX += other.rotationX + rotationY += other.rotationY + rotationZ += other.rotationZ + scaleX *= other.scaleX + scaleY *= other.scaleY + scaleZ *= other.scaleZ + configure{ + update(other.meta) + } + } return this } @@ -28,17 +34,17 @@ internal fun Solid.updateFrom(other: Solid): Solid { internal object RemoveSingleChild : VisualTreeTransform() { override fun SolidGroup.transformInPlace() { - fun SolidGroup.replaceChildren() { - items.forEach { (childName, parent) -> - if (parent is SolidReference) return@forEach //ignore refs - if (parent is SolidGroup) { + fun MutableVisionGroup.replaceChildren() { + children.forEach { (childName, parent) -> + if (parent is SolidReferenceGroup) return@forEach //ignore refs + if (parent is MutableVisionGroup) { parent.replaceChildren() } - if (parent is SolidGroup && parent.items.size == 1) { - val child: Solid = parent.items.values.first() + if (parent is VisionGroup && parent.children.size == 1) { + val child = parent.children.values.first() val newParent = child.updateFrom(parent) newParent.parent = null - children.setChild(childName.asName(), newParent) + set(childName.asName(), newParent) } } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/UnRef.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/UnRef.kt index 72fa1a76..890c8291 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/UnRef.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/UnRef.kt @@ -2,41 +2,41 @@ package space.kscience.visionforge.solid.transform import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.asName +import space.kscience.visionforge.MutableVisionGroup +import space.kscience.visionforge.VisionGroup import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.SolidReference -import kotlin.collections.component1 -import kotlin.collections.component2 -import kotlin.collections.set +import space.kscience.visionforge.solid.SolidReferenceGroup @DFExperimental internal object UnRef : VisualTreeTransform() { - private fun SolidGroup.countRefs(): Map { - return items.values.fold(HashMap()) { reducer, vision -> - if (vision is SolidGroup) { - val counter = vision.countRefs() + private fun VisionGroup.countRefs(): Map { + return children.values.fold(HashMap()) { reducer, obj -> + if (obj is VisionGroup) { + val counter = obj.countRefs() counter.forEach { (key, value) -> reducer[key] = (reducer[key] ?: 0) + value } - } else if (vision is SolidReference) { - reducer[vision.prototypeName] = (reducer[vision.prototypeName] ?: 0) + 1 + } else if (obj is SolidReferenceGroup) { + reducer[obj.refName] = (reducer[obj.refName] ?: 0) + 1 } return reducer } } - private fun SolidGroup.unref(name: Name) { + private fun MutableVisionGroup.unref(name: Name) { (this as? SolidGroup)?.prototypes{ - setChild(name, null) + set(name, null) } - items.filter { (it.value as? SolidReference)?.prototypeName == name }.forEach { (key, value) -> - val reference = value as SolidReference + children.filter { (it.value as? SolidReferenceGroup)?.refName == name }.forEach { (key, value) -> + val reference = value as SolidReferenceGroup val newChild = reference.prototype.updateFrom(reference) newChild.parent = null - children[key] = newChild // replace proxy with merged object + set(key.asName(), newChild) // replace proxy with merged object } - items.values.filterIsInstance().forEach { it.unref(name) } + children.values.filterIsInstance().forEach { it.unref(name) } } override fun SolidGroup.transformInPlace() { diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/CompositeTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/CompositeTest.kt index a7c1c688..411aa75b 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/CompositeTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/CompositeTest.kt @@ -8,7 +8,7 @@ class CompositeTest { @Test fun testCompositeBuilder(){ lateinit var composite: Composite - testSolids.solidGroup { + SolidGroup { composite = composite(CompositeType.INTERSECT) { y = 300 box(100, 100, 100) { diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/ConvexTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/ConvexTest.kt index 8d838f6b..a7133006 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/ConvexTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/ConvexTest.kt @@ -1,14 +1,18 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.meta.getIndexed +import space.kscience.dataforge.meta.node import space.kscience.dataforge.meta.toMeta +import space.kscience.dataforge.misc.DFExperimental import kotlin.test.Test import kotlin.test.assertEquals class ConvexTest { + @OptIn(DFExperimental::class) + @Suppress("UNUSED_VARIABLE") @Test fun testConvexBuilder() { - val group = testSolids.solidGroup { + val group = SolidGroup().apply { convex { point(50, 50, -50) point(50, -50, -50) @@ -21,7 +25,7 @@ class ConvexTest { } } - val convex = group.items.values.first() as Convex + val convex = group.children.values.first() as Convex val json = Solids.jsonForSolids.encodeToJsonElement(Convex.serializer(), convex) val meta = json.toMeta() 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 87527802..6f004f5c 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/GroupTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/GroupTest.kt index 78e2f03c..4e78e340 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/GroupTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/GroupTest.kt @@ -1,7 +1,7 @@ package space.kscience.visionforge.solid import space.kscience.visionforge.Colors -import space.kscience.visionforge.getChild +import space.kscience.visionforge.get import kotlin.math.PI import kotlin.test.Test import kotlin.test.assertEquals @@ -9,7 +9,7 @@ import kotlin.test.assertEquals class GroupTest { @Test fun testGroupWithComposite() { - val group = testSolids.solidGroup{ + val group = SolidGroup().apply { union("union") { box(100, 100, 100) { z = 100 @@ -44,8 +44,8 @@ class GroupTest { } } - assertEquals(3, group.items.count()) - assertEquals(300.0, (group.children.getChild("intersect") as Solid).y.toDouble()) - assertEquals(-300.0, (group.children.getChild("subtract") as Solid).y.toDouble()) + assertEquals(3, group.children.count()) + assertEquals(300.0, (group["intersect"] as Solid).y.toDouble()) + assertEquals(-300.0, (group["subtract"] as Solid).y.toDouble()) } } \ No newline at end of file diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt similarity index 54% rename from visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt rename to visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt index 87ba368c..ec58e4d2 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/PropertyTest.kt @@ -1,81 +1,72 @@ package space.kscience.visionforge.solid -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.delay -import kotlinx.coroutines.test.runTest -import space.kscience.dataforge.meta.int +import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.asName +import space.kscience.dataforge.values.int import space.kscience.visionforge.* import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.time.Duration.Companion.milliseconds -@OptIn(ExperimentalCoroutinesApi::class) @Suppress("UNUSED_VARIABLE") -class SolidPropertyTest { +class PropertyTest { @Test - fun testColor() { - val box = Box(10.0f, 10.0f, 10.0f) + fun testColor(){ + val box = Box(10.0f, 10.0f,10.0f) box.material { //meta["color"] = "pink" color("pink") } - assertEquals("pink", box.properties.getValue("material.color")?.string) + assertEquals("pink", box.meta["material.color"]?.string) assertEquals("pink", box.color.string) } @Test - fun testColorUpdate() = runTest(timeout = 200.milliseconds) { - val box = Box(10.0f, 10.0f, 10.0f) + fun testColorUpdate(){ + val box = Box(10.0f, 10.0f,10.0f) - val c = CompletableDeferred() - - - val subscription = box.onPropertyChange(this) { key -> - if (key == SolidMaterial.MATERIAL_COLOR_KEY) { - c.complete(box.color.string) + var c: String? = null + box.onPropertyChange { + if(it == SolidMaterial.MATERIAL_COLOR_KEY){ + c = box.color.string } } - delay(5) box.material { color("pink") } - assertEquals("pink", c.await()) - subscription.cancel() + assertEquals("pink", c) } @Test fun testInheritedProperty() { var box: Box? = null val group = SolidGroup().apply { - properties["test"] = 22 - solidGroup { + setPropertyNode("test", 22) + group { box = box(100, 100, 100) } } - assertEquals(22, box?.properties?.getValue("test", inherit = true)?.int) + assertEquals(22, box?.getPropertyValue("test", inherit = true)?.int) } @Test fun testStyleProperty() { var box: Box? = null - val group = testSolids.solidGroup { + val group = SolidGroup().apply { styleSheet { - update("testStyle") { + set("testStyle") { "test" put 22 } } - solidGroup { - box = box(100, 100, 100) { + group { + box = box(100, 100, 100).apply { useStyle("testStyle") } } } - assertEquals(22, box?.properties?.getValue("test")?.int) + assertEquals(22, box?.getPropertyValue("test")?.int) } @Test @@ -83,11 +74,11 @@ class SolidPropertyTest { var box: Box? = null val group = SolidGroup().apply { styleSheet { - update("testStyle") { + set("testStyle") { SolidMaterial.MATERIAL_COLOR_KEY put "#555555" } } - solidGroup { + group { box = box(100, 100, 100) { useStyle("testStyle") } @@ -98,10 +89,10 @@ class SolidPropertyTest { @Test fun testReferenceStyleProperty() { - var box: SolidReference? = null - val group = testSolids.solidGroup { + var box: SolidReferenceGroup? = null + val group = SolidGroup{ styleSheet { - update("testStyle") { + set("testStyle") { SolidMaterial.MATERIAL_COLOR_KEY put "#555555" } } @@ -110,10 +101,10 @@ class SolidPropertyTest { styles = listOf("testStyle") } } - solidGroup { + group { box = ref("box".asName()) } } - assertEquals("#555555", box!!.color.string) + assertEquals("#555555", box?.color.string) } } \ No newline at end of file diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SerializationTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SerializationTest.kt index e3069647..8f5c3f57 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SerializationTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SerializationTest.kt @@ -1,8 +1,8 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Colors -import space.kscience.visionforge.getChild +import space.kscience.visionforge.MutableVisionGroup +import space.kscience.visionforge.get import kotlin.test.Test import kotlin.test.assertEquals @@ -13,10 +13,10 @@ import kotlin.test.assertEquals fun SolidGroup.refGroup( name: String, templateName: Name = Name.parse(name), - block: SolidGroup.() -> Unit -): SolidReference { + block: MutableVisionGroup.() -> Unit +): SolidReferenceGroup { val group = SolidGroup().apply(block) - return newRef(name, group, prototypeName = templateName) + return ref(name, group, templateName) } @@ -31,7 +31,7 @@ class SerializationTest { val string = Solids.encodeToString(cube) println(string) val newCube = Solids.decodeFromString(string) - assertEquals(cube.properties.own, newCube.properties.own) + assertEquals(cube.meta, newCube.meta) } @Test @@ -41,8 +41,8 @@ class SerializationTest { x = 100 z = -100 } - val group = testSolids.solidGroup { - newRef("cube", cube) + val group = SolidGroup { + ref("cube", cube) refGroup("pg", Name.parse("pg.content")) { sphere(50) { x = -100 @@ -52,21 +52,7 @@ class SerializationTest { val string = Solids.encodeToString(group) println(string) val reconstructed = Solids.decodeFromString(string) as SolidGroup - assertEquals(group.children.getChild("cube")?.properties?.own, reconstructed.children.getChild("cube")?.properties?.own) - } - - @Test - fun lightSerialization(){ - val group = testSolids.solidGroup { - ambientLight { - color(Colors.white) - intensity = 100.0 - } - } - val serialized = Solids.encodeToString(group) - - val reconstructed = Solids.decodeFromString(serialized) as SolidGroup - assertEquals(100.0, (reconstructed.children.getChild("@ambientLight") as AmbientLightSource).intensity.toDouble()) + assertEquals(group["cube"]?.meta, reconstructed["cube"]?.meta) } } \ No newline at end of file diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt index ba8dce18..23a48a63 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt @@ -1,16 +1,14 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.request +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.getChild +import space.kscience.visionforge.get import kotlin.test.Test import kotlin.test.assertEquals -internal val testSolids = Global.request(Solids) - class SolidPluginTest { - val vision = testSolids.solidGroup { + val vision = SolidGroup { box(100, 100, 100, name = "aBox") sphere(100, name = "aSphere") { @@ -21,14 +19,11 @@ class SolidPluginTest { @DFExperimental @Test fun testPluginConverter() { - val visionManager = Global.request(Solids).visionManager + val visionManager = Global.fetch(Solids).visionManager val meta = visionManager.encodeToMeta(vision) val reconstructed = visionManager.decodeFromMeta(meta) as SolidGroup - assertEquals( - visionManager.encodeToJsonElement(vision.children.getChild("aBox")!!), - visionManager.encodeToJsonElement(reconstructed.children.getChild("aBox")!!) - ) + assertEquals(visionManager.encodeToJsonElement(vision["aBox"]!!), visionManager.encodeToJsonElement(reconstructed["aBox"]!!)) } } \ No newline at end of file diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidReferenceTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidReferenceTest.kt index d8d971bb..2f8b7781 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidReferenceTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidReferenceTest.kt @@ -2,8 +2,7 @@ package space.kscience.visionforge.solid import kotlinx.serialization.json.encodeToJsonElement import space.kscience.dataforge.misc.DFExperimental -import space.kscience.dataforge.names.get -import space.kscience.visionforge.getChild +import space.kscience.visionforge.get import space.kscience.visionforge.style import space.kscience.visionforge.useStyle import kotlin.test.Test @@ -11,11 +10,11 @@ import kotlin.test.assertEquals @DFExperimental class SolidReferenceTest { - val groupWithReference = testSolids.solidGroup { + val groupWithReference = SolidGroup { val theStyle by style { SolidMaterial.MATERIAL_COLOR_KEY put "red" } - newRef("test", Box(100f,100f,100f).apply { + ref("test", Box(100f,100f,100f).apply { color("blue") useStyle(theStyle) }) @@ -24,14 +23,13 @@ class SolidReferenceTest { @Test fun testReferenceProperty(){ - assertEquals("blue", (groupWithReference.children.getChild("test") as Solid).color.string) + assertEquals("blue", (groupWithReference["test"] as Solid).color.string) } @Test fun testReferenceSerialization(){ val serialized = Solids.jsonForSolids.encodeToJsonElement(groupWithReference) val deserialized = Solids.jsonForSolids.decodeFromJsonElement(SolidGroup.serializer(), serialized) - assertEquals(groupWithReference.items["test"]?.color.string, deserialized.items["test"]?.color.string) - assertEquals("blue", (deserialized.children.getChild("test") as Solid).color.string) + assertEquals("blue", (deserialized["test"] as Solid).color.string) } } \ No newline at end of file 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 0e495aaa..a08085d6 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 @@ -1,48 +1,45 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.request +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.getChild +import space.kscience.visionforge.get import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -internal class VisionUpdateTest { - val solidManager = Global.request(Solids) +class VisionUpdateTest { + val solidManager = Global.fetch(Solids) val visionManager = solidManager.visionManager @Test - fun testVisionUpdate() { - val targetVision = testSolids.solidGroup { - box(200, 200, 200, name = "origin") + fun testVisionUpdate(){ + val targetVision = SolidGroup { + box(200,200,200, name = "origin") } - val dif = visionManager.VisionChange { - solidGroup("top") { + val dif = VisionChange(visionManager){ + group("top") { color(123) - box(100, 100, 100) + box(100,100,100) } propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("origin".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) } targetVision.update(dif) - assertTrue { targetVision.children.getChild("top") is SolidGroup } - assertEquals("red", (targetVision.children.getChild("origin") as Solid).color.string) // Should work - assertEquals( - "#00007b", - (targetVision.children.getChild("top") as Solid).color.string - ) // new item always takes precedence + assertTrue { targetVision["top"] is SolidGroup } + assertEquals("red", (targetVision["origin"] as Solid).color.string) // Should work + assertEquals("#00007b", (targetVision["top"] as Solid).color.string) // new item always takes precedence } @Test - fun testVisionChangeSerialization() { - val change = visionManager.VisionChange { - solidGroup("top") { + fun testVisionChangeSerialization(){ + val change = VisionChange(visionManager){ + group("top") { color(123) - box(100, 100, 100) + box(100,100,100) } propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("origin".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) @@ -50,6 +47,6 @@ internal class VisionUpdateTest { val serialized = visionManager.jsonFormat.encodeToString(VisionChange.serializer(), change) println(serialized) val reconstructed = visionManager.jsonFormat.decodeFromString(VisionChange.serializer(), serialized) - assertEquals(change.properties, reconstructed.properties) + assertEquals(change.properties,reconstructed.properties) } } \ No newline at end of file diff --git a/visionforge-tables/README.md b/visionforge-tables/README.md deleted file mode 100644 index 6cdbd356..00000000 --- a/visionforge-tables/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-tables - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-tables:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-tables:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-tables:0.2.0") -} -``` diff --git a/visionforge-tables/api/visionforge-tables.api b/visionforge-tables/api/visionforge-tables.api deleted file mode 100644 index 3a4af1fb..00000000 --- a/visionforge-tables/api/visionforge-tables.api +++ /dev/null @@ -1,63 +0,0 @@ -public final class space/kscience/visionforge/tables/ColumnHeaderScheme : space/kscience/dataforge/meta/Scheme, space/kscience/tables/ColumnHeader { - public static final field Companion Lspace/kscience/visionforge/tables/ColumnHeaderScheme$Companion; - public fun ()V - public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/Meta; - public fun getName ()Ljava/lang/String; - public final fun getProperties ()Lspace/kscience/tables/ValueColumnScheme; - public fun getType ()Lkotlin/reflect/KType; - public fun setName (Ljava/lang/String;)V - public final fun setProperties (Lspace/kscience/tables/ValueColumnScheme;)V -} - -public final class space/kscience/visionforge/tables/ColumnHeaderScheme$Companion : space/kscience/dataforge/meta/SchemeSpec { -} - -public final class space/kscience/visionforge/tables/TablePlugin : space/kscience/visionforge/VisionPlugin { - public static final field Companion Lspace/kscience/visionforge/tables/TablePlugin$Companion; - public fun ()V - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; -} - -public final class space/kscience/visionforge/tables/TablePlugin$Companion : space/kscience/dataforge/context/PluginFactory { - public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/tables/TablePlugin; -} - -public final class space/kscience/visionforge/tables/VisionOfTable : space/kscience/visionforge/VisionBase, space/kscience/tables/Rows { - public static final field Companion Lspace/kscience/visionforge/tables/VisionOfTable$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getData ()Lspace/kscience/dataforge/values/Value; - public fun getHeaders ()Ljava/util/List; - public fun rowSequence ()Lkotlin/sequences/Sequence; - public final fun setData (Lspace/kscience/dataforge/values/Value;)V - public fun setHeaders (Ljava/util/List;)V - public static final fun write$Self (Lspace/kscience/visionforge/tables/VisionOfTable;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/tables/VisionOfTable$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/tables/VisionOfTable$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/tables/VisionOfTable; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/tables/VisionOfTable;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/tables/VisionOfTable$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/tables/VisionOfTableKt { - public static final fun numberTableToVision (Lspace/kscience/tables/Table;)Lspace/kscience/visionforge/tables/VisionOfTable; - public static final fun stringTableToVision (Lspace/kscience/tables/Table;)Lspace/kscience/visionforge/tables/VisionOfTable; - public static final fun table (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/tables/VisionOfTable; - public static final fun toVision (Lspace/kscience/tables/Table;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/tables/VisionOfTable; - public static final fun valueTableToVision (Lspace/kscience/tables/Table;)Lspace/kscience/visionforge/tables/VisionOfTable; -} - diff --git a/visionforge-tables/build.gradle.kts b/visionforge-tables/build.gradle.kts deleted file mode 100644 index cf813e6e..00000000 --- a/visionforge-tables/build.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -val tablesVersion = "0.2.0-dev-4" - -kscience { - jvm() - js { - useCommonJs() - binaries.library() - browser { - commonWebpackConfig { - cssSupport { - enabled.set(true) - } - } - } - } - dependencies { - api(projects.visionforgeCore) - api("space.kscience:tables-kt:${tablesVersion}") - } - dependencies(jsMain) { - implementation(npm("tabulator-tables", "5.4.4")) - implementation(npm("@types/tabulator-tables", "5.4.8")) - } - useSerialization() -} - -readme { - maturity = space.kscience.gradle.Maturity.PROTOTYPE -} \ No newline at end of file diff --git a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt deleted file mode 100644 index d6bc9b1d..00000000 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt +++ /dev/null @@ -1,28 +0,0 @@ -package space.kscience.visionforge.tables - -import kotlinx.serialization.modules.SerializersModule -import kotlinx.serialization.modules.polymorphic -import kotlinx.serialization.modules.subclass -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.PluginFactory -import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.meta.Meta -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionPlugin - -public class TableVisionPlugin : VisionPlugin() { - override val tag: PluginTag get() = Companion.tag - - override val visionSerializersModule: SerializersModule - get() = SerializersModule { - polymorphic(Vision::class) { - subclass(VisionOfTable.serializer()) - } - } - - public companion object : PluginFactory { - override val tag: PluginTag = PluginTag("vision.table", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): TableVisionPlugin = TableVisionPlugin() - } -} \ No newline at end of file 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 deleted file mode 100644 index 3e4f9da8..00000000 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt +++ /dev/null @@ -1,125 +0,0 @@ -package space.kscience.visionforge.tables - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.misc.DFExperimental -import space.kscience.tables.* -import space.kscience.visionforge.AbstractVision -import space.kscience.visionforge.html.VisionOutput -import space.kscience.visionforge.root -import kotlin.jvm.JvmName -import kotlin.reflect.typeOf - -internal object ColumnHeaderSerializer : KSerializer> { - - override val descriptor: SerialDescriptor get() = MetaSerializer.descriptor - - override fun deserialize(decoder: Decoder): ColumnHeader { - val meta = decoder.decodeSerializableValue(MetaSerializer) - return SimpleColumnHeader(meta["name"].string!!, typeOf(), meta["meta"] ?: Meta.EMPTY) - } - - override fun serialize(encoder: Encoder, value: ColumnHeader) { - val meta = Meta { - "name" put value.name - "meta" put value.meta - } - encoder.encodeSerializableValue(MetaSerializer, meta) - } -} - -public val ColumnHeader.properties: ValueColumnScheme get() = ValueColumnScheme.read(meta) - -@Serializable -@SerialName("vision.table") -public class VisionOfTable( - override val headers: List<@Serializable(ColumnHeaderSerializer::class) ColumnHeader>, -) : AbstractVision(), Rows { - - public var data: List - get() = properties.root().getIndexed("rows").entries.sortedBy { - it.key?.toInt() - }.map { - it.value - } - set(value) { - //TODO Make it better - properties.root()["rows"] = value - } - - public val rows: List get() = data.map(::MetaRow) - - override fun rowSequence(): Sequence> = rows.asSequence() -} - -/** - * Convert a table to a serializable vision - */ -@Suppress("UNCHECKED_CAST") -public fun Table.toVision( - converter: (T?) -> Value, -): VisionOfTable = VisionOfTable(headers as TableHeader).also { vision -> - vision.data = rows.map { row -> - if (row is MetaRow) { - row.meta - } else { - Meta { - headers.forEach { - it.name put converter(row[it.name]) - } - } - } - } -} - -@JvmName("valueTableToVision") -public fun Table.toVision(): VisionOfTable = toVision { it ?: Null } - -@JvmName("stringTableToVision") -public fun Table.toVision(): VisionOfTable = toVision { (it ?: "").asValue() } - -@JvmName("numberTableToVision") -public fun Table.toVision(): VisionOfTable = toVision { (it ?: Double.NaN).asValue() } - -@JvmName("anyTableToVision") -public fun Table.toVision(): VisionOfTable = toVision { - (it as? Number)?.asValue() ?: it?.toString()?.asValue() ?: Null -} - -@DFExperimental -public inline fun VisionOutput.table( - vararg headers: ColumnHeader, - block: RowTableBuilder.() -> Unit, -): VisionOfTable { - requirePlugin(TableVisionPlugin) - return RowTable(*headers, block = block).toVision() -} - -@DFExperimental -public inline fun VisionOutput.columnTable( - columnSize: Int, - block: ColumnTableBuilder.() -> Unit, -): VisionOfTable = ColumnTable(columnSize, block).toVision() - -@DFExperimental -public fun VisionOutput.columnTable( - vararg dataAndHeaders: Pair, List>, -): VisionOfTable { - requirePlugin(TableVisionPlugin) - val columns = dataAndHeaders.map { (header, data) -> - ListColumn(header, data.map { Value.of(it) }) - } - return ColumnTable(columns).toVision() -} - -//public val tabulatorCssHader: HtmlFragment = { -// link { -// href = "https://unpkg.com/tabulator-tables@5.0.10/dist/css/tabulator.min.css" -// rel = "stylesheet" -// } -//} \ No newline at end of file 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 deleted file mode 100644 index e1210ffa..00000000 --- a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package space.kscience.visionforge.tables - -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 -import kotlin.math.pow -import kotlin.test.Test -import kotlin.test.assertEquals - -internal class VisionOfTableTest { - @Test - fun tableSerialization() { - val x by ColumnHeader.typed() - val y by ColumnHeader.typed() - - val table = ColumnTable(100) { - x.fill { it.asValue() } - y.values = x.values.map { it?.double?.pow(2)?.asValue() } - } - - val vision = table.toVision() - //println(Json.encodeToString(VisionOfTable.serializer(), table.toVision())) - - val rows = vision.rowSequence().toList() - - assertEquals(50, rows[50][x].int) - } -} \ No newline at end of file diff --git a/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt b/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt deleted file mode 100644 index d61e4664..00000000 --- a/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt +++ /dev/null @@ -1,94 +0,0 @@ -package space.kscience.visionforge.tables - -import js.core.jso -import org.w3c.dom.Element -import org.w3c.dom.HTMLElement -import space.kscience.dataforge.context.AbstractPlugin -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.PluginFactory -import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.toDynamic -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName -import space.kscience.visionforge.ElementVisionRenderer -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionClient -import tabulator.Tabulator -import tabulator.TabulatorFull - -public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { - public val visionClient: VisionClient by require(VisionClient) - public val tablesBase: TableVisionPlugin by require(TableVisionPlugin) - - override val tag: PluginTag get() = Companion.tag - - override fun attach(context: Context) { - super.attach(context) - kotlinext.js.require("tabulator-tables/dist/css/tabulator.min.css") - kotlinext.js.require("tabulator-tables/src/js/modules/ResizeColumns/ResizeColumns.js") - } - - override fun rateVision(vision: Vision): Int = when (vision) { - is VisionOfTable -> ElementVisionRenderer.DEFAULT_RATING - else -> ElementVisionRenderer.ZERO_RATING - } - - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { - val table: VisionOfTable = (vision as? VisionOfTable) - ?: error("VisionOfTable expected but ${vision::class} found") - - val tableOptions = jso { - columns = table.headers.map { header -> - jso { - field = header.name - title = header.properties.title ?: header.name - resizable = true - } - }.toTypedArray() - - columns = Array(table.headers.size + 1) { - if (it == 0) { - jso { - field = "@index" - title = "#" - resizable = false - } - } else { - val header = table.headers[it - 1] - jso { - field = header.name - title = header.properties.title ?: header.name - resizable = true - } - } - } - - - data = table.rows.mapIndexed { index, row -> - val d = row.meta.toDynamic() - d["@index"] = index - d - }.toTypedArray() - - //layout = "fitColumns" - - pagination = true - paginationSize = 10 - paginationSizeSelector = arrayOf(10, 25, 50, 100) - } - - TabulatorFull(element as HTMLElement, tableOptions) - } - - override fun content(target: String): Map = when (target) { - ElementVisionRenderer.TYPE -> mapOf("table".asName() to this) - else -> super.content(target) - } - - public companion object : PluginFactory { - override val tag: PluginTag = PluginTag("vision.table.js", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): TableVisionJsPlugin = TableVisionJsPlugin() - } -} \ No newline at end of file diff --git a/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt b/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt deleted file mode 100644 index f6efd32a..00000000 --- a/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt +++ /dev/null @@ -1,2347 +0,0 @@ -@file:Suppress("INTERFACE_WITH_SUPERCLASS", - "OVERRIDING_FINAL_MEMBER", - "RETURN_TYPE_MISMATCH_ON_OVERRIDE", - "CONFLICTING_OVERLOADS", - "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING") - -@file:JsModule("tabulator-tables") - -package tabulator - -import org.w3c.dom.Element -import org.w3c.dom.HTMLElement -import org.w3c.dom.events.MouseEvent -import org.w3c.dom.events.UIEvent -import tabulator.Tabulator.* -import kotlin.js.Promise - -external interface EventCallBackMethods { - var validationFailed: (cell: CellComponent, value: Any, validators: Array) -> Unit - var scrollHorizontal: (left: Number) -> Unit - var scrollVertical: (top: Number) -> Unit - var rowAdded: (row: RowComponent) -> Unit - var rowDeleted: (row: RowComponent) -> Unit - var rowMoved: (row: RowComponent) -> Unit - var rowUpdated: (row: RowComponent) -> Unit - var rowSelectionChanged: () -> Unit - var rowSelected: (row: RowComponent) -> Unit - var rowDeselected: (row: RowComponent) -> Unit - var rowResized: (row: RowComponent) -> Unit - var rowClick: (event: UIEvent, row: RowComponent) -> Unit - var rowDblClick: (event: UIEvent, row: RowComponent) -> Unit - var rowContext: (event: UIEvent, row: RowComponent) -> Unit - var rowTap: (event: UIEvent, row: RowComponent) -> Unit - var rowDblTap: (event: UIEvent, row: RowComponent) -> Unit - var rowTapHold: (event: UIEvent, row: RowComponent) -> Unit - var rowMouseEnter: (event: UIEvent, row: RowComponent) -> Unit - var rowMouseLeave: (event: UIEvent, row: RowComponent) -> Unit - var rowMouseOver: (event: UIEvent, row: RowComponent) -> Unit - var rowMouseOut: (event: UIEvent, row: RowComponent) -> Unit - var rowMouseMove: (event: UIEvent, row: RowComponent) -> Unit - var htmlImporting: () -> Unit - var htmlImported: () -> Unit - var ajaxError: () -> Unit - var clipboardCopied: (clipboard: String) -> Unit - var clipboardPasted: (clipboard: String, rowData: Array, rows: Array) -> Unit - var clipboardPasteError: (clipboard: String) -> Unit - var downloadComplete: () -> Unit - var dataTreeRowExpanded: (row: RowComponent, level: Number) -> Unit - var dataTreeRowCollapsed: (row: RowComponent, level: Number) -> Unit - var pageLoaded: (pageNo: Number) -> Unit - var headerClick: (event: UIEvent, column: ColumnComponent) -> Unit - var headerDblClick: (event: UIEvent, column: ColumnComponent) -> Unit - var headerContext: (event: UIEvent, column: ColumnComponent) -> Unit - var headerTap: (event: UIEvent, column: ColumnComponent) -> Unit - var headerDblTap: (event: UIEvent, column: ColumnComponent) -> Unit - var headerTapHold: (event: UIEvent, column: ColumnComponent) -> Unit - var groupClick: (event: UIEvent, group: GroupComponent) -> Unit - var groupDblClick: (event: UIEvent, group: GroupComponent) -> Unit - var groupContext: (event: UIEvent, group: GroupComponent) -> Unit - var groupTap: (event: UIEvent, group: GroupComponent) -> Unit - var groupDblTap: (event: UIEvent, group: GroupComponent) -> Unit - var groupTapHold: (event: UIEvent, group: GroupComponent) -> Unit - var tableBuilding: () -> Unit - var tableBuilt: () -> Unit - var dataLoading: (data: Array) -> Unit - var dataLoaded: (data: Array) -> Unit - var dataChanged: (data: Array) -> Unit - var dataFiltering: (filters: Array) -> Unit - var dataFiltered: (filters: Array, rows: Array) -> Unit - var dataSorting: (sorters: Sorter) -> Unit - var dataSorted: (sorters: Sorter, rows: Array) -> Unit - var movableRowsSendingStart: (toTables: Array) -> Unit - var movableRowsSent: (fromRow: RowComponent, toRow: RowComponent, toTable: Tabulator) -> Unit - var movableRowsSentFailed: (fromRow: RowComponent, toRow: RowComponent, toTable: Tabulator) -> Unit - var movableRowsSendingStop: (toTables: Array) -> Unit - var movableRowsReceivingStart: (fromRow: RowComponent, fromTable: Tabulator) -> Unit - var movableRowsReceived: (fromRow: RowComponent, toRow: RowComponent, fromTable: Tabulator) -> Unit - var movableRowsReceivedFailed: (fromRow: RowComponent, toRow: RowComponent, fromTable: Tabulator) -> Unit - var movableRowsReceivingStop: (fromTable: Tabulator) -> Unit - var movableRowsElementDrop: (event: UIEvent, element: Element, row: RowComponent) -> Unit - var dataGrouping: () -> Unit - var dataGrouped: (groups: Array) -> Unit - var groupVisibilityChanged: (group: GroupComponent, visible: Boolean) -> Unit - var localized: (locale: String, lang: Any) -> Unit - var renderStarted: () -> Unit - var renderComplete: () -> Unit - var columnMoved: (column: ColumnComponent, columns: Array) -> Unit - var columnResized: (column: ColumnComponent) -> Unit - var columnTitleChanged: (column: ColumnComponent) -> Unit - var columnVisibilityChanged: (column: ColumnComponent, visible: Boolean) -> Unit - var historyUndo: (action: String /* "cellEdit" | "rowAdd" | "rowDelete" | "rowMoved" */, component: Any, data: Array) -> Unit - var historyRedo: (action: String /* "cellEdit" | "rowAdd" | "rowDelete" | "rowMoved" */, component: Any, data: Array) -> Unit - var cellEditing: (cell: CellComponent) -> Unit - var cellEdited: (cell: CellComponent) -> Unit - var cellEditCancelled: (cell: CellComponent) -> Unit - var cellClick: (event: UIEvent, cell: CellComponent) -> Unit - var cellDblClick: (event: UIEvent, cell: CellComponent) -> Unit - var cellContext: (event: UIEvent, cell: CellComponent) -> Unit - var cellTap: (event: UIEvent, cell: CellComponent) -> Unit - var cellDblTap: (event: UIEvent, cell: CellComponent) -> Unit - var cellTapHold: (event: UIEvent, cell: CellComponent) -> Unit - var cellMouseEnter: (event: UIEvent, cell: CellComponent) -> Unit - var cellMouseLeave: (event: UIEvent, cell: CellComponent) -> Unit - var cellMouseOver: (event: UIEvent, cell: CellComponent) -> Unit - var cellMouseOut: (event: UIEvent, cell: CellComponent) -> Unit - var cellMouseMove: (event: UIEvent, cell: CellComponent) -> Unit - var dataLoadError: (error: Error) -> Unit - var dataProcessing: () -> Unit - var dataProcessed: () -> Unit -} - -external open class Tabulator { - constructor(selector: String, options: Options = definedExternally) - constructor(selector: String) - constructor(selector: HTMLElement, options: Options = definedExternally) - constructor(selector: HTMLElement) - - open var columnManager: Any - open var rowManager: Any - open var footerManager: Any - open var browser: String - open var browserSlow: Boolean - open var modules: Any - open var options: Options - open var element: HTMLElement - open var download: (downloadType: dynamic /* "csv" | "json" | "xlsx" | "pdf" | "html" | (columns: Array, data: Any, options: Any, setFileContents: Any) -> Any */, fileName: String, params: DownloadOptions, filter: String /* "visible" | "active" | "selected" | "all" */) -> Unit - open var downloadToTab: (downloadType: String /* "csv" | "json" | "xlsx" | "pdf" | "html" */, fileName: String, params: DownloadOptions) -> Unit - open var copyToClipboard: (rowRangeLookup: String /* "visible" | "active" | "selected" | "all" */) -> Unit - open var undo: () -> Boolean - open var getHistoryUndoSize: () -> dynamic - open var redo: () -> Boolean - open var getHistoryRedoSize: () -> dynamic - open var getEditedCells: () -> Array - open var clearCellEdited: (clear: dynamic /* Tabulator.CellComponent | Array */) -> Unit - open var destroy: () -> Unit - open var setDataFromLocalFile: (extensions: String) -> Unit - open var setData: (data: Any, params: Any, config: Any) -> Promise - open var clearData: () -> Unit - open var getData: (activeOnly: String /* "visible" | "active" | "selected" | "all" */) -> Array - open var getDataCount: (activeOnly: String /* "visible" | "active" | "selected" | "all" */) -> Number - open var searchRows: (field: String, type: String /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" */, value: Any) -> Array - open var searchData: (field: String, type: String /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" */, value: Any) -> Array - open var getHtml: (rowRangeLookup: String /* "visible" | "active" | "selected" | "all" */, style: Boolean, config: AddditionalExportOptions) -> Any - open var print: (rowRangeLookup: String /* "visible" | "active" | "selected" | "all" */, style: Boolean, config: AddditionalExportOptions) -> Any - open var getAjaxUrl: () -> String - open var replaceData: (data: dynamic /* Array | String */, params: Any, config: Any) -> Promise - open var updateData: (data: Array) -> Promise - open var addData: (data: Array, addToTop: Boolean, positionTarget: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */) -> Promise - open var updateOrAddData: (data: Array) -> Promise> - open var getRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */) -> RowComponent - open var getRowFromPosition: (position: Number, activeOnly: Boolean) -> RowComponent - open var deleteRow: (index: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array | Array | Array */> */) -> Unit - open var addRow: (data: Any, addToTop: Boolean, positionTarget: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */) -> Promise - open var updateOrAddRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */, data: Any) -> Promise - open var updateRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */, data: Any) -> Boolean - open var scrollToRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */, position: String /* "top" | "center" | "bottom" | "nearest" */, ifVisible: Boolean) -> Promise - open var moveRow: (fromRow: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */, toRow: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */, placeAboveTarget: Boolean) -> Unit - open var getRows: (activeOnly: String /* "visible" | "active" | "selected" | "all" */) -> Array - open var getRowPosition: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */, activeOnly: Boolean) -> Number - open var setColumns: (definitions: Array) -> Unit - open var getColumns: (includeColumnGroups: Boolean) -> Array - open var getColumn: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> ColumnComponent - open var getColumnDefinitions: () -> Array - open var getColumnLayout: () -> Array - open var setColumnLayout: (layout: ColumnLayout) -> Unit - open var showColumn: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> Unit - open var hideColumn: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> Unit - open var toggleColumn: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> Unit - open var addColumn: (definition: ColumnDefinition, insertRightOfTarget: Boolean, positionTarget: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> Promise - open var deleteColumn: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> Promise - open var moveColumn: (fromColumn: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */, toColumn: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */, after: Boolean) -> Unit - open var scrollToColumn: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */, position: String /* "left" | "center" | "middle" | "right" */, ifVisible: Boolean) -> Promise - open var updateColumnDefinition: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */, definition: ColumnDefinition) -> Promise - open var setLocale: (locale: dynamic /* String | Boolean */) -> Unit - open var getLocale: () -> String - open var getLang: (locale: String) -> Any - open var redraw: (force: Boolean) -> Unit - open var blockRedraw: () -> Unit - open var restoreRedraw: () -> Unit - open var setHeight: (height: dynamic /* Number | String */) -> Unit - open var setSort: (sortList: dynamic /* String | Array */, dir: String /* "asc" | "desc" */) -> Unit - open var getSorters: () -> Array - open var clearSort: () -> Unit - open var setFilter: (p1: dynamic /* String | Array | Array | (data: Any, filterParams: Any) -> Boolean */, p2: dynamic /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" | Any */, value: Any, filterParams: FilterParams) -> Unit - open var addFilter: FilterFunction - open var getFilters: (includeHeaderFilters: Boolean) -> Array - open var setHeaderFilterValue: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */, value: String) -> Unit - open var setHeaderFilterFocus: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> Unit - open var getHeaderFilters: () -> Array - open var getHeaderFilterValue: (column: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */) -> String - open var removeFilter: FilterFunction - open var clearFilter: (includeHeaderFilters: Boolean) -> Unit - open var clearHeaderFilter: () -> Unit - open var selectRow: (lookup: dynamic /* Array | Array */> | "visible" | "active" | "selected" | "all" | Boolean */) -> Unit - open var deselectRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */) -> Unit - open var toggleSelectRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */) -> Unit - open var getSelectedRows: () -> Array - open var getSelectedData: () -> Array - open var setMaxPage: (max: Number) -> Unit - open var setPage: (page: dynamic /* Number | "first" | "prev" | "next" | "last" */) -> Promise - open var setPageToRow: (row: dynamic /* RowComponent | HTMLElement | String | Number | Array | Array */) -> Promise - open var setPageSize: (size: Number) -> Unit - open var getPageSize: () -> Number - open var previousPage: () -> Promise - open var nextPage: () -> Promise - open var getPage: () -> dynamic - open var getPageMax: () -> dynamic - open var setGroupBy: (groups: dynamic /* String | Array | (data: Any) -> Any */) -> Unit - open var setGroupStartOpen: (values: dynamic /* Boolean | (value: Any, count: Number, data: Any, group: Tabulator.GroupComponent) -> Boolean */) -> Unit - open var setGroupHeader: (values: dynamic /* (value: Any, count: Number, data: Any, group: Tabulator.GroupComponent) -> String | Array<(value: Any, count: Number, data: Any) -> String> */) -> Unit - open var getGroups: () -> Array - open var getGroupedData: (activeOnly: Boolean) -> Any - open var getCalcResults: () -> Any - open var recalc: () -> Unit - open var navigatePrev: () -> Unit - open var navigateNext: () -> Unit - open var navigateLeft: () -> Unit - open var navigateRight: () -> Unit - open var navigateUp: () -> Unit - open var navigateDown: () -> Unit - open var getInvalidCells: () -> Array - open var clearCellValidation: (clearType: dynamic /* Tabulator.CellComponent | Array */) -> Unit - open var validate: () -> dynamic - open var setGroupValues: (data: GroupValuesArg) -> Unit - open var refreshFilters: () -> Unit - open var clearHistory: () -> Unit - - // open var on: (event: K, callback: Any) -> Unit - // open var off: (event: K, callback: Any) -> Unit - interface Options : OptionsGeneral, OptionsMenu, OptionsHistory, OptionsLocale, OptionsDownload, OptionsColumns, - OptionsRows, OptionsData, OptionsSorting, OptionsFiltering, OptionsRowGrouping, OptionsPagination, - OptionsPersistentConfiguration, OptionsClipboard, OptionsDataTree, OptionsCells, OptionsDebug, OptionsHTML - - interface OptionsDebug { - var invalidOptionWarning: Boolean? - get() = definedExternally - set(value) = definedExternally - var debugInvalidOptions: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsCells : CellCallbacks { - var validationFailed: ((cell: CellComponent, value: Any, validators: dynamic /* Array | Array */) -> Unit)? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsDataTree { - var dataTree: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataTreeElementColumn: dynamic /* Boolean? | String? */ - get() = definedExternally - set(value) = definedExternally - var dataTreeBranchElement: dynamic /* Boolean? | String? */ - get() = definedExternally - set(value) = definedExternally - var dataTreeChildIndent: Number? - get() = definedExternally - set(value) = definedExternally - var dataTreeChildField: String? - get() = definedExternally - set(value) = definedExternally - var dataTreeCollapseElement: dynamic /* String? | HTMLElement? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var dataTreeExpandElement: dynamic /* String? | HTMLElement? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var dataTreeStartExpanded: dynamic /* Boolean? | Array? | ((row: RowComponent, level: Number) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var dataTreeSelectPropagate: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataTreeFilter: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataTreeSort: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsClipboard { - var clipboard: dynamic /* Boolean? | "copy" | "paste" */ - get() = definedExternally - set(value) = definedExternally - var clipboardCopyRowRange: String? /* "visible" | "active" | "selected" | "all" */ - get() = definedExternally - set(value) = definedExternally - var clipboardCopyFormatter: dynamic /* "table" | ((type: String /* "plain" | "html" */, output: String) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var clipboardCopyHeader: Boolean? - get() = definedExternally - set(value) = definedExternally - var clipboardPasteParser: dynamic /* String? | ((clipboard: Any) -> Array)? */ - get() = definedExternally - set(value) = definedExternally - var clipboardPasteAction: String? /* "insert" | "update" | "replace" */ - get() = definedExternally - set(value) = definedExternally - var clipboardCopyStyled: Boolean? - get() = definedExternally - set(value) = definedExternally - var clipboardCopyConfig: dynamic /* AddditionalExportOptions? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var clipboardCopied: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var clipboardPasted: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var clipboardPasteError: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var groupHeaderClipboard: dynamic /* ((value: Any, count: Number, data: Any, group: GroupComponent) -> String)? | Array<(value: Any, count: Number, data: Any) -> String>? */ - get() = definedExternally - set(value) = definedExternally - var groupHeaderHtmlOutput: dynamic /* ((value: Any, count: Number, data: Any, group: GroupComponent) -> String)? | Array<(value: Any, count: Number, data: Any) -> String>? */ - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsPersistentConfiguration { - var persistenceID: String? - get() = definedExternally - set(value) = definedExternally - var persistenceMode: dynamic /* "local" | "cookie" | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var persistentLayout: Boolean? - get() = definedExternally - set(value) = definedExternally - var persistentSort: Boolean? - get() = definedExternally - set(value) = definedExternally - var persistentFilter: Boolean? - get() = definedExternally - set(value) = definedExternally - var persistence: dynamic /* Boolean? | PersistenceOptions? */ - get() = definedExternally - set(value) = definedExternally - var persistenceWriterFunc: ((id: String, type: String? /* "sort" | "filter" | "group" | "page" | "columns" */, data: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - var persistenceReaderFunc: ((id: String, type: String? /* "sort" | "filter" | "group" | "page" | "columns" */) -> Any)? - get() = definedExternally - set(value) = definedExternally - } - - interface PersistenceOptions { - var sort: Boolean? - get() = definedExternally - set(value) = definedExternally - var filter: Boolean? - get() = definedExternally - set(value) = definedExternally - var group: dynamic /* Boolean? | PersistenceGroupOptions? */ - get() = definedExternally - set(value) = definedExternally - var page: dynamic /* Boolean? | PersistencePageOptions? */ - get() = definedExternally - set(value) = definedExternally - var columns: dynamic /* Boolean? | Array? */ - get() = definedExternally - set(value) = definedExternally - } - - interface PersistenceGroupOptions { - var groupBy: Boolean? - get() = definedExternally - set(value) = definedExternally - var groupStartOpen: Boolean? - get() = definedExternally - set(value) = definedExternally - var groupHeader: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface PersistencePageOptions { - var size: Boolean? - get() = definedExternally - set(value) = definedExternally - var page: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsPagination { - var pagination: Boolean? - get() = definedExternally - set(value) = definedExternally - var paginationMode: String? /* "remote" | "local" */ - get() = definedExternally - set(value) = definedExternally - var paginationSize: Number? - get() = definedExternally - set(value) = definedExternally - var paginationSizeSelector: dynamic /* Boolean? | Array? | Array? */ - get() = definedExternally - set(value) = definedExternally - var paginationElement: dynamic /* HTMLElement? | String? */ - get() = definedExternally - set(value) = definedExternally - var dataReceiveParams: Record? - get() = definedExternally - set(value) = definedExternally - var dataSendParams: Record? - get() = definedExternally - set(value) = definedExternally - var paginationAddRow: String? /* "table" | "page" */ - get() = definedExternally - set(value) = definedExternally - var paginationButtonCount: Number? - get() = definedExternally - set(value) = definedExternally - var paginationInitialPage: Number? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsRowGrouping { - var groupBy: dynamic /* String? | Array? | ((data: Any) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var groupValues: GroupValuesArg? - get() = definedExternally - set(value) = definedExternally - var groupHeader: dynamic /* ((value: Any, count: Number, data: Any, group: GroupComponent) -> String)? | Array<(value: Any, count: Number, data: Any) -> String>? */ - get() = definedExternally - set(value) = definedExternally - var groupHeaderPrint: dynamic /* ((value: Any, count: Number, data: Any, group: GroupComponent) -> String)? | Array<(value: Any, count: Number, data: Any) -> String>? */ - get() = definedExternally - set(value) = definedExternally - var groupStartOpen: dynamic /* Boolean? | ((value: Any, count: Number, data: Any, group: GroupComponent) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var groupToggleElement: dynamic /* "arrow" | "header" | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var groupClosedShowCalcs: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataGrouping: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var dataGrouped: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var groupVisibilityChanged: ((group: GroupComponent, visible: Boolean) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var groupClick: GroupEventCallback? - get() = definedExternally - set(value) = definedExternally - var groupDblClick: GroupEventCallback? - get() = definedExternally - set(value) = definedExternally - var groupContext: GroupEventCallback? - get() = definedExternally - set(value) = definedExternally - var groupTap: GroupEventCallback? - get() = definedExternally - set(value) = definedExternally - var groupDblTap: GroupEventCallback? - get() = definedExternally - set(value) = definedExternally - var groupTapHold: GroupEventCallback? - get() = definedExternally - set(value) = definedExternally - var groupUpdateOnCellEdit: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface Filter { - var field: String - var type: String /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" */ - var value: Any - } - - interface FilterParams { - var separator: String? - get() = definedExternally - set(value) = definedExternally - var matchAll: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsFiltering { - var initialFilter: Array? - get() = definedExternally - set(value) = definedExternally - var initialHeaderFilter: Array>? - get() = definedExternally - set(value) = definedExternally - var dataFiltering: ((filters: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var dataFiltered: ((filters: Array, rows: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var headerFilterLiveFilterDelay: Number? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsSorting { - var initialSort: Array? - get() = definedExternally - set(value) = definedExternally - var sortOrderReverse: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface Sorter { - var column: String - var dir: String /* "asc" | "desc" */ - } - - interface SorterFromTable { - var column: ColumnComponent - var field: String - var dir: String /* "asc" | "desc" */ - } - - interface OptionsData { - var index: dynamic /* Number? | String? */ - get() = definedExternally - set(value) = definedExternally - var data: Array? - get() = definedExternally - set(value) = definedExternally - var ajaxURL: String? - get() = definedExternally - set(value) = definedExternally - var ajaxParams: Any? - get() = definedExternally - set(value) = definedExternally - var ajaxConfig: dynamic /* "GET" | "POST" | AjaxConfig? */ - get() = definedExternally - set(value) = definedExternally - var ajaxContentType: dynamic /* "form" | "json" | AjaxContentType? */ - get() = definedExternally - set(value) = definedExternally - var ajaxURLGenerator: ((url: String, config: Any, params: Any) -> String)? - get() = definedExternally - set(value) = definedExternally - var ajaxRequestFunc: ((url: String, config: Any, params: Any) -> Promise)? - get() = definedExternally - set(value) = definedExternally - var ajaxFiltering: Boolean? - get() = definedExternally - set(value) = definedExternally - var ajaxSorting: Boolean? - get() = definedExternally - set(value) = definedExternally - var progressiveLoad: String? /* "load" | "scroll" */ - get() = definedExternally - set(value) = definedExternally - var progressiveLoadDelay: Number? - get() = definedExternally - set(value) = definedExternally - var progressiveLoadScrollMargin: Number? - get() = definedExternally - set(value) = definedExternally - var ajaxLoader: dynamic /* Boolean? | (() -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var ajaxLoaderLoading: String? - get() = definedExternally - set(value) = definedExternally - var ajaxLoaderError: String? - get() = definedExternally - set(value) = definedExternally - var ajaxRequesting: ((url: String, params: Any) -> Boolean)? - get() = definedExternally - set(value) = definedExternally - var ajaxResponse: ((url: String, params: Any, response: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - var ajaxError: ((xhr: Any, textStatus: Any, errorThrown: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var dataLoader: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataLoaderLoading: String? - get() = definedExternally - set(value) = definedExternally - var dataLoaderError: String? - get() = definedExternally - set(value) = definedExternally - var sortMode: String? /* "remote" | "local" */ - get() = definedExternally - set(value) = definedExternally - var filterMode: String? /* "remote" | "local" */ - get() = definedExternally - set(value) = definedExternally - } - - interface AjaxContentType { - var headers: JSONRecord - var body: (url: String, config: Any, params: Any) -> Any - } - - interface AjaxConfig { - var method: String? /* "GET" | "POST" */ - get() = definedExternally - set(value) = definedExternally - var headers: JSONRecord? - get() = definedExternally - set(value) = definedExternally - var mode: String? - get() = definedExternally - set(value) = definedExternally - var credentials: String? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsRows { - var rowFormatter: ((row: RowComponent) -> Any)? - get() = definedExternally - set(value) = definedExternally - var rowFormatterPrint: dynamic /* Boolean? | ((row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var rowFormatterHtmlOutput: dynamic /* Boolean? | ((row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var rowFormatterClipboard: dynamic /* Boolean? | ((row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var addRowPos: String? /* "bottom" | "top" */ - get() = definedExternally - set(value) = definedExternally - var selectable: dynamic /* Boolean? | Number? | "highlight" */ - get() = definedExternally - set(value) = definedExternally - var selectableRangeMode: String? /* "click" */ - get() = definedExternally - set(value) = definedExternally - var selectableRollingSelection: Boolean? - get() = definedExternally - set(value) = definedExternally - var selectablePersistence: Boolean? - get() = definedExternally - set(value) = definedExternally - var selectableCheck: ((row: RowComponent) -> Boolean)? - get() = definedExternally - set(value) = definedExternally - var movableRows: Boolean? - get() = definedExternally - set(value) = definedExternally - var movableRowsConnectedTables: dynamic /* String? | Array? | HTMLElement? | Array? */ - get() = definedExternally - set(value) = definedExternally - var movableRowsSender: dynamic /* Boolean? | "delete" | ((fromRow: RowComponent, toRow: RowComponent, toTable: Tabulator) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var movableRowsReceiver: dynamic /* "insert" | "add" | "update" | "replace" | ((fromRow: RowComponent, toRow: RowComponent, fromTable: Tabulator) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var movableRowsConnectedElements: dynamic /* String? | HTMLElement? */ - get() = definedExternally - set(value) = definedExternally - var movableRowsElementDrop: ((e: MouseEvent, element: HTMLElement, row: RowComponent) -> Any)? - get() = definedExternally - set(value) = definedExternally - var resizableRows: Boolean? - get() = definedExternally - set(value) = definedExternally - var scrollToRowPosition: String? /* "top" | "center" | "bottom" | "nearest" */ - get() = definedExternally - set(value) = definedExternally - var scrollToRowIfVisible: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataTreeRowExpanded: ((row: RowComponent, level: Number) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var dataTreeRowCollapsed: ((row: RowComponent, level: Number) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsSendingStart: ((toTables: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsSent: ((fromRow: RowComponent, toRow: RowComponent, toTable: Tabulator) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsSentFailed: ((fromRow: RowComponent, toRow: RowComponent, toTable: Tabulator) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsSendingStop: ((toTables: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsReceivingStart: ((fromRow: RowComponent, toTable: Tabulator) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsReceived: ((fromRow: RowComponent, toRow: RowComponent, fromTable: Tabulator) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsReceivedFailed: ((fromRow: RowComponent, toRow: RowComponent, fromTable: Tabulator) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var movableRowsReceivingStop: ((fromTable: Tabulator) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var rowClick: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowDblClick: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowContext: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowTap: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowDblTap: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowTapHold: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowMouseEnter: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowMouseLeave: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowMouseOver: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowMouseOut: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowMouseMove: RowEventCallback? - get() = definedExternally - set(value) = definedExternally - var rowAdded: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var rowUpdated: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var rowDeleted: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var rowMoved: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var rowResized: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var rowSelectionChanged: ((data: Array, rows: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var rowSelected: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var rowDeselected: RowChangedCallback? - get() = definedExternally - set(value) = definedExternally - var tabEndNewRow: dynamic /* Boolean? | JSONRecord? | ((row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsColumns { - var columns: Array? - get() = definedExternally - set(value) = definedExternally - var autoColumns: Boolean? - get() = definedExternally - set(value) = definedExternally - var autoColumnsDefinitions: dynamic /* ((columnDefinitions: Array) -> Array)? | Array? | Record? */ - get() = definedExternally - set(value) = definedExternally - var layout: String? /* "fitData" | "fitColumns" | "fitDataFill" | "fitDataStretch" | "fitDataTable" */ - get() = definedExternally - set(value) = definedExternally - var layoutColumnsOnNewData: Boolean? - get() = definedExternally - set(value) = definedExternally - var responsiveLayout: dynamic /* Boolean? | "hide" | "collapse" */ - get() = definedExternally - set(value) = definedExternally - var responsiveLayoutCollapseStartOpen: Boolean? - get() = definedExternally - set(value) = definedExternally - var responsiveLayoutCollapseUseFormatters: Boolean? - get() = definedExternally - set(value) = definedExternally - var responsiveLayoutCollapseFormatter: ((data: Array) -> Any)? - get() = definedExternally - set(value) = definedExternally - var movableColumns: Boolean? - get() = definedExternally - set(value) = definedExternally - var columnHeaderVertAlign: String? /* "top" | "middle" | "bottom" */ - get() = definedExternally - set(value) = definedExternally - var scrollToColumnPosition: String? /* "left" | "center" | "middle" | "right" */ - get() = definedExternally - set(value) = definedExternally - var scrollToColumnIfVisible: Boolean? - get() = definedExternally - set(value) = definedExternally - var columnCalcs: dynamic /* Boolean? | "both" | "table" | "group" */ - get() = definedExternally - set(value) = definedExternally - var nestedFieldSeparator: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var columnHeaderSortMulti: Boolean? - get() = definedExternally - set(value) = definedExternally - var columnMoved: ((column: ColumnComponent, columns: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var columnResized: ((column: ColumnComponent) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var columnVisibilityChanged: ((column: ColumnComponent, visible: Boolean) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var columnTitleChanged: ((column: ColumnComponent) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var headerVisible: Boolean? - get() = definedExternally - set(value) = definedExternally - var print: Boolean? - get() = definedExternally - set(value) = definedExternally - var headerSort: Boolean? - get() = definedExternally - set(value) = definedExternally - var headerSortElement: String? - get() = definedExternally - set(value) = definedExternally - var columnDefaults: ColumnDefinition? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsCell { - var cellClick: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellDblClick: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellContext: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellTap: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellDblTap: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellTapHold: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseEnter: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseLeave: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseOver: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseOut: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseMove: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEditing: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEdited: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEditCancelled: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsGeneral { - var height: dynamic /* String? | Number? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var maxHeight: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally - var minHeight: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally - var renderVertical: dynamic /* "virtual" | "basic" | Renderer? */ - get() = definedExternally - set(value) = definedExternally - var renderHorizontal: dynamic /* "virtual" | "basic" | Renderer? */ - get() = definedExternally - set(value) = definedExternally - var renderVerticalBuffer: dynamic /* Boolean? | Number? */ - get() = definedExternally - set(value) = definedExternally - var placeholder: dynamic /* String? | HTMLElement? */ - get() = definedExternally - set(value) = definedExternally - var footerElement: dynamic /* String? | HTMLElement? */ - get() = definedExternally - set(value) = definedExternally - var tooltipGenerationMode: String? /* "load" | "hover" */ - get() = definedExternally - set(value) = definedExternally - var keybindings: dynamic /* Boolean? | KeyBinding? */ - get() = definedExternally - set(value) = definedExternally - var reactiveData: Boolean? - get() = definedExternally - set(value) = definedExternally - var autoResize: Boolean? - get() = definedExternally - set(value) = definedExternally - var tableBuilding: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var tableBuilt: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var renderStarted: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var renderComplete: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var htmlImporting: EmptyCallback? - get() = definedExternally - set(value) = definedExternally - var htmlImported: EmptyCallback? - get() = definedExternally - set(value) = definedExternally - var dataChanged: ((data: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var pageLoaded: ((pageno: Number) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var dataSorting: ((sorters: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var dataSorted: ((sorters: Array, rows: Array) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var invalidOptionWarnings: Boolean? - get() = definedExternally - set(value) = definedExternally - var scrollVertical: ((top: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var scrollHorizontal: ((left: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var validationMode: String? /* "blocking" | "highlight" | "manual" */ - get() = definedExternally - set(value) = definedExternally - var textDirection: String? /* "auto" | "ltr" | "rtl" */ - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsMenu { - var rowContextMenu: dynamic /* Array | MenuSeparator */>? | ((component: RowComponent, e: MouseEvent) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var rowClickMenu: dynamic /* Array | MenuSeparator */>? | ((component: RowComponent, e: MouseEvent) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var groupClickMenu: dynamic /* Array | MenuSeparator */>? | ((component: GroupComponent, e: MouseEvent) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var groupContextMenu: Array>? - get() = definedExternally - set(value) = definedExternally - } - - interface MenuObject { - var label: dynamic /* String | HTMLElement | (component: T) -> dynamic */ - get() = definedExternally - set(value) = definedExternally - var action: ((e: Any, component: T) -> Any)? - get() = definedExternally - set(value) = definedExternally - var disabled: dynamic /* Boolean? | ((component: T) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var menu: Array>? - get() = definedExternally - set(value) = definedExternally - } - - interface MenuSeparator { - var separator: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface DownloadOptions : DownloadCSV, DownloadXLXS, DownloadPDF, DownloadHTML { - override var documentProcessing: ((input: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - } - - interface DownloadCSV { - var delimiter: String? - get() = definedExternally - set(value) = definedExternally - var bom: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface DownloadHTML { - var style: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface DownloadXLXS { - var sheetName: String? - get() = definedExternally - set(value) = definedExternally - var documentProcessing: ((input: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - } - - interface DownloadPDF { - var orientation: String? /* "portrait" | "landscape" */ - get() = definedExternally - set(value) = definedExternally - var title: String? - get() = definedExternally - set(value) = definedExternally - var rowGroupStyles: Any? - get() = definedExternally - set(value) = definedExternally - var rowCalcStyles: Any? - get() = definedExternally - set(value) = definedExternally - var jsPDF: Any? - get() = definedExternally - set(value) = definedExternally - var autoTable: dynamic /* Any? | ((doc: Any) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var documentProcessing: ((doc: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsDownload { - var downloadReady: ((fileContents: Any, blob: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - var downloadComplete: (() -> Unit)? - get() = definedExternally - set(value) = definedExternally - var downloadConfig: AddditionalExportOptions? - get() = definedExternally - set(value) = definedExternally - var downloadRowRange: String? /* "visible" | "active" | "selected" | "all" */ - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsHTML { - var htmlOutputConfig: AddditionalExportOptions? - get() = definedExternally - set(value) = definedExternally - var printAsHtml: Boolean? - get() = definedExternally - set(value) = definedExternally - var printConfig: AddditionalExportOptions? - get() = definedExternally - set(value) = definedExternally - var printStyled: Boolean? - get() = definedExternally - set(value) = definedExternally - var printRowRange: dynamic /* "visible" | "active" | "selected" | "all" | (() -> Array)? */ - get() = definedExternally - set(value) = definedExternally - var printHeader: dynamic /* String? | HTMLElement? | (() -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var printFooter: dynamic /* String? | HTMLElement? | (() -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var printFormatter: ((tableHolderElement: Any, tableElement: Any) -> Any)? - get() = definedExternally - set(value) = definedExternally - var groupHeaderDownload: dynamic /* ((value: Any, count: Number, data: Any, group: GroupComponent) -> String)? | Array<(value: Any, count: Number, data: Any) -> String>? */ - get() = definedExternally - set(value) = definedExternally - } - - interface AddditionalExportOptions { - var columnHeaders: Boolean? - get() = definedExternally - set(value) = definedExternally - var columnGroups: Boolean? - get() = definedExternally - set(value) = definedExternally - var rowGroups: Boolean? - get() = definedExternally - set(value) = definedExternally - var columnCalcs: Boolean? - get() = definedExternally - set(value) = definedExternally - var dataTree: Boolean? - get() = definedExternally - set(value) = definedExternally - var formatCells: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsLocale { - var locale: dynamic /* Boolean? | String? */ - get() = definedExternally - set(value) = definedExternally - var langs: Any? - get() = definedExternally - set(value) = definedExternally - var localized: ((locale: String, lang: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - } - - interface OptionsHistory { - var history: Boolean? - get() = definedExternally - set(value) = definedExternally - var historyUndo: ((action: String? /* "cellEdit" | "rowAdd" | "rowDelete" | "rowMoved" */, component: dynamic /* CellComponent | RowComponent */, data: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - var historyRedo: ((action: String? /* "cellEdit" | "rowAdd" | "rowDelete" | "rowMoved" */, component: dynamic /* CellComponent | RowComponent */, data: Any) -> Unit)? - get() = definedExternally - set(value) = definedExternally - } - - interface ColumnLayout { - var title: String - var field: String? - get() = definedExternally - set(value) = definedExternally - var visible: Boolean? - get() = definedExternally - set(value) = definedExternally - var width: dynamic /* Number? | String? */ - get() = definedExternally - set(value) = definedExternally - } - - interface ColumnLayoutPartial { - var title: String? - get() = definedExternally - set(value) = definedExternally - var field: String? - get() = definedExternally - set(value) = definedExternally - var visible: Boolean? - get() = definedExternally - set(value) = definedExternally - var width: dynamic /* Number? | String? */ - get() = definedExternally - set(value) = definedExternally - } - - interface ColumnDefinition : ColumnLayout, CellCallbacks { - var hozAlign: String? /* "left" | "center" | "right" */ - get() = definedExternally - set(value) = definedExternally - var headerHozAlign: String? /* "left" | "center" | "right" */ - get() = definedExternally - set(value) = definedExternally - var vertAlign: String? /* "top" | "middle" | "bottom" */ - get() = definedExternally - set(value) = definedExternally - var minWidth: Number? - get() = definedExternally - set(value) = definedExternally - var widthGrow: Number? - get() = definedExternally - set(value) = definedExternally - var widthShrink: Number? - get() = definedExternally - set(value) = definedExternally - var resizable: dynamic /* Boolean? | "header" | "cell" */ - get() = definedExternally - set(value) = definedExternally - var frozen: Boolean? - get() = definedExternally - set(value) = definedExternally - var responsive: Number? - get() = definedExternally - set(value) = definedExternally - var tooltip: dynamic /* String? | Boolean? | ((cell: CellComponent) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var cssClass: String? - get() = definedExternally - set(value) = definedExternally - var rowHandle: Boolean? - get() = definedExternally - set(value) = definedExternally - var hideInHtml: Boolean? - get() = definedExternally - set(value) = definedExternally - var sorter: dynamic /* "string" | "number" | "alphanum" | "boolean" | "exists" | "date" | "time" | "datetime" | "array" | ((a: Any, b: Any, aRow: RowComponent, bRow: RowComponent, column: ColumnComponent, dir: String /* "asc" | "desc" */, sorterParams: Any) -> Number)? */ - get() = definedExternally - set(value) = definedExternally - var sorterParams: dynamic /* ColumnDefinitionSorterParams? | ColumnSorterParamLookupFunction? */ - get() = definedExternally - set(value) = definedExternally - var formatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var formatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var variableHeight: Boolean? - get() = definedExternally - set(value) = definedExternally - var editable: dynamic /* Boolean? | ((cell: CellComponent) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var editor: dynamic /* Boolean? | "input" | "textarea" | "number" | "range" | "tickCross" | "star" | "select" | "autocomplete" | ((cell: CellComponent, onRendered: EmptyCallback, success: ValueBooleanCallback, cancel: ValueVoidCallback, editorParams: Any) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var editorParams: dynamic /* NumberParams? | CheckboxParams? | SelectParams? | AutoCompleteParams? | InputParams? | TextAreaParams? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var validator: dynamic /* "required" | "unique" | "integer" | "float" | "numeric" | "string" | Array? | Validator? | Array? | String? */ - get() = definedExternally - set(value) = definedExternally - var mutator: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var mutatorData: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorDataParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var mutatorEdit: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorEditParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var mutatorClipboard: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorClipboardParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessor: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorDownload: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorDownloadParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorClipboard: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorClipboardParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var download: Boolean? - get() = definedExternally - set(value) = definedExternally - var titleDownload: String? - get() = definedExternally - set(value) = definedExternally - var topCalc: dynamic /* "avg" | "max" | "min" | "sum" | "concat" | "count" | ((values: Array, data: Array, calcParams: Any) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var topCalcParams: ColumnCalcParams? - get() = definedExternally - set(value) = definedExternally - var topCalcFormatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var topCalcFormatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var bottomCalc: dynamic /* "avg" | "max" | "min" | "sum" | "concat" | "count" | ((values: Array, data: Array, calcParams: Any) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var bottomCalcParams: ColumnCalcParams? - get() = definedExternally - set(value) = definedExternally - var bottomCalcFormatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var bottomCalcFormatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var headerSort: Boolean? - get() = definedExternally - set(value) = definedExternally - var headerSortStartingDir: String? /* "asc" | "desc" */ - get() = definedExternally - set(value) = definedExternally - var headerSortTristate: Boolean? - get() = definedExternally - set(value) = definedExternally - var headerClick: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerDblClick: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerContext: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerTap: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerDblTap: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerTapHold: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerTooltip: dynamic /* Boolean? | String? | ((column: ColumnComponent) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var headerVertical: dynamic /* Boolean? | "flip" */ - get() = definedExternally - set(value) = definedExternally - var editableTitle: Boolean? - get() = definedExternally - set(value) = definedExternally - var titleFormatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var titleFormatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilter: dynamic /* Boolean? | "input" | "textarea" | "number" | "range" | "tickCross" | "star" | "select" | "autocomplete" | ((cell: CellComponent, onRendered: EmptyCallback, success: ValueBooleanCallback, cancel: ValueVoidCallback, editorParams: Any) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilterParams: dynamic /* NumberParams? | CheckboxParams? | SelectParams? | AutoCompleteParams? | InputParams? | TextAreaParams? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilterPlaceholder: String? - get() = definedExternally - set(value) = definedExternally - var headerFilterEmptyCheck: ValueBooleanCallback? - get() = definedExternally - set(value) = definedExternally - var headerFilterFunc: dynamic /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" | ((headerValue: Any, rowValue: Any, rowdata: Any, filterparams: Any) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilterFuncParams: Any? - get() = definedExternally - set(value) = definedExternally - var headerFilterLiveFilter: Boolean? - get() = definedExternally - set(value) = definedExternally - var htmlOutput: Boolean? - get() = definedExternally - set(value) = definedExternally - var clipboard: Boolean? - get() = definedExternally - set(value) = definedExternally - var columns: Array? - get() = definedExternally - set(value) = definedExternally - var headerMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var headerContextMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var contextMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var clickMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var formatterClipboard: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var formatterClipboardParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var formatterPrint: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var formatterPrintParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorPrint: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorPrintParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorHtmlOutput: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorHtmlOutputParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var formatterHtmlOutput: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var formatterHtmlOutputParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var titleClipboard: String? - get() = definedExternally - set(value) = definedExternally - var titleHtmlOutput: String? - get() = definedExternally - set(value) = definedExternally - var titlePrint: String? - get() = definedExternally - set(value) = definedExternally - var maxWidth: dynamic /* Number? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - } - - interface ColumnDefinitionPartial : ColumnLayoutPartial, CellCallbacksPartial { - var hozAlign: String? /* "left" | "center" | "right" */ - get() = definedExternally - set(value) = definedExternally - var headerHozAlign: String? /* "left" | "center" | "right" */ - get() = definedExternally - set(value) = definedExternally - var vertAlign: String? /* "top" | "middle" | "bottom" */ - get() = definedExternally - set(value) = definedExternally - var minWidth: Number? - get() = definedExternally - set(value) = definedExternally - var widthGrow: Number? - get() = definedExternally - set(value) = definedExternally - var widthShrink: Number? - get() = definedExternally - set(value) = definedExternally - var resizable: dynamic /* Boolean? | "header" | "cell" */ - get() = definedExternally - set(value) = definedExternally - var frozen: Boolean? - get() = definedExternally - set(value) = definedExternally - var responsive: Number? - get() = definedExternally - set(value) = definedExternally - var tooltip: dynamic /* String? | Boolean? | ((cell: CellComponent) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var cssClass: String? - get() = definedExternally - set(value) = definedExternally - var rowHandle: Boolean? - get() = definedExternally - set(value) = definedExternally - var hideInHtml: Boolean? - get() = definedExternally - set(value) = definedExternally - var sorter: dynamic /* "string" | "number" | "alphanum" | "boolean" | "exists" | "date" | "time" | "datetime" | "array" | ((a: Any, b: Any, aRow: RowComponent, bRow: RowComponent, column: ColumnComponent, dir: String /* "asc" | "desc" */, sorterParams: Any) -> Number)? */ - get() = definedExternally - set(value) = definedExternally - var sorterParams: dynamic /* ColumnDefinitionSorterParams? | ColumnSorterParamLookupFunction? */ - get() = definedExternally - set(value) = definedExternally - var formatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var formatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var variableHeight: Boolean? - get() = definedExternally - set(value) = definedExternally - var editable: dynamic /* Boolean? | ((cell: CellComponent) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var editor: dynamic /* Boolean? | "input" | "textarea" | "number" | "range" | "tickCross" | "star" | "select" | "autocomplete" | ((cell: CellComponent, onRendered: EmptyCallback, success: ValueBooleanCallback, cancel: ValueVoidCallback, editorParams: Any) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var editorParams: dynamic /* NumberParams? | CheckboxParams? | SelectParams? | AutoCompleteParams? | InputParams? | TextAreaParams? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var validator: dynamic /* "required" | "unique" | "integer" | "float" | "numeric" | "string" | Array? | Validator? | Array? | String? */ - get() = definedExternally - set(value) = definedExternally - var mutator: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var mutatorData: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorDataParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var mutatorEdit: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorEditParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var mutatorClipboard: CustomMutator? - get() = definedExternally - set(value) = definedExternally - var mutatorClipboardParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "edit" */, cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessor: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorDownload: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorDownloadParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorClipboard: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorClipboardParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var download: Boolean? - get() = definedExternally - set(value) = definedExternally - var titleDownload: String? - get() = definedExternally - set(value) = definedExternally - var topCalc: dynamic /* "avg" | "max" | "min" | "sum" | "concat" | "count" | ((values: Array, data: Array, calcParams: Any) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var topCalcParams: ColumnCalcParams? - get() = definedExternally - set(value) = definedExternally - var topCalcFormatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var topCalcFormatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var bottomCalc: dynamic /* "avg" | "max" | "min" | "sum" | "concat" | "count" | ((values: Array, data: Array, calcParams: Any) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var bottomCalcParams: ColumnCalcParams? - get() = definedExternally - set(value) = definedExternally - var bottomCalcFormatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var bottomCalcFormatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var headerSort: Boolean? - get() = definedExternally - set(value) = definedExternally - var headerSortStartingDir: String? /* "asc" | "desc" */ - get() = definedExternally - set(value) = definedExternally - var headerSortTristate: Boolean? - get() = definedExternally - set(value) = definedExternally - var headerClick: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerDblClick: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerContext: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerTap: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerDblTap: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerTapHold: ColumnEventCallback? - get() = definedExternally - set(value) = definedExternally - var headerTooltip: dynamic /* Boolean? | String? | ((column: ColumnComponent) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var headerVertical: dynamic /* Boolean? | "flip" */ - get() = definedExternally - set(value) = definedExternally - var editableTitle: Boolean? - get() = definedExternally - set(value) = definedExternally - var titleFormatter: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var titleFormatterParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilter: dynamic /* Boolean? | "input" | "textarea" | "number" | "range" | "tickCross" | "star" | "select" | "autocomplete" | ((cell: CellComponent, onRendered: EmptyCallback, success: ValueBooleanCallback, cancel: ValueVoidCallback, editorParams: Any) -> dynamic)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilterParams: dynamic /* NumberParams? | CheckboxParams? | SelectParams? | AutoCompleteParams? | InputParams? | TextAreaParams? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilterPlaceholder: String? - get() = definedExternally - set(value) = definedExternally - var headerFilterEmptyCheck: ValueBooleanCallback? - get() = definedExternally - set(value) = definedExternally - var headerFilterFunc: dynamic /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" | ((headerValue: Any, rowValue: Any, rowdata: Any, filterparams: Any) -> Boolean)? */ - get() = definedExternally - set(value) = definedExternally - var headerFilterFuncParams: Any? - get() = definedExternally - set(value) = definedExternally - var headerFilterLiveFilter: Boolean? - get() = definedExternally - set(value) = definedExternally - var htmlOutput: Boolean? - get() = definedExternally - set(value) = definedExternally - var clipboard: Boolean? - get() = definedExternally - set(value) = definedExternally - var columns: Array? - get() = definedExternally - set(value) = definedExternally - var headerMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var headerContextMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var contextMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var clickMenu: Array | MenuSeparator */>? - get() = definedExternally - set(value) = definedExternally - var formatterClipboard: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var formatterClipboardParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var formatterPrint: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var formatterPrintParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorPrint: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorPrintParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var accessorHtmlOutput: CustomAccessor? - get() = definedExternally - set(value) = definedExternally - var accessorHtmlOutputParams: dynamic /* Any? | ((value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, column: ColumnComponent, row: RowComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var formatterHtmlOutput: dynamic /* "plaintext" | "textarea" | "html" | "money" | "image" | "datetime" | "datetimediff" | "link" | "tickCross" | "color" | "star" | "traffic" | "progress" | "lookup" | "buttonTick" | "buttonCross" | "rownum" | "handle" | "rowSelection" | "responsiveCollapse" | ((cell: CellComponent, formatterParams: Any, onRendered: EmptyCallback) -> dynamic)? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var formatterHtmlOutputParams: dynamic /* MoneyParams? | ImageParams? | LinkParams? | DateTimeParams? | DateTimeDifferenceParams? | TickCrossParams? | TrafficParams? | ProgressBarParams? | StarRatingParams? | RowSelectionParams? | JSONRecord? | ((cell: CellComponent) -> Any)? */ - get() = definedExternally - set(value) = definedExternally - var titleClipboard: String? - get() = definedExternally - set(value) = definedExternally - var titleHtmlOutput: String? - get() = definedExternally - set(value) = definedExternally - var titlePrint: String? - get() = definedExternally - set(value) = definedExternally - var maxWidth: dynamic /* Number? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - } - - interface CellCallbacks { - var cellClick: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellDblClick: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellContext: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellTap: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellDblTap: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellTapHold: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseEnter: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseLeave: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseOver: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseOut: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseMove: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEditing: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEdited: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEditCancelled: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - } - - interface CellCallbacksPartial { - var cellClick: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellDblClick: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellContext: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellTap: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellDblTap: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellTapHold: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseEnter: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseLeave: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseOver: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseOut: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellMouseMove: CellEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEditing: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEdited: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - var cellEditCancelled: CellEditEventCallback? - get() = definedExternally - set(value) = definedExternally - } - - interface ColumnDefinitionSorterParams { - var format: String? - get() = definedExternally - set(value) = definedExternally - var locale: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var alignEmptyValues: String? /* "top" | "bottom" */ - get() = definedExternally - set(value) = definedExternally - var type: String? /* "length" | "sum" | "max" | "min" | "avg" */ - get() = definedExternally - set(value) = definedExternally - } - - interface MoneyParams { - var decimal: String? - get() = definedExternally - set(value) = definedExternally - var thousand: String? - get() = definedExternally - set(value) = definedExternally - var symbol: String? - get() = definedExternally - set(value) = definedExternally - var symbolAfter: Boolean? - get() = definedExternally - set(value) = definedExternally - var precision: dynamic /* Boolean? | Number? */ - get() = definedExternally - set(value) = definedExternally - } - - interface ImageParams { - var height: String? - get() = definedExternally - set(value) = definedExternally - var width: String? - get() = definedExternally - set(value) = definedExternally - var urlPrefix: String? - get() = definedExternally - set(value) = definedExternally - var urlSuffix: String? - get() = definedExternally - set(value) = definedExternally - } - - interface LinkParams { - var labelField: String? - get() = definedExternally - set(value) = definedExternally - var label: dynamic /* String? | ((cell: CellComponent) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var urlPrefix: String? - get() = definedExternally - set(value) = definedExternally - var urlField: String? - get() = definedExternally - set(value) = definedExternally - var url: dynamic /* String? | ((cell: CellComponent) -> String)? */ - get() = definedExternally - set(value) = definedExternally - var target: String? - get() = definedExternally - set(value) = definedExternally - var download: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface DateTimeParams { - var inputFormat: String? - get() = definedExternally - set(value) = definedExternally - var outputFormat: String? - get() = definedExternally - set(value) = definedExternally - var invalidPlaceholder: dynamic /* Boolean? | String? | Number? | ValueStringCallback? */ - get() = definedExternally - set(value) = definedExternally - var timezone: String? - get() = definedExternally - set(value) = definedExternally - } - - interface DateTimeDifferenceParams : DateTimeParams { - var date: Any? - get() = definedExternally - set(value) = definedExternally - var humanize: Boolean? - get() = definedExternally - set(value) = definedExternally - var unit: String? /* "years" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds" */ - get() = definedExternally - set(value) = definedExternally - var suffix: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface TickCrossParams { - var allowEmpty: Boolean? - get() = definedExternally - set(value) = definedExternally - var allowTruthy: Boolean? - get() = definedExternally - set(value) = definedExternally - var tickElement: dynamic /* Boolean? | String? */ - get() = definedExternally - set(value) = definedExternally - var crossElement: dynamic /* Boolean? | String? */ - get() = definedExternally - set(value) = definedExternally - } - - interface TrafficParams { - var min: Number? - get() = definedExternally - set(value) = definedExternally - var max: Number? - get() = definedExternally - set(value) = definedExternally - var color: dynamic /* String? | Array? | ValueStringCallback? */ - get() = definedExternally - set(value) = definedExternally - } - - interface ProgressBarParams : TrafficParams { - var legend: dynamic /* String? | Boolean? | ValueStringCallback? */ - get() = definedExternally - set(value) = definedExternally - var legendColor: dynamic /* String? | Array? | ValueStringCallback? */ - get() = definedExternally - set(value) = definedExternally - var legendAlign: String? /* "center" | "left" | "right" | "justify" */ - get() = definedExternally - set(value) = definedExternally - } - - interface StarRatingParams { - var stars: Number? - get() = definedExternally - set(value) = definedExternally - } - - interface RowSelectionParams { - var rowRange: String? /* "visible" | "active" | "selected" | "all" */ - get() = definedExternally - set(value) = definedExternally - } - - interface SharedEditorParams { - var elementAttributes: JSONRecord? - get() = definedExternally - set(value) = definedExternally - var mask: String? - get() = definedExternally - set(value) = definedExternally - var maskAutoFill: Boolean? - get() = definedExternally - set(value) = definedExternally - var maskLetterChar: String? - get() = definedExternally - set(value) = definedExternally - var maskNumberChar: String? - get() = definedExternally - set(value) = definedExternally - var maskWildcardChar: String? - get() = definedExternally - set(value) = definedExternally - } - - interface NumberParams : SharedEditorParams { - var min: Number? - get() = definedExternally - set(value) = definedExternally - var max: Number? - get() = definedExternally - set(value) = definedExternally - var step: Number? - get() = definedExternally - set(value) = definedExternally - var verticalNavigation: String? /* "editor" | "table" */ - get() = definedExternally - set(value) = definedExternally - } - - interface InputParams : SharedEditorParams { - var search: Boolean? - get() = definedExternally - set(value) = definedExternally - } - - interface TextAreaParams : SharedEditorParams { - var verticalNavigation: String? /* "editor" | "table" | "hybrid" */ - get() = definedExternally - set(value) = definedExternally - } - - interface CheckboxParams : SharedEditorParams { - var tristate: Boolean? - get() = definedExternally - set(value) = definedExternally - var indeterminateValue: String? - get() = definedExternally - set(value) = definedExternally - } - - interface SharedSelectAutoCompleteEditorParams { - var defaultValue: String? - get() = definedExternally - set(value) = definedExternally - var sortValuesList: String? /* "asc" | "desc" */ - get() = definedExternally - set(value) = definedExternally - } - - interface SelectParams : SharedEditorParams, SharedSelectAutoCompleteEditorParams { - var values: dynamic /* Boolean | Array | JSONRecord | Array | String */ - get() = definedExternally - set(value) = definedExternally - var listItemFormatter: ((value: String, text: String) -> String)? - get() = definedExternally - set(value) = definedExternally - var verticalNavigation: String? /* "editor" | "table" | "hybrid" */ - get() = definedExternally - set(value) = definedExternally - var multiselect: dynamic /* Boolean? | Number? */ - get() = definedExternally - set(value) = definedExternally - } - - interface SelectParamsGroup { - var label: String - var value: dynamic /* String? | Number? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var options: Array? - get() = definedExternally - set(value) = definedExternally - var elementAttributes: Any? - get() = definedExternally - set(value) = definedExternally - } - - interface SelectLabelValue { - var label: String - var value: dynamic /* String | Number | Boolean */ - get() = definedExternally - set(value) = definedExternally - } - - interface AutoCompleteParams : SharedEditorParams, SharedSelectAutoCompleteEditorParams { - var values: dynamic /* Boolean | Array | JSONRecord | String | Array */ - get() = definedExternally - set(value) = definedExternally - var listItemFormatter: ((value: String, text: String) -> String)? - get() = definedExternally - set(value) = definedExternally - var searchFunc: ((term: String, values: Array) -> dynamic)? - get() = definedExternally - set(value) = definedExternally - var allowEmpty: Boolean? - get() = definedExternally - set(value) = definedExternally - var freetext: Boolean? - get() = definedExternally - set(value) = definedExternally - var showListOnEmpty: Boolean? - get() = definedExternally - set(value) = definedExternally - var verticalNavigation: String? /* "editor" | "table" | "hybrid" */ - get() = definedExternally - set(value) = definedExternally - var searchingPlaceholder: dynamic /* String? | HTMLElement? */ - get() = definedExternally - set(value) = definedExternally - var emptyPlaceholder: dynamic /* String? | HTMLElement? */ - get() = definedExternally - set(value) = definedExternally - } - - interface Validator { - var type: dynamic /* "required" | "unique" | "integer" | "float" | "numeric" | "string" | (cell: CellComponent, value: Any, parameters: Any) -> Boolean */ - get() = definedExternally - set(value) = definedExternally - var parameters: Any? - get() = definedExternally - set(value) = definedExternally - } - - interface KeyBinding { - var navPrev: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var navNext: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var navLeft: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var navRight: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var navUp: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var navDown: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var undo: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var redo: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var scrollPageUp: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var scrollPageDown: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var scrollToStart: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var scrollToEnd: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - var copyToClipboard: dynamic /* String? | Boolean? */ - get() = definedExternally - set(value) = definedExternally - } - - interface CalculationComponent { - var getData: () -> Any - var getElement: () -> HTMLElement - var getTable: () -> Tabulator - var getCells: () -> Array - var getCell: (column: dynamic /* ColumnComponent | HTMLElement | String */) -> CellComponent - } - - interface RowComponent : CalculationComponent { - var getNextRow: () -> dynamic - var getPrevRow: () -> dynamic - var getIndex: () -> Any - var getPosition: (filteredPosition: Boolean) -> Number - var getGroup: () -> GroupComponent - var delete: () -> Promise - var scrollTo: () -> Promise - var pageTo: () -> Promise - var move: (lookup: dynamic /* RowComponent | HTMLElement | Number */, belowTarget: Boolean) -> Unit - var update: (data: Any) -> Promise - var select: () -> Unit - var deselect: () -> Unit - var toggleSelect: () -> Unit - var isSelected: () -> Boolean - var normalizeHeight: () -> Unit - var reformat: () -> Unit - var freeze: () -> Unit - var unfreeze: () -> Unit - var treeExpand: () -> Unit - var treeCollapse: () -> Unit - var treeToggle: () -> Unit - var getTreeParent: () -> dynamic - var getTreeChildren: () -> Array - var addTreeChild: (rowData: Any, position: Boolean, existingRow: RowComponent) -> Unit - var validate: () -> dynamic - var isFrozen: () -> Boolean - } - - interface GroupComponent { - var getElement: () -> HTMLElement - var getTable: () -> Tabulator - var getKey: () -> Any - var getField: () -> String - var getRows: () -> Array - var getSubGroups: () -> Array - var getParentGroup: () -> dynamic - var isVisible: () -> Boolean - var show: () -> Unit - var hide: () -> Unit - var toggle: () -> Unit - } - - interface ColumnComponent { - var getElement: () -> HTMLElement - var getTable: () -> Tabulator - var getDefinition: () -> ColumnDefinition - var getField: () -> String - var getCells: () -> Array - var getNextColumn: () -> dynamic - var getPrevColumn: () -> dynamic - var move: (toColumn: dynamic /* ColumnComponent | ColumnDefinition | HTMLElement | String */, after: Boolean) -> Unit - var isVisible: () -> Boolean - var show: () -> Unit - var hide: () -> Unit - var toggle: () -> Unit - var delete: () -> Promise - var scrollTo: () -> Promise - var getSubColumns: () -> Array - var getParentColumn: () -> dynamic - var headerFilterFocus: () -> Unit - var setHeaderFilterValue: (value: Any) -> Unit - var reloadHeaderFilter: () -> Unit - var getHeaderFilterValue: () -> Any - var updateDefinition: (definition: ColumnDefinition) -> Promise - var getWidth: () -> Number - var setWidth: (width: dynamic /* Number | Boolean */) -> Unit - var validate: () -> dynamic - } - - interface CellComponent { - var getValue: () -> Any - var getOldValue: () -> Any - var restoreOldValue: () -> Any - var getInitialValue: () -> Any - var restoreInitialValue: () -> Any - var getElement: () -> HTMLElement - var getTable: () -> Tabulator - var getRow: () -> RowComponent - var getColumn: () -> ColumnComponent - var getData: () -> Any - var getField: () -> String - var setValue: (value: Any, mutate: Boolean) -> Unit - var checkHeight: () -> Unit - var edit: (ignoreEditable: Boolean) -> Unit - var cancelEdit: () -> Unit - var navigatePrev: () -> Boolean - var navigateNext: () -> Boolean - var navigateLeft: () -> Boolean - var navigateRight: () -> Boolean - var navigateUp: () -> Unit - var navigateDown: () -> Unit - var isEdited: () -> Boolean - var clearEdited: () -> Unit - var isValid: () -> Boolean - var clearValidation: () -> Unit - var validate: () -> Boolean - } - - companion object { - var defaultOptions: Options - var extendModule: (name: String, property: String, values: Any) -> Unit - var findTable: (query: String) -> Array - var registerModule: (module: Module) -> Unit - var bindModules: (__0: Any) -> Unit - } -} - -external open class Module(table: Tabulator) { - companion object { - var moduleName: String - } -} - -external open class AccessorModule - -external open class AjaxModule - -external open class ClipboardModule - -external open class ColumnCalcsModule - -external open class DataTreeModule - -external open class DownloadModule - -external open class EditModule - -external open class ExportModule - -external open class FilterModule - -external open class FormatModule - -external open class FrozenColumnsModule - -external open class FrozenRowsModule - -external open class GroupRowsModule - -external open class HistoryModule - -external open class HtmlTableImportModule - -external open class InteractionModule - -external open class KeybindingsModule - -external open class MenuModule - -external open class MoveColumnsModule - -external open class MoveRowsModule - -external open class MutatorModule - -external open class PageModule - -external open class PersistenceModule - -external open class PrintModule - -external open class PseudoRow - -external open class ReactiveDataModule - -external open class Renderer - -external open class ResizeColumnsModule - -external open class ResizeRowsModule - -external open class ResizeTableModule - -external open class ResponsiveLayoutModule - -external open class SelectRowModule - -external open class SortModule - -external open class TabulatorFull : Tabulator { - constructor(selector: String, options: Options = definedExternally) - constructor(selector: String) - constructor(selector: HTMLElement, options: Options = definedExternally) - constructor(selector: HTMLElement) -} - -external open class ValidateModule \ No newline at end of file diff --git a/visionforge-tables/src/jsMain/kotlin/tabulator/typealiases.kt b/visionforge-tables/src/jsMain/kotlin/tabulator/typealiases.kt deleted file mode 100644 index 28dced17..00000000 --- a/visionforge-tables/src/jsMain/kotlin/tabulator/typealiases.kt +++ /dev/null @@ -1,45 +0,0 @@ -@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING") - -package tabulator - -import org.w3c.dom.events.UIEvent - -@Suppress("UNUSED_TYPEALIAS_PARAMETER") -internal typealias Pick = Any - -@Suppress("UNUSED_TYPEALIAS_PARAMETER") -internal typealias Record = Any - -internal typealias FilterFunction = (field: String, type: String /* "=" | "!=" | "like" | "<" | ">" | "<=" | ">=" | "in" | "regex" | "starts" | "ends" */, value: Any, filterParams: Tabulator.FilterParams) -> Unit - -internal typealias GroupValuesArg = Array> - -internal typealias CustomMutator = (value: Any, data: Any, type: String /* "data" | "edit" */, mutatorParams: Any, cell: Tabulator.CellComponent) -> Any - -internal typealias CustomAccessor = (value: Any, data: Any, type: String /* "data" | "download" | "clipboard" */, AccessorParams: Any, column: Tabulator.ColumnComponent, row: Tabulator.RowComponent) -> Any - -internal typealias ColumnCalcParams = (values: Any, data: Any) -> Any - -internal typealias ValueStringCallback = (value: Any) -> String - -internal typealias ValueBooleanCallback = (value: Any) -> Boolean - -internal typealias ValueVoidCallback = (value: Any) -> Unit - -internal typealias EmptyCallback = (callback: () -> Unit) -> Unit - -internal typealias CellEventCallback = (e: UIEvent, cell: Tabulator.CellComponent) -> Unit - -internal typealias CellEditEventCallback = (cell: Tabulator.CellComponent) -> Unit - -internal typealias ColumnEventCallback = (e: UIEvent, column: Tabulator.ColumnComponent) -> Unit - -internal typealias RowEventCallback = (e: UIEvent, row: Tabulator.RowComponent) -> Unit - -internal typealias RowChangedCallback = (row: Tabulator.RowComponent) -> Unit - -internal typealias GroupEventCallback = (e: UIEvent, group: Tabulator.GroupComponent) -> Unit - -internal typealias JSONRecord = Record - -internal typealias ColumnSorterParamLookupFunction = (column: Tabulator.ColumnComponent, dir: String /* "asc" | "desc" */) -> Any \ No newline at end of file diff --git a/visionforge-threejs/README.md b/visionforge-threejs/README.md deleted file mode 100644 index 98c13b7a..00000000 --- a/visionforge-threejs/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-threejs - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-threejs:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-threejs:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-threejs:0.2.0") -} -``` diff --git a/visionforge-threejs/build.gradle.kts b/visionforge-threejs/build.gradle.kts index f04275f3..a6407d13 100644 --- a/visionforge-threejs/build.gradle.kts +++ b/visionforge-threejs/build.gradle.kts @@ -1,17 +1,9 @@ plugins { - id("space.kscience.gradle.js") -} - -kotlin{ - explicitApi = org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Disabled - js{ - binaries.library() - } + id("ru.mipt.npm.gradle.js") } dependencies { - api(projects.visionforgeSolid) - implementation(npm("three", "0.143.0")) - implementation(npm("three-csg-ts", "3.1.10")) - implementation(npm("three.meshline","1.4.0")) + api(project(":visionforge-solid")) + implementation(npm("three", "0.130.1")) + implementation(npm("three-csg-ts", "3.1.6")) } diff --git a/visionforge-threejs/src/main/kotlin/three/THREE.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/THREE.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt index 4dca1f62..3f8028cb 100644 --- a/visionforge-threejs/src/main/kotlin/three/THREE.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt @@ -26,7 +26,7 @@ @file:JsNonModule @file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "unused") -package three +package info.laht.threekt external val REVISION: String diff --git a/visionforge-threejs/src/main/kotlin/three/animation/AnimationAction.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationAction.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/animation/AnimationAction.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationAction.kt index 185793ff..d0e9b073 100644 --- a/visionforge-threejs/src/main/kotlin/three/animation/AnimationAction.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationAction.kt @@ -2,9 +2,9 @@ @file:JsModule("three") @file:JsNonModule -package three.animation +package info.laht.threekt.animation -import three.core.Object3D +import info.laht.threekt.core.Object3D external class AnimationAction( mixer: AnimationMixer, diff --git a/visionforge-threejs/src/main/kotlin/three/animation/AnimationClip.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationClip.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/animation/AnimationClip.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationClip.kt index dfb1df5a..262f02dc 100644 --- a/visionforge-threejs/src/main/kotlin/three/animation/AnimationClip.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationClip.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.animation +package info.laht.threekt.animation /** * An AnimationClip is a reusable set of keyframe tracks which represent an animation. diff --git a/visionforge-threejs/src/main/kotlin/three/animation/AnimationMixer.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationMixer.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/animation/AnimationMixer.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationMixer.kt index 45932e59..383f88f7 100644 --- a/visionforge-threejs/src/main/kotlin/three/animation/AnimationMixer.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationMixer.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.animation +package info.laht.threekt.animation -import three.core.Object3D +import info.laht.threekt.core.Object3D /** * The AnimationMixer is a player for animations on a particular object in the scene. diff --git a/visionforge-threejs/src/main/kotlin/three/animation/AnimationUtils.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationUtils.kt similarity index 70% rename from visionforge-threejs/src/main/kotlin/three/animation/AnimationUtils.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationUtils.kt index c0e05b3a..34a9633b 100644 --- a/visionforge-threejs/src/main/kotlin/three/animation/AnimationUtils.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/AnimationUtils.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.animation +package info.laht.threekt.animation external object AnimationUtils { //TODO diff --git a/visionforge-threejs/src/main/kotlin/three/animation/KeyFrameTrack.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/KeyFrameTrack.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/animation/KeyFrameTrack.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/KeyFrameTrack.kt index 2f3f3436..478fd1f6 100644 --- a/visionforge-threejs/src/main/kotlin/three/animation/KeyFrameTrack.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/animation/KeyFrameTrack.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.animation +package info.laht.threekt.animation import org.khronos.webgl.Float32Array diff --git a/visionforge-threejs/src/main/kotlin/three/audio/Audio.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/Audio.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/audio/Audio.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/Audio.kt index 95918ede..f6266c41 100644 --- a/visionforge-threejs/src/main/kotlin/three/audio/Audio.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/Audio.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.audio +package info.laht.threekt.audio /** * Create a non-positional ( global ) audio object. diff --git a/visionforge-threejs/src/main/kotlin/three/audio/AudioContext.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/AudioContext.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/audio/AudioContext.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/AudioContext.kt index 3908a548..3bccd0ac 100644 --- a/visionforge-threejs/src/main/kotlin/three/audio/AudioContext.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/AudioContext.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.audio +package info.laht.threekt.audio /** * This contains methods for setting up an AudioContext. diff --git a/visionforge-threejs/src/main/kotlin/three/audio/AudioListener.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/AudioListener.kt similarity index 89% rename from visionforge-threejs/src/main/kotlin/three/audio/AudioListener.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/AudioListener.kt index cbdb06f1..e99b9b13 100644 --- a/visionforge-threejs/src/main/kotlin/three/audio/AudioListener.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/AudioListener.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.audio +package info.laht.threekt.audio -import three.core.Object3D +import info.laht.threekt.core.Object3D /** * Create a non-positional ( global ) audio object. diff --git a/visionforge-threejs/src/main/kotlin/three/audio/PositionalAudio.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/PositionalAudio.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/audio/PositionalAudio.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/PositionalAudio.kt index 7c1006f4..19c17bea 100644 --- a/visionforge-threejs/src/main/kotlin/three/audio/PositionalAudio.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/audio/PositionalAudio.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.audio +package info.laht.threekt.audio /** * Create a positional audio object. diff --git a/visionforge-threejs/src/main/kotlin/three/cameras/Camera.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/Camera.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/cameras/Camera.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/Camera.kt index 5f1ba54f..6ab80298 100644 --- a/visionforge-threejs/src/main/kotlin/three/cameras/Camera.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/Camera.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.cameras +package info.laht.threekt.cameras -import three.core.Object3D -import three.math.Matrix4 -import three.math.Vector3 +import info.laht.threekt.core.Object3D +import info.laht.threekt.math.Matrix4 +import info.laht.threekt.math.Vector3 external interface View { var enabled: Boolean diff --git a/visionforge-threejs/src/main/kotlin/three/cameras/OrthographicCamera.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/OrthographicCamera.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/cameras/OrthographicCamera.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/OrthographicCamera.kt index 706c8746..320d71b5 100644 --- a/visionforge-threejs/src/main/kotlin/three/cameras/OrthographicCamera.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/OrthographicCamera.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.cameras +package info.laht.threekt.cameras external class OrthographicCamera( varleft: Int, diff --git a/visionforge-threejs/src/main/kotlin/three/cameras/PerspectiveCamera.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/PerspectiveCamera.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/cameras/PerspectiveCamera.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/PerspectiveCamera.kt index a5b12de8..4deee300 100644 --- a/visionforge-threejs/src/main/kotlin/three/cameras/PerspectiveCamera.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/cameras/PerspectiveCamera.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.cameras +package info.laht.threekt.cameras external class PerspectiveCamera(fov: Int, aspect: Double, near: Number, far: Number) : Camera { diff --git a/visionforge-threejs/src/main/kotlin/three/core/BufferAttribute.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/BufferAttribute.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/core/BufferAttribute.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/BufferAttribute.kt index e045b2d6..6a773330 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/BufferAttribute.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/BufferAttribute.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core -import three.math.Color -import three.math.Vector2 -import three.math.Vector3 -import three.math.Vector4 +import info.laht.threekt.math.Color +import info.laht.threekt.math.Vector2 +import info.laht.threekt.math.Vector3 +import info.laht.threekt.math.Vector4 abstract external class BufferAttribute protected constructor( array: dynamic, diff --git a/visionforge-threejs/src/main/kotlin/three/core/BufferGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/BufferGeometry.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/core/BufferGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/BufferGeometry.kt index 5038aee7..251627a7 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/BufferGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/BufferGeometry.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core -import three.math.Box3 -import three.math.Matrix4 -import three.math.Sphere -import three.math.Vector3 +import info.laht.threekt.math.Box3 +import info.laht.threekt.math.Matrix4 +import info.laht.threekt.math.Sphere +import info.laht.threekt.math.Vector3 /** * This class is an efficient alternative to Geometry, because it stores all data, including vertex positions, diff --git a/visionforge-threejs/src/main/kotlin/three/core/Clock.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Clock.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/core/Clock.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Clock.kt index e5925f56..8cce902c 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/Clock.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Clock.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core /** * Object for keeping track of time. diff --git a/visionforge-threejs/src/main/kotlin/three/core/EventDispatcher.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/EventDispatcher.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/core/EventDispatcher.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/EventDispatcher.kt index 1646775e..459da88b 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/EventDispatcher.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/EventDispatcher.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core external open class EventDispatcher { diff --git a/visionforge-threejs/src/main/kotlin/three/core/Face3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Face3.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/core/Face3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Face3.kt index a7ec7f0b..ff48d022 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/Face3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Face3.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core -import three.math.Color -import three.math.Vector3 +import info.laht.threekt.math.Color +import info.laht.threekt.math.Vector3 external class Face3 { diff --git a/visionforge-threejs/src/main/kotlin/three/core/InstancedBufferGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/InstancedBufferGeometry.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/core/InstancedBufferGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/InstancedBufferGeometry.kt index 99c4df70..92137432 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/InstancedBufferGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/InstancedBufferGeometry.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core external class InstancedBufferGeometry : BufferGeometry { diff --git a/visionforge-threejs/src/main/kotlin/three/core/Layers.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Layers.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/core/Layers.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Layers.kt index 6d29399c..503878d1 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/Layers.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Layers.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core /** * A Layers object assigns an Object3D to 1 or more of 32 layers numbered 0 to 31 - internally the diff --git a/visionforge-threejs/src/main/kotlin/three/core/Object3D.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Object3D.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/core/Object3D.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Object3D.kt index 86739f76..e49add5e 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/Object3D.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Object3D.kt @@ -26,9 +26,9 @@ @file:JsNonModule -package three.core +package info.laht.threekt.core -import three.math.* +import info.laht.threekt.math.* /** * This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space. diff --git a/visionforge-threejs/src/main/kotlin/three/core/Raycaster.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Raycaster.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/core/Raycaster.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Raycaster.kt index e03844f6..2e2944af 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/Raycaster.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Raycaster.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core -import three.cameras.Camera -import three.math.Ray -import three.math.Vector2 -import three.math.Vector3 +import info.laht.threekt.cameras.Camera +import info.laht.threekt.math.Ray +import info.laht.threekt.math.Vector2 +import info.laht.threekt.math.Vector3 external interface Params { var Mesh: dynamic diff --git a/visionforge-threejs/src/main/kotlin/three/core/Uniform.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Uniform.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/core/Uniform.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Uniform.kt index a2bef114..a92cdf2a 100644 --- a/visionforge-threejs/src/main/kotlin/three/core/Uniform.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/core/Uniform.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.core +package info.laht.threekt.core external class Uniform { diff --git a/visionforge-threejs/src/main/kotlin/three/external/Detector.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/Detector.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/external/Detector.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/Detector.kt index 3dc1ed28..716e5d74 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/Detector.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/Detector.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.external +package info.laht.threekt.external import org.w3c.dom.Element diff --git a/visionforge-threejs/src/main/kotlin/three/external/ImprovedNoise.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/ImprovedNoise.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/external/ImprovedNoise.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/ImprovedNoise.kt index 4ee3942d..bc380022 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/ImprovedNoise.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/ImprovedNoise.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.external +package info.laht.threekt.external external object ImprovedNoise { diff --git a/visionforge-threejs/src/main/kotlin/three/external/SimplexNoise.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/SimplexNoise.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/external/SimplexNoise.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/SimplexNoise.kt index 6856c354..f8ab5a82 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/SimplexNoise.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/SimplexNoise.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.external +package info.laht.threekt.external external object SimplexNoise { diff --git a/visionforge-threejs/src/main/kotlin/three/external/controls/FlyControls.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/FlyControls.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/external/controls/FlyControls.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/FlyControls.kt index 77de67e0..11e25207 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/controls/FlyControls.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/FlyControls.kt @@ -25,10 +25,10 @@ @file:JsModule("three/examples/jsm/controls/FlyControls.js") @file:JsNonModule -package three.external.controls +package info.laht.threekt.external.controls +import info.laht.threekt.core.Object3D import org.w3c.dom.Node -import three.core.Object3D external class FlyControls(`object`: Object3D, domElement: Node = definedExternally) { diff --git a/visionforge-threejs/src/main/kotlin/three/external/controls/OrbitControls.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/OrbitControls.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/external/controls/OrbitControls.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/OrbitControls.kt index 94223fc4..db7f2ac9 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/controls/OrbitControls.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/OrbitControls.kt @@ -25,11 +25,11 @@ @file:JsModule("three/examples/jsm/controls/OrbitControls.js") @file:JsNonModule -package three.external.controls +package info.laht.threekt.external.controls +import info.laht.threekt.core.Object3D +import info.laht.threekt.math.Vector3 import org.w3c.dom.Node -import three.core.Object3D -import three.math.Vector3 /** * This set of controls performs orbiting, dollying (zooming), and panning. diff --git a/visionforge-threejs/src/main/kotlin/three/external/controls/TrackballControls.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/TrackballControls.kt similarity index 90% rename from visionforge-threejs/src/main/kotlin/three/external/controls/TrackballControls.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/TrackballControls.kt index 64998dc2..b128553e 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/controls/TrackballControls.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/TrackballControls.kt @@ -9,13 +9,13 @@ @file:JsModule("three/examples/jsm/controls/TrackballControls.js") @file:JsNonModule -package three.external.controls +package info.laht.threekt.external.controls +import info.laht.threekt.cameras.Camera +import info.laht.threekt.core.EventDispatcher +import info.laht.threekt.math.Vector3 import org.w3c.dom.HTMLElement import org.w3c.dom.Node -import three.cameras.Camera -import three.core.EventDispatcher -import three.math.Vector3 external interface `T$0` { var left: Number diff --git a/visionforge-threejs/src/main/kotlin/three/external/controls/TransformControls.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/TransformControls.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/external/controls/TransformControls.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/TransformControls.kt index e03da682..0a1c7a43 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/controls/TransformControls.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/controls/TransformControls.kt @@ -25,10 +25,10 @@ @file:JsModule("three/examples/jsm/controls/TransformControls.js") @file:JsNonModule -package three.external.controls +package info.laht.threekt.external.controls +import info.laht.threekt.core.Object3D import org.w3c.dom.Node -import three.core.Object3D external class TransformControls(`object`: Object3D, domElement: Node = definedExternally) : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/external/exporters/OBJExporter.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/exporters/OBJExporter.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/external/exporters/OBJExporter.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/exporters/OBJExporter.kt index 843a9f72..36eefa9f 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/exporters/OBJExporter.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/exporters/OBJExporter.kt @@ -25,9 +25,9 @@ @file:JsModule("three/examples/jsm/exporters/OBJExporter.js") @file:JsNonModule -package three.external.exporters +package info.laht.threekt.external.exporters -import three.core.Object3D +import info.laht.threekt.core.Object3D external class OBJExporter { diff --git a/visionforge-threejs/src/main/kotlin/three/external/exporters/STLExporter.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/exporters/STLExporter.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/external/exporters/STLExporter.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/exporters/STLExporter.kt index a89c1179..4c6e3fb1 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/exporters/STLExporter.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/exporters/STLExporter.kt @@ -25,10 +25,10 @@ @file:JsModule("three/examples/jsm/exporters/STLExporter.js") @file:JsNonModule -package three.external.exporters +package info.laht.threekt.external.exporters +import info.laht.threekt.core.Object3D import org.khronos.webgl.DataView -import three.core.Object3D external class STLExporter { diff --git a/visionforge-threejs/src/main/kotlin/three/external/geometries/ConvexGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/geometries/ConvexGeometry.kt similarity index 61% rename from visionforge-threejs/src/main/kotlin/three/external/geometries/ConvexGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/geometries/ConvexGeometry.kt index 6c981460..cbc0fbb5 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/geometries/ConvexGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/geometries/ConvexGeometry.kt @@ -1,10 +1,10 @@ @file:JsModule("three/examples/jsm/geometries/ConvexGeometry.js") @file:JsNonModule -package three.external.geometries +package info.laht.threekt.external.geometries -import three.core.BufferGeometry -import three.math.Vector3 +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.math.Vector3 external class ConvexGeometry(points: Array) : BufferGeometry diff --git a/visionforge-threejs/src/main/kotlin/three/external/libs/GUIParams.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/GUIParams.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/external/libs/GUIParams.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/GUIParams.kt index 4b48bcc2..13d08a29 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/libs/GUIParams.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/GUIParams.kt @@ -1,4 +1,4 @@ -package three.external.libs +package info.laht.threekt.external.libs /** * @param name The name of this GUI diff --git a/visionforge-threejs/src/main/kotlin/three/external/libs/Stats.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/Stats.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/external/libs/Stats.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/Stats.kt index fd72886e..a6c2e86f 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/libs/Stats.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/Stats.kt @@ -25,7 +25,7 @@ @file:JsModule("three/examples/jsm/libs/stats.module.js") @file:JsNonModule -package three.external.libs +package info.laht.threekt.external.libs import org.w3c.dom.Node diff --git a/visionforge-threejs/src/main/kotlin/three/external/libs/datgui.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/datgui.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/external/libs/datgui.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/datgui.kt index 345d0cf5..c3496ea0 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/libs/datgui.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/libs/datgui.kt @@ -24,7 +24,7 @@ @file:JsModule("three/examples/jsm/libs/dat.gui.module.js") @file:JsNonModule -package three.external.libs +package info.laht.threekt.external.libs import org.w3c.dom.Element diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/BabylonLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/BabylonLoader.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/BabylonLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/BabylonLoader.kt index 437beba6..2eae2988 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/BabylonLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/BabylonLoader.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders +import info.laht.threekt.core.Object3D +import info.laht.threekt.loaders.LoadingManager import org.w3c.xhr.XMLHttpRequest -import three.core.Object3D -import three.loaders.LoadingManager external class BabylonLoader( manager: LoadingManager = definedExternally diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/GLTFLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/GLTFLoader.kt similarity index 89% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/GLTFLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/GLTFLoader.kt index 40fdd556..e353372e 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/GLTFLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/GLTFLoader.kt @@ -1,14 +1,14 @@ @file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders +import info.laht.threekt.animation.AnimationClip +import info.laht.threekt.cameras.Camera +import info.laht.threekt.loaders.LoadingManager +import info.laht.threekt.scenes.Scene import org.khronos.webgl.ArrayBuffer import org.w3c.xhr.XMLHttpRequest -import three.animation.AnimationClip -import three.cameras.Camera -import three.loaders.LoadingManager -import three.scenes.Scene external interface GLTFOnLoadCallback { val animations: Array diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/LoaderSupport.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/LoaderSupport.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/LoaderSupport.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/LoaderSupport.kt index 5636fdc9..de1bafcd 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/LoaderSupport.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/LoaderSupport.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders external object LoaderSupport { diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/MTLLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/MTLLoader.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/MTLLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/MTLLoader.kt index 1eecd588..9af877f5 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/MTLLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/MTLLoader.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders +import info.laht.threekt.core.Object3D +import info.laht.threekt.loaders.LoadingManager import org.w3c.xhr.XMLHttpRequest -import three.core.Object3D -import three.loaders.LoadingManager external class MTLLoader( loadingManager: LoadingManager = definedExternally diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/OBJLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/OBJLoader.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/OBJLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/OBJLoader.kt index 0bddd83a..ff4f2150 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/OBJLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/OBJLoader.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders +import info.laht.threekt.core.Object3D +import info.laht.threekt.loaders.LoadingManager +import info.laht.threekt.objects.Mesh import org.w3c.xhr.XMLHttpRequest -import three.core.Object3D -import three.loaders.LoadingManager -import three.objects.Mesh /** * A loader for loading a .obj resource. diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/OBJLoader2.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/OBJLoader2.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/OBJLoader2.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/OBJLoader2.kt index e12ad3fe..009e5e81 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/OBJLoader2.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/OBJLoader2.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders +import info.laht.threekt.loaders.LoadingManager +import info.laht.threekt.objects.Mesh import org.w3c.xhr.XMLHttpRequest -import three.loaders.LoadingManager -import three.objects.Mesh external interface Detail { var loaderRootNode: Mesh diff --git a/visionforge-threejs/src/main/kotlin/three/external/loaders/STLLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/STLLoader.kt similarity index 80% rename from visionforge-threejs/src/main/kotlin/three/external/loaders/STLLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/STLLoader.kt index e3e6133f..707fdc0c 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/loaders/STLLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/loaders/STLLoader.kt @@ -22,19 +22,17 @@ * THE SOFTWARE. */ -@file:JsModule("three/examples/jsm/loaders/STLLoader.js") +@file:JsModule("three") @file:JsNonModule -package three.external.loaders +package info.laht.threekt.external.loaders -import org.khronos.webgl.ArrayBuffer +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Object3D import org.w3c.xhr.XMLHttpRequest -import three.core.BufferGeometry external class STLLoader { - var requestHeader: List - fun load( url: String, onLoad: (BufferGeometry) -> Unit, @@ -42,10 +40,7 @@ external class STLLoader { onError: () -> Unit = definedExternally ) - fun parse(data: String): BufferGeometry - - fun parse(data: ByteArray): BufferGeometry - - fun parse(data: ArrayBuffer): BufferGeometry + fun parse(data: String): Object3D + fun parse(data: ByteArray): Object3D } \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/external/objects/Sky.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/Sky.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/external/objects/Sky.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/Sky.kt index c7272138..47ad39ef 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/objects/Sky.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/Sky.kt @@ -25,8 +25,8 @@ @file:JsModule("three") @file:JsNonModule -package three.external.objects +package info.laht.threekt.external.objects -import three.objects.Mesh +import info.laht.threekt.objects.Mesh external class Sky : Mesh \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/external/objects/Water.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/Water.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/external/objects/Water.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/Water.kt index 9a886a95..9ad3f043 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/objects/Water.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/Water.kt @@ -25,8 +25,8 @@ @file:JsModule("three") @file:JsNonModule -package three.external.objects +package info.laht.threekt.external.objects -import three.objects.Mesh +import info.laht.threekt.objects.Mesh external class Water(width: Int, height: Int, options: WaterOptions = definedExternally) : Mesh \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/external/objects/WaterOptions.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/WaterOptions.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/external/objects/WaterOptions.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/WaterOptions.kt index 498f9883..74434846 100644 --- a/visionforge-threejs/src/main/kotlin/three/external/objects/WaterOptions.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/external/objects/WaterOptions.kt @@ -22,10 +22,10 @@ * THE SOFTWARE. */ -package three.external.objects +package info.laht.threekt.external.objects -import three.math.Vector3 -import three.textures.Texture +import info.laht.threekt.math.Vector3 +import info.laht.threekt.textures.Texture data class WaterOptions( diff --git a/visionforge-threejs/src/main/kotlin/three/extras/SceneUtils.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/SceneUtils.kt similarity index 87% rename from visionforge-threejs/src/main/kotlin/three/extras/SceneUtils.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/SceneUtils.kt index 1ad837d0..fb4338fd 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/SceneUtils.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/SceneUtils.kt @@ -1,13 +1,13 @@ @file:JsModule("three") @file:JsNonModule -package three.extras +package info.laht.threekt.extras -import three.core.BufferGeometry -import three.core.Object3D -import three.materials.Material -import three.objects.Group -import three.scenes.Scene +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Object3D +import info.laht.threekt.materials.Material +import info.laht.threekt.objects.Group +import info.laht.threekt.scenes.Scene /** * A class containing useful utility functions for scene manipulation. diff --git a/visionforge-threejs/src/main/kotlin/three/extras/core/Curve.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Curve.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/extras/core/Curve.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Curve.kt index 4b688b1a..f5a8ced6 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/core/Curve.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Curve.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.core +package info.laht.threekt.extras.core external abstract class Curve { diff --git a/visionforge-threejs/src/main/kotlin/three/extras/core/CurvePath.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/CurvePath.kt similarity index 89% rename from visionforge-threejs/src/main/kotlin/three/extras/core/CurvePath.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/CurvePath.kt index 5a05ab14..18ae2165 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/core/CurvePath.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/CurvePath.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.core +package info.laht.threekt.extras.core open external class CurvePath : Curve { diff --git a/visionforge-threejs/src/main/kotlin/three/extras/core/Path.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Path.kt similarity index 61% rename from visionforge-threejs/src/main/kotlin/three/extras/core/Path.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Path.kt index bd78a31d..7b944a7c 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/core/Path.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Path.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.core +package info.laht.threekt.extras.core -import three.math.Vector2 +import info.laht.threekt.math.Vector2 open external class Path : CurvePath { diff --git a/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Shape.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Shape.kt new file mode 100644 index 00000000..0b584f1f --- /dev/null +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/Shape.kt @@ -0,0 +1,8 @@ +@file:JsModule("three") +@file:JsNonModule + +package info.laht.threekt.extras.core + +import info.laht.threekt.math.Vector2 + +external class Shape(points: Array) : Path \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/ShapePath.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/ShapePath.kt new file mode 100644 index 00000000..bd6e69b9 --- /dev/null +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/core/ShapePath.kt @@ -0,0 +1,6 @@ +@file:JsModule("three") +@file:JsNonModule + +package info.laht.threekt.extras.core + +external class ShapePath \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/ArcCurve.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/ArcCurve.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/ArcCurve.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/ArcCurve.kt index c3891ff1..a6f2d172 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/ArcCurve.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/ArcCurve.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves external class ArcCurve( aX: Number = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/CatmullRomCurve3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/CatmullRomCurve3.kt similarity index 79% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/CatmullRomCurve3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/CatmullRomCurve3.kt index e968cfb0..93a5d931 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/CatmullRomCurve3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/CatmullRomCurve3.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector3 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector3 external class CatmullRomCurve3( diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/EllipseCurve.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/EllipseCurve.kt similarity index 85% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/EllipseCurve.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/EllipseCurve.kt index dbcaec3f..d3ead4c5 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/EllipseCurve.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/EllipseCurve.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector2 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector2 open external class EllipseCurve( aX: Number = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/LineCurve.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/LineCurve.kt similarity index 66% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/LineCurve.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/LineCurve.kt index 74c2d239..ca9dc41b 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/LineCurve.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/LineCurve.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector2 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector2 external class LineCurve( v1: Vector2 = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/LineCurve3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/LineCurve3.kt similarity index 67% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/LineCurve3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/LineCurve3.kt index 68f14b72..90218d60 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/LineCurve3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/LineCurve3.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector3 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector3 external class LineCurve3( v1: Vector3 = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/QuadricBezierCurve.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/QuadricBezierCurve.kt similarity index 74% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/QuadricBezierCurve.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/QuadricBezierCurve.kt index 849b41c0..aa7b2a95 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/QuadricBezierCurve.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/QuadricBezierCurve.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector2 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector2 external class QuadricBezierCurve : Curve { diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/QuadricBezierCurve3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/QuadricBezierCurve3.kt similarity index 74% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/QuadricBezierCurve3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/QuadricBezierCurve3.kt index 0da5444f..b4b30426 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/QuadricBezierCurve3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/QuadricBezierCurve3.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector3 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector3 external class QuadricBezierCurve3 : Curve { diff --git a/visionforge-threejs/src/main/kotlin/three/extras/curves/SplineCurve.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/SplineCurve.kt similarity index 67% rename from visionforge-threejs/src/main/kotlin/three/extras/curves/SplineCurve.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/SplineCurve.kt index 357cf50f..df3fb8cd 100644 --- a/visionforge-threejs/src/main/kotlin/three/extras/curves/SplineCurve.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/extras/curves/SplineCurve.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.extras.curves +package info.laht.threekt.extras.curves -import three.extras.core.Curve -import three.math.Vector2 +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector2 external class SplineCurve( points: Array = definedExternally diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/BoxGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/BoxGeometry.kt similarity index 77% rename from visionforge-threejs/src/main/kotlin/three/geometries/BoxGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/BoxGeometry.kt index d80a96a2..8d0e5ec5 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/BoxGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/BoxGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry external class BoxGeometry( diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/ConeGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/ConeGeometry.kt similarity index 79% rename from visionforge-threejs/src/main/kotlin/three/geometries/ConeGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/ConeGeometry.kt index 7492d5ec..f98ad2dd 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/ConeGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/ConeGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry external class ConeGeometry( diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/CylinderGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/CylinderGeometry.kt similarity index 78% rename from visionforge-threejs/src/main/kotlin/three/geometries/CylinderGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/CylinderGeometry.kt index f2f1160c..b10e5c11 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/CylinderGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/CylinderGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry external class CylinderGeometry( radiusTop: Number, diff --git a/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/EdgesGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/EdgesGeometry.kt new file mode 100644 index 00000000..b0a5c91b --- /dev/null +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/EdgesGeometry.kt @@ -0,0 +1,8 @@ +@file:JsModule("three") +@file:JsNonModule + +package info.laht.threekt.geometries + +import info.laht.threekt.core.BufferGeometry + +public external class EdgesGeometry(geometry: BufferGeometry, thresholdAngle: Int = definedExternally) : BufferGeometry \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/ExtrudeGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/ExtrudeGeometry.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/geometries/ExtrudeGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/ExtrudeGeometry.kt index 5c256878..4b30e7af 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/ExtrudeGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/ExtrudeGeometry.kt @@ -8,11 +8,11 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry -import three.extras.core.Shape -import three.math.Vector2 +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.extras.core.Shape +import info.laht.threekt.math.Vector2 external interface ExtrudeGeometryOptions { var curveSegments: Number? diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/PlaneGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/PlaneGeometry.kt similarity index 67% rename from visionforge-threejs/src/main/kotlin/three/geometries/PlaneGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/PlaneGeometry.kt index aff535a2..0b1072ef 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/PlaneGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/PlaneGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry external class PlaneGeometry( diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/SphereGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/SphereGeometry.kt similarity index 78% rename from visionforge-threejs/src/main/kotlin/three/geometries/SphereGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/SphereGeometry.kt index 2b9e5279..5b0c9fc6 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/SphereGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/SphereGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry external class SphereGeometry( radius: Number, diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/TextGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TextGeometry.kt similarity index 96% rename from visionforge-threejs/src/main/kotlin/three/geometries/TextGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TextGeometry.kt index aab53955..b8c935f3 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/TextGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TextGeometry.kt @@ -1,7 +1,7 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries external interface TextGeometryParameters { diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/TorusGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TorusGeometry.kt similarity index 73% rename from visionforge-threejs/src/main/kotlin/three/geometries/TorusGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TorusGeometry.kt index 493b7984..0a53525f 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/TorusGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TorusGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry external class TorusGeometry( diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/TubeGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TubeGeometry.kt similarity index 72% rename from visionforge-threejs/src/main/kotlin/three/geometries/TubeGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TubeGeometry.kt index e1dc9a75..36afa6ae 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/TubeGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/TubeGeometry.kt @@ -1,8 +1,8 @@ -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry -import three.extras.core.Curve -import three.math.Vector3 +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.extras.core.Curve +import info.laht.threekt.math.Vector3 /** diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/WireframeGeometry.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/WireframeGeometry.kt similarity index 68% rename from visionforge-threejs/src/main/kotlin/three/geometries/WireframeGeometry.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/WireframeGeometry.kt index 622ef80d..f52c61cc 100644 --- a/visionforge-threejs/src/main/kotlin/three/geometries/WireframeGeometry.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/geometries/WireframeGeometry.kt @@ -1,9 +1,9 @@ @file:JsModule("three") @file:JsNonModule -package three.geometries +package info.laht.threekt.geometries -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry /** * This can be used as a helper object to view a Geometry object as a wireframe. diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/ArrowHelper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/ArrowHelper.kt similarity index 87% rename from visionforge-threejs/src/main/kotlin/three/helpers/ArrowHelper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/ArrowHelper.kt index 18c0d8de..ea1764dd 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/ArrowHelper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/ArrowHelper.kt @@ -25,13 +25,13 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.core.Object3D -import three.math.Color -import three.math.Vector3 -import three.objects.Line -import three.objects.Mesh +import info.laht.threekt.core.Object3D +import info.laht.threekt.math.Color +import info.laht.threekt.math.Vector3 +import info.laht.threekt.objects.Line +import info.laht.threekt.objects.Mesh external class ArrowHelper( dir: Vector3, diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/AxesHelper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/AxesHelper.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/helpers/AxesHelper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/AxesHelper.kt index 5927991f..d4b515be 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/AxesHelper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/AxesHelper.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.objects.LineSegments +import info.laht.threekt.objects.LineSegments external class AxesHelper( size: Int = definedExternally diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/Box3Helper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/Box3Helper.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/helpers/Box3Helper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/Box3Helper.kt index 1eefb43b..27aef631 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/Box3Helper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/Box3Helper.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.math.Box3 -import three.objects.LineSegments +import info.laht.threekt.math.Box3 +import info.laht.threekt.objects.LineSegments /** * Helper object to visualize a Box3. diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/CameraHelper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/CameraHelper.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/helpers/CameraHelper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/CameraHelper.kt index 716f8234..6b199f3f 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/CameraHelper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/CameraHelper.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.cameras.Camera -import three.objects.LineSegments +import info.laht.threekt.cameras.Camera +import info.laht.threekt.objects.LineSegments external class CameraHelper( camera: Camera diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/GridHelper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/GridHelper.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/helpers/GridHelper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/GridHelper.kt index 0c080ead..0d987ae5 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/GridHelper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/GridHelper.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.objects.LineSegments +import info.laht.threekt.objects.LineSegments external class GridHelper( size: Int = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/HemisphereLightHelper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/HemisphereLightHelper.kt similarity index 91% rename from visionforge-threejs/src/main/kotlin/three/helpers/HemisphereLightHelper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/HemisphereLightHelper.kt index 23f21837..4351faa7 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/HemisphereLightHelper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/HemisphereLightHelper.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.core.Object3D -import three.lights.HemisphereLight -import three.lights.Light +import info.laht.threekt.core.Object3D +import info.laht.threekt.lights.HemisphereLight +import info.laht.threekt.lights.Light /** * Creates a visual aid consisting of a spherical Mesh for a HemisphereLight. diff --git a/visionforge-threejs/src/main/kotlin/three/helpers/PlaneHelper.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/PlaneHelper.kt similarity index 58% rename from visionforge-threejs/src/main/kotlin/three/helpers/PlaneHelper.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/PlaneHelper.kt index 338c9593..dbe6dc8d 100644 --- a/visionforge-threejs/src/main/kotlin/three/helpers/PlaneHelper.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/helpers/PlaneHelper.kt @@ -1,10 +1,10 @@ @file:JsModule("three") @file:JsNonModule -package three.helpers +package info.laht.threekt.helpers -import three.math.Color -import three.math.Plane -import three.objects.LineSegments +import info.laht.threekt.math.Color +import info.laht.threekt.math.Plane +import info.laht.threekt.objects.LineSegments /** * Helper object to visualize a [Plane]. diff --git a/visionforge-threejs/src/main/kotlin/info/laht/threekt/ktutils.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/ktutils.kt new file mode 100644 index 00000000..a0ef343e --- /dev/null +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/ktutils.kt @@ -0,0 +1,9 @@ +@file:Suppress("FunctionName") + +package info.laht.threekt + +import info.laht.threekt.renderers.WebGLRenderer +import info.laht.threekt.renderers.WebGLRendererParams + +fun WebGLRenderer(builder: WebGLRendererParams.() -> Unit): WebGLRenderer = + WebGLRenderer(WebGLRendererParams().apply(builder)) \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/lights/AmbientLight.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/AmbientLight.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/lights/AmbientLight.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/AmbientLight.kt index b5ddd88d..0d2cae66 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/AmbientLight.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/AmbientLight.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights /** * This light globally illuminates all objects in the scene equally. diff --git a/visionforge-threejs/src/main/kotlin/three/lights/DirectionalLight.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/DirectionalLight.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/lights/DirectionalLight.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/DirectionalLight.kt index 482fd628..f85d3e24 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/DirectionalLight.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/DirectionalLight.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights -import three.core.Object3D +import info.laht.threekt.core.Object3D external class DirectionalLight( color: Int = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/lights/DirectionalLightShadow.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/DirectionalLightShadow.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/lights/DirectionalLightShadow.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/DirectionalLightShadow.kt index 205c46bb..e2886e0b 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/DirectionalLightShadow.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/DirectionalLightShadow.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights external class DirectionalLightShadow : LightShadow { diff --git a/visionforge-threejs/src/main/kotlin/three/lights/HemisphereLight.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/HemisphereLight.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/lights/HemisphereLight.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/HemisphereLight.kt index bf761479..c98fbd5d 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/HemisphereLight.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/HemisphereLight.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights -import three.math.Color +import info.laht.threekt.math.Color /** * A light source positioned directly above the scene, with color fading from the sky color to the ground color. diff --git a/visionforge-threejs/src/main/kotlin/three/lights/Light.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/Light.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/lights/Light.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/Light.kt index d0c07d15..6ffd9a2d 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/Light.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/Light.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights -import three.core.Object3D -import three.math.Color +import info.laht.threekt.core.Object3D +import info.laht.threekt.math.Color /** * Abstract base class for lights - all other light types inherit the properties and methods described here. diff --git a/visionforge-threejs/src/main/kotlin/three/lights/LightShadow.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/LightShadow.kt similarity index 90% rename from visionforge-threejs/src/main/kotlin/three/lights/LightShadow.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/LightShadow.kt index b7fc1f12..ef62b843 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/LightShadow.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/LightShadow.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights -import three.cameras.Camera -import three.math.Matrix4 -import three.math.Vector2 +import info.laht.threekt.cameras.Camera +import info.laht.threekt.math.Matrix4 +import info.laht.threekt.math.Vector2 open external class LightShadow(camera: Camera) { diff --git a/visionforge-threejs/src/main/kotlin/three/lights/PointLight.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/PointLight.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/lights/PointLight.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/PointLight.kt index 9ff6627a..6a708e58 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/PointLight.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/PointLight.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights external class PointLight( color: Int = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/lights/SpotLight.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/SpotLight.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/lights/SpotLight.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/SpotLight.kt index ebd422f7..70c14e6a 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/SpotLight.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/SpotLight.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights -import three.core.Object3D +import info.laht.threekt.core.Object3D external class SpotLight( color: Int = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/lights/SpotLightShadow.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/SpotLightShadow.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/lights/SpotLightShadow.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/SpotLightShadow.kt index 14df1315..8d8e052f 100644 --- a/visionforge-threejs/src/main/kotlin/three/lights/SpotLightShadow.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/lights/SpotLightShadow.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.lights +package info.laht.threekt.lights external class SpotLightShadow : LightShadow { diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/Cache.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/Cache.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/loaders/Cache.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/Cache.kt index 38278cf1..1424d8e7 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/Cache.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/Cache.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders external object Cache { diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/CompressedTextureLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/CompressedTextureLoader.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/loaders/CompressedTextureLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/CompressedTextureLoader.kt index d827d4a5..889c5d18 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/CompressedTextureLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/CompressedTextureLoader.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders +import info.laht.threekt.textures.Texture import org.w3c.xhr.XMLHttpRequest -import three.textures.Texture /** * Abstract base class for block based textures loader (dds, pvr, ...). diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/ImageLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/ImageLoader.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/loaders/ImageLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/ImageLoader.kt index 555f268b..ade47d72 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/ImageLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/ImageLoader.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders import org.w3c.dom.Element import org.w3c.xhr.XMLHttpRequest diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/JSONLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/JSONLoader.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/loaders/JSONLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/JSONLoader.kt index 8871b540..db38edb6 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/JSONLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/JSONLoader.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Object3D +import info.laht.threekt.materials.Material import org.w3c.xhr.XMLHttpRequest -import three.core.BufferGeometry -import three.core.Object3D -import three.materials.Material /** * A loader for loading objects in JSON format. This uses the FileLoader internally for loading files. diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/Loader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/Loader.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/loaders/Loader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/Loader.kt index d094b6d9..2d60ee93 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/Loader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/Loader.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders /** * Base class for implementing loaders. diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/LoadingManager.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/LoadingManager.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/loaders/LoadingManager.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/LoadingManager.kt index e9180dad..ebf5d2bc 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/LoadingManager.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/LoadingManager.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders external object DefaultLoadingManager : LoadingManager diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/MaterialLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/MaterialLoader.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/loaders/MaterialLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/MaterialLoader.kt index f294ffd5..ef30c71f 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/MaterialLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/MaterialLoader.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders +import info.laht.threekt.materials.Material +import info.laht.threekt.textures.Texture import org.w3c.xhr.XMLHttpRequest -import three.materials.Material -import three.textures.Texture external class MaterialLoader { diff --git a/visionforge-threejs/src/main/kotlin/three/loaders/TextureLoader.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/TextureLoader.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/loaders/TextureLoader.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/TextureLoader.kt index 5ddac48b..5d57ab88 100644 --- a/visionforge-threejs/src/main/kotlin/three/loaders/TextureLoader.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/loaders/TextureLoader.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.loaders +package info.laht.threekt.loaders +import info.laht.threekt.textures.Texture import org.w3c.xhr.XMLHttpRequest -import three.textures.Texture /** * Class for loading a texture. This uses the ImageLoader internally for loading files. diff --git a/visionforge-threejs/src/main/kotlin/three/materials/LineBasicMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/LineBasicMaterial.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/materials/LineBasicMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/LineBasicMaterial.kt index 1445c427..308e5a52 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/LineBasicMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/LineBasicMaterial.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color +import info.laht.threekt.math.Color open external class LineBasicMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/LineDashedMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/LineDashedMaterial.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/materials/LineDashedMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/LineDashedMaterial.kt index aa2a5d6a..79ad5ada 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/LineDashedMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/LineDashedMaterial.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials external class LineDashedMaterial : LineBasicMaterial { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/Material.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/Material.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/materials/Material.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/Material.kt index 2edbca90..9a2b72d0 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/Material.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/Material.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials @JsName("Material") open external class Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshBasicMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshBasicMaterial.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshBasicMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshBasicMaterial.kt index f1ee1f27..96eae5e0 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshBasicMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshBasicMaterial.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color -import three.textures.Texture +import info.laht.threekt.math.Color +import info.laht.threekt.textures.Texture external class MeshBasicMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshDepthMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshDepthMaterial.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshDepthMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshDepthMaterial.kt index 584bcab6..185dce93 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshDepthMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshDepthMaterial.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.textures.Texture +import info.laht.threekt.textures.Texture external class MeshDepthMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshLambertMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshLambertMaterial.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshLambertMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshLambertMaterial.kt index 089c96c1..dcd0670a 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshLambertMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshLambertMaterial.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color -import three.textures.Texture +import info.laht.threekt.math.Color +import info.laht.threekt.textures.Texture external class MeshLambertMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshNormalMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshNormalMaterial.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshNormalMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshNormalMaterial.kt index 5972a702..ea7c0960 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshNormalMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshNormalMaterial.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Vector2 -import three.textures.Texture +import info.laht.threekt.math.Vector2 +import info.laht.threekt.textures.Texture external class MeshNormalMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshPhongMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshPhongMaterial.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshPhongMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshPhongMaterial.kt index eaabf8ca..693ba8b4 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshPhongMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshPhongMaterial.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color -import three.math.Vector2 -import three.textures.Texture +import info.laht.threekt.math.Color +import info.laht.threekt.math.Vector2 +import info.laht.threekt.textures.Texture external class MeshPhongMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshPhysicalMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshPhysicalMaterial.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshPhysicalMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshPhysicalMaterial.kt index e6674917..42fef98f 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshPhysicalMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshPhysicalMaterial.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials external class MeshPhysicalMaterial : MeshStandardMaterial { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/MeshStandardMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshStandardMaterial.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/materials/MeshStandardMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshStandardMaterial.kt index 137ee095..19b6901e 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/MeshStandardMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/MeshStandardMaterial.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color -import three.math.Vector2 -import three.textures.Texture +import info.laht.threekt.math.Color +import info.laht.threekt.math.Vector2 +import info.laht.threekt.textures.Texture open external class MeshStandardMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/PointsMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/PointsMaterial.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/materials/PointsMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/PointsMaterial.kt index a46fb65e..bb9c4bd8 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/PointsMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/PointsMaterial.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color -import three.textures.Texture +import info.laht.threekt.math.Color +import info.laht.threekt.textures.Texture external class PointsMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/RawShaderMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/RawShaderMaterial.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/materials/RawShaderMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/RawShaderMaterial.kt index d1f53c16..2a096459 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/RawShaderMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/RawShaderMaterial.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials external class RawShaderMaterial : ShaderMaterial { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/ShaderMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/ShaderMaterial.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/materials/ShaderMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/ShaderMaterial.kt index 3ca841db..016520eb 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/ShaderMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/ShaderMaterial.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials open external class ShaderMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/materials/SpriteMaterial.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/SpriteMaterial.kt similarity index 92% rename from visionforge-threejs/src/main/kotlin/three/materials/SpriteMaterial.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/SpriteMaterial.kt index 13587157..32056537 100644 --- a/visionforge-threejs/src/main/kotlin/three/materials/SpriteMaterial.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/materials/SpriteMaterial.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.materials +package info.laht.threekt.materials -import three.math.Color -import three.textures.Texture +import info.laht.threekt.math.Color +import info.laht.threekt.textures.Texture external class SpriteMaterial : Material { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Box2.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Box2.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/math/Box2.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Box2.kt index 5b446e3c..c00da8eb 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Box2.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Box2.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Box2( min: Vector2 = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/math/Box3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Box3.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Box3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Box3.kt index 25730ad2..a34622fa 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Box3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Box3.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math -import three.core.Object3D +import info.laht.threekt.core.Object3D /** * Represents a box or cube in 3D space. The main purpose of this is to represent the Minimum Bounding Boxes for objects. diff --git a/visionforge-threejs/src/main/kotlin/three/math/Color.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Color.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Color.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Color.kt index 485d04f1..26a2a760 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Color.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Color.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Color { diff --git a/visionforge-threejs/src/main/kotlin/three/math/ColorConstants.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/ColorConstants.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/math/ColorConstants.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/ColorConstants.kt index e60aba4a..34475bd1 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/ColorConstants.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/ColorConstants.kt @@ -23,7 +23,7 @@ */ -package three.math +package info.laht.threekt.math object ColorConstants { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Cylindrical.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Cylindrical.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Cylindrical.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Cylindrical.kt index bee46185..9e0cd8ba 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Cylindrical.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Cylindrical.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Cylindrical( radius: Number, diff --git a/visionforge-threejs/src/main/kotlin/three/math/Euler.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Euler.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Euler.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Euler.kt index 5cd2f5cf..5b8dc1ce 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Euler.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Euler.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Euler( diff --git a/visionforge-threejs/src/main/kotlin/three/math/Frustrum.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Frustrum.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/math/Frustrum.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Frustrum.kt index 8d6fe374..cce6a0bc 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Frustrum.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Frustrum.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Frustrum( p0: Plane = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/math/Line3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Line3.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Line3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Line3.kt index 4596edd9..6bb1b4e2 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Line3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Line3.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Line3( start: Vector3 = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/math/Math.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Math.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Math.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Math.kt index 7a340d51..9bae9dba 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Math.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Math.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Math { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Matrix3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Matrix3.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/math/Matrix3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Matrix3.kt index f5ea461a..6f31380b 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Matrix3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Matrix3.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math -import three.core.BufferAttribute +import info.laht.threekt.core.BufferAttribute external class Matrix3 { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Matrix4.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Matrix4.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Matrix4.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Matrix4.kt index 20e03eae..49ed3bfe 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Matrix4.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Matrix4.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry /** * A class representing a 4x4 matrix. diff --git a/visionforge-threejs/src/main/kotlin/three/math/Plane.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Plane.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/math/Plane.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Plane.kt index 41568fc8..2848938d 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Plane.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Plane.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Plane() { constructor(normal: Vector3, constant: Double) diff --git a/visionforge-threejs/src/main/kotlin/three/math/Quaternion.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Quaternion.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Quaternion.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Quaternion.kt index b1916723..a3a0af8b 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Quaternion.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Quaternion.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Quaternion( diff --git a/visionforge-threejs/src/main/kotlin/three/math/Ray.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Ray.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Ray.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Ray.kt index 707985b9..731a3d2b 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Ray.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Ray.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Ray { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Sphere.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Sphere.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Sphere.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Sphere.kt index abea7add..cbbc24c4 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Sphere.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Sphere.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Sphere { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Spherical.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Spherical.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Spherical.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Spherical.kt index 1596bd25..187dcd94 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Spherical.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Spherical.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Spherical { diff --git a/visionforge-threejs/src/main/kotlin/three/math/Triangle.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Triangle.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/Triangle.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Triangle.kt index 890d1f87..9dd99c52 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Triangle.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Triangle.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Triangle( a: Vector3 = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/math/Vector2.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector2.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/math/Vector2.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector2.kt index c508421a..86049df0 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Vector2.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector2.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Vector2( x: Number = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/math/Vector3.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector3.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/math/Vector3.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector3.kt index 881bc586..85f1c74b 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Vector3.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector3.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math -import three.cameras.Camera +import info.laht.threekt.cameras.Camera /** * Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z), which can be used to represent a number of things, such as: diff --git a/visionforge-threejs/src/main/kotlin/three/math/Vector4.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector4.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/math/Vector4.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector4.kt index 5bd672d5..f017f4d4 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/Vector4.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/Vector4.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.math +package info.laht.threekt.math external class Vector4( x: Number = definedExternally, diff --git a/visionforge-threejs/src/main/kotlin/three/math/operators.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/operators.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/math/operators.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/math/operators.kt index 245cc83f..b30baf00 100644 --- a/visionforge-threejs/src/main/kotlin/three/math/operators.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/math/operators.kt @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package three.math +package info.laht.threekt.math operator fun Vector3.unaryMinus() = this.clone().negate() operator fun Vector3.plusAssign(v: Vector3) = this.let { add(v); Unit } diff --git a/visionforge-threejs/src/main/kotlin/three/objects/Group.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Group.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/objects/Group.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Group.kt index a280a11f..e5420f29 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/Group.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Group.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.Object3D +import info.laht.threekt.core.Object3D external class Group : Object3D diff --git a/visionforge-threejs/src/main/kotlin/three/objects/LOD.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LOD.kt similarity index 88% rename from visionforge-threejs/src/main/kotlin/three/objects/LOD.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LOD.kt index 4eec3195..89e405ac 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/LOD.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LOD.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.cameras.Camera -import three.core.Intersect -import three.core.Object3D -import three.core.Raycaster +import info.laht.threekt.cameras.Camera +import info.laht.threekt.core.Intersect +import info.laht.threekt.core.Object3D +import info.laht.threekt.core.Raycaster external class LOD : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/objects/Line.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Line.kt similarity index 85% rename from visionforge-threejs/src/main/kotlin/three/objects/Line.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Line.kt index 799884f8..e0a217bc 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/Line.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Line.kt @@ -25,13 +25,13 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.BufferGeometry -import three.core.Intersect -import three.core.Object3D -import three.core.Raycaster -import three.materials.Material +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Intersect +import info.laht.threekt.core.Object3D +import info.laht.threekt.core.Raycaster +import info.laht.threekt.materials.Material open external class Line(geometry: BufferGeometry, material: Material) : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/objects/LineLoop.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LineLoop.kt similarity index 90% rename from visionforge-threejs/src/main/kotlin/three/objects/LineLoop.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LineLoop.kt index e3e8cbc3..50aa390e 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/LineLoop.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LineLoop.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.BufferGeometry -import three.materials.Material +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.materials.Material external class LineLoop(geometry: BufferGeometry, material: Material) : Line \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/objects/LineSegments.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LineSegments.kt similarity index 89% rename from visionforge-threejs/src/main/kotlin/three/objects/LineSegments.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LineSegments.kt index 2ffd85ee..03bef34e 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/LineSegments.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/LineSegments.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.BufferGeometry -import three.core.Object3D -import three.materials.Material +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Object3D +import info.laht.threekt.materials.Material open external class LineSegments(geometry: BufferGeometry, material: Material) : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/objects/Mesh.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Mesh.kt similarity index 86% rename from visionforge-threejs/src/main/kotlin/three/objects/Mesh.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Mesh.kt index 867b8000..fc91e333 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/Mesh.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Mesh.kt @@ -25,13 +25,13 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.BufferGeometry -import three.core.Intersect -import three.core.Object3D -import three.core.Raycaster -import three.materials.Material +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Intersect +import info.laht.threekt.core.Object3D +import info.laht.threekt.core.Raycaster +import info.laht.threekt.materials.Material open external class Mesh(geometry: BufferGeometry?, material: Material?) : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/objects/Points.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Points.kt similarity index 87% rename from visionforge-threejs/src/main/kotlin/three/objects/Points.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Points.kt index 7fede72c..f296937a 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/Points.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Points.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.Intersect -import three.core.Object3D -import three.core.Raycaster -import three.materials.Material +import info.laht.threekt.core.Intersect +import info.laht.threekt.core.Object3D +import info.laht.threekt.core.Raycaster +import info.laht.threekt.materials.Material external class Points : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/objects/Sprite.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Sprite.kt similarity index 87% rename from visionforge-threejs/src/main/kotlin/three/objects/Sprite.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Sprite.kt index c9e06bac..60e2d0de 100644 --- a/visionforge-threejs/src/main/kotlin/three/objects/Sprite.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/objects/Sprite.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.objects +package info.laht.threekt.objects -import three.core.Intersect -import three.core.Object3D -import three.core.Raycaster -import three.materials.Material +import info.laht.threekt.core.Intersect +import info.laht.threekt.core.Object3D +import info.laht.threekt.core.Raycaster +import info.laht.threekt.materials.Material external class Sprite(material: Material = definedExternally) : Object3D { diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/WebGL2Renderer.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGL2Renderer.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/renderers/WebGL2Renderer.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGL2Renderer.kt index 7ca6120f..1c5208ad 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/WebGL2Renderer.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGL2Renderer.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.renderers +package info.laht.threekt.renderers -import three.cameras.Camera -import three.scenes.Scene +import info.laht.threekt.cameras.Camera +import info.laht.threekt.scenes.Scene external class WebGL2Renderer { diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/WebGL2RendererParams.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGL2RendererParams.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/renderers/WebGL2RendererParams.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGL2RendererParams.kt index 8379d142..a2ef9eaf 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/WebGL2RendererParams.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGL2RendererParams.kt @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package three.renderers +package info.laht.threekt.renderers import org.w3c.dom.Node diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderTarget.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderTarget.kt similarity index 93% rename from visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderTarget.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderTarget.kt index 2cbd272b..08c44a36 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderTarget.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderTarget.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.renderers +package info.laht.threekt.renderers -import three.math.Vector4 -import three.textures.Texture +import info.laht.threekt.math.Vector4 +import info.laht.threekt.textures.Texture external class WebGLRenderTarget { diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderTargetOptions.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderTargetOptions.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderTargetOptions.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderTargetOptions.kt index 145431ce..4ba8b941 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderTargetOptions.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderTargetOptions.kt @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package three.renderers +package info.laht.threekt.renderers data class WebGLRenderTargetOptions( val wrapS: Int? = undefined, diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderer.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderer.kt similarity index 96% rename from visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderer.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderer.kt index 45fc212e..aa95f1ba 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRenderer.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRenderer.kt @@ -25,12 +25,12 @@ @file:JsModule("three") @file:JsNonModule -package three.renderers +package info.laht.threekt.renderers +import info.laht.threekt.cameras.Camera +import info.laht.threekt.math.Plane +import info.laht.threekt.scenes.Scene import org.w3c.dom.Node -import three.cameras.Camera -import three.math.Plane -import three.scenes.Scene external class WebGLRenderer(params: WebGLRendererParams = definedExternally) { diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRendererParams.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRendererParams.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/renderers/WebGLRendererParams.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRendererParams.kt index 6b979e8f..e6800673 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/WebGLRendererParams.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/WebGLRendererParams.kt @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package three.renderers +package info.laht.threekt.renderers import org.w3c.dom.Node diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/shaders/ShaderChunk.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/ShaderChunk.kt similarity index 99% rename from visionforge-threejs/src/main/kotlin/three/renderers/shaders/ShaderChunk.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/ShaderChunk.kt index ccf4d37f..f70c7137 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/shaders/ShaderChunk.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/ShaderChunk.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.renderers.shaders +package info.laht.threekt.renderers.shaders external object ShaderChunk { val alphamap_fragment: String diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/shaders/ShaderLib.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/ShaderLib.kt similarity index 96% rename from visionforge-threejs/src/main/kotlin/three/renderers/shaders/ShaderLib.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/ShaderLib.kt index 67ed1215..f168f740 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/shaders/ShaderLib.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/ShaderLib.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.renderers.shaders +package info.laht.threekt.renderers.shaders external object ShaderLib { diff --git a/visionforge-threejs/src/main/kotlin/three/renderers/shaders/UniformsUtil.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/UniformsUtil.kt similarity index 94% rename from visionforge-threejs/src/main/kotlin/three/renderers/shaders/UniformsUtil.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/UniformsUtil.kt index 3d68f177..fb68d712 100644 --- a/visionforge-threejs/src/main/kotlin/three/renderers/shaders/UniformsUtil.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/renderers/shaders/UniformsUtil.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.renderers.shaders +package info.laht.threekt.renderers.shaders -import three.core.Uniform +import info.laht.threekt.core.Uniform external object UniformsUtil { diff --git a/visionforge-threejs/src/main/kotlin/three/scenes/Fog.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/Fog.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/scenes/Fog.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/Fog.kt index 87b67fb0..c5682f36 100644 --- a/visionforge-threejs/src/main/kotlin/three/scenes/Fog.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/Fog.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.scenes +package info.laht.threekt.scenes -import three.math.Color +import info.laht.threekt.math.Color external class Fog { diff --git a/visionforge-threejs/src/main/kotlin/three/scenes/FogExp2.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/FogExp2.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/scenes/FogExp2.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/FogExp2.kt index fed2c580..017fd34b 100644 --- a/visionforge-threejs/src/main/kotlin/three/scenes/FogExp2.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/FogExp2.kt @@ -25,9 +25,9 @@ @file:JsModule("three") @file:JsNonModule -package three.scenes +package info.laht.threekt.scenes -import three.math.Color +import info.laht.threekt.math.Color external class FogExp2 { diff --git a/visionforge-threejs/src/main/kotlin/three/scenes/Scene.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/Scene.kt similarity index 95% rename from visionforge-threejs/src/main/kotlin/three/scenes/Scene.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/Scene.kt index 41fc011c..16e5e3cd 100644 --- a/visionforge-threejs/src/main/kotlin/three/scenes/Scene.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/scenes/Scene.kt @@ -25,10 +25,10 @@ @file:JsModule("three") @file:JsNonModule -package three.scenes +package info.laht.threekt.scenes -import three.core.Object3D -import three.materials.Material +import info.laht.threekt.core.Object3D +import info.laht.threekt.materials.Material /** * Scenes allow you to set up what and where is to be rendered by three.js. diff --git a/visionforge-threejs/src/main/kotlin/three/textures/CompressedTexture.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/CompressedTexture.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/textures/CompressedTexture.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/CompressedTexture.kt index 10b72f45..1d25e61d 100644 --- a/visionforge-threejs/src/main/kotlin/three/textures/CompressedTexture.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/CompressedTexture.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.textures +package info.laht.threekt.textures /** * Creates a texture based on data in compressed form, for example from a DDS file. diff --git a/visionforge-threejs/src/main/kotlin/three/textures/CubeTexture.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/CubeTexture.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/textures/CubeTexture.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/CubeTexture.kt index b386f264..b5eb6e89 100644 --- a/visionforge-threejs/src/main/kotlin/three/textures/CubeTexture.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/CubeTexture.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.textures +package info.laht.threekt.textures import org.w3c.dom.Element diff --git a/visionforge-threejs/src/main/kotlin/three/textures/DepthTexture.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/DepthTexture.kt similarity index 97% rename from visionforge-threejs/src/main/kotlin/three/textures/DepthTexture.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/DepthTexture.kt index eabc7d9c..0ce9a308 100644 --- a/visionforge-threejs/src/main/kotlin/three/textures/DepthTexture.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/DepthTexture.kt @@ -25,7 +25,7 @@ @file:JsModule("three") @file:JsNonModule -package three.textures +package info.laht.threekt.textures external class DepthTexture( width: Int, diff --git a/visionforge-threejs/src/main/kotlin/three/textures/Texture.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/Texture.kt similarity index 98% rename from visionforge-threejs/src/main/kotlin/three/textures/Texture.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/Texture.kt index 853ae54e..b936c2f5 100644 --- a/visionforge-threejs/src/main/kotlin/three/textures/Texture.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/textures/Texture.kt @@ -25,11 +25,11 @@ @file:JsModule("three") @file:JsNonModule -package three.textures +package info.laht.threekt.textures +import info.laht.threekt.math.Matrix3 +import info.laht.threekt.math.Vector2 import org.w3c.dom.Element -import three.math.Matrix3 -import three.math.Vector2 /** * Create a texture to apply to a surface or as a reflection or refraction map. diff --git a/visionforge-threejs/src/main/kotlin/three/utils/BufferGeometryUtils.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/utils/BufferGeometryUtils.kt similarity index 87% rename from visionforge-threejs/src/main/kotlin/three/utils/BufferGeometryUtils.kt rename to visionforge-threejs/src/main/kotlin/info/laht/threekt/utils/BufferGeometryUtils.kt index 9c52f8be..dd15b514 100644 --- a/visionforge-threejs/src/main/kotlin/three/utils/BufferGeometryUtils.kt +++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/utils/BufferGeometryUtils.kt @@ -1,8 +1,8 @@ @file:JsModule("three/examples/jsm/utils/BufferGeometryUtils") @file:JsNonModule -package three.utils +package info.laht.threekt.utils -import three.core.BufferGeometry +import info.laht.threekt.core.BufferGeometry public external object BufferGeometryUtils { 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 new file mode 100644 index 00000000..8b1428ec --- /dev/null +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/MeshThreeFactory.kt @@ -0,0 +1,138 @@ +package space.kscience.visionforge.solid.three + +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.geometries.EdgesGeometry +import info.laht.threekt.objects.LineSegments +import info.laht.threekt.objects.Mesh +import space.kscience.dataforge.meta.updateWith +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.asName +import space.kscience.dataforge.names.plus +import space.kscience.dataforge.names.startsWith +import space.kscience.dataforge.values.boolean +import space.kscience.visionforge.computePropertyNode +import space.kscience.visionforge.onPropertyChange +import space.kscience.visionforge.setProperty +import space.kscience.visionforge.solid.Solid +import space.kscience.visionforge.solid.SolidMaterial +import space.kscience.visionforge.solid.layer +import space.kscience.visionforge.solid.three.MeshThreeFactory.Companion.EDGES_ENABLED_KEY +import space.kscience.visionforge.solid.three.MeshThreeFactory.Companion.EDGES_MATERIAL_KEY +import kotlin.reflect.KClass + +/** + * Basic geometry-based factory + */ +public abstract class MeshThreeFactory( + override val type: KClass, +) : ThreeFactory { + /** + * Build a geometry for an object + */ + public abstract fun buildGeometry(obj: T): BufferGeometry + + override fun invoke(three: ThreePlugin, obj: T): Mesh { + val geometry = buildGeometry(obj) + + //val meshMeta: Meta = obj.properties[Material3D.MATERIAL_KEY]?.node ?: Meta.empty + + val mesh = Mesh(geometry, ThreeMaterials.DEFAULT).apply { + matrixAutoUpdate = false + //set position for mesh + updatePosition(obj) + applyProperties(obj) + } + + //add listener to object properties + obj.onPropertyChange { name -> + when { + name.startsWith(Solid.GEOMETRY_KEY) -> { + val oldGeometry = mesh.geometry as BufferGeometry + val newGeometry = buildGeometry(obj) + oldGeometry.attributes = newGeometry.attributes + //mesh.applyWireFrame(obj) + mesh.applyEdges(obj) + newGeometry.dispose() + } + //name.startsWith(WIREFRAME_KEY) -> mesh.applyWireFrame(obj) + name.startsWith(EDGES_KEY) -> mesh.applyEdges(obj) + else -> mesh.updateProperty(obj, name) + } + } + + return mesh + } + + public companion object { + public val EDGES_KEY: Name = "edges".asName() + + //public val WIREFRAME_KEY: Name = "wireframe".asName() + public val ENABLED_KEY: Name = "enabled".asName() + public val EDGES_ENABLED_KEY: Name = EDGES_KEY + ENABLED_KEY + public val EDGES_MATERIAL_KEY: Name = EDGES_KEY + SolidMaterial.MATERIAL_KEY + //public val WIREFRAME_ENABLED_KEY: Name = WIREFRAME_KEY + ENABLED_KEY + //public val WIREFRAME_MATERIAL_KEY: Name = WIREFRAME_KEY + SolidMaterial.MATERIAL_KEY + } +} + +public fun Solid.edges(enabled: Boolean = true, block: SolidMaterial.() -> Unit = {}) { + setProperty(EDGES_ENABLED_KEY, enabled) + meta.getOrCreate(EDGES_MATERIAL_KEY).updateWith(SolidMaterial, block) +} + +internal fun Mesh.applyProperties(obj: Solid): Mesh = apply { + updateMaterial(obj) + applyEdges(obj) + //applyWireFrame(obj) + layers.set(obj.layer) + children.forEach { + it.layers.set(obj.layer) + } +} + +public fun Mesh.applyEdges(obj: Solid) { + val edges = children.find { it.name == "@edges" } as? LineSegments + //inherited edges definition, enabled by default + if (obj.getPropertyValue(EDGES_ENABLED_KEY, inherit = true)?.boolean != false) { + val bufferGeometry = geometry as? BufferGeometry ?: return + val material = ThreeMaterials.getLineMaterial(obj.computePropertyNode(EDGES_MATERIAL_KEY), true) + if (edges == null) { + add( + LineSegments( + EdgesGeometry(bufferGeometry), + material + ).apply { + name = "@edges" + } + ) + } else { + edges.material = material + } + } else { + edges?.let { + remove(it) + it.dispose() + } + } +} + +//public fun Mesh.applyWireFrame(obj: Solid) { +// children.find { it.name == "@wireframe" }?.let { +// remove(it) +// (it as LineSegments).dispose() +// } +// //inherited wireframe definition, disabled by default +// if (obj.getProperty(MeshThreeFactory.WIREFRAME_ENABLED_KEY).boolean == true) { +// val bufferGeometry = geometry as? BufferGeometry ?: return +// val material = +// ThreeMaterials.getLineMaterial(obj.getProperty(MeshThreeFactory.WIREFRAME_MATERIAL_KEY).node, true) +// add( +// LineSegments( +// WireframeGeometry(bufferGeometry), +// material +// ).apply { +// name = "@wireframe" +// } +// ) +// } +//} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeAmbientLightFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeAmbientLightFactory.kt deleted file mode 100644 index f15f2c78..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeAmbientLightFactory.kt +++ /dev/null @@ -1,35 +0,0 @@ -package space.kscience.visionforge.solid.three - -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Vision -import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.solid.AmbientLightSource -import space.kscience.visionforge.solid.LightSource -import space.kscience.visionforge.solid.SolidMaterial -import space.kscience.visionforge.visible -import three.lights.AmbientLight -import three.math.Color -import kotlin.reflect.KClass - -public object ThreeAmbientLightFactory : ThreeFactory { - override val type: KClass get() = AmbientLightSource::class - - override suspend fun build(three: ThreePlugin, vision: AmbientLightSource, observe: Boolean): AmbientLight { - val res = AmbientLight().apply { - color = vision.color.threeColor() ?: Color(0x404040) - intensity = vision.intensity.toDouble() - } - - if (observe) { - vision.onPropertyChange(three.context) { propertyName: Name -> - when (propertyName) { - Vision.VISIBLE_KEY -> res.visible = vision.visible ?: true - SolidMaterial.COLOR_KEY -> res.color = vision.color.threeColor() ?: Color(0x404040) - LightSource.INTENSITY_KEY -> res.intensity = vision.intensity.toDouble() - } - } - } - - return res - } -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeAxesFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeAxesFactory.kt deleted file mode 100644 index 8af445b9..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeAxesFactory.kt +++ /dev/null @@ -1,22 +0,0 @@ -package space.kscience.visionforge.solid.three - -import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.solid.AxesSolid -import three.helpers.AxesHelper -import kotlin.reflect.KClass - -public object ThreeAxesFactory : ThreeFactory { - override val type: KClass get() = AxesSolid::class - - override suspend fun build(three: ThreePlugin, vision: AxesSolid, observe: Boolean): AxesHelper { - val res = AxesHelper(vision.size.toInt()) - - if (observe) { - vision.onPropertyChange(three.context) { propertyName -> - res.updateProperty(vision, propertyName) - } - } - - return res - } -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeBoxFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeBoxFactory.kt index d6840f75..a5b50688 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeBoxFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeBoxFactory.kt @@ -1,11 +1,11 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.geometries.BoxGeometry import space.kscience.visionforge.solid.Box import space.kscience.visionforge.solid.detail -import three.geometries.BoxGeometry -public object ThreeBoxFactory : ThreeMeshFactory(Box::class) { - override suspend fun buildGeometry(obj: Box): BoxGeometry = +public object ThreeBoxFactory : MeshThreeFactory(Box::class) { + override fun buildGeometry(obj: Box): BoxGeometry = obj.detail?.let { detail -> BoxGeometry(obj.xSize, obj.ySize, obj.zSize, detail, detail, detail) } ?: BoxGeometry(obj.xSize, obj.ySize, obj.zSize) diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt index c692b88d..3b5ae6ae 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt @@ -1,7 +1,23 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.WebGLRenderer +import info.laht.threekt.cameras.PerspectiveCamera +import info.laht.threekt.core.Object3D +import info.laht.threekt.core.Raycaster +import info.laht.threekt.external.controls.OrbitControls +import info.laht.threekt.external.controls.TrackballControls +import info.laht.threekt.geometries.EdgesGeometry +import info.laht.threekt.helpers.AxesHelper +import info.laht.threekt.lights.AmbientLight +import info.laht.threekt.materials.LineBasicMaterial +import info.laht.threekt.math.Box3 +import info.laht.threekt.math.Plane +import info.laht.threekt.math.Vector2 +import info.laht.threekt.math.Vector3 +import info.laht.threekt.objects.LineSegments +import info.laht.threekt.objects.Mesh +import info.laht.threekt.scenes.Scene import kotlinx.browser.window -import kotlinx.coroutines.launch import org.w3c.dom.Element import org.w3c.dom.HTMLCanvasElement import org.w3c.dom.Node @@ -13,27 +29,13 @@ import space.kscience.dataforge.names.* import space.kscience.visionforge.Colors import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.specifications.* -import three.WebGLRenderer -import three.cameras.PerspectiveCamera -import three.core.Object3D -import three.core.Raycaster -import three.external.controls.OrbitControls -import three.external.controls.TrackballControls -import three.geometries.EdgesGeometry -import three.helpers.AxesHelper -import three.materials.Material -import three.math.* -import three.meshline.MeshLine -import three.meshline.MeshLineMaterial -import three.meshline.isMeshLineMaterial -import three.objects.LineSegments -import three.objects.Mesh -import three.scenes.Scene +import space.kscience.visionforge.solid.three.ThreeMaterials.HIGHLIGHT_MATERIAL +import space.kscience.visionforge.solid.three.ThreeMaterials.SELECTED_MATERIAL import kotlin.math.cos import kotlin.math.sin /** - * A canvas for three-js rendering + * */ public class ThreeCanvas( public val three: ThreePlugin, @@ -51,16 +53,26 @@ public class ThreeCanvas( private val mousePosition: Vector2 = Vector2() private val scene: Scene = Scene().apply { - options.useProperty(Canvas3DOptions::axes, this) { + options.useProperty(Canvas3DOptions::axes, this) { axesConfig -> getObjectByName(AXES_NAME)?.let { remove(it) } val axesObject = AxesHelper(axes.size.toInt()).apply { visible = axes.visible } axesObject.name = AXES_NAME add(axesObject) } + + //Set up light + options.useProperty(Canvas3DOptions::light, this) { lightConfig -> + //remove old light if present + getObjectByName(LIGHT_NAME)?.let { remove(it) } + //add new light + val lightObject = buildLight(lightConfig) + lightObject.name = LIGHT_NAME + add(lightObject) + } } - private fun buildCamera(spec: CameraScheme) = PerspectiveCamera( + private fun buildCamera(spec: Camera) = PerspectiveCamera( spec.fov, 1.0, spec.nearClip, @@ -100,7 +112,7 @@ public class ThreeCanvas( } /** - * Force camera aspect ratio and renderer size recalculation + * Force camera aspect ration and renderer size recalculation */ private fun updateSize() { val width = element.clientWidth @@ -155,7 +167,7 @@ public class ThreeCanvas( } //Clipping planes - options.useProperty(Canvas3DOptions::clipping) { clipping -> + options.useProperty(Canvas3DOptions::clipping){clipping -> if (!clipping.meta.isEmpty()) { renderer.localClippingEnabled = true boundingBox?.let { boundingBox -> @@ -180,7 +192,7 @@ public class ThreeCanvas( } } - options.useProperty(Canvas3DOptions::size) { + options.useProperty(Canvas3DOptions::size){ canvas.style.apply { minWidth = "${options.size.minWith.toInt()}px" maxWidth = "${options.size.maxWith.toInt()}px" @@ -192,7 +204,7 @@ public class ThreeCanvas( } /** - * Resolve the full name of the object relative to the global root + * Resolve full name of the object relative to the global root */ private fun Object3D.fullName(): Name { if (root == null) error("Can't resolve element name without the root") @@ -203,8 +215,8 @@ public class ThreeCanvas( } } - //find the first non-static parent in this object ancestry - private tailrec fun Object3D.upTrace(): Object3D? = if (!name.startsWith("@")) this else parent?.upTrace() + //find first non-static parent in this object ancestry + private fun Object3D?.upTrace(): Object3D? = if (this?.name?.startsWith("@") == true) parent else this private fun pick(): Object3D? { // update the picking ray with the camera and mouse position @@ -214,29 +226,14 @@ public class ThreeCanvas( return root?.let { root -> val intersects = raycaster.intersectObject(root, true) //skip invisible objects - val obj: Object3D? = intersects.map { it.`object` }.firstOrNull { it.visible } - obj?.upTrace() + val obj = intersects.map { it.`object` }.firstOrNull { it.visible } + obj.upTrace() } } -// private fun buildLight(spec: AmbientLightScheme?): info.laht.threekt.lights.Light = when (spec?.type) { -// AmbientLightScheme.Type.POINT -> PointLight().apply { -// position.x = spec.position.x ?: 0.0 -// position.y = spec.position.y ?: 0.0 -// position.z = spec.position.z ?: 0.0 -// } -// else -> AmbientLight().apply { -// -// } -// }.apply { -// this.color = spec?.color?.threeColor() ?: Color(0x404040) -// -// spec?.intensity?.coerceIn(0.0, 1.0)?.let { -// this.intensity = it -// } -// } + private fun buildLight(spec: Light?): info.laht.threekt.lights.Light = AmbientLight(0x404040) - private fun addControls(element: Node, controls: ControlsScheme) { + private fun addControls(element: Node, controls: Controls) { when (controls.meta["type"].string) { "trackball" -> TrackballControls(camera, element) else -> OrbitControls(camera, element) @@ -255,13 +252,11 @@ public class ThreeCanvas( scene.findChild("@root".asName())?.let { scene.remove(it) } root?.dispose() } - three.context.launch { - val object3D = three.buildObject3D(vision) - object3D.name = "@root" - scene.add(object3D) - root = object3D - } + val object3D = three.buildObject3D(vision) + object3D.name = "@root" + scene.add(object3D) + root = object3D } private var selected: Object3D? = null @@ -272,29 +267,26 @@ public class ThreeCanvas( private fun Object3D.toggleHighlight( highlight: Boolean, edgesName: String, - material: Material, + material: LineBasicMaterial = SELECTED_MATERIAL, ) { - if (userData[DO_NOT_HIGHLIGHT_TAG] == true) { return } - - if (isMesh(this)) { - val highlightMesh = getObjectByName(edgesName) ?: if (isMeshLineMaterial(material)) { - Mesh( - MeshLine(EdgesGeometry(geometry)), + if (this is Mesh) { + if (highlight) { + val edges = LineSegments( + EdgesGeometry(geometry), material - ) + ).apply { + name = edgesName + } + add(edges) } else { - LineSegments(EdgesGeometry(geometry), material) - }.also { - it.name = edgesName - add(it) + val highlightEdges = children.find { it.name == edgesName } + highlightEdges?.let { remove(it) } } - highlightMesh.visible = highlight } else { - //ignore service objects if they are not statics - children.filter { it.name.startsWith("@static") || !it.name.startsWith("@") }.forEach { + children.filter { it.name != edgesName }.forEach { it.toggleHighlight(highlight, edgesName, material) } } @@ -318,35 +310,12 @@ public class ThreeCanvas( } public companion object { - public val SELECTED_MATERIAL: MeshLineMaterial = MeshLineMaterial().apply { - color.set(Colors.ivory) - thickness = 2f - cached = true - } - - public val HIGHLIGHT_MATERIAL: MeshLineMaterial = MeshLineMaterial().apply { - color.set(Colors.blue) - thickness = 2f - cached = true - } -// -// public val SELECTED_MATERIAL: LineBasicMaterial = LineBasicMaterial().apply { -// color.set(Colors.ivory) -// cached = true -// } -// -// public val HIGHLIGHT_MATERIAL: LineBasicMaterial = LineBasicMaterial().apply { -// color.set(Colors.blue) -// cached = true -// } - - public const val DO_NOT_HIGHLIGHT_TAG: String = "doNotHighlight" private const val HIGHLIGHT_NAME = "@highlight" private const val SELECT_NAME = "@select" private const val LIGHT_NAME = "@light" private const val AXES_NAME = "@axes" - //private const val CLIP_HELPER_NAME = "@clipping" + private const val CLIP_HELPER_NAME = "@clipping" } } 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 93bf170b..7dd30a34 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 @@ -1,5 +1,11 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.DoubleSide +import info.laht.threekt.core.Object3D +import info.laht.threekt.geometries.PlaneGeometry +import info.laht.threekt.materials.MeshBasicMaterial +import info.laht.threekt.objects.Mesh +import info.laht.threekt.textures.Texture import kotlinx.browser.document import org.w3c.dom.CanvasRenderingContext2D import org.w3c.dom.CanvasTextBaseline @@ -8,12 +14,6 @@ import org.w3c.dom.MIDDLE import space.kscience.visionforge.solid.SolidLabel import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.three.ThreeCanvas.Companion.DO_NOT_HIGHLIGHT_TAG -import three.DoubleSide -import three.core.Object3D -import three.geometries.PlaneGeometry -import three.materials.MeshBasicMaterial -import three.objects.Mesh -import three.textures.Texture import kotlin.reflect.KClass /** @@ -22,40 +22,35 @@ import kotlin.reflect.KClass public object ThreeCanvasLabelFactory : ThreeFactory { override val type: KClass get() = SolidLabel::class - override suspend fun build(three: ThreePlugin, vision: SolidLabel, observe: Boolean): Object3D { + override fun invoke(three: ThreePlugin, obj: SolidLabel): Object3D { val canvas = document.createElement("canvas") as HTMLCanvasElement - canvas.width = 200 - canvas.height = 200 + val context = canvas.getContext("2d") as CanvasRenderingContext2D + context.font = "Bold ${obj.fontSize}pt ${obj.fontFamily}" + context.fillStyle = obj.getPropertyValue(SolidMaterial.MATERIAL_COLOR_KEY)?.value ?: "black" + context.textBaseline = CanvasTextBaseline.MIDDLE + val metrics = context.measureText(obj.text) + //canvas.width = metrics.width.toInt() - canvas.getContext("2d").apply { - this as CanvasRenderingContext2D - font = "Bold ${vision.fontSize}pt ${vision.fontFamily}" - fillStyle = vision.properties.getValue( - SolidMaterial.MATERIAL_COLOR_KEY, - inherit = false, - includeStyles = true - )?.value ?: "black" - textBaseline = CanvasTextBaseline.MIDDLE - val metrics = measureText(vision.text) - //canvas.width = metrics.width.toInt() - fillText(vision.text, (canvas.width - metrics.width) / 2, 0.5 * canvas.height) - } + + context.fillText(obj.text, (canvas.width - metrics.width) / 2, 0.5 * canvas.height) // canvas contents will be used for a texture val texture = Texture(canvas) texture.needsUpdate = true + val material = MeshBasicMaterial().apply { + map = texture + side = DoubleSide + transparent = true + } + val mesh = Mesh( PlaneGeometry(canvas.width, canvas.height), - MeshBasicMaterial().apply { - map = texture - side = DoubleSide - transparent = true - } + material ) - mesh.updatePosition(vision) + mesh.updatePosition(obj) mesh.userData[DO_NOT_HIGHLIGHT_TAG] = true return mesh diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt index e6e9641c..5705459a 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt @@ -1,12 +1,12 @@ package space.kscience.visionforge.solid.three import CSG +import info.laht.threekt.core.Object3D +import info.laht.threekt.objects.Mesh import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.solid.Composite import space.kscience.visionforge.solid.CompositeType -import space.kscience.visionforge.solid.SolidMaterial.Companion.EDGES_KEY -import three.objects.Mesh import kotlin.reflect.KClass /** @@ -38,26 +38,21 @@ public class ThreeCompositeFactory(public val three: ThreePlugin) : ThreeFactory override val type: KClass get() = Composite::class - override suspend fun build(three: ThreePlugin, vision: Composite, observe: Boolean): Mesh { - val first = three.buildObject3D(vision.first, observe).takeIfMesh() - ?: error("First part of composite is not a mesh") - val second = three.buildObject3D(vision.second, observe).takeIfMesh() - ?: error("Second part of composite is not a mesh") - return when (vision.compositeType) { - CompositeType.GROUP, CompositeType.UNION -> CSG.union(first, second) + override fun invoke(three: ThreePlugin, obj: Composite): Object3D { + val first = three.buildObject3D(obj.first) as? Mesh ?: error("First part of composite is not a mesh") + val second = three.buildObject3D(obj.second) as? Mesh ?: error("Second part of composite is not a mesh") + return when (obj.compositeType) { + CompositeType.SUM, CompositeType.UNION -> CSG.union(first, second) CompositeType.INTERSECT -> CSG.intersect(first, second) CompositeType.SUBTRACT -> CSG.subtract(first, second) }.apply { - updatePosition(vision) - applyProperties(vision) - - if (observe) { - vision.onPropertyChange { name -> - when { - //name.startsWith(WIREFRAME_KEY) -> mesh.applyWireFrame(obj) - name.startsWith(EDGES_KEY) -> applyEdges(vision) - else -> updateProperty(vision, name) - } + updatePosition(obj) + applyProperties(obj) + obj.onPropertyChange { name -> + when { + //name.startsWith(WIREFRAME_KEY) -> mesh.applyWireFrame(obj) + name.startsWith(MeshThreeFactory.EDGES_KEY) -> applyEdges(obj) + else -> updateProperty(obj, name) } } } diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConeFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConeFactory.kt index bcc147c7..5789c30e 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConeFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConeFactory.kt @@ -1,14 +1,14 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.geometries.CylinderGeometry import space.kscience.visionforge.solid.ConeSegment import space.kscience.visionforge.solid.detail -import three.core.BufferGeometry -import three.geometries.CylinderGeometry import kotlin.math.PI import kotlin.math.pow -public object ThreeConeFactory : ThreeMeshFactory(ConeSegment::class) { - override suspend fun buildGeometry(obj: ConeSegment): BufferGeometry { +public object ThreeConeFactory : MeshThreeFactory(ConeSegment::class) { + override fun buildGeometry(obj: ConeSegment): BufferGeometry { val cylinder = obj.detail?.let { val segments = it.toDouble().pow(0.5).toInt() CylinderGeometry( @@ -18,16 +18,16 @@ public object ThreeConeFactory : ThreeMeshFactory(ConeSegment::clas radialSegments = segments, heightSegments = segments, openEnded = false, - thetaStart = obj.phiStart, - thetaLength = obj.phi + thetaStart = obj.startAngle, + thetaLength = obj.angle ) } ?: CylinderGeometry( radiusTop = obj.topRadius, radiusBottom = obj.bottomRadius, height = obj.height, openEnded = false, - thetaStart = obj.phiStart, - thetaLength = obj.phi + thetaStart = obj.startAngle, + thetaLength = obj.angle ) return cylinder.rotateX(PI/2) } diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConvexFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConvexFactory.kt index b772c1bf..fe08b1cf 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConvexFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeConvexFactory.kt @@ -1,10 +1,10 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.external.geometries.ConvexBufferGeometry import space.kscience.visionforge.solid.Convex -import three.external.geometries.ConvexBufferGeometry -public object ThreeConvexFactory : ThreeMeshFactory(Convex::class) { - override suspend fun buildGeometry(obj: Convex): ConvexBufferGeometry { +public object ThreeConvexFactory : MeshThreeFactory(Convex::class) { + override fun buildGeometry(obj: Convex): ConvexBufferGeometry { val vectors = obj.points.map { it.toVector() }.toTypedArray() return ConvexBufferGeometry(vectors) } diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt index 46e3d41b..81749fd3 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt @@ -1,17 +1,17 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Object3D +import info.laht.threekt.objects.Mesh import space.kscience.dataforge.misc.Type import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.Vision +import space.kscience.visionforge.computeProperty import space.kscience.visionforge.solid.* import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_KEY import space.kscience.visionforge.solid.three.ThreeFactory.Companion.TYPE import space.kscience.visionforge.visible -import three.core.BufferGeometry -import three.core.Object3D -import three.math.Euler -import three.math.Quaternion import kotlin.reflect.KClass /** @@ -22,11 +22,7 @@ public interface ThreeFactory { public val type: KClass - /** - * Build an [Object3D] from [vision]. - * @param observe if false, does not observe the changes in [vision] after render (useful for statics). - */ - public suspend fun build(three: ThreePlugin, vision: T, observe: Boolean = true): Object3D + public operator fun invoke(three: ThreePlugin, obj: T): Object3D public companion object { public const val TYPE: String = "threeFactory" @@ -36,27 +32,12 @@ public interface ThreeFactory { /** * Update position, rotation and visibility */ -public fun Object3D.updatePosition(vision: Vision) { -// visible = vision.visible ?: true - if (vision is Solid) { - position.set(vision.x, vision.y, vision.z) - - val quaternion = vision.quaternionValue - - if (quaternion != null) { - setRotationFromQuaternion( - Quaternion( - quaternion.x, - quaternion.y, - quaternion.z, - quaternion.w - ) - ) - } else { - setRotationFromEuler(Euler(vision.rotationX, vision.rotationY, vision.rotationZ, vision.rotationOrder.name)) - } - - scale.set(vision.scaleX, vision.scaleY, vision.scaleZ) +public fun Object3D.updatePosition(obj: Vision) { + visible = obj.visible ?: true + if (obj is Solid) { + position.set(obj.x, obj.y, obj.z) + setRotationFromEuler(obj.euler) + scale.set(obj.scaleX, obj.scaleY, obj.scaleZ) updateMatrix() } } @@ -65,8 +46,8 @@ public fun Object3D.updatePosition(vision: Vision) { * Update non-position non-geometry property */ public fun Object3D.updateProperty(source: Vision, propertyName: Name) { - // console.log("$source updated $propertyName with ${source.computeProperty(propertyName)}") - if (isMesh(this) && propertyName.startsWith(MATERIAL_KEY)) { + console.log("$source updated $propertyName with ${source.computeProperty(propertyName)}") + if (this is Mesh && propertyName.startsWith(MATERIAL_KEY)) { updateMaterialProperty(source, propertyName) } else if ( propertyName.startsWith(Solid.POSITION_KEY) @@ -83,8 +64,8 @@ public fun Object3D.updateProperty(source: Vision, propertyName: Name) { /** * Generic factory for elements which provide inside geometry builder */ -public object ThreeShapeFactory : ThreeMeshFactory(GeometrySolid::class) { - override suspend fun buildGeometry(obj: GeometrySolid): BufferGeometry = ThreeGeometryBuilder().apply { +public object ThreeShapeFactory : MeshThreeFactory(GeometrySolid::class) { + override fun buildGeometry(obj: GeometrySolid): BufferGeometry = ThreeGeometryBuilder().apply { obj.toGeometry(this) }.build() } \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt index 7a5f3c49..fc226de6 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt @@ -1,14 +1,15 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Float32BufferAttribute +import info.laht.threekt.math.Vector3 import space.kscience.dataforge.meta.Meta -import space.kscience.visionforge.solid.Float32Euclidean3DSpace -import space.kscience.visionforge.solid.Float32Vector3D import space.kscience.visionforge.solid.GeometryBuilder -import three.core.BufferGeometry -import three.core.Float32BufferAttribute -import three.math.Vector3 +import space.kscience.visionforge.solid.Point3D +import space.kscience.visionforge.solid.cross +import space.kscience.visionforge.solid.minus -internal fun Float32Vector3D.toVector() = Vector3(x, y, z) +internal fun Point3D.toVector() = Vector3(x, y, z) internal fun MutableList.add(vararg values: T) { values.forEach { @@ -26,10 +27,10 @@ public class ThreeGeometryBuilder : GeometryBuilder { private val normals = ArrayList() // private val colors = ArrayList() - private val vertexCache = HashMap() + private val vertexCache = HashMap() private var counter: Short = -1 - private fun vertex(vertex: Float32Vector3D, normal: Float32Vector3D): Short = vertexCache.getOrPut(vertex) { + private fun vertex(vertex: Point3D, normal: Point3D): Short = vertexCache.getOrPut(vertex) { //add vertex and update cache if needed positions.add(vertex.x, vertex.y, vertex.z) normals.add(normal.x, vertex.y, vertex.z) @@ -38,14 +39,8 @@ public class ThreeGeometryBuilder : GeometryBuilder { counter } - override fun face( - vertex1: Float32Vector3D, - vertex2: Float32Vector3D, - vertex3: Float32Vector3D, - normal: Float32Vector3D?, - meta: Meta, - ) = with(Float32Euclidean3DSpace) { - val actualNormal: Float32Vector3D = normal ?: ((vertex3 - vertex2) cross (vertex1 - vertex2)) + override fun face(vertex1: Point3D, vertex2: Point3D, vertex3: Point3D, normal: Point3D?, meta: Meta) { + val actualNormal: Point3D = normal ?: ((vertex3 - vertex2) cross (vertex1 - vertex2)) indices.add( vertex(vertex1, actualNormal), vertex(vertex2, actualNormal), 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 6f6e166a..27a5da44 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 @@ -1,11 +1,11 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.Object3D import space.kscience.visionforge.solid.SolidBase -import three.core.Object3D /** * A custom visual object that has its own Three.js renderer */ -public abstract class ThreeJsVision : SolidBase() { - public abstract suspend fun render(three: ThreePlugin): Object3D +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/ThreeLabelFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt index 45068a3a..34ee5ed1 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt @@ -1,14 +1,14 @@ package space.kscience.visionforge.solid.three -import js.core.jso +import info.laht.threekt.core.Object3D +import info.laht.threekt.geometries.TextBufferGeometry +import info.laht.threekt.objects.Mesh +import kotlinext.js.jsObject import space.kscience.dataforge.context.logger import space.kscience.dataforge.context.warn import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.solid.SolidLabel -import three.core.Object3D -import three.geometries.TextBufferGeometry -import three.objects.Mesh import kotlin.reflect.KClass /** @@ -17,21 +17,19 @@ import kotlin.reflect.KClass public object ThreeLabelFactory : ThreeFactory { override val type: KClass get() = SolidLabel::class - override suspend fun build(three: ThreePlugin, vision: SolidLabel, observe: Boolean): Object3D { - val textGeo = TextBufferGeometry(vision.text, jso { - font = vision.fontFamily + override fun invoke(three: ThreePlugin, obj: SolidLabel): Object3D { + val textGeo = TextBufferGeometry(obj.text, jsObject { + font = obj.fontFamily size = 20 height = 1 curveSegments = 1 }) return Mesh(textGeo, ThreeMaterials.DEFAULT).apply { - setMaterial(vision) - updatePosition(vision) - if(observe) { - vision.onPropertyChange(three.context) { - //TODO - three.logger.warn { "Label parameter change not implemented" } - } + updateMaterial(obj) + updatePosition(obj) + obj.onPropertyChange { _ -> + //TODO + three.logger.warn { "Label parameter change not implemented" } } } } 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 45325430..ee36d74b 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 @@ -1,44 +1,43 @@ package space.kscience.visionforge.solid.three +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.computePropertyNode import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.solid.PolyLine import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.color import space.kscience.visionforge.solid.string import space.kscience.visionforge.solid.three.ThreeMaterials.DEFAULT_LINE_COLOR -import three.core.BufferGeometry -import three.core.Object3D -import three.math.Color -import three.objects.LineSegments import kotlin.math.ceil import kotlin.reflect.KClass public object ThreeLineFactory : ThreeFactory { override val type: KClass get() = PolyLine::class - override suspend fun build(three: ThreePlugin, vision: PolyLine, observe: Boolean): Object3D { + override fun invoke(three: ThreePlugin, obj: PolyLine): Object3D { val geometry = BufferGeometry().apply { - setFromPoints(Array((vision.points.size - 1) * 2) { - vision.points[ceil(it / 2.0).toInt()].toVector() + setFromPoints(Array((obj.points.size - 1) * 2) { + obj.points[ceil(it / 2.0).toInt()].toVector() }) } val material = ThreeMaterials.getLineMaterial( - vision.properties.getProperty(SolidMaterial.MATERIAL_KEY), + obj.computePropertyNode(SolidMaterial.MATERIAL_KEY), false ) - material.linewidth = vision.thickness.toDouble() - material.color = vision.color.string?.let { Color(it) } ?: DEFAULT_LINE_COLOR + material.linewidth = obj.thickness.toDouble() + material.color = obj.color.string?.let { Color(it) } ?: DEFAULT_LINE_COLOR return LineSegments(geometry, material).apply { - updatePosition(vision) + updatePosition(obj) //layers.enable(obj.layer) //add listener to object properties - if(observe) { - vision.onPropertyChange(three.context) { propertyName -> - updateProperty(vision, propertyName) - } + obj.onPropertyChange { propertyName -> + updateProperty(obj, propertyName) } } } 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 f5ac5c2b..522c0362 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 @@ -1,43 +1,44 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.materials.LineBasicMaterial +import info.laht.threekt.materials.Material +import info.laht.threekt.materials.MeshBasicMaterial +import info.laht.threekt.math.Color +import info.laht.threekt.objects.Mesh 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.solid.ColorAccessor import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.SolidReference -import three.materials.LineBasicMaterial -import three.materials.Material -import three.materials.MeshBasicMaterial -import three.materials.MeshStandardMaterial -import three.math.Color -import three.objects.Mesh public object ThreeMaterials { public val DEFAULT_COLOR: Color = Color(Colors.darkgreen) - - public val DEFAULT: MeshStandardMaterial = MeshStandardMaterial().apply { + public val DEFAULT: MeshBasicMaterial = MeshBasicMaterial().apply { color.set(DEFAULT_COLOR) cached = true } - - public val BLACK_COLOR: Color = Color(Colors.black) - - public val DEFAULT_EMISSIVE_COLOR: Color = BLACK_COLOR - - public val DEFAULT_LINE_COLOR: Color get() = BLACK_COLOR - + public val DEFAULT_LINE_COLOR: Color = Color(Colors.black) public val DEFAULT_LINE: LineBasicMaterial = LineBasicMaterial().apply { color.set(DEFAULT_LINE_COLOR) - cached = true } - private val lineMaterialCache = HashMap() + public val SELECTED_MATERIAL: LineBasicMaterial = LineBasicMaterial().apply { + color.set(Colors.ivory) + linewidth = 8.0 + } + + public val HIGHLIGHT_MATERIAL: LineBasicMaterial = LineBasicMaterial().apply { + color.set(Colors.blue) + linewidth = 8.0 + } + + private val lineMaterialCache = HashMap() private fun buildLineMaterial(meta: Meta): LineBasicMaterial = LineBasicMaterial().apply { color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_LINE_COLOR @@ -49,41 +50,45 @@ public object ThreeMaterials { public fun getLineMaterial(meta: Meta?, cache: Boolean): LineBasicMaterial { if (meta == null) return DEFAULT_LINE return if (cache) { - lineMaterialCache.getOrPut(meta.hashCode()) { buildLineMaterial(meta) } + lineMaterialCache.getOrPut(meta) { buildLineMaterial(meta) } } else { buildLineMaterial(meta) } } - internal fun buildMaterial(meta: Meta): Material = when (meta[SolidMaterial.TYPE_KEY]?.string) { - "simple" -> MeshBasicMaterial().apply { - color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR - wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false - } + private val materialCache = HashMap() - else -> MeshStandardMaterial().apply { - color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR - emissive = meta[SolidMaterial.EMISSIVE_COLOR_KEY]?.threeColor() ?: DEFAULT_EMISSIVE_COLOR - wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false - } - }.apply { + internal fun buildMaterial(meta: Meta): Material = MeshBasicMaterial().apply { + color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0 transparent = opacity < 1.0 + wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false needsUpdate = true } - -// private val materialCache = HashMap() -// -// internal fun cacheMaterial(meta: Meta): Material = materialCache.getOrPut(meta.hashCode()) { -// buildMaterial(meta).apply { -// cached = true +// val material = SolidMaterial.read(meta) +// return meta[SolidMaterial.SPECULAR_COLOR_KEY]?.let { specularColor -> +// MeshPhongMaterial().apply { +// color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR +// specular = specularColor.threeColor() +// emissive = material.emissiveColor.threeColor() ?: specular +// reflectivity = 0.5 +// refractionRatio = 1.0 +// shininess = 100.0 +// opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0 +// transparent = opacity < 1.0 +// wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false +// needsUpdate = true +// } +// } ?: MeshBasicMaterial().apply { +// color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR +// opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0 +// transparent = opacity < 1.0 +// wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false +// needsUpdate = true // } -// } - private val visionMaterialCache = HashMap() - - internal fun cacheMaterial(vision: Vision): Material = visionMaterialCache.getOrPut(vision) { - buildMaterial(vision.properties.getProperty(SolidMaterial.MATERIAL_KEY)).apply { + internal fun cacheMaterial(meta: Meta): Material = materialCache.getOrPut(meta) { + buildMaterial(meta).apply { cached = true } } @@ -93,100 +98,74 @@ public object ThreeMaterials { * Compute color */ public fun Meta.threeColor(): Color? { - value?.let { value -> - return when { + val value = getValue(Name.EMPTY) + return if (isLeaf) { + when { + value == null -> null value === Null -> null value.type == ValueType.NUMBER -> Color(value.int) else -> Color(value.string) } - } - val red = getValue(Colors.RED_KEY.asName())?.int - val green = getValue(Colors.GREEN_KEY.asName())?.int - val blue = getValue(Colors.BLUE_KEY.asName())?.int - return if (red == null && green == null && blue == null) null else Color(red ?: 0, green ?: 0, blue ?: 0) -} - -public fun ColorAccessor.threeColor(): Color? { - val value = value - return when { - value == null -> null - value === Null -> null - value.type == ValueType.NUMBER -> Color(value.int) - else -> Color(value.string) + } else { + Color( + getValue(Colors.RED_KEY.asName())?.int ?: 0, + getValue(Colors.GREEN_KEY.asName())?.int ?: 0, + getValue(Colors.BLUE_KEY.asName())?.int ?: 0 + ) } } -internal var Material.cached: Boolean +private var Material.cached: Boolean get() = userData["cached"] == true set(value) { userData["cached"] = value } -public fun Mesh.setMaterial(vision: Vision) { - if ( - vision.properties.own?.get(SolidMaterial.MATERIAL_KEY) == null - && vision.getStyleNodes(SolidMaterial.MATERIAL_KEY).isEmpty() - ) { - //if this is a reference, use material of the prototype - if (vision is SolidReference) { - ThreeMaterials.cacheMaterial(vision.prototype) +public fun Mesh.updateMaterial(vision: Vision) { + val ownMaterialMeta = vision.meta.getMeta(SolidMaterial.MATERIAL_KEY) + if (ownMaterialMeta == null) { + if (vision is SolidReference && vision.getStyleNodes(SolidMaterial.MATERIAL_KEY).isEmpty()) { + updateMaterial(vision.prototype) } else { - material = vision.parent?.let { parent -> - //TODO cache parent material - ThreeMaterials.buildMaterial(parent.properties.getProperty(SolidMaterial.MATERIAL_KEY)) - } ?: ThreeMaterials.cacheMaterial(vision) + material = vision.computePropertyNode(SolidMaterial.MATERIAL_KEY)?.let { + ThreeMaterials.cacheMaterial(it) + } ?: ThreeMaterials.DEFAULT } } else { - material = ThreeMaterials.buildMaterial(vision.properties.getProperty(SolidMaterial.MATERIAL_KEY)) + material = vision.computePropertyNode(SolidMaterial.MATERIAL_KEY)?.let { + ThreeMaterials.buildMaterial(it) + } ?: ThreeMaterials.DEFAULT } } public fun Mesh.updateMaterialProperty(vision: Vision, propertyName: Name) { - if ( - material.cached - || propertyName == SolidMaterial.MATERIAL_KEY - || propertyName == SolidMaterial.MATERIAL_KEY + SolidMaterial.TYPE_KEY - ) { + if (material.cached || propertyName == SolidMaterial.MATERIAL_KEY) { //generate a new material since cached material should not be changed - setMaterial(vision) + updateMaterial(vision) } else { when (propertyName) { SolidMaterial.MATERIAL_COLOR_KEY -> { - material.asDynamic().color = - vision.properties.getProperty(SolidMaterial.MATERIAL_COLOR_KEY).threeColor() - ?: ThreeMaterials.DEFAULT_COLOR + material.asDynamic().color = vision.computePropertyNode(SolidMaterial.MATERIAL_COLOR_KEY)?.threeColor() + ?: ThreeMaterials.DEFAULT_COLOR + material.needsUpdate = true } - - SolidMaterial.SPECULAR_COLOR_KEY -> { - material.asDynamic().specular = - vision.properties.getProperty(SolidMaterial.SPECULAR_COLOR_KEY).threeColor() - ?: ThreeMaterials.DEFAULT_COLOR - } - - SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY -> { - material.asDynamic().emissive = vision.properties.getProperty(SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY) - .threeColor() - ?: ThreeMaterials.BLACK_COLOR - } - SolidMaterial.MATERIAL_OPACITY_KEY -> { - val opacity = vision.properties.getValue( + val opacity = vision.getPropertyValue( SolidMaterial.MATERIAL_OPACITY_KEY, inherit = true, )?.double ?: 1.0 material.opacity = opacity material.transparent = opacity < 1.0 + material.needsUpdate = true } - SolidMaterial.MATERIAL_WIREFRAME_KEY -> { - material.asDynamic().wireframe = vision.properties.getValue( + material.asDynamic().wireframe = vision.getPropertyValue( SolidMaterial.MATERIAL_WIREFRAME_KEY, inherit = true, )?.boolean ?: false + material.needsUpdate = true } - else -> console.warn("Unrecognized material property: $propertyName") } - material.needsUpdate = true } } \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt deleted file mode 100644 index 06224bbb..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt +++ /dev/null @@ -1,98 +0,0 @@ -package space.kscience.visionforge.solid.three - -import space.kscience.dataforge.meta.boolean -import space.kscience.dataforge.names.startsWith -import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.SolidMaterial.Companion.EDGES_ENABLED_KEY -import space.kscience.visionforge.solid.SolidMaterial.Companion.EDGES_KEY -import space.kscience.visionforge.solid.SolidMaterial.Companion.EDGES_MATERIAL_KEY -import space.kscience.visionforge.solid.layer -import space.kscience.visionforge.solid.three.ThreeMeshFactory.Companion.EDGES_OBJECT_NAME -import three.core.BufferGeometry -import three.geometries.EdgesGeometry -import three.objects.LineSegments -import three.objects.Mesh -import kotlin.reflect.KClass - -/** - * Basic geometry-based factory - */ -public abstract class ThreeMeshFactory( - override val type: KClass, -) : ThreeFactory { - - /** - * Build a geometry for an object - */ - public abstract suspend fun buildGeometry(obj: T): BufferGeometry - - override suspend fun build(three: ThreePlugin, vision: T, observe: Boolean): Mesh { - val geometry = buildGeometry(vision) - - val mesh = Mesh(geometry, ThreeMaterials.DEFAULT).apply { - matrixAutoUpdate = false - //set position for mesh - updatePosition(vision) - applyProperties(vision) - } - - if (observe) { - //add listener to object properties - vision.onPropertyChange(three.context) { name -> - when { - name.startsWith(Solid.GEOMETRY_KEY) -> { - val oldGeometry = mesh.geometry - val newGeometry = buildGeometry(vision) - oldGeometry.attributes = newGeometry.attributes - - mesh.applyEdges(vision) - newGeometry.dispose() - } - name.startsWith(EDGES_KEY) -> mesh.applyEdges(vision) - else -> mesh.updateProperty(vision, name) - } - } - } - - return mesh - } - - public companion object { - internal const val EDGES_OBJECT_NAME: String = "@edges" - } -} - -internal fun Mesh.applyProperties(vision: Solid): Mesh = apply { - setMaterial(vision) - applyEdges(vision) - layers.set(vision.layer) - children.forEach { - it.layers.set(vision.layer) - } -} - -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.getProperty(EDGES_MATERIAL_KEY), true) - if (edges == null) { - add( - LineSegments( - EdgesGeometry(geometry), - material - ).apply { - name = EDGES_OBJECT_NAME - } - ) - } else { - edges.material = material - } - } else { - edges?.let { - remove(it) - it.dispose() - } - } -} diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMeshLineFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMeshLineFactory.kt deleted file mode 100644 index 4a94823b..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeMeshLineFactory.kt +++ /dev/null @@ -1,41 +0,0 @@ -package space.kscience.visionforge.solid.three - -import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.solid.PolyLine -import space.kscience.visionforge.solid.color -import space.kscience.visionforge.solid.string -import three.core.Object3D -import three.math.Color -import three.meshline.MeshLine -import three.meshline.MeshLineMaterial -import three.objects.Mesh -import kotlin.math.ceil -import kotlin.reflect.KClass - -public object ThreeMeshLineFactory : ThreeFactory { - override val type: KClass get() = PolyLine::class - - override suspend fun build(three: ThreePlugin, vision: PolyLine, observe: Boolean): Object3D { - val geometry = MeshLine( - Array((vision.points.size - 1) * 2) { - vision.points[ceil(it / 2.0).toInt()].toVector() - } - ) - - val material = MeshLineMaterial().apply { - thickness = vision.thickness.toFloat() - color = vision.color.string?.let { Color(it) } ?: ThreeMaterials.DEFAULT_LINE_COLOR - } - - return Mesh(geometry, material).apply { - updatePosition(vision) - //layers.enable(obj.layer) - //add listener to object properties - if (observe) { - vision.onPropertyChange(three.context) { propertyName -> - updateProperty(vision, propertyName) - } - } - } - } -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt index c1c2cf4d..aa5c2a14 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt @@ -1,22 +1,23 @@ package space.kscience.visionforge.solid.three -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach +import info.laht.threekt.core.Object3D +import kotlinx.coroutines.CoroutineScope import org.w3c.dom.Element import org.w3c.dom.HTMLElement import space.kscience.dataforge.context.* import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.update import space.kscience.dataforge.names.* import space.kscience.visionforge.ElementVisionRenderer import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionChildren +import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.solid.* import space.kscience.visionforge.solid.specifications.Canvas3DOptions +import space.kscience.visionforge.solid.three.set import space.kscience.visionforge.visible -import three.core.Object3D import kotlin.collections.set import kotlin.reflect.KClass -import three.objects.Group as ThreeGroup +import info.laht.threekt.objects.Group as ThreeGroup public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { override val tag: PluginTag get() = Companion.tag @@ -26,19 +27,17 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { private val objectFactories = HashMap, ThreeFactory<*>>() private val compositeFactory = ThreeCompositeFactory(this) -// internal val updateScope: CoroutineScope get() = context + //TODO generate a separate supervisor update scope + internal val updateScope: CoroutineScope get() = context init { //Add specialized factories here objectFactories[Box::class] = ThreeBoxFactory objectFactories[Convex::class] = ThreeConvexFactory objectFactories[Sphere::class] = ThreeSphereFactory - objectFactories[PolyLine::class] = ThreeSmartLineFactory + objectFactories[ConeSegment::class] = ThreeConeFactory + objectFactories[PolyLine::class] = ThreeLineFactory objectFactories[SolidLabel::class] = ThreeCanvasLabelFactory - objectFactories[AmbientLightSource::class] = ThreeAmbientLightFactory - objectFactories[PointLightSource::class] = ThreePointLightFactory - objectFactories[StlSolid::class] = ThreeStlFactory - objectFactories[AxesSolid::class] = ThreeAxesFactory } @Suppress("UNCHECKED_CAST") @@ -48,75 +47,68 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { as ThreeFactory? } - public suspend fun buildObject3D(vision: Solid, observe: Boolean = true): Object3D = when (vision) { - is ThreeJsVision -> vision.render(this) - is SolidReference -> ThreeReferenceFactory.build(this, vision, observe) + public fun buildObject3D(obj: Solid): Object3D = when (obj) { + is ThreeJsVision -> obj.render(this) + is SolidReferenceGroup -> ThreeReferenceFactory(this, obj) is SolidGroup -> { val group = ThreeGroup() - vision.items.forEach { (token, child) -> - if (token != SolidGroup.PROTOTYPES_TOKEN && child.ignore != true) { + obj.children.forEach { (token, child) -> + if (child is Solid && token != SolidGroup.PROTOTYPES_TOKEN && child.ignore != true) { try { - val object3D = buildObject3D( - child, - if (token.body == VisionChildren.STATIC_TOKEN_BODY) false else observe - ) - // disable tracking changes for statics + val object3D = buildObject3D(child) group[token] = object3D } catch (ex: Throwable) { logger.error(ex) { "Failed to render $child" } + ex.printStackTrace() } } } group.apply { - updatePosition(vision) + updatePosition(obj) //obj.onChildrenChange() - if (observe) { - vision.properties.changes.onEach { name -> - if ( - name.startsWith(Solid.POSITION_KEY) || - name.startsWith(Solid.ROTATION_KEY) || - name.startsWith(Solid.SCALE_KEY) - ) { - //update position of mesh using this object - updatePosition(vision) - } else if (name == Vision.VISIBLE_KEY) { - visible = vision.visible ?: true + + obj.onPropertyChange { name -> + if ( + name.startsWith(Solid.POSITION_KEY) || + name.startsWith(Solid.ROTATION_KEY) || + name.startsWith(Solid.SCALE_KEY) + ) { + //update position of mesh using this object + updatePosition(obj) + } else if (name == Vision.VISIBLE_KEY) { + visible = obj.visible ?: true + } + } + + obj.onStructureChanged(this){ childName -> + val child = get(childName) + + //removing old object + findChild(childName)?.let { oldChild -> + oldChild.parent?.remove(oldChild) + } + + //adding new object + if (child != null && child is Solid) { + try { + val object3D = buildObject3D(child) + set(childName, object3D) + } catch (ex: Throwable) { + logger.error(ex) { "Failed to render $child" } } - }.launchIn(context) - - vision.children.changes.onEach { childName -> - if (childName.isEmpty()) return@onEach - - val child = vision.children.getChild(childName) - - //removing old object - findChild(childName)?.let { oldChild -> - oldChild.parent?.remove(oldChild) - } - - //adding new object - if (child != null && child is Solid) { - try { - val object3D = buildObject3D(child) - set(childName, object3D) - } catch (ex: Throwable) { - logger.error(ex) { "Failed to render $child" } - } - } - }.launchIn(context) + } } } } - - is Composite -> compositeFactory.build(this, vision, observe) + is Composite -> compositeFactory(this, obj) else -> { - //find a specialized factory for this type if it is present - val factory: ThreeFactory? = findObjectFactory(vision::class) + //find specialized factory for this type if it is present + val factory: ThreeFactory? = findObjectFactory(obj::class) when { - factory != null -> factory.build(this, vision, observe) - vision is GeometrySolid -> ThreeShapeFactory.build(this, vision, observe) - else -> error("Renderer for ${vision::class} not found") + factory != null -> factory(this, obj) + obj is GeometrySolid -> ThreeShapeFactory(this, obj) + else -> error("Renderer for ${obj::class} not found") } } } @@ -125,7 +117,7 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { public fun getOrCreateCanvas( element: Element, - options: Canvas3DOptions, + options: Canvas3DOptions = Canvas3DOptions(), ): ThreeCanvas = canvasCache.getOrPut(element) { ThreeCanvas(this, element, options) } @@ -143,23 +135,23 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { internal fun renderSolid( element: Element, vision: Solid, - options: Canvas3DOptions, - ): ThreeCanvas = getOrCreateCanvas(element, options).apply { + ): ThreeCanvas = getOrCreateCanvas(element).apply { render(vision) } - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { + override fun render(element: Element, vision: Vision, meta: Meta) { renderSolid( element, vision as? Solid ?: error("Solid expected but ${vision::class} found"), - Canvas3DOptions.read(meta) - ) + ).apply { + options.meta.update(meta) + } } public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.threejs", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): ThreePlugin = ThreePlugin() + override val type: KClass = ThreePlugin::class + override fun invoke(meta: Meta, context: Context): ThreePlugin = ThreePlugin() } } @@ -167,7 +159,7 @@ public fun ThreePlugin.render( element: HTMLElement, obj: Solid, optionsBuilder: Canvas3DOptions.() -> Unit = {}, -): ThreeCanvas = renderSolid(element, obj, Canvas3DOptions(optionsBuilder)).apply { +): ThreeCanvas = renderSolid(element, obj).apply { options.apply(optionsBuilder) } @@ -181,12 +173,11 @@ internal fun Object3D.getOrCreateGroup(name: Name): Object3D { name.isEmpty() -> this name.length == 1 -> { val token = name.tokens.first() - children.find { it.name == token.toString() } ?: ThreeGroup().also { group -> + children.find { it.name == token.toString() } ?: info.laht.threekt.objects.Group().also { group -> group.name = token.toString() this.add(group) } } - else -> getOrCreateGroup(name.tokens.first().asName()).getOrCreateGroup(name.cutFirst()) } } diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePointLightFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePointLightFactory.kt deleted file mode 100644 index b0a0bfeb..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePointLightFactory.kt +++ /dev/null @@ -1,37 +0,0 @@ -package space.kscience.visionforge.solid.three - -import space.kscience.dataforge.names.asName -import space.kscience.visionforge.onPropertyChange -import space.kscience.visionforge.solid.LightSource -import space.kscience.visionforge.solid.PointLightSource -import three.lights.PointLight -import three.math.Color -import kotlin.reflect.KClass - -public object ThreePointLightFactory : ThreeFactory { - override val type: KClass get() = PointLightSource::class - - private val DEFAULT_COLOR = Color(0x404040) - - override suspend fun build(three: ThreePlugin, vision: PointLightSource, observe: Boolean): PointLight { - val res = PointLight().apply { - matrixAutoUpdate = false - color = vision.color.threeColor() ?: DEFAULT_COLOR - intensity = vision.intensity.toDouble() - updatePosition(vision) - } - - if(observe) { - vision.onPropertyChange(three.context) { name -> - when (name) { - LightSource::color.name.asName() -> res.color = vision.color.threeColor() ?: DEFAULT_COLOR - LightSource::intensity.name.asName() -> res.intensity = vision.intensity.toDouble() - else -> res.updateProperty(vision, name) - } - } - } - - return res - } - -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeReferenceFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeReferenceFactory.kt index beb59df8..aa779e46 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeReferenceFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeReferenceFactory.kt @@ -1,65 +1,60 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.Object3D +import info.laht.threekt.objects.Mesh import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.cutFirst import space.kscience.dataforge.names.firstOrNull import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.SolidReference -import space.kscience.visionforge.solid.SolidReference.Companion.REFERENCE_CHILD_PROPERTY_PREFIX -import three.core.Object3D -import three.objects.Mesh +import space.kscience.visionforge.solid.SolidReferenceGroup +import space.kscience.visionforge.solid.SolidReferenceGroup.Companion.REFERENCE_CHILD_PROPERTY_PREFIX import kotlin.reflect.KClass -public object ThreeReferenceFactory : ThreeFactory { +public object ThreeReferenceFactory : ThreeFactory { private val cache = HashMap() - override val type: KClass = SolidReference::class + override val type: KClass = SolidReferenceGroup::class - private fun Object3D.replicate(): Object3D = when { - isMesh(this) -> Mesh(geometry, material).also { - //clone geometry - it.material.cached = true - it.applyMatrix4(matrix) - } - - else -> clone(false) - }.also { obj: Object3D -> - obj.name = this.name - children.forEach { child: Object3D -> - obj.add(child.replicate()) + private fun Object3D.replicate(): Object3D { + return when (this) { + is Mesh -> Mesh(geometry, material).also { + it.applyMatrix4(matrix) + } + else -> clone(false) + }.also { obj: Object3D -> + obj.name = this.name + children.forEach { child: Object3D -> + obj.add(child.replicate()) + } } } - override suspend fun build(three: ThreePlugin, vision: SolidReference, observe: Boolean): Object3D { - val template = vision.prototype + override fun invoke(three: ThreePlugin, obj: SolidReferenceGroup): Object3D { + val template = obj.prototype val cachedObject = cache.getOrPut(template) { three.buildObject3D(template) } val object3D: Object3D = cachedObject.replicate() - object3D.updatePosition(vision) + object3D.updatePosition(obj) - if (isMesh(object3D)) { + if(object3D is Mesh){ //object3D.material = ThreeMaterials.buildMaterial(obj.getProperty(SolidMaterial.MATERIAL_KEY).node!!) - object3D.applyProperties(vision) + object3D.applyProperties(obj) } //TODO apply child properties - if (observe) { - vision.onPropertyChange(three.context) { name -> - if (name.firstOrNull()?.body == REFERENCE_CHILD_PROPERTY_PREFIX) { - val childName = name.firstOrNull()?.index?.let(Name::parse) - ?: error("Wrong syntax for reference child property: '$name'") - val propertyName = name.cutFirst() - val referenceChild = - vision.children.getChild(childName) ?: error("Reference child with name '$childName' not found") - val child = object3D.findChild(childName) ?: error("Object child with name '$childName' not found") - child.updateProperty(referenceChild, propertyName) - } else { - object3D.updateProperty(vision, name) - } + obj.onPropertyChange { name-> + if (name.firstOrNull()?.body == REFERENCE_CHILD_PROPERTY_PREFIX) { + val childName = name.firstOrNull()?.index?.let(Name::parse) ?: error("Wrong syntax for reference child property: '$name'") + val propertyName = name.cutFirst() + val referenceChild = obj[childName] ?: error("Reference child with name '$childName' not found") + val child = object3D.findChild(childName) ?: error("Object child with name '$childName' not found") + child.updateProperty(referenceChild, propertyName) + } else { + object3D.updateProperty(obj, name) } } diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSmartLineFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSmartLineFactory.kt deleted file mode 100644 index b3609b66..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSmartLineFactory.kt +++ /dev/null @@ -1,19 +0,0 @@ -package space.kscience.visionforge.solid.three - -import space.kscience.visionforge.solid.PolyLine -import three.core.Object3D -import kotlin.reflect.KClass - -public object ThreeSmartLineFactory : ThreeFactory { - override val type: KClass get() = PolyLine::class - - override suspend fun build( - three: ThreePlugin, - vision: PolyLine, - observe: Boolean, - ): Object3D = if (vision.thickness == 1.0) { - ThreeLineFactory.build(three, vision, observe) - } else { - ThreeMeshLineFactory.build(three, vision, observe) - } -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSphereFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSphereFactory.kt index 9753f9ad..8932a6c8 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSphereFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeSphereFactory.kt @@ -1,13 +1,13 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.geometries.SphereGeometry import space.kscience.visionforge.solid.Sphere import space.kscience.visionforge.solid.detail -import three.core.BufferGeometry -import three.geometries.SphereGeometry -public object ThreeSphereFactory : ThreeMeshFactory(Sphere::class) { - override suspend fun buildGeometry(obj: Sphere): BufferGeometry { - return obj.detail?.let { detail -> +public object ThreeSphereFactory : MeshThreeFactory(Sphere::class) { + override fun buildGeometry(obj: Sphere): BufferGeometry { + return obj.detail?.let {detail -> SphereGeometry( radius = obj.radius, phiStart = obj.phiStart, @@ -17,7 +17,7 @@ public object ThreeSphereFactory : ThreeMeshFactory(Sphere::class) { widthSegments = detail, heightSegments = detail ) - } ?: SphereGeometry( + }?: SphereGeometry( radius = obj.radius, phiStart = obj.phiStart, phiLength = obj.phi, diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt deleted file mode 100644 index e3fb676f..00000000 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt +++ /dev/null @@ -1,38 +0,0 @@ -package space.kscience.visionforge.solid.three - -import org.khronos.webgl.ArrayBuffer -import org.khronos.webgl.Int8Array -import space.kscience.visionforge.solid.StlBinarySolid -import space.kscience.visionforge.solid.StlSolid -import space.kscience.visionforge.solid.StlUrlSolid -import three.core.BufferGeometry -import three.external.loaders.STLLoader -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException -import kotlin.coroutines.suspendCoroutine - -fun ArrayBuffer.toByteArray(): ByteArray = Int8Array(this).unsafeCast() - -public object ThreeStlFactory : ThreeMeshFactory(StlSolid::class) { - - private val loader = STLLoader().apply { - requestHeader = listOf("Access-Control-Allow-Origin: *") - } - - override suspend fun buildGeometry(obj: StlSolid): BufferGeometry = when (obj) { - is StlBinarySolid -> loader.parse(obj.data) - is StlUrlSolid -> suspendCoroutine { continuation -> - loader.load( - url = obj.url, - onLoad = { - continuation.resume(it) - }, - onError = { - continuation.resumeWithException(RuntimeException("Failed to load STL object from ${obj.url}")) - } - ) - } - } - - -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/csg.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/csg.kt index 0d7f774d..ac2fefc0 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/csg.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/csg.kt @@ -3,16 +3,17 @@ "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", - "EXTERNAL_DELEGATION" + "EXTERNAL_DELEGATION", + "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING" ) @file:JsModule("three-csg-ts") @file:JsNonModule -import three.core.BufferGeometry -import three.math.Matrix4 -import three.math.Vector3 -import three.objects.Mesh +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.math.Matrix4 +import info.laht.threekt.math.Vector3 +import info.laht.threekt.objects.Mesh public external class CSG { public fun clone(): CSG diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/three.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/three.kt index f3fc0594..ea609e58 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/three.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/three.kt @@ -1,21 +1,28 @@ package space.kscience.visionforge.solid.three +import info.laht.threekt.core.BufferGeometry +import info.laht.threekt.core.Layers +import info.laht.threekt.external.controls.OrbitControls +import info.laht.threekt.materials.Material +import info.laht.threekt.math.Euler +import info.laht.threekt.math.Vector3 +import info.laht.threekt.objects.Mesh +import info.laht.threekt.textures.Texture import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.float import space.kscience.dataforge.meta.get -import three.core.BufferGeometry -import three.core.Layers -import three.core.Object3D -import three.external.controls.OrbitControls -import three.materials.Material -import three.math.Vector3 -import three.objects.Mesh -import three.textures.Texture -import kotlin.contracts.contract +import space.kscience.dataforge.meta.node +import space.kscience.visionforge.solid.* +import kotlin.math.PI + +public val Solid.euler: Euler get() = Euler(rotationX, rotationY, rotationZ, rotationOrder.name) public val Meta.vector: Vector3 get() = Vector3(this["x"].float ?: 0f, this["y"].float ?: 0f, this["z"].float ?: 0f) +internal fun Double.toRadians() = this * PI / 180 + + internal fun Any.dispose() { when (this) { is BufferGeometry -> dispose() @@ -29,21 +36,4 @@ internal fun Any.dispose() { } } -public fun Layers.check(layer: Int): Boolean = (mask shr (layer) and 0x00000001) > 0 - - -internal fun isMesh(object3D: Object3D): Boolean{ - contract { - returns(true) implies (object3D is Mesh) - } - return object3D.asDynamic().isMesh as? Boolean ?: false -} - -internal fun Object3D.takeIfMesh(): Mesh? { - val d = asDynamic() - return if(d.isMesh as Boolean){ - d.unsafeCast() - } else { - null - } -} \ No newline at end of file +public fun Layers.check(layer: Int): Boolean = (mask shr(layer) and 0x00000001) > 0 \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/extras/core/Shape.kt b/visionforge-threejs/src/main/kotlin/three/extras/core/Shape.kt deleted file mode 100644 index d05486b5..00000000 --- a/visionforge-threejs/src/main/kotlin/three/extras/core/Shape.kt +++ /dev/null @@ -1,8 +0,0 @@ -@file:JsModule("three") -@file:JsNonModule - -package three.extras.core - -import three.math.Vector2 - -external class Shape(points: Array) : Path \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/extras/core/ShapePath.kt b/visionforge-threejs/src/main/kotlin/three/extras/core/ShapePath.kt deleted file mode 100644 index 5ea28758..00000000 --- a/visionforge-threejs/src/main/kotlin/three/extras/core/ShapePath.kt +++ /dev/null @@ -1,6 +0,0 @@ -@file:JsModule("three") -@file:JsNonModule - -package three.extras.core - -external class ShapePath \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/geometries/EdgesGeometry.kt b/visionforge-threejs/src/main/kotlin/three/geometries/EdgesGeometry.kt deleted file mode 100644 index fe53213e..00000000 --- a/visionforge-threejs/src/main/kotlin/three/geometries/EdgesGeometry.kt +++ /dev/null @@ -1,8 +0,0 @@ -@file:JsModule("three") -@file:JsNonModule - -package three.geometries - -import three.core.BufferGeometry - -public external class EdgesGeometry(geometry: BufferGeometry, thresholdAngle: Int = definedExternally) : BufferGeometry \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/ktutils.kt b/visionforge-threejs/src/main/kotlin/three/ktutils.kt deleted file mode 100644 index d0735c84..00000000 --- a/visionforge-threejs/src/main/kotlin/three/ktutils.kt +++ /dev/null @@ -1,9 +0,0 @@ -@file:Suppress("FunctionName") - -package three - -import three.renderers.WebGLRenderer -import three.renderers.WebGLRendererParams - -fun WebGLRenderer(builder: WebGLRendererParams.() -> Unit): WebGLRenderer = - WebGLRenderer(WebGLRendererParams().apply(builder)) \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/meshline/MeshLine.kt b/visionforge-threejs/src/main/kotlin/three/meshline/MeshLine.kt deleted file mode 100644 index 21e0ce34..00000000 --- a/visionforge-threejs/src/main/kotlin/three/meshline/MeshLine.kt +++ /dev/null @@ -1,37 +0,0 @@ -@file:JsModule("three.meshline") -@file:JsNonModule - -package three.meshline - -import three.core.BufferGeometry -import three.materials.ShaderMaterial -import three.math.Color -import three.math.Vector3 -import three.textures.Texture - -/* - * https://github.com/spite/THREE.MeshLine - */ - -public external class MeshLine : BufferGeometry { - public fun setGeometry(geometry: BufferGeometry) - public fun setPoints(points: Array) -} - -public external class MeshLineMaterial : ShaderMaterial { - @JsName("lineWidth") - public var thickness: Float - public var color: Color - - public var map: Texture? - public var useMap: Boolean - public var alphaMap: Texture? - public var useAlphaMap: Boolean - - public var repeat: dynamic // - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) - public var dashArray: dynamic //- the length and space between dashes. (0 - no dash) - public var dashOffset: dynamic // - defines the location where the dash will begin. Ideal to animate the line. - public var dashRatio: dynamic // - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). - public var resolution: dynamic // - THREE.Vector2 specifying the canvas size (REQUIRED) - public var sizeAttenuation: Int // - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) -} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/three/meshline/meshLineExt.kt b/visionforge-threejs/src/main/kotlin/three/meshline/meshLineExt.kt deleted file mode 100644 index 60047884..00000000 --- a/visionforge-threejs/src/main/kotlin/three/meshline/meshLineExt.kt +++ /dev/null @@ -1,11 +0,0 @@ -package three.meshline - -import three.core.BufferGeometry -import three.materials.Material -import three.math.Vector3 - -public fun MeshLine(geometry: BufferGeometry): MeshLine = MeshLine().apply { setGeometry(geometry) } - -public fun MeshLine(points: Array): MeshLine = MeshLine().apply { setPoints(points) } - -internal fun isMeshLineMaterial(material: Material): Boolean = material.asDynamic().isMeshLineMaterial == true \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/README.md b/visionforge-threejs/visionforge-threejs-server/README.md deleted file mode 100644 index 0b9d9e4e..00000000 --- a/visionforge-threejs/visionforge-threejs-server/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module visionforge-threejs-server - - - -## Usage - -## Artifact: - -The Maven coordinates of this project are `space.kscience:visionforge-threejs-server:0.2.0`. - -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-threejs-server:0.2.0' -} -``` -**Gradle Kotlin DSL:** -```kotlin -repositories { - maven("https://repo.kotlin.link") - mavenCentral() -} - -dependencies { - implementation("space.kscience:visionforge-threejs-server:0.2.0") -} -``` diff --git a/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api b/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api deleted file mode 100644 index d2d708d9..00000000 --- a/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api +++ /dev/null @@ -1,6 +0,0 @@ -public final class space/kscience/visionforge/three/ServerExtensionsKt { - public static final fun getThreeJsHeader (Lspace/kscience/visionforge/html/Page$Companion;)Lkotlin/jvm/functions/Function1; - public static final fun makeThreeJsFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;)V - public static synthetic fun makeThreeJsFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V -} - diff --git a/visionforge-threejs/visionforge-threejs-server/build.gradle.kts b/visionforge-threejs/visionforge-threejs-server/build.gradle.kts index 059f3784..696b30cf 100644 --- a/visionforge-threejs/visionforge-threejs-server/build.gradle.kts +++ b/visionforge-threejs/visionforge-threejs-server/build.gradle.kts @@ -1,29 +1,45 @@ plugins { - id("space.kscience.gradle.mpp") -} + id("ru.mipt.npm.gradle.mpp") + } val ktorVersion: String by rootProject.extra -kscience { - fullStack("js/visionforge-three.js") { - commonWebpackConfig { - cssSupport { - enabled.set(false) +kotlin { + js{ + browser { + webpackTask { + this.outputFileName = "js/visionforge-three.js" + } + } + binaries.executable() + } + + afterEvaluate { + val jsBrowserDistribution by tasks.getting + + tasks.getByName("jvmProcessResources") { + dependsOn(jsBrowserDistribution) + afterEvaluate { + from(jsBrowserDistribution) } } } - dependencies { - api(projects.visionforgeSolid) - } - - dependencies(jvmMain) { - api(projects.visionforgeServer) - } - - dependencies(jsMain) { - api(projects.visionforgeThreejs) - api(projects.ui.ring) - compileOnly(npm("webpack-bundle-analyzer","4.5.0")) + sourceSets { + commonMain { + dependencies { + api(project(":visionforge-solid")) + } + } + jvmMain { + dependencies { + api(project(":visionforge-server")) + } + } + jsMain { + dependencies { + api(project(":visionforge-threejs")) + } + } } } \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/server/jsMain.kt b/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/server/jsMain.kt new file mode 100644 index 00000000..d6d191f0 --- /dev/null +++ b/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/server/jsMain.kt @@ -0,0 +1,11 @@ +package space.kscience.visionforge.three.server + +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.visionforge.runVisionClient +import space.kscience.visionforge.solid.three.ThreePlugin + + +@DFExperimental +public fun main(): Unit = runVisionClient { + plugin(ThreePlugin) +} \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/src/jvmMain/kotlin/space/kscience/visionforge/three/server/serverExtensions.kt b/visionforge-threejs/visionforge-threejs-server/src/jvmMain/kotlin/space/kscience/visionforge/three/server/serverExtensions.kt new file mode 100644 index 00000000..94034547 --- /dev/null +++ b/visionforge-threejs/visionforge-threejs-server/src/jvmMain/kotlin/space/kscience/visionforge/three/server/serverExtensions.kt @@ -0,0 +1,30 @@ +package space.kscience.visionforge.three.server + +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.misc.DFExperimental +import space.kscience.visionforge.html.HtmlVisionFragment +import space.kscience.visionforge.html.ResourceLocation +import space.kscience.visionforge.html.page +import space.kscience.visionforge.html.scriptHeader +import space.kscience.visionforge.makeFile +import java.awt.Desktop +import java.nio.file.Path + + +public fun VisionServer.useThreeJs(): Unit { + useScript("js/visionforge-three.js") +} + +@DFExperimental +public fun Context.makeThreeJsFile( + content: HtmlVisionFragment, + path: Path? = null, + title: String = "VisionForge page", + resourceLocation: ResourceLocation = ResourceLocation.SYSTEM, + show: Boolean = true, +): Unit { + val actualPath = page(title, content = content).makeFile(path) { actualPath -> + mapOf("threeJs" to scriptHeader("js/visionforge-three.js", resourceLocation, actualPath)) + } + if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI()) +} diff --git a/visionforge-threejs/visionforge-threejs-server/src/jvmMain/kotlin/space/kscience/visionforge/three/serverExtensions.kt b/visionforge-threejs/visionforge-threejs-server/src/jvmMain/kotlin/space/kscience/visionforge/three/serverExtensions.kt deleted file mode 100644 index 28f04f8d..00000000 --- a/visionforge-threejs/visionforge-threejs-server/src/jvmMain/kotlin/space/kscience/visionforge/three/serverExtensions.kt +++ /dev/null @@ -1,32 +0,0 @@ -package space.kscience.visionforge.three - -import space.kscience.dataforge.context.Global -import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.html.* -import space.kscience.visionforge.visionManager -import java.awt.Desktop -import java.nio.file.Path - - -public val VisionPage.Companion.threeJsHeader: HtmlFragment get() = scriptHeader("js/visionforge-three.js") - -@DFExperimental -public fun makeThreeJsFile( - path: Path? = null, - title: String = "VisionForge page", - resourceLocation: ResourceLocation = ResourceLocation.SYSTEM, - show: Boolean = true, - content: HtmlVisionFragment, -): Unit { - val actualPath = VisionPage(Global.visionManager, content = content).makeFile(path) { actualPath -> - mapOf( - "title" to VisionPage.title(title), - "threeJs" to VisionPage.importScriptHeader( - "js/visionforge-three.js", - resourceLocation, - actualPath, - ) - ) - } - if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI()) -} diff --git a/visionforge-threejs/visionforge-threejs-server/src/jvmTest/kotlin/space/kscience/visionforge/three/TestServerExtensions.kt b/visionforge-threejs/visionforge-threejs-server/src/jvmTest/kotlin/space/kscience/visionforge/three/TestServerExtensions.kt deleted file mode 100644 index 95d9e6f7..00000000 --- a/visionforge-threejs/visionforge-threejs-server/src/jvmTest/kotlin/space/kscience/visionforge/three/TestServerExtensions.kt +++ /dev/null @@ -1,25 +0,0 @@ -package space.kscience.visionforge.three - -import kotlinx.html.stream.createHTML -import space.kscience.visionforge.html.ResourceLocation -import space.kscience.visionforge.html.VisionPage -import space.kscience.visionforge.html.appendTo -import space.kscience.visionforge.html.importScriptHeader -import kotlin.test.Test - -class TestServerExtensions { - - @Suppress("UNUSED_VARIABLE") - @Test - fun testServerHeader(){ - val string = createHTML().apply { - VisionPage.importScriptHeader( - "js/visionforge-three.js", - ResourceLocation.SYSTEM - ).appendTo(this) - }.finalize() - - - //println(string) - } -} \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/01.ring.js b/visionforge-threejs/visionforge-threejs-server/webpack.config.d/01.ring.js deleted file mode 100644 index b3cc4770..00000000 --- a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/01.ring.js +++ /dev/null @@ -1,23 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; -const path = require('path'); - -config.module.rules.push(...ringConfig.module.rules) - -config.module.rules.push( - { - test: /\.css$/, - exclude: [ - path.resolve(__dirname, "../../node_modules/@jetbrains/ring-ui") - ], - use: [ - { - loader: 'style-loader', - options: {} - }, - { - loader: 'css-loader', - options: {} - } - ] - } -) \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/02.bundle.js b/visionforge-threejs/visionforge-threejs-server/webpack.config.d/02.bundle.js deleted file mode 100644 index 947253ca..00000000 --- a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/02.bundle.js +++ /dev/null @@ -1,10 +0,0 @@ -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - -module.exports = { - plugins: [ - new BundleAnalyzerPlugin({ - analyzerMode: "static", - reportFilename: "bundle-report.html" - }) - ] -} \ No newline at end of file