From ea82082304d46fb560b3cc529e376e0b2d26d7aa Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 26 Aug 2020 23:00:21 +0300 Subject: [PATCH] Add edges to transparent objects. remove unnecessary re-configuration --- .../vision/gdml/demo/GDMLAppComponent.kt | 2 +- .../vision/gdml/demo/GdmlJsDemoApp.kt | 14 +---------- .../dataforge/vision/gdml/demo/readFile.kt | 24 +++++++++---------- .../dataforge/vision/gdml/GDMLTransformer.kt | 5 ++-- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GDMLAppComponent.kt b/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GDMLAppComponent.kt index 99d4bc59..9cd2c2bd 100644 --- a/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GDMLAppComponent.kt +++ b/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GDMLAppComponent.kt @@ -59,7 +59,7 @@ val GDMLApp = component { props -> val parsedVision = when { name.endsWith(".gdml") || name.endsWith(".xml") -> { val gdml = GDML.parse(data) - gdml.toVision(gdmlConfiguration) + gdml.toVision() } name.endsWith(".json") -> SolidGroup.parseJson(data) else -> { diff --git a/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GdmlJsDemoApp.kt b/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GdmlJsDemoApp.kt index 40d35a09..fc0478f0 100644 --- a/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GdmlJsDemoApp.kt +++ b/demo/gdml/src/jsMain/kotlin/hep/dataforge/vision/gdml/demo/GdmlJsDemoApp.kt @@ -14,18 +14,6 @@ import styled.injectGlobal import kotlin.browser.document -val gdmlConfiguration: GDMLTransformer.() -> Unit = { - lUnit = LUnit.CM - - solidConfiguration = { parent, _ -> - if (parent.physVolumes.isNotEmpty()) { - useStyle("opaque") { - MATERIAL_OPACITY_KEY put 0.3 - } - } - } -} - private class GDMLDemoApp : Application { override fun start(state: Map) { @@ -46,7 +34,7 @@ private class GDMLDemoApp : Application { child(GDMLApp) { attrs { this.context = context - this.rootObject = cubes().toVision(gdmlConfiguration) + this.rootObject = cubes().toVision() } } } diff --git a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vision/gdml/demo/readFile.kt b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vision/gdml/demo/readFile.kt index c0fcd2ed..355d6f98 100644 --- a/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vision/gdml/demo/readFile.kt +++ b/demo/gdml/src/jvmMain/kotlin/hep/dataforge/vision/gdml/demo/readFile.kt @@ -18,18 +18,18 @@ import java.util.zip.ZipInputStream fun SolidManager.Companion.readFile(file: File): SolidGroup = when { file.extension == "gdml" || file.extension == "xml" -> { GDML.readFile(file.toPath()).toVision { - lUnit = LUnit.CM - - solidConfiguration = { parent, solid -> - if (solid.name == "cave") { - setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue()) - } - if (parent.physVolumes.isNotEmpty()) { - useStyle("opaque") { - SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 - } - } - } +// lUnit = LUnit.CM +// +// solidConfiguration = { parent, solid -> +// if (solid.name == "cave") { +// setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue()) +// } +// if (parent.physVolumes.isNotEmpty()) { +// useStyle("opaque") { +// SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 +// } +// } +// } } } file.extension == "json" -> SolidGroup.parseJson(file.readText()) diff --git a/visionforge-gdml/src/commonMain/kotlin/hep/dataforge/vision/gdml/GDMLTransformer.kt b/visionforge-gdml/src/commonMain/kotlin/hep/dataforge/vision/gdml/GDMLTransformer.kt index 299a9b16..df14eb40 100644 --- a/visionforge-gdml/src/commonMain/kotlin/hep/dataforge/vision/gdml/GDMLTransformer.kt +++ b/visionforge-gdml/src/commonMain/kotlin/hep/dataforge/vision/gdml/GDMLTransformer.kt @@ -47,9 +47,7 @@ class GDMLTransformer(val root: GDML) { } internal val volumes by lazy { - proto.group(volumesName) { - config["edges.enabled"] = true - } + proto.group(volumesName) } private val styleCache = HashMap() @@ -58,6 +56,7 @@ class GDMLTransformer(val root: GDML) { if (parent.physVolumes.isNotEmpty()) { useStyle("opaque") { SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 + "edges.enabled" put true } } }