From 1742d03b44d05cafcdc6050c422e081cc217c3e3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 15 May 2018 20:55:33 +0300 Subject: [PATCH] Updates to plot output --- .../inr/numass/actions/TimeAnalyzerAction.kt | 4 +- .../kotlin/inr/numass/viewer/AmplitudeView.kt | 5 +- .../main/kotlin/inr/numass/viewer/MainView.kt | 57 +++++++++++-------- .../kotlin/inr/numass/viewer/StorageView.kt | 15 +++-- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt index 20180317..344709f5 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt @@ -84,11 +84,9 @@ class TimeAnalyzerAction : OneToOneAction() { histPlot.add(histogramPlot) - //val cr = input.events.count().toDouble() / input.length.toMillis() *1000 - histPlot.add( XYFunctionPlot.plot(name + "_theory", 0.0, binSize * binNum) { - trueCR * Math.exp(- it * trueCR / 1e6) + trueCR * Math.exp(-it * trueCR / 1e6) * binSize } ) } 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 3b9eb472..70540cd0 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt @@ -160,8 +160,9 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag } fun clear() { - frame.plots.clear() - plots.clear() + data.clear() +// frame.plots.clear() +// plots.clear() invalidate() } 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 eee3970d..1a7b75c8 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt @@ -56,22 +56,28 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title if (homeDir == null) { chooser.initialDirectory = File(".").absoluteFile } else { - chooser.initialDirectory = File(homeDir) + val file = File(homeDir) + if (file.isDirectory) { + chooser.initialDirectory = file + } else { + chooser.initialDirectory = file.parentFile + } + } + + val rootDir = chooser.showDialog(primaryStage.scene.window) + + if (rootDir != null) { + NumassProperties.setNumassProperty("numass.viewer.lastPath", rootDir.absolutePath) + async { + runLater { + path = rootDir.toPath() + } + load(rootDir.toPath()) + } } } catch (ex: Exception) { NumassProperties.setNumassProperty("numass.viewer.lastPath", null) - } - - val rootDir = chooser.showDialog(primaryStage.scene.window) - - if (rootDir != null) { - NumassProperties.setNumassProperty("numass.viewer.lastPath", rootDir.absolutePath) - async { - runLater { - path = rootDir.toPath() - } - load(rootDir.toPath()) - } + error("Error", content = "Failed to laod file with message: ${ex.message}") } } } @@ -86,19 +92,21 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title } else { chooser.initialDirectory = File(homeDir) } + + + val file = chooser.showOpenDialog(primaryStage.scene.window) + if (file != null) { + NumassProperties.setNumassProperty("numass.viewer.lastPath", file.parentFile.absolutePath) + async { + runLater { + path = file.toPath() + } + load(file.toPath()) + } + } } catch (ex: Exception) { NumassProperties.setNumassProperty("numass.viewer.lastPath", null) - } - - val file = chooser.showOpenDialog(primaryStage.scene.window) - if (file != null) { - NumassProperties.setNumassProperty("numass.viewer.lastPath", file.parentFile.absolutePath) - async { - runLater { - path = file.toPath() - } - load(file.toPath()) - } + error("Error", content = "Failed to laod file with message: ${ex.message}") } } } @@ -144,6 +152,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title NumassDataLoader.fromDir(context, path) } ui { contentView = SpectrumView().apply { + clear() set(it.name, CachedSet(it)) } infoView = MetaViewer(it.meta) diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt index 7a4f7841..4d7762a8 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt @@ -17,10 +17,17 @@ import tornadofx.* class StorageView(val storage: Storage) : View(title = "Numass storage", icon = dfIconView) { - private val ampView: AmplitudeView by inject(); - private val spectrumView: SpectrumView by inject(); - private val hvView: HVView by inject(); - private val scView: SlowControlView by inject(); + private val ampView: AmplitudeView by inject() + private val spectrumView: SpectrumView by inject() + private val hvView: HVView by inject() + private val scView: SlowControlView by inject() + + init { + ampView.clear() + spectrumView.clear() + hvView.clear() + scView.clear() + } private inner class Container(val id: String, val content: Any) { val checkedProperty = SimpleBooleanProperty(false)