0.2.0 #71

Merged
altavir merged 139 commits from dev into master 2022-01-24 09:44:18 +03:00
5 changed files with 22 additions and 13 deletions
Showing only changes of commit e38bac8d23 - Show all commits

View File

@ -28,7 +28,6 @@ class Model(val manager: VisionManager) {
private fun SolidGroup.detector(detector: SC16) {
group(detector.name) {
position = detector.center
detector.pixels.forEach {
pixel(it)
}
@ -65,6 +64,7 @@ class Model(val manager: VisionManager) {
}
private fun highlight(pixel: String) {
println("highlight $pixel")
map[pixel]?.color?.invoke("blue")
}
@ -76,6 +76,7 @@ class Model(val manager: VisionManager) {
}
fun displayEvent(event: Event) {
println("Received event: $event")
events.add(event)
event.hits.forEach {
highlight(it)
@ -83,6 +84,7 @@ class Model(val manager: VisionManager) {
event.track?.let {
tracks.polyline(*it.toTypedArray(), name = "track[${event.id}]") {
thickness = 4
color("red")
}
}
}

View File

@ -3,6 +3,7 @@ package ru.mipt.npm.muon.monitor
import ru.mipt.npm.muon.monitor.Monitor.PIXEL_XY_SIZE
import ru.mipt.npm.muon.monitor.Monitor.PIXEL_Z_SIZE
import space.kscience.visionforge.solid.Point3D
import space.kscience.visionforge.solid.plus
/**
* A single pixel
@ -97,7 +98,7 @@ class SC16(
}
val offset = Point3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0));
val pixelName = "${name}_${index}"
SC1(pixelName, offset)
SC1(pixelName, offset + center)
}
}
}

View File

@ -56,8 +56,10 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
}
}
val root = props.model.root.apply {
edges()
val root = useMemo(props.model) {
props.model.root.apply {
edges()
}
}
gridRow {

View File

@ -16,10 +16,10 @@ import kotlin.random.Random
*/
internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
// val layer: Layer = findLayer(center.z);
private val upLayer =
findLayer(sc.center.z + sc.zSize / 2f)//Layer("${name}_up", center.z + zSize / 2.0);
private val bottomLayer =
findLayer(sc.center.z - sc.zSize / 2f)//Layer("${name}_bottom", center.z - zSize / 2.0);
private val upLayer = findLayer(sc.center.z + sc.zSize / 2f)
//Layer("${name}_up", center.z + zSize / 2.0);
private val bottomLayer = findLayer(sc.center.z - sc.zSize / 2f)
//Layer("${name}_bottom", center.z - zSize / 2.0);
private val centralLayer = findLayer(sc.center.z)
private val center = Vector3D(sc.center.x.toDouble(), sc.center.y.toDouble(), sc.center.z.toDouble())
@ -115,8 +115,8 @@ internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
private val auxCache = HashMap<SC1, SC1Aux>()
fun SC1.isHit(track: Line): Boolean{
return auxCache.getOrPut(this){
fun SC1.isHit(track: Line): Boolean {
return auxCache.getOrPut(this) {
SC1Aux(this)
}.isHit(track)
}

View File

@ -7,9 +7,11 @@ import info.laht.threekt.objects.LineSegments
import space.kscience.visionforge.computePropertyNode
import space.kscience.visionforge.onPropertyChange
import space.kscience.visionforge.solid.PolyLine
import space.kscience.visionforge.solid.SolidMaterial
import space.kscience.visionforge.solid.color
import space.kscience.visionforge.solid.string
import space.kscience.visionforge.solid.three.ThreeMaterials.DEFAULT_LINE_COLOR
import kotlin.math.ceil
import kotlin.reflect.KClass
public object ThreeLineFactory : ThreeFactory<PolyLine> {
@ -17,12 +19,14 @@ public object ThreeLineFactory : ThreeFactory<PolyLine> {
override fun invoke(three: ThreePlugin, obj: PolyLine): Object3D {
val geometry = BufferGeometry().apply {
setFromPoints(Array(obj.points.size) { obj.points[it].toVector() })
setFromPoints(Array((obj.points.size - 1) * 2) {
obj.points[ceil(it / 2.0).toInt()].toVector()
})
}
val material = ThreeMaterials.getLineMaterial(
obj.computePropertyNode(MeshThreeFactory.EDGES_MATERIAL_KEY),
true
obj.computePropertyNode(SolidMaterial.MATERIAL_KEY),
false
)
material.linewidth = obj.thickness.toDouble()