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 {
@Throws(IOException::class)
fun fromFile(storage: Storage, zipFile: Path): NumassDataLoader {
throw UnsupportedOperationException("TODO")

View File

@ -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)
}

View File

@ -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,
@ -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(

View File

@ -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()) }
}
}