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("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("jquery","3.5.0"))
//api(npm("jsoneditor", "8.6.1"))

View File

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

View File

@ -37,3 +37,9 @@ kotlin {
application {
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
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.readFile
import hep.dataforge.vis.spatial.gdml.toVisual
@ -10,11 +8,21 @@ import scientifik.gdml.GDML
import java.io.File
import java.nio.file.Paths
fun main() {
val gdml = GDML.readFile(Paths.get("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.gdml"))
fun main(args: Array<String>) {
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 {
lUnit = LUnit.CM
}
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 name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">-->
<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">
<script type="text/javascript" src="main.bundle.js"></script>
</head>