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