forked from kscience/visionforge
Moved to DF 0.1.4
This commit is contained in:
parent
1d5debb8a6
commit
9bf438749c
@ -1,4 +1,4 @@
|
|||||||
val dataforgeVersion by extra("0.1.3")
|
val dataforgeVersion by extra("0.1.4")
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
val kotlinVersion = "1.3.50"
|
val kotlinVersion = "1.3.50"
|
||||||
@ -15,6 +15,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||||
maven("http://maven.jzy3d.org/releases")
|
maven("http://maven.jzy3d.org/releases")
|
||||||
maven("https://kotlin.bintray.com/js-externals")
|
maven("https://kotlin.bintray.com/js-externals")
|
||||||
|
@ -30,7 +30,8 @@ class VisualPlugin(meta: Meta) : AbstractPlugin(meta) {
|
|||||||
companion object : PluginFactory<VisualPlugin> {
|
companion object : PluginFactory<VisualPlugin> {
|
||||||
override val tag: PluginTag = PluginTag(name = "visual", group = PluginTag.DATAFORGE_GROUP)
|
override val tag: PluginTag = PluginTag(name = "visual", group = PluginTag.DATAFORGE_GROUP)
|
||||||
override val type: KClass<out VisualPlugin> = VisualPlugin::class
|
override val type: KClass<out VisualPlugin> = VisualPlugin::class
|
||||||
override fun invoke(meta: Meta): VisualPlugin = VisualPlugin(meta)
|
|
||||||
|
override fun invoke(meta: Meta, context: Context): VisualPlugin = VisualPlugin(meta)
|
||||||
|
|
||||||
const val VISUAL_FACTORY_TYPE = "visual.factory"
|
const val VISUAL_FACTORY_TYPE = "visual.factory"
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ class FXPlugin(meta: Meta = EmptyMeta) : AbstractPlugin(meta) {
|
|||||||
companion object : PluginFactory<FXPlugin> {
|
companion object : PluginFactory<FXPlugin> {
|
||||||
override val type: KClass<out FXPlugin> = FXPlugin::class
|
override val type: KClass<out FXPlugin> = FXPlugin::class
|
||||||
override val tag: PluginTag = PluginTag("vis.fx", group = PluginTag.DATAFORGE_GROUP)
|
override val tag: PluginTag = PluginTag("vis.fx", group = PluginTag.DATAFORGE_GROUP)
|
||||||
override fun invoke(meta: Meta): FXPlugin = FXPlugin(meta)
|
override fun invoke(meta: Meta, context: Context): FXPlugin = FXPlugin(meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class FXMetaNode<M : MetaNode<M>>(
|
|||||||
override val hasValue: ObservableBooleanValue = nodeProperty.booleanBinding { it != null }
|
override val hasValue: ObservableBooleanValue = nodeProperty.booleanBinding { it != null }
|
||||||
|
|
||||||
private val filter: (FXMeta<M>) -> Boolean = { cfg ->
|
private val filter: (FXMeta<M>) -> Boolean = { cfg ->
|
||||||
!(cfg.descriptor?.tags?.contains(ConfigEditor.NO_CONFIGURATOR_TAG) ?: false)
|
!(cfg.descriptor?.attributes?.get(ConfigEditor.NO_CONFIGURATOR_TAG)?.boolean ?: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val children = object : ListBinding<FXMeta<M>>() {
|
val children = object : ListBinding<FXMeta<M>>() {
|
||||||
@ -172,7 +172,7 @@ fun <M : MutableMeta<M>> FXMetaNode<M>.remove(name: NameToken) {
|
|||||||
private fun <M : MutableMeta<M>> M.createEmptyNode(token: NameToken, append: Boolean): M {
|
private fun <M : MutableMeta<M>> M.createEmptyNode(token: NameToken, append: Boolean): M {
|
||||||
return if (append && token.index.isNotEmpty()) {
|
return if (append && token.index.isNotEmpty()) {
|
||||||
val name = token.asName()
|
val name = token.asName()
|
||||||
val index = (getAll(name).keys.mapNotNull { it.toIntOrNull() }.max() ?: -1) + 1
|
val index = (getIndexed(name).keys.mapNotNull { it.toIntOrNull() }.max() ?: -1) + 1
|
||||||
val newName = name.withIndex(index.toString())
|
val newName = name.withIndex(index.toString())
|
||||||
set(newName, EmptyMeta)
|
set(newName, EmptyMeta)
|
||||||
get(newName).node!!
|
get(newName).node!!
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package hep.dataforge.vis.fx.values
|
package hep.dataforge.vis.fx.values
|
||||||
|
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.names.Name
|
||||||
|
import hep.dataforge.names.asName
|
||||||
import hep.dataforge.values.Null
|
import hep.dataforge.values.Null
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
import hep.dataforge.values.asValue
|
import hep.dataforge.values.asValue
|
||||||
@ -40,7 +42,7 @@ class ColorValueChooser : ValueChooserBase<ColorPicker>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : ValueChooser.Factory {
|
companion object : ValueChooser.Factory {
|
||||||
override val name: String = "color"
|
override val name: Name = "color".asName()
|
||||||
|
|
||||||
override fun invoke(meta: Meta): ValueChooser = ColorValueChooser()
|
override fun invoke(meta: Meta): ValueChooser = ColorValueChooser()
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ package hep.dataforge.vis.fx.values
|
|||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.meta.get
|
import hep.dataforge.meta.get
|
||||||
import hep.dataforge.meta.value
|
import hep.dataforge.meta.value
|
||||||
|
import hep.dataforge.names.Name
|
||||||
|
import hep.dataforge.names.asName
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
import hep.dataforge.values.parseValue
|
import hep.dataforge.values.parseValue
|
||||||
import javafx.collections.FXCollections
|
import javafx.collections.FXCollections
|
||||||
@ -50,7 +52,7 @@ class ComboBoxValueChooser(val values: Collection<Value>? = null) : ValueChooser
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : ValueChooser.Factory {
|
companion object : ValueChooser.Factory {
|
||||||
override val name: String = "combo"
|
override val name: Name = "combo".asName()
|
||||||
|
|
||||||
override fun invoke(meta: Meta): ValueChooser = ComboBoxValueChooser(meta["values"].value?.list)
|
override fun invoke(meta: Meta): ValueChooser = ComboBoxValueChooser(meta["values"].value?.list)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
package hep.dataforge.vis.fx.values
|
package hep.dataforge.vis.fx.values
|
||||||
|
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.names.Name
|
||||||
|
import hep.dataforge.names.asName
|
||||||
import hep.dataforge.values.*
|
import hep.dataforge.values.*
|
||||||
import javafx.beans.value.ObservableValue
|
import javafx.beans.value.ObservableValue
|
||||||
import javafx.scene.control.TextField
|
import javafx.scene.control.TextField
|
||||||
@ -100,7 +102,7 @@ class TextValueChooser : ValueChooserBase<TextField>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : ValueChooser.Factory {
|
companion object : ValueChooser.Factory {
|
||||||
override val name: String = "text"
|
override val name: Name = "text".asName()
|
||||||
override fun invoke(meta: Meta): ValueChooser = TextValueChooser()
|
override fun invoke(meta: Meta): ValueChooser = TextValueChooser()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import hep.dataforge.context.Named
|
|||||||
import hep.dataforge.descriptors.ValueDescriptor
|
import hep.dataforge.descriptors.ValueDescriptor
|
||||||
import hep.dataforge.meta.EmptyMeta
|
import hep.dataforge.meta.EmptyMeta
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.names.toName
|
||||||
import hep.dataforge.provider.Type
|
import hep.dataforge.provider.Type
|
||||||
import hep.dataforge.provider.provideByType
|
import hep.dataforge.provider.provideByType
|
||||||
import hep.dataforge.values.Null
|
import hep.dataforge.values.Null
|
||||||
@ -71,7 +72,7 @@ interface ValueChooser {
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private fun findWidgetByType(context: Context, type: String): Factory? {
|
private fun findWidgetByType(context: Context, type: String): Factory? {
|
||||||
return when (type) {
|
return when (type.toName()) {
|
||||||
TextValueChooser.name -> TextValueChooser
|
TextValueChooser.name -> TextValueChooser
|
||||||
ColorValueChooser.name -> ColorValueChooser
|
ColorValueChooser.name -> ColorValueChooser
|
||||||
ComboBoxValueChooser.name -> ComboBoxValueChooser
|
ComboBoxValueChooser.name -> ComboBoxValueChooser
|
||||||
|
@ -29,7 +29,7 @@ class GDMLTransformer(val root: GDML) {
|
|||||||
/**
|
/**
|
||||||
* A special group for local templates
|
* A special group for local templates
|
||||||
*/
|
*/
|
||||||
val templates by lazy { VisualGroup3D() }
|
val proto by lazy { VisualGroup3D() }
|
||||||
private val styleCache = HashMap<Name, Meta>()
|
private val styleCache = HashMap<Name, Meta>()
|
||||||
|
|
||||||
var lUnit: LUnit = LUnit.MM
|
var lUnit: LUnit = LUnit.MM
|
||||||
@ -67,7 +67,7 @@ class GDMLTransformer(val root: GDML) {
|
|||||||
var onFinish: GDMLTransformer.() -> Unit = {}
|
var onFinish: GDMLTransformer.() -> Unit = {}
|
||||||
|
|
||||||
internal fun finalize(final: VisualGroup3D): VisualGroup3D {
|
internal fun finalize(final: VisualGroup3D): VisualGroup3D {
|
||||||
final.templates = templates
|
final.prototypes = proto
|
||||||
styleCache.forEach {
|
styleCache.forEach {
|
||||||
final.addStyle(it.key, it.value, false)
|
final.addStyle(it.key, it.value, false)
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,8 @@ private fun VisualGroup3D.addPhysicalVolume(
|
|||||||
}
|
}
|
||||||
GDMLTransformer.Action.CACHE -> {
|
GDMLTransformer.Action.CACHE -> {
|
||||||
val fullName = volumesName + volume.name.asName()
|
val fullName = volumesName + volume.name.asName()
|
||||||
if (context.templates[fullName] == null) {
|
if (context.proto[fullName] == null) {
|
||||||
context.templates[fullName] = volume(context, volume)
|
context.proto[fullName] = volume(context, volume)
|
||||||
}
|
}
|
||||||
|
|
||||||
this[physVolume.name ?: ""] = Proxy(fullName).apply {
|
this[physVolume.name ?: ""] = Proxy(fullName).apply {
|
||||||
@ -215,8 +215,8 @@ private fun volume(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GDMLTransformer.Action.CACHE -> {
|
GDMLTransformer.Action.CACHE -> {
|
||||||
if (context.templates[solid.name] == null) {
|
if (context.proto[solid.name] == null) {
|
||||||
context.templates.addSolid(context, solid, solid.name) {
|
context.proto.addSolid(context, solid, solid.name) {
|
||||||
context.configureSolid(this, group, solid)
|
context.configureSolid(this, group, solid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,14 +119,14 @@ private class GDMLDemoApp : Application {
|
|||||||
val three = context.plugins.load(ThreePlugin)
|
val three = context.plugins.load(ThreePlugin)
|
||||||
//val url = URL("https://drive.google.com/open?id=1w5e7fILMN83JGgB8WANJUYm8OW2s0WVO")
|
//val url = URL("https://drive.google.com/open?id=1w5e7fILMN83JGgB8WANJUYm8OW2s0WVO")
|
||||||
|
|
||||||
val canvas = document.getElementById("canvas") ?: error("Element with id 'canvas' not found on page")
|
val canvasElement = document.getElementById("canvas") ?: error("Element with id 'canvas' not found on page")
|
||||||
val layers = document.getElementById("layers") ?: error("Element with id 'layers' not found on page")
|
val configElement = document.getElementById("layers") ?: error("Element with id 'layers' not found on page")
|
||||||
val tree = document.getElementById("tree") ?: error("Element with id 'tree' not found on page")
|
val treeElement = document.getElementById("tree") ?: error("Element with id 'tree' not found on page")
|
||||||
val editor = document.getElementById("editor") ?: error("Element with id 'editor' not found on page")
|
val editorElement = document.getElementById("editor") ?: error("Element with id 'editor' not found on page")
|
||||||
canvas.clear()
|
canvasElement.clear()
|
||||||
|
|
||||||
val action: (name: String, data: String) -> Unit = { name, data ->
|
val action: (name: String, data: String) -> Unit = { name, data ->
|
||||||
canvas.clear()
|
canvasElement.clear()
|
||||||
spinner(true)
|
spinner(true)
|
||||||
message("Loading GDML")
|
message("Loading GDML")
|
||||||
val gdml = GDML.format.parse(GDML.serializer(), data)
|
val gdml = GDML.format.parse(GDML.serializer(), data)
|
||||||
@ -149,12 +149,12 @@ private class GDMLDemoApp : Application {
|
|||||||
message("Rendering")
|
message("Rendering")
|
||||||
|
|
||||||
//output.camera.layers.enable(1)
|
//output.camera.layers.enable(1)
|
||||||
val output = three.output(canvas as HTMLElement)
|
val output = three.output(canvasElement as HTMLElement)
|
||||||
|
|
||||||
output.camera.layers.set(0)
|
output.camera.layers.set(0)
|
||||||
layers.threeOutputConfig(output)
|
configElement.threeOutputConfig(output)
|
||||||
//tree.visualObjectTree(visual, editor::propertyEditor)
|
//tree.visualObjectTree(visual, editor::propertyEditor)
|
||||||
tree.objectTree(NameToken("World"),visual, editor::propertyEditor)
|
treeElement.objectTree(NameToken("World"),visual, editorElement::propertyEditor)
|
||||||
|
|
||||||
|
|
||||||
output.render(visual)
|
output.render(visual)
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package hep.dataforge.vis.spatial.gdml
|
||||||
|
|
||||||
|
import hep.dataforge.names.toName
|
||||||
|
import hep.dataforge.vis.spatial.*
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val vis = VisualGroup3D().apply {
|
||||||
|
val box = Box(100f, 100f, 20f).apply {
|
||||||
|
color(0u, 0u, 255u)
|
||||||
|
}
|
||||||
|
proxy("some.name".toName(), box, "obj")
|
||||||
|
}
|
||||||
|
|
||||||
|
val string = Visual3DPlugin.json.stringify(VisualGroup3D.serializer(),vis)
|
||||||
|
println(string)
|
||||||
|
}
|
@ -21,7 +21,6 @@ kotlin {
|
|||||||
}
|
}
|
||||||
jvmMain {
|
jvmMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":dataforge-vis-fx"))
|
|
||||||
implementation("org.fxyz3d:fxyz3d:0.5.2")
|
implementation("org.fxyz3d:fxyz3d:0.5.2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
package hep.dataforge.vis.spatial
|
package hep.dataforge.vis.spatial
|
||||||
|
|
||||||
import hep.dataforge.io.ConfigSerializer
|
import hep.dataforge.io.ConfigSerializer
|
||||||
import hep.dataforge.io.NameSerializer
|
|
||||||
|
import hep.dataforge.io.serialization.NameSerializer
|
||||||
import hep.dataforge.meta.*
|
import hep.dataforge.meta.*
|
||||||
import hep.dataforge.names.Name
|
import hep.dataforge.names.Name
|
||||||
import hep.dataforge.names.NameToken
|
import hep.dataforge.names.NameToken
|
||||||
@ -36,7 +37,7 @@ class Proxy(val templateName: Name) : AbstractVisualObject(), VisualGroup, Visua
|
|||||||
* Recursively search for defined template in the parent
|
* Recursively search for defined template in the parent
|
||||||
*/
|
*/
|
||||||
val prototype: VisualObject3D
|
val prototype: VisualObject3D
|
||||||
get() = (parent as? VisualGroup3D)?.getTemplate(templateName)
|
get() = (parent as? VisualGroup3D)?.getPrototype(templateName)
|
||||||
?: error("Template with name $templateName not found in $parent")
|
?: error("Template with name $templateName not found in $parent")
|
||||||
|
|
||||||
override fun getStyle(name: Name): Meta? = (parent as VisualGroup?)?.getStyle(name)
|
override fun getStyle(name: Name): Meta? = (parent as VisualGroup?)?.getStyle(name)
|
||||||
@ -65,7 +66,9 @@ class Proxy(val templateName: Name) : AbstractVisualObject(), VisualGroup, Visua
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val children: Map<NameToken, ProxyChild>
|
override val children: Map<NameToken, ProxyChild>
|
||||||
get() = (prototype as? MutableVisualGroup)?.children?.mapValues {
|
get() = (prototype as? MutableVisualGroup)?.children
|
||||||
|
?.filter { !it.key.toString().startsWith("@") }
|
||||||
|
?.mapValues {
|
||||||
ProxyChild(it.key.asName())
|
ProxyChild(it.key.asName())
|
||||||
} ?: emptyMap()
|
} ?: emptyMap()
|
||||||
|
|
||||||
@ -152,8 +155,30 @@ val VisualObject.prototype: VisualObject?
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create ref for existing prototype
|
||||||
|
*/
|
||||||
inline fun VisualGroup3D.ref(
|
inline fun VisualGroup3D.ref(
|
||||||
templateName: Name,
|
templateName: Name,
|
||||||
name: String = "",
|
name: String = "",
|
||||||
action: Proxy.() -> Unit = {}
|
block: Proxy.() -> Unit = {}
|
||||||
) = Proxy(templateName).apply(action).also { set(name, it) }
|
) = Proxy(templateName).apply(block).also { set(name, it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new proxy wrapping given object and automatically adding it to the prototypes
|
||||||
|
*/
|
||||||
|
fun VisualGroup3D.proxy(
|
||||||
|
templateName: Name,
|
||||||
|
obj: VisualObject3D,
|
||||||
|
name: String = "",
|
||||||
|
attachToParent: Boolean = false,
|
||||||
|
block: Proxy.() -> Unit = {}
|
||||||
|
): Proxy {
|
||||||
|
val existing = getPrototype(templateName)
|
||||||
|
if (existing == null) {
|
||||||
|
setPrototype(templateName,obj, attachToParent)
|
||||||
|
} else if(existing != obj) {
|
||||||
|
error("Can't add different prototype on top of existing one")
|
||||||
|
}
|
||||||
|
return ref(templateName, name, block)
|
||||||
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package hep.dataforge.vis.spatial
|
package hep.dataforge.vis.spatial
|
||||||
|
|
||||||
import hep.dataforge.context.AbstractPlugin
|
import hep.dataforge.context.AbstractPlugin
|
||||||
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.PluginFactory
|
import hep.dataforge.context.PluginFactory
|
||||||
import hep.dataforge.context.PluginTag
|
import hep.dataforge.context.PluginTag
|
||||||
import hep.dataforge.io.ConfigSerializer
|
import hep.dataforge.io.ConfigSerializer
|
||||||
import hep.dataforge.io.MetaSerializer
|
import hep.dataforge.io.MetaSerializer
|
||||||
import hep.dataforge.io.NameSerializer
|
import hep.dataforge.io.serialization.NameSerializer
|
||||||
import hep.dataforge.meta.*
|
import hep.dataforge.meta.*
|
||||||
import hep.dataforge.names.Name
|
import hep.dataforge.names.Name
|
||||||
import hep.dataforge.vis.common.VisualObject
|
import hep.dataforge.vis.common.VisualObject
|
||||||
@ -30,7 +31,7 @@ class Visual3DPlugin(meta: Meta) : AbstractPlugin(meta) {
|
|||||||
companion object : PluginFactory<Visual3DPlugin> {
|
companion object : PluginFactory<Visual3DPlugin> {
|
||||||
override val tag: PluginTag = PluginTag(name = "visual.spatial", group = PluginTag.DATAFORGE_GROUP)
|
override val tag: PluginTag = PluginTag(name = "visual.spatial", group = PluginTag.DATAFORGE_GROUP)
|
||||||
override val type: KClass<out Visual3DPlugin> = Visual3DPlugin::class
|
override val type: KClass<out Visual3DPlugin> = Visual3DPlugin::class
|
||||||
override fun invoke(meta: Meta): Visual3DPlugin = Visual3DPlugin(meta)
|
override fun invoke(meta: Meta, context: Context): Visual3DPlugin = Visual3DPlugin(meta)
|
||||||
|
|
||||||
val serialModule = SerializersModule {
|
val serialModule = SerializersModule {
|
||||||
contextual(Point3DSerializer)
|
contextual(Point3DSerializer)
|
||||||
|
@ -10,7 +10,7 @@ package hep.dataforge.vis.spatial
|
|||||||
|
|
||||||
import hep.dataforge.io.ConfigSerializer
|
import hep.dataforge.io.ConfigSerializer
|
||||||
import hep.dataforge.io.MetaSerializer
|
import hep.dataforge.io.MetaSerializer
|
||||||
import hep.dataforge.io.NameSerializer
|
import hep.dataforge.io.serialization.NameSerializer
|
||||||
import hep.dataforge.meta.Config
|
import hep.dataforge.meta.Config
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.meta.MetaBuilder
|
import hep.dataforge.meta.MetaBuilder
|
||||||
@ -32,7 +32,8 @@ class VisualGroup3D : AbstractVisualGroup(), VisualObject3D {
|
|||||||
/**
|
/**
|
||||||
* A container for templates visible inside this group
|
* A container for templates visible inside this group
|
||||||
*/
|
*/
|
||||||
var templates: VisualGroup3D? = null
|
@SerialName(PROTOTYPES_KEY)
|
||||||
|
var prototypes: VisualGroup3D? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.parent = this
|
value?.parent = this
|
||||||
field = value
|
field = value
|
||||||
@ -85,18 +86,26 @@ class VisualGroup3D : AbstractVisualGroup(), VisualObject3D {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTemplate(name: Name): VisualObject3D? =
|
fun getPrototype(name: Name): VisualObject3D? =
|
||||||
templates?.get(name) as? VisualObject3D
|
prototypes?.get(name) as? VisualObject3D ?: (parent as? VisualGroup3D)?.getPrototype(name)
|
||||||
?: (parent as? VisualGroup3D)?.getTemplate(name)
|
|
||||||
|
fun setPrototype(name: Name, obj: VisualObject3D, attachToParent: Boolean = false) {
|
||||||
|
val parent = this.parent
|
||||||
|
if (attachToParent && parent is VisualGroup3D) {
|
||||||
|
parent.setPrototype(name, obj, attachToParent)
|
||||||
|
} else {
|
||||||
|
(prototypes ?: VisualGroup3D().also { this.prototypes = it }).set(name, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun MetaBuilder.updateMeta() {
|
override fun MetaBuilder.updateMeta() {
|
||||||
set(TEMPLATES_KEY, templates?.toMeta())
|
set(PROTOTYPES_KEY, prototypes?.toMeta())
|
||||||
updatePosition()
|
updatePosition()
|
||||||
updateChildren()
|
updateChildren()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TEMPLATES_KEY = "templates"
|
const val PROTOTYPES_KEY = "templates"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +118,7 @@ fun VisualGroup.attachChildren() {
|
|||||||
(it as? VisualGroup)?.attachChildren()
|
(it as? VisualGroup)?.attachChildren()
|
||||||
}
|
}
|
||||||
if (this is VisualGroup3D) {
|
if (this is VisualGroup3D) {
|
||||||
templates?.also {
|
prototypes?.also {
|
||||||
it.parent = this
|
it.parent = this
|
||||||
it.attachChildren()
|
it.attachChildren()
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
package hep.dataforge.vis.spatial
|
package hep.dataforge.vis.spatial
|
||||||
|
|
||||||
import hep.dataforge.io.NameSerializer
|
import hep.dataforge.io.serialization.NameSerializer
|
||||||
import hep.dataforge.meta.*
|
import hep.dataforge.meta.*
|
||||||
import hep.dataforge.names.asName
|
import hep.dataforge.names.asName
|
||||||
import hep.dataforge.names.plus
|
import hep.dataforge.names.plus
|
||||||
import hep.dataforge.output.Output
|
import hep.dataforge.output.Output
|
||||||
import hep.dataforge.vis.common.VisualObject
|
import hep.dataforge.vis.common.VisualObject
|
||||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.DETAIL_KEY
|
import hep.dataforge.vis.spatial.VisualObject3D.Companion.DETAIL_KEY
|
||||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.LAYER_KEY
|
|
||||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.IGNORE_KEY
|
import hep.dataforge.vis.spatial.VisualObject3D.Companion.IGNORE_KEY
|
||||||
|
import hep.dataforge.vis.spatial.VisualObject3D.Companion.LAYER_KEY
|
||||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.SELECTED_KEY
|
import hep.dataforge.vis.spatial.VisualObject3D.Companion.SELECTED_KEY
|
||||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.VISIBLE_KEY
|
import hep.dataforge.vis.spatial.VisualObject3D.Companion.VISIBLE_KEY
|
||||||
import kotlinx.serialization.UseSerializers
|
import kotlinx.serialization.UseSerializers
|
||||||
|
@ -49,7 +49,7 @@ object RemoveSingleChild : VisualTreeTransform<VisualGroup3D>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replaceChildren()
|
replaceChildren()
|
||||||
templates?.replaceChildren()
|
prototypes?.replaceChildren()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun VisualGroup3D.clone(): VisualGroup3D {
|
override fun VisualGroup3D.clone(): VisualGroup3D {
|
||||||
|
@ -24,7 +24,7 @@ object UnRef : VisualTreeTransform<VisualGroup3D>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun MutableVisualGroup.unref(name: Name) {
|
private fun MutableVisualGroup.unref(name: Name) {
|
||||||
(this as? VisualGroup3D)?.templates?.set(name, null)
|
(this as? VisualGroup3D)?.prototypes?.set(name, null)
|
||||||
children.filter { (it.value as? Proxy)?.templateName == name }.forEach { (key, value) ->
|
children.filter { (it.value as? Proxy)?.templateName == name }.forEach { (key, value) ->
|
||||||
val proxy = value as Proxy
|
val proxy = value as Proxy
|
||||||
val newChild = mergeChild(proxy, proxy.prototype)
|
val newChild = mergeChild(proxy, proxy.prototype)
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package hep.dataforge.vis.spatial.three
|
package hep.dataforge.vis.spatial.three
|
||||||
|
|
||||||
import hep.dataforge.context.AbstractPlugin
|
import hep.dataforge.context.*
|
||||||
import hep.dataforge.context.PluginFactory
|
|
||||||
import hep.dataforge.context.PluginTag
|
|
||||||
import hep.dataforge.context.content
|
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.names.Name
|
import hep.dataforge.names.Name
|
||||||
import hep.dataforge.names.asName
|
import hep.dataforge.names.asName
|
||||||
@ -88,7 +85,7 @@ class ThreePlugin : AbstractPlugin() {
|
|||||||
companion object : PluginFactory<ThreePlugin> {
|
companion object : PluginFactory<ThreePlugin> {
|
||||||
override val tag = PluginTag("visual.three", PluginTag.DATAFORGE_GROUP)
|
override val tag = PluginTag("visual.three", PluginTag.DATAFORGE_GROUP)
|
||||||
override val type = ThreePlugin::class
|
override val type = ThreePlugin::class
|
||||||
override fun invoke(meta: Meta) = ThreePlugin()
|
override fun invoke(meta: Meta,context: Context) = ThreePlugin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager {
|
|||||||
|
|
||||||
override val type: KClass<out ThreeDemoGrid> = ThreeDemoGrid::class
|
override val type: KClass<out ThreeDemoGrid> = ThreeDemoGrid::class
|
||||||
|
|
||||||
override fun invoke(meta: Meta): ThreeDemoGrid = ThreeDemoGrid(meta)
|
override fun invoke(meta: Meta,context: Context): ThreeDemoGrid = ThreeDemoGrid(meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ kotlin{
|
|||||||
sourceSets["main"].apply{
|
sourceSets["main"].apply{
|
||||||
dependencies{
|
dependencies{
|
||||||
api(npm("style-loader"))
|
api(npm("style-loader"))
|
||||||
api(npm("inspire-tree","6.0.1"))
|
// api(npm("inspire-tree","6.0.1"))
|
||||||
api(npm("inspire-tree-dom","4.0.6"))
|
// api(npm("inspire-tree-dom","4.0.6"))
|
||||||
api(npm("jsoneditor"))
|
api(npm("jsoneditor"))
|
||||||
api(npm("dat.gui"))
|
api(npm("dat.gui"))
|
||||||
//api("org.jetbrains:kotlin-extensions:1.0.1-pre.83-kotlin-1.3.50")
|
//api("org.jetbrains:kotlin-extensions:1.0.1-pre.83-kotlin-1.3.50")
|
||||||
|
Loading…
Reference in New Issue
Block a user