Viewer update

This commit is contained in:
Alexander Nozik 2018-04-21 17:08:07 +03:00
parent 6cd618e5a3
commit 804b4c6d4f
4 changed files with 20 additions and 9 deletions

View File

@ -125,7 +125,6 @@ class NumassDataLoader(
companion object { companion object {
@Throws(IOException::class) @Throws(IOException::class)
fun fromFile(storage: Storage, zipFile: Path): NumassDataLoader { fun fromFile(storage: Storage, zipFile: Path): NumassDataLoader {
throw UnsupportedOperationException("TODO") throw UnsupportedOperationException("TODO")

View File

@ -158,7 +158,7 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag
val plot = DataPlot.plot( val plot = DataPlot.plot(
key.toString(), key.toString(),
adapter, adapter,
PointCache[point].withBinning(binning) PointCache[block].withBinning(binning)
) )
group.add(plot) group.add(plot)
} }

View File

@ -4,6 +4,7 @@ import hep.dataforge.context.Context
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.fx.* import hep.dataforge.fx.*
import hep.dataforge.fx.fragments.LogFragment import hep.dataforge.fx.fragments.LogFragment
import hep.dataforge.fx.meta.MetaViewer
import hep.dataforge.storage.commons.StorageManager import hep.dataforge.storage.commons.StorageManager
import inr.numass.NumassProperties import inr.numass.NumassProperties
import inr.numass.data.api.NumassPoint 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 val pathProperty = SimpleObjectProperty<Path>()
private var path: Path by pathProperty private var path: Path by pathProperty
val contentViewProperty = SimpleObjectProperty<UIComponent>() private val contentViewProperty = SimpleObjectProperty<UIComponent>()
var contentView: UIComponent? by contentViewProperty var contentView: UIComponent? by contentViewProperty
private val infoViewProperty = SimpleObjectProperty<UIComponent>()
var infoView: UIComponent? by infoViewProperty
override val root = borderpane { override val root = borderpane {
prefHeight = 600.0 prefHeight = 600.0
@ -107,6 +110,11 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
pane { pane {
hgrow = Priority.ALWAYS hgrow = Priority.ALWAYS
} }
button("Info") {
action {
infoView?.openModal(escapeClosesWindow = true)
}
}
togglebutton("Console") { togglebutton("Console") {
isSelected = false isSelected = false
logFragment.bindWindow(this@togglebutton) logFragment.bindWindow(this@togglebutton)
@ -125,6 +133,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
private suspend fun load(path: Path) { private suspend fun load(path: Path) {
runLater { runLater {
contentView = null contentView = null
infoView = null
} }
if (Files.isDirectory(path)) { if (Files.isDirectory(path)) {
if (Files.exists(path.resolve(NumassDataLoader.META_FRAGMENT_NAME))) { 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 { contentView = SpectrumView().apply {
add(it.name, it) add(it.name, it)
} }
infoView = MetaViewer(it.meta)
} except { } except {
alert( alert(
type = Alert.AlertType.ERROR, type = Alert.AlertType.ERROR,
@ -155,6 +165,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
) )
} ui { } ui {
contentView = StorageView(it) contentView = StorageView(it)
infoView = MetaViewer(it.meta)
} except { } except {
alert( alert(
type = Alert.AlertType.ERROR, type = Alert.AlertType.ERROR,
@ -166,8 +177,8 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
} else { } else {
//Reading individual file //Reading individual file
val envelope = try { val envelope = try {
NumassFileEnvelope.open(path,true) NumassFileEnvelope.open(path, true)
} catch (ex: Exception){ } catch (ex: Exception) {
runLater { runLater {
alert( alert(
type = Alert.AlertType.ERROR, type = Alert.AlertType.ERROR,
@ -179,13 +190,14 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
} }
envelope?.let { envelope?.let {
if(it.meta.hasMeta("external_meta")){ if (it.meta.hasMeta("external_meta")) {
//try to read as point //try to read as point
val point = NumassPoint.read(it) val point = NumassPoint.read(it)
runLater { runLater {
contentView = AmplitudeView().apply { contentView = AmplitudeView().apply {
add(path.toString(), point) add(path.toString(), point)
} }
infoView = PointInfoView(point)
} }
} else { } else {
alert( alert(

View File

@ -8,7 +8,7 @@ import hep.dataforge.meta.Meta
import hep.dataforge.tables.Table import hep.dataforge.tables.Table
import hep.dataforge.utils.Misc import hep.dataforge.utils.Misc
import inr.numass.data.analyzers.SimpleAnalyzer import inr.numass.data.analyzers.SimpleAnalyzer
import inr.numass.data.api.NumassPoint import inr.numass.data.api.NumassBlock
import javafx.stage.Stage import javafx.stage.Stage
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import tornadofx.* import tornadofx.*
@ -37,9 +37,9 @@ class Viewer : App(MainView::class) {
*/ */
object PointCache{ object PointCache{
private val analyzer = SimpleAnalyzer() 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()) } return cache.computeIfAbsent(point) { analyzer.getAmplitudeSpectrum(point, Meta.empty()) }
} }
} }