forked from kscience/visionforge
Fixed build and dependencies
This commit is contained in:
parent
74e70819ee
commit
fc5af5e469
@ -21,7 +21,7 @@ interface DisplayObject {
|
||||
// */
|
||||
// val type: String
|
||||
|
||||
val properties: MutableMeta<*>
|
||||
val properties: Styled
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_TYPE = ""
|
||||
@ -63,15 +63,14 @@ val DisplayObject.meta: Meta get() = properties[META_KEY]?.node ?: EmptyMeta
|
||||
|
||||
val DisplayObject.tags: List<String> get() = properties[TAGS_KEY].stringList
|
||||
|
||||
///**
|
||||
// * Basic [DisplayObject] leaf element
|
||||
// */
|
||||
//open class DisplayLeaf(
|
||||
// override val parent: DisplayObject?,
|
||||
//// override val type: String,
|
||||
// meta: Meta = EmptyMeta
|
||||
//) : DisplayObject {
|
||||
// final override val properties = Styled(meta)
|
||||
//}
|
||||
/**
|
||||
* Basic [DisplayObject] leaf element
|
||||
*/
|
||||
open class DisplayLeaf(
|
||||
override val parent: DisplayObject?,
|
||||
meta: Meta = EmptyMeta
|
||||
) : DisplayObject {
|
||||
final override val properties = Styled(meta)
|
||||
}
|
||||
|
||||
interface DisplayGroup: DisplayObject, Iterable<DisplayObject>
|
||||
|
@ -20,7 +20,7 @@ class MetaEditorDemo : View("Meta editor demo") {
|
||||
"innerNode" to {
|
||||
"innerValue" to true
|
||||
}
|
||||
"b" to 22
|
||||
"b" to 223
|
||||
"c" to "StringValue"
|
||||
}
|
||||
}.toConfig()
|
||||
@ -40,6 +40,10 @@ class MetaEditorDemo : View("Meta editor demo") {
|
||||
}
|
||||
}
|
||||
}
|
||||
value("multiple"){
|
||||
info = "A sns value"
|
||||
multiple = true
|
||||
}
|
||||
}
|
||||
|
||||
private val rootNode = FXMeta.root(meta,descriptor)
|
||||
|
@ -19,12 +19,13 @@ import org.controlsfx.glyphfont.Glyph
|
||||
import tornadofx.*
|
||||
|
||||
/**
|
||||
* FXML Controller class
|
||||
* A configuration editor fragment
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
class ConfigEditor(
|
||||
val rootNode: FXMetaNode<Config>,
|
||||
val allowNew: Boolean = true,
|
||||
title: String = "Configuration editor"
|
||||
) : Fragment(title = title, icon = dfIconView) {
|
||||
|
||||
@ -129,6 +130,7 @@ class ConfigEditor(
|
||||
graphic = chooser.node
|
||||
}
|
||||
is FXMetaNode<Config> -> {
|
||||
if(allowNew) {
|
||||
text = null
|
||||
graphic = hbox {
|
||||
button("node", Glyph("FontAwesome", "PLUS_CIRCLE")) {
|
||||
@ -150,6 +152,9 @@ class ConfigEditor(
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ fun <M : MutableMeta<M>> FXMetaNode<M>.remove(name: NameToken) {
|
||||
children.invalidate()
|
||||
}
|
||||
|
||||
private fun <M : MutableMeta<M>> M.createEmptyNode(token: NameToken): M {
|
||||
private fun <M : MutableMeta<M>> M.createEmptyNode(token: NameToken, append: Boolean): M {
|
||||
this.setNode(token.asName(), EmptyMeta)
|
||||
//FIXME possible concurrency bug
|
||||
return get(token).node!!
|
||||
@ -178,7 +178,7 @@ fun <M : MutableMeta<M>> FXMetaNode<out M>.getOrCreateNode(): M {
|
||||
val node = node
|
||||
return when {
|
||||
node != null -> node
|
||||
parent != null -> parent.getOrCreateNode().createEmptyNode(this.name).also {
|
||||
parent != null -> parent.getOrCreateNode().createEmptyNode(this.name, descriptor?.multiple == true).also {
|
||||
parent.children.invalidate()
|
||||
}
|
||||
else -> kotlin.error("Orphan empty node is not allowed")
|
||||
@ -191,13 +191,27 @@ fun <M : MutableMeta<M>> FXMeta<M>.remove() {
|
||||
}
|
||||
|
||||
fun <M : MutableMeta<M>> FXMetaNode<M>.addValue(key: String) {
|
||||
getOrCreateNode()[key] = Null
|
||||
val parent = getOrCreateNode()
|
||||
if(descriptor?.multiple == true){
|
||||
parent.append(key, Null)
|
||||
} else{
|
||||
parent[key] = Null
|
||||
}
|
||||
}
|
||||
|
||||
fun <M : MutableMeta<M>> FXMetaNode<M>.addNode(key: String) {
|
||||
getOrCreateNode()[key] = EmptyMeta
|
||||
val parent = getOrCreateNode()
|
||||
if(descriptor?.multiple == true){
|
||||
parent.append(key, EmptyMeta)
|
||||
} else{
|
||||
parent[key] = EmptyMeta
|
||||
}
|
||||
}
|
||||
|
||||
fun <M : MutableMeta<M>> FXMetaValue<M>.set(value: Value?) {
|
||||
if(descriptor?.multiple == true){
|
||||
parent.getOrCreateNode().append(this.name.body, value)
|
||||
} else {
|
||||
parent.getOrCreateNode()[this.name] = value
|
||||
}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package hep.dataforge.vis
|
||||
package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.getProperty
|
||||
import hep.dataforge.vis.onChange
|
||||
import javafx.beans.binding.ObjectBinding
|
||||
import tornadofx.*
|
||||
|
||||
@ -21,7 +24,7 @@ class DisplayObjectFXListener(val obj: DisplayObject) {
|
||||
operator fun get(key: Name): ObjectBinding<MetaItem<*>?> {
|
||||
return binndings.getOrPut(key) {
|
||||
object : ObjectBinding<MetaItem<*>?>() {
|
||||
override fun computeValue(): MetaItem<*>? = obj.get(key)
|
||||
override fun computeValue(): MetaItem<*>? = obj.getProperty(key)
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,8 @@ package hep.dataforge.vis.spatial
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.output.Output
|
||||
import hep.dataforge.vis.*
|
||||
import hep.dataforge.vis.DisplayGroup
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import javafx.scene.Group
|
||||
import javafx.scene.Node
|
||||
import org.fxyz3d.shapes.primitives.CuboidMesh
|
||||
@ -26,7 +27,7 @@ class FX3DOutput(override val context: Context) : Output<DisplayObject> {
|
||||
org.fxyz3d.geometry.Point3D(x.value ?: 0f, y.value ?: 0f, z.value ?: 0f)
|
||||
}
|
||||
return when (obj) {
|
||||
is DisplayGroup -> Group(obj.children.map { buildNode(it) }).apply {
|
||||
is DisplayGroup -> Group(obj.map { buildNode(it) }).apply {
|
||||
this.translateXProperty().bind(x)
|
||||
this.translateYProperty().bind(y)
|
||||
this.translateZProperty().bind(z)
|
||||
|
@ -3,7 +3,7 @@ package hep.dataforge.vis.spatial
|
||||
import hep.dataforge.meta.boolean
|
||||
import hep.dataforge.provider.Type
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.get
|
||||
import hep.dataforge.vis.getProperty
|
||||
import hep.dataforge.vis.onChange
|
||||
import hep.dataforge.vis.spatial.ThreeFactory.Companion.TYPE
|
||||
import hep.dataforge.vis.spatial.ThreeFactory.Companion.buildMesh
|
||||
@ -20,7 +20,7 @@ import info.laht.threekt.objects.LineSegments
|
||||
import info.laht.threekt.objects.Mesh
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal val DisplayObject.material get() = this["color"].material()
|
||||
internal val DisplayObject.material get() = getProperty("color").material()
|
||||
|
||||
/**
|
||||
* Builder and updater for three.js object
|
||||
@ -49,13 +49,13 @@ interface ThreeFactory<T : DisplayObject> {
|
||||
|
||||
internal fun buildMesh(obj: DisplayObject, geometry: BufferGeometry): Mesh {
|
||||
val mesh = Mesh(geometry, obj.material)
|
||||
if (obj["edges.enabled"]?.boolean != false) {
|
||||
val material = obj["edges.material"]?.material() ?: Materials.DEFAULT
|
||||
if (obj.getProperty("edges.enabled")?.boolean != false) {
|
||||
val material = obj.getProperty("edges.material")?.material() ?: Materials.DEFAULT
|
||||
mesh.add(LineSegments(EdgesGeometry(mesh.geometry as BufferGeometry), material))
|
||||
}
|
||||
|
||||
if (obj["wireframe.enabled"]?.boolean == true) {
|
||||
val material = obj["edges.material"]?.material() ?: Materials.DEFAULT
|
||||
if (obj.getProperty("wireframe.enabled")?.boolean == true) {
|
||||
val material = obj.getProperty("edges.material")?.material() ?: Materials.DEFAULT
|
||||
mesh.add(LineSegments(WireframeGeometry(mesh.geometry as BufferGeometry), material))
|
||||
}
|
||||
return mesh
|
||||
|
@ -64,7 +64,7 @@ class ThreeOutput(override val context: Context, val meta: Meta = EmptyMeta) : O
|
||||
|
||||
private fun buildNode(obj: DisplayObject): Object3D? {
|
||||
return when (obj) {
|
||||
is DisplayGroup -> Group(obj.children.mapNotNull { buildNode(it) }).apply {
|
||||
is DisplayGroup -> Group(obj.mapNotNull { buildNode(it) }).apply {
|
||||
ThreeFactory.updatePosition(obj, this)
|
||||
}
|
||||
//is Box -> ThreeBoxFactory(obj)
|
||||
|
@ -16,7 +16,7 @@ import info.laht.threekt.core.BufferGeometry
|
||||
|
||||
|
||||
class GDMLShape(parent: DisplayObject?, meta: Meta, val shape: GDMLSolid) :
|
||||
DisplayLeaf(parent, "$TYPE.${shape.type}", meta) {
|
||||
DisplayLeaf(parent, meta) {
|
||||
|
||||
var facesLimit by int(0)
|
||||
|
||||
|
@ -8,7 +8,7 @@ import hep.dataforge.vis.*
|
||||
import hep.dataforge.vis.spatial.MeshThreeFactory
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
|
||||
class JSRootGeometry(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, TYPE, meta) {
|
||||
class JSRootGeometry(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, meta) {
|
||||
|
||||
var shape by node()
|
||||
|
||||
@ -53,7 +53,7 @@ class JSRootGeometry(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, T
|
||||
}
|
||||
}
|
||||
|
||||
fun DisplayGroup.jsRootGeometry(meta: Meta = EmptyMeta, action: JSRootGeometry.() -> Unit = {}) =
|
||||
fun DisplayObjectList.jsRootGeometry(meta: Meta = EmptyMeta, action: JSRootGeometry.() -> Unit = {}) =
|
||||
JSRootGeometry(this, meta).apply(action).also { addChild(it) }
|
||||
|
||||
//fun Meta.toDynamic(): dynamic {
|
||||
|
@ -3,14 +3,14 @@ package hep.dataforge.vis.spatial.jsroot
|
||||
import hep.dataforge.meta.EmptyMeta
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.toDynamic
|
||||
import hep.dataforge.vis.DisplayGroup
|
||||
import hep.dataforge.vis.DisplayLeaf
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.DisplayObjectList
|
||||
import hep.dataforge.vis.node
|
||||
import hep.dataforge.vis.spatial.ThreeFactory
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
class JSRootObject(parent: DisplayObject?, meta: Meta, val data: dynamic) : DisplayLeaf(parent, TYPE, meta) {
|
||||
class JSRootObject(parent: DisplayObject?, meta: Meta, val data: dynamic) : DisplayLeaf(parent, meta) {
|
||||
|
||||
var options by node()
|
||||
|
||||
@ -28,7 +28,7 @@ object ThreeJSRootObjectFactory : ThreeFactory<JSRootObject> {
|
||||
}
|
||||
}
|
||||
|
||||
fun DisplayGroup.jsRootObject(str: String) {
|
||||
fun DisplayObjectList.jsRootObject(str: String) {
|
||||
val json = JSON.parse<Any>(str)
|
||||
JSRootObject(this, EmptyMeta, json).also { addChild(it) }
|
||||
}
|
@ -2,10 +2,12 @@ package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.meta.EmptyMeta
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.vis.DisplayLeaf
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.DisplayObjectList
|
||||
import hep.dataforge.vis.double
|
||||
|
||||
class Box(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, TYPE, meta) {
|
||||
class Box(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, meta) {
|
||||
var xSize by double(1.0)
|
||||
var ySize by double(1.0)
|
||||
var zSize by double(1.0)
|
||||
|
@ -2,10 +2,11 @@ package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.vis.DisplayLeaf
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.DisplayObjectList
|
||||
|
||||
class Convex(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, TYPE, meta) {
|
||||
class Convex(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, meta) {
|
||||
|
||||
val points = points(properties["points"] ?: error("Vertices not defined"))
|
||||
|
||||
|
@ -2,10 +2,11 @@ package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.vis.DisplayLeaf
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.DisplayObjectList
|
||||
|
||||
class Extruded(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, TYPE, meta) {
|
||||
class Extruded(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, meta) {
|
||||
|
||||
val shape get() = shape(properties["shape"] ?: error("Shape not defined"))
|
||||
|
||||
|
@ -4,16 +4,15 @@ import hep.dataforge.meta.*
|
||||
import hep.dataforge.output.Output
|
||||
import hep.dataforge.vis.DisplayGroup
|
||||
import hep.dataforge.vis.DisplayObject
|
||||
import hep.dataforge.vis.DisplayObject.Companion.DEFAULT_TYPE
|
||||
import hep.dataforge.vis.DisplayObjectList
|
||||
import hep.dataforge.vis.getProperty
|
||||
|
||||
fun DisplayObjectList.group(meta: Meta = EmptyMeta, action: DisplayObjectList.() -> Unit = {}): DisplayGroup =
|
||||
DisplayObjectList(this, DEFAULT_TYPE, meta).apply(action).also { addChild(it) }
|
||||
DisplayObjectList(this, meta).apply(action).also { addChild(it) }
|
||||
|
||||
|
||||
fun Output<DisplayObject>.render(meta: Meta = EmptyMeta, action: DisplayObjectList.() -> Unit) =
|
||||
render(DisplayObjectList(null, DEFAULT_TYPE, EmptyMeta).apply(action), meta)
|
||||
render(DisplayObjectList(null, EmptyMeta).apply(action), meta)
|
||||
|
||||
//TODO replace properties by containers?
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.meta.get
|
||||
import hep.dataforge.meta.getAll
|
||||
import hep.dataforge.meta.node
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.vis.DisplayObjectList
|
||||
import kotlin.test.Test
|
||||
|
Loading…
Reference in New Issue
Block a user