forked from kscience/visionforge
Remove bootstrap from solid
This commit is contained in:
parent
22c3521a9e
commit
3edb00b6bf
@ -4,7 +4,7 @@ plugins {
|
||||
id("ru.mipt.npm.project")
|
||||
}
|
||||
|
||||
val dataforgeVersion by extra("0.2.0-dev-3")
|
||||
val dataforgeVersion by extra("0.2.0-dev-4")
|
||||
val ktorVersion by extra("1.4.1")
|
||||
|
||||
allprojects {
|
||||
|
@ -14,11 +14,8 @@ kscience {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
jvm {
|
||||
afterEvaluate {
|
||||
withJava()
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
commonMain {
|
||||
@ -37,7 +34,7 @@ kotlin {
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "hep.dataforge.vision.gdml.demo.GdmlFxDemoAppKt"
|
||||
mainClass.set("hep.dataforge.vision.gdml.demo.GdmlFxDemoAppKt")
|
||||
}
|
||||
|
||||
val convertGdmlToJson by tasks.creating(JavaExec::class) {
|
||||
|
@ -9,14 +9,10 @@ import hep.dataforge.vision.bootstrap.*
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.react.component
|
||||
import hep.dataforge.vision.react.objectTree
|
||||
import hep.dataforge.vision.react.state
|
||||
import hep.dataforge.vision.solid.Solid
|
||||
import hep.dataforge.vision.solid.SolidGroup
|
||||
import hep.dataforge.vision.solid.specifications.Camera
|
||||
import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvas
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvasComponent
|
||||
import hep.dataforge.vision.solid.three.canvasControls
|
||||
import kotlinx.browser.window
|
||||
import kotlinx.css.FlexBasis
|
||||
import kotlinx.css.Overflow
|
||||
@ -28,8 +24,10 @@ import org.w3c.files.FileReader
|
||||
import org.w3c.files.get
|
||||
import react.RProps
|
||||
import react.dom.h1
|
||||
import react.getValue
|
||||
import react.setValue
|
||||
import react.useState
|
||||
import styled.css
|
||||
import kotlin.math.PI
|
||||
|
||||
external interface GDMLAppProps : RProps {
|
||||
var context: Context
|
||||
@ -37,18 +35,19 @@ external interface GDMLAppProps : RProps {
|
||||
var selected: Name?
|
||||
}
|
||||
|
||||
private val canvasConfig = Canvas3DOptions {
|
||||
camera = Camera {
|
||||
distance = 2100.0
|
||||
latitude = PI / 6
|
||||
azimuth = PI + PI / 6
|
||||
}
|
||||
}
|
||||
//private val canvasConfig = Canvas3DOptions {
|
||||
// camera = Camera {
|
||||
// distance = 2100.0
|
||||
// latitude = PI / 6
|
||||
// azimuth = PI + PI / 6
|
||||
// }
|
||||
//}
|
||||
|
||||
@JsExport
|
||||
val GDMLApp = component<GDMLAppProps> { props ->
|
||||
var selected by state { props.selected }
|
||||
var canvas: ThreeCanvas? by state { null }
|
||||
var vision: Vision? by state { props.rootObject }
|
||||
var selected by useState { props.selected }
|
||||
var canvas: ThreeCanvas? by useState { null }
|
||||
var vision: Vision? by useState { props.rootObject }
|
||||
|
||||
val select: (Name?) -> Unit = {
|
||||
selected = it
|
||||
|
@ -55,7 +55,7 @@ kotlin {
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "ru.mipt.npm.muon.monitor.server.MMServerKt"
|
||||
mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt")
|
||||
}
|
||||
|
||||
distributions {
|
||||
|
@ -6,16 +6,15 @@ import hep.dataforge.names.NameToken
|
||||
import hep.dataforge.names.isEmpty
|
||||
import hep.dataforge.names.length
|
||||
import hep.dataforge.vision.Vision
|
||||
import hep.dataforge.vision.bootstrap.canvasControls
|
||||
import hep.dataforge.vision.bootstrap.card
|
||||
import hep.dataforge.vision.react.component
|
||||
import hep.dataforge.vision.react.configEditor
|
||||
import hep.dataforge.vision.react.objectTree
|
||||
import hep.dataforge.vision.react.state
|
||||
import hep.dataforge.vision.solid.specifications.Camera
|
||||
import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvas
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvasComponent
|
||||
import hep.dataforge.vision.solid.three.canvasControls
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.get
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@ -23,6 +22,9 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.html.js.onClickFunction
|
||||
import react.RProps
|
||||
import react.dom.*
|
||||
import react.getValue
|
||||
import react.setValue
|
||||
import react.useState
|
||||
import kotlin.math.PI
|
||||
|
||||
external interface MMAppProps : RProps {
|
||||
@ -42,14 +44,14 @@ private val canvasConfig = Canvas3DOptions {
|
||||
|
||||
@JsExport
|
||||
val MMApp = component<MMAppProps> { props ->
|
||||
var selected by state { props.selected }
|
||||
var canvas: ThreeCanvas? by state { null }
|
||||
var selected by useState { props.selected }
|
||||
var canvas: ThreeCanvas? by useState { null }
|
||||
|
||||
val select: (Name?) -> Unit = {
|
||||
selected = it
|
||||
}
|
||||
|
||||
val visual = props.model.root
|
||||
val root = props.model.root
|
||||
|
||||
div("row") {
|
||||
h1("mx-auto") {
|
||||
@ -60,7 +62,7 @@ val MMApp = component<MMAppProps> { props ->
|
||||
div("col-lg-3 px-0 overflow-auto") {
|
||||
//tree
|
||||
card("Object tree") {
|
||||
objectTree(visual, selected, select)
|
||||
objectTree(root, selected, select)
|
||||
}
|
||||
}
|
||||
div("col-lg-6") {
|
||||
@ -68,7 +70,7 @@ val MMApp = component<MMAppProps> { props ->
|
||||
child(ThreeCanvasComponent::class) {
|
||||
attrs {
|
||||
this.context = props.context
|
||||
this.obj = visual
|
||||
this.obj = root
|
||||
this.options = canvasConfig
|
||||
this.selected = selected
|
||||
this.clickCallback = select
|
||||
@ -153,8 +155,8 @@ val MMApp = component<MMAppProps> { props ->
|
||||
selected.let { selected ->
|
||||
val selectedObject: Vision? = when {
|
||||
selected == null -> null
|
||||
selected.isEmpty() -> visual
|
||||
else -> visual[selected]
|
||||
selected.isEmpty() -> root
|
||||
else -> root[selected]
|
||||
}
|
||||
if (selectedObject != null) {
|
||||
configEditor(selectedObject, default = selectedObject.getAllProperties(), key = selected)
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,9 +1,9 @@
|
||||
pluginManagement {
|
||||
val kotlinVersion = "1.4.20-M1"
|
||||
val toolsVersion = "0.6.3-dev-1.4.20-M1"
|
||||
val kotlinVersion = "1.4.20-M2"
|
||||
val toolsVersion = "0.6.4-dev-1.4.20-M2"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
// mavenLocal()
|
||||
jcenter()
|
||||
gradlePluginPortal()
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
|
@ -5,5 +5,6 @@ plugins {
|
||||
val dataforgeVersion: String by rootProject.extra
|
||||
|
||||
dependencies{
|
||||
api(project(":visionforge-solid"))
|
||||
api(project(":ui:react"))
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package hep.dataforge.vision.solid.three
|
||||
package hep.dataforge.vision.bootstrap
|
||||
|
||||
import hep.dataforge.js.requireJS
|
||||
import hep.dataforge.meta.DFExperimental
|
||||
import hep.dataforge.vision.bootstrap.accordion
|
||||
import hep.dataforge.vision.bootstrap.entry
|
||||
import hep.dataforge.vision.solid.SolidGroup
|
||||
import hep.dataforge.vision.solid.SolidManager
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvas
|
||||
import kotlinx.dom.clear
|
||||
import kotlinx.html.*
|
||||
import kotlinx.html.dom.append
|
||||
import kotlinx.html.js.onChangeFunction
|
||||
@ -21,7 +21,6 @@ import react.dom.button
|
||||
import react.dom.div
|
||||
import react.dom.input
|
||||
import react.dom.label
|
||||
import kotlin.dom.clear
|
||||
|
||||
private fun saveData(event: Event, fileName: String, mimeType: String = "text/plain", dataBuilder: () -> String) {
|
||||
event.stopPropagation();
|
@ -2,13 +2,13 @@ plugins {
|
||||
id("ru.mipt.npm.js")
|
||||
}
|
||||
|
||||
val reactVersion by extra("16.13.1")
|
||||
val reactVersion by extra("17.0.0")
|
||||
|
||||
dependencies{
|
||||
api(project(":visionforge-core"))
|
||||
|
||||
//api("org.jetbrains:kotlin-react:16.13.1-pre.104-kotlin-1.3.72")
|
||||
api("org.jetbrains:kotlin-react-dom:$reactVersion-pre.123-kotlin-1.4.10")
|
||||
api("org.jetbrains:kotlin-react-dom:$reactVersion-pre.126-kotlin-1.4.10")
|
||||
|
||||
api(npm("react", reactVersion))
|
||||
api(npm("react-dom", reactVersion))
|
||||
|
@ -42,11 +42,11 @@ private val ConfigEditorItem: FunctionalComponent<ConfigEditorItemProps> = compo
|
||||
}
|
||||
|
||||
private fun RFBuilder.configEditorItem(props: ConfigEditorItemProps) {
|
||||
var expanded: Boolean by state { true }
|
||||
var item: MetaItem<Config>? by state { props.root[props.name] }
|
||||
var expanded: Boolean by useState { true }
|
||||
var item: MetaItem<Config>? by useState { props.root[props.name] }
|
||||
val descriptorItem: ItemDescriptor? = props.descriptor?.get(props.name)
|
||||
val defaultItem = props.default?.get(props.name)
|
||||
var actualItem: MetaItem<Meta>? by state { item ?: defaultItem ?: descriptorItem?.defaultItem() }
|
||||
var actualItem: MetaItem<Meta>? by useState { item ?: defaultItem ?: descriptorItem?.defaultItem() }
|
||||
|
||||
val token = props.name.lastOrNull()?.toString() ?: "Properties"
|
||||
|
||||
@ -191,13 +191,14 @@ private fun RFBuilder.configEditorItem(props: ConfigEditorItemProps) {
|
||||
}
|
||||
|
||||
public external interface ConfigEditorProps : RProps {
|
||||
var id: Name
|
||||
var root: Config
|
||||
var default: Meta?
|
||||
var descriptor: NodeDescriptor?
|
||||
public var id: Name
|
||||
public var root: Config
|
||||
public var default: Meta?
|
||||
public var descriptor: NodeDescriptor?
|
||||
}
|
||||
|
||||
val ConfigEditor = component<ConfigEditorProps> { props ->
|
||||
@JsExport
|
||||
public val ConfigEditor: FunctionalComponent<ConfigEditorProps> = component { props ->
|
||||
child(ConfigEditorItem) {
|
||||
attrs {
|
||||
this.key = ""
|
||||
@ -209,7 +210,7 @@ val ConfigEditor = component<ConfigEditorProps> { props ->
|
||||
}
|
||||
}
|
||||
|
||||
fun Element.configEditor(config: Config, descriptor: NodeDescriptor? = null, default: Meta? = null, key: Any? = null) {
|
||||
public fun Element.configEditor(config: Config, descriptor: NodeDescriptor? = null, default: Meta? = null, key: Any? = null) {
|
||||
render(this) {
|
||||
child(ConfigEditor) {
|
||||
attrs {
|
||||
|
@ -39,7 +39,7 @@ private val MetaViewerItem: FunctionalComponent<MetaViewerProps> = component { p
|
||||
}
|
||||
|
||||
private fun RFBuilder.metaViewerItem(props: MetaViewerProps) {
|
||||
var expanded: Boolean by state { true }
|
||||
var expanded: Boolean by useState { true }
|
||||
val item = props.root[props.name]
|
||||
val descriptorItem: ItemDescriptor? = props.descriptor?.get(props.name)
|
||||
val actualItem = item ?: descriptorItem?.defaultItem()
|
||||
|
@ -13,10 +13,10 @@ import react.*
|
||||
import styled.*
|
||||
|
||||
public external interface ObjectTreeProps : RProps {
|
||||
var name: Name
|
||||
var selected: Name?
|
||||
var obj: Vision
|
||||
var clickCallback: (Name) -> Unit
|
||||
public var name: Name
|
||||
public var selected: Name?
|
||||
public var obj: Vision
|
||||
public var clickCallback: (Name) -> Unit
|
||||
}
|
||||
|
||||
private fun RFBuilder.objectTree(props: ObjectTreeProps): Unit {
|
||||
|
@ -1,16 +1,14 @@
|
||||
package hep.dataforge.vision.react
|
||||
|
||||
import react.*
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class RFBuilder : RBuilder()
|
||||
public class RFBuilder : RBuilder()
|
||||
|
||||
/**
|
||||
* Get functional component from [func]
|
||||
*/
|
||||
fun <P : RProps> component(
|
||||
func: RFBuilder.(props: P) -> Unit
|
||||
public inline fun <P : RProps> component(
|
||||
crossinline func: RFBuilder.(props: P) -> Unit,
|
||||
): FunctionalComponent<P> {
|
||||
return { props: P ->
|
||||
val nodes = RFBuilder().apply { func(props) }.childList
|
||||
@ -21,18 +19,6 @@ fun <P : RProps> component(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> RFBuilder.state(init: () -> T): ReadWriteProperty<Any?, T> =
|
||||
object : ReadWriteProperty<Any?, T> {
|
||||
val pair = react.useState(init)
|
||||
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||
return pair.first
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
||||
pair.second(value)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> RFBuilder.memoize(vararg deps: dynamic, builder: () -> T): T = useMemo(builder, deps)
|
||||
//
|
||||
//public fun <T> RFBuilder.memoize(vararg deps: dynamic, builder: () -> T): T = useMemo(builder, deps)
|
||||
|
||||
|
@ -31,7 +31,7 @@ kotlin {
|
||||
|
||||
//api("org.jetbrains:kotlin-extensions:1.0.1-pre.105-kotlin-1.3.72")
|
||||
//api("org.jetbrains:kotlin-css-js:1.0.0-pre.105-kotlin-1.3.72")
|
||||
api("org.jetbrains:kotlin-styled:5.2.0-pre.123-kotlin-1.4.10")
|
||||
api("org.jetbrains:kotlin-styled:5.2.0-pre.126-kotlin-1.4.10")
|
||||
|
||||
api(npm("core-js", "2.6.5"))
|
||||
api(npm("inline-style-prefixer", "5.1.0"))
|
||||
|
@ -7,7 +7,7 @@ kotlin {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(project(":visionforge-solid"))
|
||||
api("kscience.gdml:gdml:0.2.0-dev-2")
|
||||
api("kscience.gdml:gdml:0.2.0-dev-3")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.asName
|
||||
import hep.dataforge.names.plus
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.vision.MutableVisionGroup
|
||||
import hep.dataforge.vision.set
|
||||
import hep.dataforge.vision.solid.*
|
||||
import hep.dataforge.vision.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY
|
||||
@ -20,21 +19,21 @@ import kotlin.random.Random
|
||||
private val solidsName = "solids".asName()
|
||||
private val volumesName = "volumes".asName()
|
||||
|
||||
public class GDMLTransformer internal constructor(val root: GDML) {
|
||||
public class GDMLTransformer internal constructor(public val root: GDML) {
|
||||
//private val materialCache = HashMap<GDMLMaterial, Meta>()
|
||||
private val random = Random(222)
|
||||
|
||||
enum class Action {
|
||||
public enum class Action {
|
||||
ADD,
|
||||
REJECT,
|
||||
PROTOTYPE
|
||||
}
|
||||
|
||||
var lUnit: LUnit = LUnit.MM
|
||||
var aUnit: AUnit = AUnit.RADIAN
|
||||
public var lUnit: LUnit = LUnit.MM
|
||||
public var aUnit: AUnit = AUnit.RADIAN
|
||||
|
||||
var solidAction: (GDMLSolid) -> Action = { Action.PROTOTYPE }
|
||||
var volumeAction: (GDMLGroup) -> Action = { Action.PROTOTYPE }
|
||||
public var solidAction: (GDMLSolid) -> Action = { Action.PROTOTYPE }
|
||||
public var volumeAction: (GDMLGroup) -> Action = { Action.PROTOTYPE }
|
||||
|
||||
/**
|
||||
* A special group for local templates
|
||||
@ -71,7 +70,7 @@ public class GDMLTransformer internal constructor(val root: GDML) {
|
||||
|
||||
private val styleCache = HashMap<Name, Meta>()
|
||||
|
||||
var solidConfiguration: Solid.(parent: GDMLVolume, solid: GDMLSolid) -> Unit = { parent, _ ->
|
||||
public var solidConfiguration: Solid.(parent: GDMLVolume, solid: GDMLSolid) -> Unit = { parent, _ ->
|
||||
lUnit = LUnit.CM
|
||||
if (parent.physVolumes.isNotEmpty()) {
|
||||
useStyle("opaque") {
|
||||
@ -101,7 +100,7 @@ public class GDMLTransformer internal constructor(val root: GDML) {
|
||||
obj.solidConfiguration(parent, solid)
|
||||
}
|
||||
|
||||
var onFinish: GDMLTransformer.() -> Unit = {}
|
||||
public var onFinish: GDMLTransformer.() -> Unit = {}
|
||||
|
||||
|
||||
private fun <T : Solid> T.withPosition(
|
||||
@ -356,13 +355,13 @@ public class GDMLTransformer internal constructor(val root: GDML) {
|
||||
return final
|
||||
}
|
||||
|
||||
val result by lazy {
|
||||
public val result: SolidGroup by lazy {
|
||||
finalize(volume(root.world))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun GDML.toVision(block: GDMLTransformer.() -> Unit = {}): SolidGroup {
|
||||
public fun GDML.toVision(block: GDMLTransformer.() -> Unit = {}): SolidGroup {
|
||||
val context = GDMLTransformer(this).apply(block)
|
||||
return context.result
|
||||
}
|
||||
@ -370,7 +369,7 @@ fun GDML.toVision(block: GDMLTransformer.() -> Unit = {}): SolidGroup {
|
||||
/**
|
||||
* Append gdml node to the group
|
||||
*/
|
||||
fun SolidGroup.gdml(gdml: GDML, key: String = "", transformer: GDMLTransformer.() -> Unit = {}) {
|
||||
public fun SolidGroup.gdml(gdml: GDML, key: String = "", transformer: GDMLTransformer.() -> Unit = {}) {
|
||||
val visual = gdml.toVision(transformer)
|
||||
//println(Visual3DPlugin.json.stringify(VisualGroup3D.serializer(), visual))
|
||||
set(key, visual)
|
||||
|
@ -29,7 +29,6 @@ kotlin {
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation(project(":ui:bootstrap"))//to be removed later
|
||||
implementation(npm("three", "0.114.0"))
|
||||
implementation(npm("three-csg-ts", "1.0.1"))
|
||||
api(npm("file-saver", "2.0.2"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
package hep.dataforge.vision.solid
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import kotlinx.serialization.json.toJson
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
@ -28,7 +28,7 @@ public external interface ThreeCanvasState : RState {
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class ThreeCanvasComponent : RComponent<ThreeCanvasProps, ThreeCanvasState>() {
|
||||
public class ThreeCanvasComponent : RComponent<ThreeCanvasProps, ThreeCanvasState>() {
|
||||
|
||||
private var canvas: ThreeCanvas? = null
|
||||
|
||||
@ -62,7 +62,7 @@ class ThreeCanvasComponent : RComponent<ThreeCanvasProps, ThreeCanvasState>() {
|
||||
}
|
||||
}
|
||||
|
||||
fun RBuilder.threeCanvas(object3D: Solid, options: Canvas3DOptions.() -> Unit = {}) {
|
||||
public fun RBuilder.threeCanvas(object3D: Solid, options: Canvas3DOptions.() -> Unit = {}) {
|
||||
child(ThreeCanvasComponent::class) {
|
||||
attrs {
|
||||
this.obj = object3D
|
||||
|
Loading…
Reference in New Issue
Block a user