Moved to DF 0.1.4
This commit is contained in:
parent
9bf438749c
commit
b72300bfaa
@ -151,7 +151,7 @@ abstract class AbstractVisualGroup : AbstractVisualObject(), MutableVisualGroup
|
||||
protected fun MetaBuilder.updateChildren() {
|
||||
//adding named children
|
||||
children.forEach {
|
||||
"children[${it.key}]" to it.value.toMeta()
|
||||
"children[${it.key}]" put it.value.toMeta()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ abstract class AbstractVisualObject : VisualObject {
|
||||
protected open fun MetaBuilder.updateMeta() {}
|
||||
|
||||
override fun toMeta(): Meta = buildMeta {
|
||||
"type" to this::class.simpleName
|
||||
"properties" to properties
|
||||
"type" putValue this::class.simpleName
|
||||
"properties" put properties
|
||||
updateMeta()
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ class MetaEditorDemoApp : App(MetaEditorDemo::class)
|
||||
class MetaEditorDemo : View("Meta editor demo") {
|
||||
|
||||
val meta = buildMeta {
|
||||
"aNode" to {
|
||||
"innerNode" to {
|
||||
"innerValue" to true
|
||||
"aNode" put {
|
||||
"innerNode" put {
|
||||
"innerValue" put true
|
||||
}
|
||||
"b" to 223
|
||||
"c" to "StringValue"
|
||||
"b" put 223
|
||||
"c" put "StringValue"
|
||||
}
|
||||
}.toConfig()
|
||||
|
||||
|
@ -74,5 +74,5 @@ class JSRootDemoApp : ApplicationBase() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() = emptyMap<String, Any>()//mapOf("lines" to presenter.dispose())
|
||||
override fun dispose() = emptyMap<String, Any>()//mapOf("lines" put presenter.dispose())
|
||||
}
|
@ -15,37 +15,37 @@ class JSRootGeometry(parent: VisualObject?, meta: Meta) : DisplayLeaf(parent, me
|
||||
var facesLimit by int(0)
|
||||
|
||||
fun box(xSize: Number, ySize: Number, zSize: Number) = buildMeta {
|
||||
"_typename" to "TGeoBBox"
|
||||
"fDX" to xSize
|
||||
"fDY" to ySize
|
||||
"fDZ" to zSize
|
||||
"_typename" put "TGeoBBox"
|
||||
"fDX" put xSize
|
||||
"fDY" put ySize
|
||||
"fDZ" put zSize
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GDML union
|
||||
*/
|
||||
operator fun Meta.plus(other: Meta) = buildMeta {
|
||||
"fNode.fLeft" to this
|
||||
"fNode.fRight" to other
|
||||
"fNode._typename" to "TGeoUnion"
|
||||
"fNode.fLeft" put this
|
||||
"fNode.fRight" put other
|
||||
"fNode._typename" put "TGeoUnion"
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GDML subtraction
|
||||
*/
|
||||
operator fun Meta.minus(other: Meta) = buildMeta {
|
||||
"fNode.fLeft" to this
|
||||
"fNode.fRight" to other
|
||||
"fNode._typename" to "TGeoSubtraction"
|
||||
"fNode.fLeft" put this
|
||||
"fNode.fRight" put other
|
||||
"fNode._typename" put "TGeoSubtraction"
|
||||
}
|
||||
|
||||
/**
|
||||
* Intersect two GDML geometries
|
||||
*/
|
||||
infix fun Meta.intersect(other: Meta) = buildMeta {
|
||||
"fNode.fLeft" to this
|
||||
"fNode.fRight" to other
|
||||
"fNode._typename" to "TGeoIntersection"
|
||||
"fNode.fLeft" put this
|
||||
"fNode.fRight" put other
|
||||
"fNode._typename" put "TGeoIntersection"
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -54,7 +54,7 @@ class GDMLTransformer(val root: GDML) {
|
||||
|
||||
obj.useStyle(styleName){
|
||||
COLOR_KEY to Colors.rgbToString(random.nextInt(0, Int.MAX_VALUE))
|
||||
"gdml.material" to material.name
|
||||
"gdml.material" put material.name
|
||||
}
|
||||
|
||||
obj.solidConfiguration(parent, solid)
|
||||
|
@ -47,9 +47,9 @@ class Box(
|
||||
}
|
||||
|
||||
override fun MetaBuilder.updateMeta() {
|
||||
"xSize" to xSize
|
||||
"ySize" to ySize
|
||||
"zSize" to ySize
|
||||
"xSize" put xSize
|
||||
"ySize" put ySize
|
||||
"zSize" put ySize
|
||||
updatePosition()
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ class Composite(
|
||||
override var properties: Config? = null
|
||||
|
||||
override fun MetaBuilder.updateMeta() {
|
||||
"compositeType" to compositeType
|
||||
"first" to first.toMeta()
|
||||
"second" to second.toMeta()
|
||||
"compositeType" put compositeType
|
||||
"first" put first.toMeta()
|
||||
"second" put second.toMeta()
|
||||
updatePosition()
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ class Convex(val points: List<Point3D>) : AbstractVisualObject(), VisualObject3D
|
||||
override var scale: Point3D? = null
|
||||
|
||||
override fun MetaBuilder.updateMeta() {
|
||||
"points" to {
|
||||
"point" to points.map { it.toMeta() }
|
||||
"points" put {
|
||||
"point" put points.map { it.toMeta() }
|
||||
}
|
||||
updatePosition()
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import hep.dataforge.vis.spatial.Material3D.Companion.OPACITY_KEY
|
||||
|
||||
class Material3D(override val config: Config) : Specific {
|
||||
|
||||
val color by string()
|
||||
var color by string()
|
||||
|
||||
val opacity by float(1f)
|
||||
var opacity by float(1f)
|
||||
|
||||
companion object : Specification<Material3D> {
|
||||
override fun wrap(config: Config): Material3D = Material3D(config)
|
||||
|
@ -1,9 +1,8 @@
|
||||
package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.meta.get
|
||||
import hep.dataforge.meta.getAll
|
||||
import hep.dataforge.meta.getIndexed
|
||||
import hep.dataforge.meta.node
|
||||
import hep.dataforge.names.toName
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@ -31,7 +30,7 @@ class ConvexTest {
|
||||
val pointsNode = convex.toMeta()["points"].node
|
||||
|
||||
assertEquals(8, pointsNode?.items?.count())
|
||||
val points = pointsNode?.getAll("point".toName())
|
||||
val points = pointsNode?.getIndexed("points")
|
||||
|
||||
assertEquals(8, convex.points.size)
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ class GroupTest {
|
||||
}
|
||||
box(100, 100, 100)
|
||||
material {
|
||||
"color" to Colors.lightgreen
|
||||
"opacity" to 0.3
|
||||
color(Colors.lightgreen)
|
||||
opacity = 0.3f
|
||||
}
|
||||
}
|
||||
intersect("intersect") {
|
||||
@ -46,6 +46,6 @@ class GroupTest {
|
||||
|
||||
assertEquals(3, group.count())
|
||||
assertEquals(300.0, (group["intersect"] as VisualObject3D).y.toDouble())
|
||||
assertEquals(-300.0, (group["subtract"] as VisualObject3D).y.toDouble())
|
||||
assertEquals(-300.0, (group["subtract"] as VisualObject3D).y.toDouble())
|
||||
}
|
||||
}
|
@ -99,8 +99,8 @@ private class ThreeDemoApp : Application {
|
||||
}
|
||||
sphere(50)
|
||||
material {
|
||||
"color" to Colors.lightgreen
|
||||
"opacity" to 0.3
|
||||
color(Colors.lightgreen)
|
||||
opacity = 0.3f
|
||||
}
|
||||
}
|
||||
composite(CompositeType.INTERSECT) {
|
||||
@ -148,7 +148,7 @@ private class ThreeDemoApp : Application {
|
||||
|
||||
}
|
||||
|
||||
override fun dispose() = emptyMap<String, Any>()//mapOf("lines" to presenter.dispose())
|
||||
override fun dispose() = emptyMap<String, Any>()//mapOf("lines" put presenter.dispose())
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
@ -35,7 +35,9 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager {
|
||||
private val gridRoot = document.create.div("row")
|
||||
private val outputs: MutableMap<Name, ThreeOutput> = HashMap()
|
||||
|
||||
override fun dependsOn(): List<PluginFactory<*>> = listOf(ThreePlugin)
|
||||
init {
|
||||
require(ThreePlugin)
|
||||
}
|
||||
|
||||
override fun attach(context: Context) {
|
||||
super.attach(context)
|
||||
@ -52,9 +54,9 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager {
|
||||
return outputs.getOrPut(name) {
|
||||
if (type != VisualObject::class) error("Supports only DisplayObject")
|
||||
val output = three.output(meta = meta) {
|
||||
"minSize" to 500
|
||||
"axis" to {
|
||||
"size" to 500
|
||||
"minSize" put 500
|
||||
"axis" put {
|
||||
"size" put 500
|
||||
}
|
||||
}
|
||||
//TODO calculate cell width here using jquery
|
||||
@ -85,7 +87,7 @@ class ThreeDemoGrid(meta: Meta) : AbstractPlugin(meta), OutputManager {
|
||||
|
||||
fun ThreeDemoGrid.demo(name: String, title: String = name, block: VisualGroup3D.() -> Unit) {
|
||||
val meta = buildMeta {
|
||||
"title" to title
|
||||
"title" put title
|
||||
}
|
||||
val output = get(VisualObject::class, name.toName(), meta = meta)
|
||||
output.render(action = block)
|
||||
|
Loading…
Reference in New Issue
Block a user