Quick and dirty gdml to json converter

This commit is contained in:
Alexander Nozik 2020-04-13 19:24:03 +03:00
parent c49b143a65
commit 656c6f931b
7 changed files with 37 additions and 17 deletions

View File

@ -40,7 +40,7 @@ kotlin {
api(npm("inline-style-prefixer")) api(npm("inline-style-prefixer"))
api(npm("source-map-resolve","0.6.0")) api(npm("source-map-resolve","0.6.0"))
api(npm("bootstrap","4.3.1")) api(npm("bootstrap","4.4.1"))
api(npm("popper.js","1.14.7")) api(npm("popper.js","1.14.7"))
api(npm("jquery","3.5.0")) api(npm("jquery","3.5.0"))
//api(npm("jsoneditor", "8.6.1")) //api(npm("jsoneditor", "8.6.1"))

View File

@ -75,7 +75,7 @@ class ConfigEditorComponent : RComponent<ConfigEditorProps, TreeState>() {
private val onValueChange: (Event) -> Unit = { private val onValueChange: (Event) -> Unit = {
val value = (it.target as HTMLInputElement).value val value = (it.target as HTMLInputElement).value
try { try {
if(value.isEmpty()){ if (value.isEmpty()) {
props.root.remove(props.name) props.root.remove(props.name)
} }
props.root.setValue(props.name, value.asValue()) props.root.setValue(props.name, value.asValue())
@ -94,7 +94,7 @@ class ConfigEditorComponent : RComponent<ConfigEditorProps, TreeState>() {
when (actualItem) { when (actualItem) {
is MetaItem.NodeItem -> { is MetaItem.NodeItem -> {
div("d-inline-block text-truncate") { div("d-block text-truncate") {
span("tree-caret") { span("tree-caret") {
attrs { attrs {
if (state.expanded) { if (state.expanded) {
@ -139,7 +139,7 @@ class ConfigEditorComponent : RComponent<ConfigEditorProps, TreeState>() {
} }
} }
is MetaItem.ValueItem -> { is MetaItem.ValueItem -> {
div("d-inline-block text-truncate") { div("d-block text-truncate") {
div("row") { div("row") {
div("col") { div("col") {
p("tree-label") { p("tree-label") {
@ -152,15 +152,13 @@ class ConfigEditorComponent : RComponent<ConfigEditorProps, TreeState>() {
} }
} }
div("col") { div("col") {
div("float-right") { input(type = InputType.text, classes = "float-right") {
input(type = InputType.text) { attrs {
attrs { defaultValue = actualItem.value.string
defaultValue = actualItem.value.string onChangeFunction = onValueChange
onChangeFunction = onValueChange
}
} }
//+actualItem.value.toString()
} }
//+actualItem.value.toString()
} }
} }
} }

View File

@ -36,4 +36,10 @@ kotlin {
application { application {
mainClassName = "hep.dataforge.vis.spatial.gdml.demo.GDMLDemoAppKt" mainClassName = "hep.dataforge.vis.spatial.gdml.demo.GDMLDemoAppKt"
}
val convertGdmlToJson by tasks.creating(JavaExec::class) {
group = "application"
classpath = sourceSets["main"].runtimeClasspath
main = "hep.dataforge.vis.spatial.gdml.demo.SaveToJsonKt"
} }

View File

@ -1,7 +1,5 @@
package hep.dataforge.vis.spatial.gdml.demo package hep.dataforge.vis.spatial.gdml.demo
import hep.dataforge.vis.spatial.Visual3D
import hep.dataforge.vis.spatial.VisualGroup3D
import hep.dataforge.vis.spatial.gdml.LUnit import hep.dataforge.vis.spatial.gdml.LUnit
import hep.dataforge.vis.spatial.gdml.readFile import hep.dataforge.vis.spatial.gdml.readFile
import hep.dataforge.vis.spatial.gdml.toVisual import hep.dataforge.vis.spatial.gdml.toVisual
@ -10,11 +8,21 @@ import scientifik.gdml.GDML
import java.io.File import java.io.File
import java.nio.file.Paths import java.nio.file.Paths
fun main() { fun main(args: Array<String>) {
val gdml = GDML.readFile(Paths.get("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.gdml")) require(args.isNotEmpty()){"At least one argument is required"}
val inputFileName = args[0]
require(inputFileName.endsWith(".gdml")){"GDML requires"}
val outputFileName = args.getOrNull(1)?:inputFileName.replace(".gdml",".json")
val gdml = GDML.readFile(Paths.get(inputFileName))
//GDML.readFile(Paths.get("D:\\Work\\Projects\\dataforge-vis\\dataforge-vis-spatial-gdml\\src\\jvmTest\\resources\\gdml\\simple1.gdml"))
val visual = gdml.toVisual { val visual = gdml.toVisual {
lUnit = LUnit.CM lUnit = LUnit.CM
} }
val json = visual.stringify() val json = visual.stringify()
File("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.json").writeText(json) println(json)
File(outputFileName).writeText(json)
//File("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.json").writeText(json)
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">--> <!-- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">-->
<title>Three js demo for particle physics</title> <title>Three js demo for particle physics</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/main.css"> <link rel="stylesheet" href="css/main.css">
<script type="text/javascript" src="main.bundle.js"></script> <script type="text/javascript" src="main.bundle.js"></script>
</head> </head>