Viewer update
This commit is contained in:
parent
6cd618e5a3
commit
804b4c6d4f
@ -125,7 +125,6 @@ class NumassDataLoader(
|
||||
|
||||
companion object {
|
||||
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun fromFile(storage: Storage, zipFile: Path): NumassDataLoader {
|
||||
throw UnsupportedOperationException("TODO")
|
||||
|
@ -158,7 +158,7 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag
|
||||
val plot = DataPlot.plot(
|
||||
key.toString(),
|
||||
adapter,
|
||||
PointCache[point].withBinning(binning)
|
||||
PointCache[block].withBinning(binning)
|
||||
)
|
||||
group.add(plot)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.fx.*
|
||||
import hep.dataforge.fx.fragments.LogFragment
|
||||
import hep.dataforge.fx.meta.MetaViewer
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.NumassProperties
|
||||
import inr.numass.data.api.NumassPoint
|
||||
@ -34,9 +35,11 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
|
||||
private val pathProperty = SimpleObjectProperty<Path>()
|
||||
private var path: Path by pathProperty
|
||||
|
||||
val contentViewProperty = SimpleObjectProperty<UIComponent>()
|
||||
private val contentViewProperty = SimpleObjectProperty<UIComponent>()
|
||||
var contentView: UIComponent? by contentViewProperty
|
||||
|
||||
private val infoViewProperty = SimpleObjectProperty<UIComponent>()
|
||||
var infoView: UIComponent? by infoViewProperty
|
||||
|
||||
override val root = borderpane {
|
||||
prefHeight = 600.0
|
||||
@ -107,6 +110,11 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
|
||||
pane {
|
||||
hgrow = Priority.ALWAYS
|
||||
}
|
||||
button("Info") {
|
||||
action {
|
||||
infoView?.openModal(escapeClosesWindow = true)
|
||||
}
|
||||
}
|
||||
togglebutton("Console") {
|
||||
isSelected = false
|
||||
logFragment.bindWindow(this@togglebutton)
|
||||
@ -125,6 +133,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
|
||||
private suspend fun load(path: Path) {
|
||||
runLater {
|
||||
contentView = null
|
||||
infoView = null
|
||||
}
|
||||
if (Files.isDirectory(path)) {
|
||||
if (Files.exists(path.resolve(NumassDataLoader.META_FRAGMENT_NAME))) {
|
||||
@ -137,6 +146,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
|
||||
contentView = SpectrumView().apply {
|
||||
add(it.name, it)
|
||||
}
|
||||
infoView = MetaViewer(it.meta)
|
||||
} except {
|
||||
alert(
|
||||
type = Alert.AlertType.ERROR,
|
||||
@ -155,6 +165,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
|
||||
)
|
||||
} ui {
|
||||
contentView = StorageView(it)
|
||||
infoView = MetaViewer(it.meta)
|
||||
} except {
|
||||
alert(
|
||||
type = Alert.AlertType.ERROR,
|
||||
@ -186,6 +197,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
|
||||
contentView = AmplitudeView().apply {
|
||||
add(path.toString(), point)
|
||||
}
|
||||
infoView = PointInfoView(point)
|
||||
}
|
||||
} else {
|
||||
alert(
|
||||
|
@ -8,7 +8,7 @@ import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.tables.Table
|
||||
import hep.dataforge.utils.Misc
|
||||
import inr.numass.data.analyzers.SimpleAnalyzer
|
||||
import inr.numass.data.api.NumassPoint
|
||||
import inr.numass.data.api.NumassBlock
|
||||
import javafx.stage.Stage
|
||||
import org.slf4j.LoggerFactory
|
||||
import tornadofx.*
|
||||
@ -37,9 +37,9 @@ class Viewer : App(MainView::class) {
|
||||
*/
|
||||
object PointCache{
|
||||
private val analyzer = SimpleAnalyzer()
|
||||
private val cache: MutableMap<NumassPoint, Table> = Misc.getLRUCache(1000)
|
||||
private val cache: MutableMap<NumassBlock, Table> = Misc.getLRUCache(1000)
|
||||
|
||||
operator fun get(point: NumassPoint): Table {
|
||||
operator fun get(point: NumassBlock): Table {
|
||||
return cache.computeIfAbsent(point) { analyzer.getAmplitudeSpectrum(point, Meta.empty()) }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user