From 804b4c6d4f03d144ddb32f04c6edf4d983b308aa Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 21 Apr 2018 17:08:07 +0300 Subject: [PATCH] Viewer update --- .../numass/data/storage/NumassDataLoader.kt | 1 - .../kotlin/inr/numass/viewer/AmplitudeView.kt | 2 +- .../main/kotlin/inr/numass/viewer/MainView.kt | 20 +++++++++++++++---- .../main/kotlin/inr/numass/viewer/Viewer.kt | 6 +++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataLoader.kt b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataLoader.kt index 40656487..049ec67e 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataLoader.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataLoader.kt @@ -125,7 +125,6 @@ class NumassDataLoader( companion object { - @Throws(IOException::class) fun fromFile(storage: Storage, zipFile: Path): NumassDataLoader { throw UnsupportedOperationException("TODO") diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt index 0ccac565..d80d28cc 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt @@ -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) } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt index d18606b1..b474487a 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt @@ -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() private var path: Path by pathProperty - val contentViewProperty = SimpleObjectProperty() + private val contentViewProperty = SimpleObjectProperty() var contentView: UIComponent? by contentViewProperty + private val infoViewProperty = SimpleObjectProperty() + 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, @@ -166,8 +177,8 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title } else { //Reading individual file val envelope = try { - NumassFileEnvelope.open(path,true) - } catch (ex: Exception){ + NumassFileEnvelope.open(path, true) + } catch (ex: Exception) { runLater { alert( type = Alert.AlertType.ERROR, @@ -179,13 +190,14 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title } envelope?.let { - if(it.meta.hasMeta("external_meta")){ + if (it.meta.hasMeta("external_meta")) { //try to read as point val point = NumassPoint.read(it) runLater { contentView = AmplitudeView().apply { add(path.toString(), point) } + infoView = PointInfoView(point) } } else { alert( diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt index bf186cd1..6b9dfe60 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt @@ -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 = Misc.getLRUCache(1000) + private val cache: MutableMap = Misc.getLRUCache(1000) - operator fun get(point: NumassPoint): Table { + operator fun get(point: NumassBlock): Table { return cache.computeIfAbsent(point) { analyzer.getAmplitudeSpectrum(point, Meta.empty()) } } } \ No newline at end of file