Fix style merge

This commit is contained in:
Alexander Nozik 2020-08-08 17:21:35 +03:00
parent 2f570f2791
commit 5e3e3908ea
19 changed files with 43 additions and 37 deletions

View File

@ -1,6 +1,5 @@
import scientifik.DependencyConfiguration import scientifik.DependencyConfiguration
import scientifik.FXModule import scientifik.FXModule
import scientifik.useFx
plugins { plugins {
id("scientifik.mpp") id("scientifik.mpp")
@ -37,7 +36,7 @@ kotlin {
} }
application { application {
mainClassName = "hep.dataforge.vis.spatial.gdml.demo.GDMLDemoAppKt" mainClassName = "hep.dataforge.vision.gdml.demo.GDMLDemoAppKt"
} }
val convertGdmlToJson by tasks.creating(JavaExec::class) { val convertGdmlToJson by tasks.creating(JavaExec::class) {

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import scientifik.gdml.* import scientifik.gdml.*

View File

@ -1,11 +1,11 @@
package hep.dataforge.vision.solid.gdml package hep.dataforge.vision.gdml
import hep.dataforge.meta.setItem import hep.dataforge.meta.setItem
import hep.dataforge.meta.string import hep.dataforge.meta.string
import hep.dataforge.names.toName import hep.dataforge.names.toName
import hep.dataforge.values.asValue import hep.dataforge.values.asValue
import hep.dataforge.vision.gdml.demo.cubes
import hep.dataforge.vision.solid.SolidMaterial import hep.dataforge.vision.solid.SolidMaterial
import hep.dataforge.vision.solid.gdml.demo.cubes
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import hep.dataforge.context.Context import hep.dataforge.context.Context
import hep.dataforge.names.Name import hep.dataforge.names.Name
@ -6,13 +6,13 @@ import hep.dataforge.names.isEmpty
import hep.dataforge.vision.Vision import hep.dataforge.vision.Vision
import hep.dataforge.vision.VisionGroup import hep.dataforge.vision.VisionGroup
import hep.dataforge.vision.bootstrap.* import hep.dataforge.vision.bootstrap.*
import hep.dataforge.vision.gdml.toVision
import hep.dataforge.vision.react.component import hep.dataforge.vision.react.component
import hep.dataforge.vision.react.configEditor import hep.dataforge.vision.react.configEditor
import hep.dataforge.vision.react.flexColumn import hep.dataforge.vision.react.flexColumn
import hep.dataforge.vision.react.state import hep.dataforge.vision.react.state
import hep.dataforge.vision.solid.Solid import hep.dataforge.vision.solid.Solid
import hep.dataforge.vision.solid.SolidGroup import hep.dataforge.vision.solid.SolidGroup
import hep.dataforge.vision.solid.gdml.toVision
import hep.dataforge.vision.solid.specifications.Camera import hep.dataforge.vision.solid.specifications.Camera
import hep.dataforge.vision.solid.specifications.Canvas3DOptions import hep.dataforge.vision.solid.specifications.Canvas3DOptions
import hep.dataforge.vision.solid.three.ThreeCanvas import hep.dataforge.vision.solid.three.ThreeCanvas

View File

@ -1,12 +1,12 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.js.Application import hep.dataforge.js.Application
import hep.dataforge.js.startApplication import hep.dataforge.js.startApplication
import hep.dataforge.vision.gdml.GDMLTransformer
import hep.dataforge.vision.gdml.LUnit
import hep.dataforge.vision.gdml.toVision
import hep.dataforge.vision.solid.SolidMaterial.Companion.MATERIAL_OPACITY_KEY import hep.dataforge.vision.solid.SolidMaterial.Companion.MATERIAL_OPACITY_KEY
import hep.dataforge.vision.solid.gdml.GDMLTransformer
import hep.dataforge.vision.solid.gdml.LUnit
import hep.dataforge.vision.solid.gdml.toVision
import kotlinx.css.* import kotlinx.css.*
import react.child import react.child
import react.dom.render import react.dom.render

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import drop.FileDrop import drop.FileDrop
import kotlinx.css.* import kotlinx.css.*

View File

@ -1,13 +1,13 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.vision.editor.VisualObjectEditorFragment import hep.dataforge.vision.editor.VisualObjectEditorFragment
import hep.dataforge.vision.editor.VisualObjectTreeFragment import hep.dataforge.vision.editor.VisualObjectTreeFragment
import hep.dataforge.vision.gdml.toVision
import hep.dataforge.vision.solid.SolidManager import hep.dataforge.vision.solid.SolidManager
import hep.dataforge.vision.solid.SolidMaterial import hep.dataforge.vision.solid.SolidMaterial
import hep.dataforge.vision.solid.fx.FX3DPlugin import hep.dataforge.vision.solid.fx.FX3DPlugin
import hep.dataforge.vision.solid.fx.FXCanvas3D import hep.dataforge.vision.solid.fx.FXCanvas3D
import hep.dataforge.vision.solid.gdml.toVision
import javafx.geometry.Orientation import javafx.geometry.Orientation
import javafx.scene.Parent import javafx.scene.Parent
import javafx.stage.FileChooser import javafx.stage.FileChooser

View File

@ -1,14 +1,14 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import hep.dataforge.meta.DFExperimental import hep.dataforge.meta.DFExperimental
import hep.dataforge.meta.setItem import hep.dataforge.meta.setItem
import hep.dataforge.values.asValue import hep.dataforge.values.asValue
import hep.dataforge.vision.gdml.LUnit
import hep.dataforge.vision.gdml.readFile
import hep.dataforge.vision.gdml.toVision
import hep.dataforge.vision.solid.SolidGroup import hep.dataforge.vision.solid.SolidGroup
import hep.dataforge.vision.solid.SolidManager import hep.dataforge.vision.solid.SolidManager
import hep.dataforge.vision.solid.SolidMaterial import hep.dataforge.vision.solid.SolidMaterial
import hep.dataforge.vision.solid.gdml.LUnit
import hep.dataforge.vision.solid.gdml.readFile
import hep.dataforge.vision.solid.gdml.toVision
import scientifik.gdml.GDML import scientifik.gdml.GDML
import java.io.File import java.io.File
import java.util.zip.GZIPInputStream import java.util.zip.GZIPInputStream

View File

@ -1,8 +1,8 @@
package hep.dataforge.vision.solid.gdml.demo package hep.dataforge.vision.gdml.demo
import hep.dataforge.vision.solid.gdml.LUnit import hep.dataforge.vision.gdml.LUnit
import hep.dataforge.vision.solid.gdml.readFile import hep.dataforge.vision.gdml.readFile
import hep.dataforge.vision.solid.gdml.toVision import hep.dataforge.vision.gdml.toVision
import hep.dataforge.vision.solid.stringify import hep.dataforge.vision.solid.stringify
import scientifik.gdml.GDML import scientifik.gdml.GDML
import java.io.File import java.io.File

View File

@ -1,6 +1,6 @@
package hep.dataforge.vision.solid.demo package hep.dataforge.vision.solid.demo
import hep.dataforge.vision.solid.gdml.gdml import hep.dataforge.vision.gdml.gdml
import javafx.stage.Stage import javafx.stage.Stage
import tornadofx.* import tornadofx.*
import java.nio.file.NoSuchFileException import java.nio.file.NoSuchFileException

View File

@ -73,13 +73,13 @@ abstract class AbstractVision : Vision {
return if (inherit) { return if (inherit) {
sequence { sequence {
yield(properties?.get(name)) yield(properties?.get(name))
yield(getStyleItem(name)) yieldAll(getStyleItems(name))
yield(parent?.getProperty(name, inherit)) yield(parent?.getProperty(name, inherit))
}.merge() }.merge()
} else { } else {
sequence { sequence {
yield(properties?.get(name)) yield(properties?.get(name))
yield(getStyleItem(name)) yieldAll(getStyleItems(name))
}.merge() }.merge()
} }
} }

View File

@ -106,8 +106,15 @@ fun Vision.useStyle(name: String) {
styles = styles + name styles = styles + name
} }
fun Vision.getStyleItem(name: Name): MetaItem<*>? { /**
return styles.asSequence().map { resolveStyle(it) }.map { it[name] }.firstOrNull() * Resolve an item in all style layers
*/
fun Vision.getStyleItems(name: Name): Sequence<MetaItem<*>> {
return styles.asSequence().map {
resolveStyle(it)
}.map {
it[name]
}.filterNotNull()
} }
/** /**

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml package hep.dataforge.vision.gdml
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.MetaBuilder

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml package hep.dataforge.vision.gdml
import hep.dataforge.names.Name import hep.dataforge.names.Name

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml package hep.dataforge.vision.gdml
import scientifik.gdml.AUnit import scientifik.gdml.AUnit
import scientifik.gdml.GDMLPosition import scientifik.gdml.GDMLPosition

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml package hep.dataforge.vision.gdml
import hep.dataforge.vision.solid.SolidGroup import hep.dataforge.vision.solid.SolidGroup
import nl.adaptivity.xmlutil.StAXReader import nl.adaptivity.xmlutil.StAXReader

View File

@ -1,4 +1,4 @@
package hep.dataforge.vision.solid.gdml package hep.dataforge.vision.gdml
import hep.dataforge.vision.solid.stringify import hep.dataforge.vision.solid.stringify
import nl.adaptivity.xmlutil.StAXReader import nl.adaptivity.xmlutil.StAXReader

View File

@ -48,14 +48,14 @@ class Proxy private constructor(
return if (inherit) { return if (inherit) {
sequence { sequence {
yield(properties?.get(name)) yield(properties?.get(name))
yield(getStyleItem(name)) yieldAll(getStyleItems(name))
yield(prototype.getItem(name)) yield(prototype.getItem(name))
yield(parent?.getProperty(name, inherit)) yield(parent?.getProperty(name, inherit))
}.merge() }.merge()
} else { } else {
sequence { sequence {
yield(properties?.get(name)) yield(properties?.get(name))
yield(getStyleItem(name)) yieldAll(getStyleItems(name))
yield(prototype.getProperty(name, false)) yield(prototype.getProperty(name, false))
}.merge() }.merge()
} }
@ -126,14 +126,14 @@ class Proxy private constructor(
return if (inherit) { return if (inherit) {
sequence { sequence {
yield(properties?.get(name)) yield(properties?.get(name))
yield(getStyleItem(name)) yieldAll(getStyleItems(name))
yield(prototype.getItem(name)) yield(prototype.getItem(name))
yield(parent?.getProperty(name, inherit)) yield(parent?.getProperty(name, inherit))
}.merge() }.merge()
} else { } else {
sequence { sequence {
yield(properties?.get(name)) yield(properties?.get(name))
yield(getStyleItem(name)) yieldAll(getStyleItems(name))
yield(prototype.getProperty(name, false)) yield(prototype.getProperty(name, false))
}.merge() }.merge()
} }

View File

@ -44,7 +44,7 @@ object ThreeMaterials {
} }
fun getMaterial(vision3D: Vision): Material { fun getMaterial(vision3D: Vision): Material {
val meta = vision3D.getItem(SolidMaterial.MATERIAL_KEY).node ?: return ThreeMaterials.DEFAULT val meta = vision3D.getItem(SolidMaterial.MATERIAL_KEY).node ?: return DEFAULT
return if (meta[SolidMaterial.SPECULAR_COLOR_KEY] != null) { return if (meta[SolidMaterial.SPECULAR_COLOR_KEY] != null) {
MeshPhongMaterial().apply { MeshPhongMaterial().apply {
color = meta[SolidMaterial.COLOR_KEY]?.getColor() ?: DEFAULT_COLOR color = meta[SolidMaterial.COLOR_KEY]?.getColor() ?: DEFAULT_COLOR