From 26d1ec5aca88c44d1e3451bb9f0113c201e6c962 Mon Sep 17 00:00:00 2001 From: Conrad Parker Date: Fri, 13 Jan 2012 14:00:10 +0800 Subject: [PATCH] Layer: add ScopeFile record --- Scope/Layer.hs | 8 +++++--- Scope/Types.hs | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Scope/Layer.hs b/Scope/Layer.hs index f596dac..82bfd5b 100644 --- a/Scope/Layer.hs +++ b/Scope/Layer.hs @@ -87,9 +87,11 @@ layersFromFile path = do where ub = utcTimeFromTimeStamp b + file = ScopeFile path + rawListLayer :: Maybe UTCTime -> TrackNo -> [Summary Double] -> Layer (TimeStamp, [Double]) - rawListLayer base trackNo ss = Layer path trackNo + rawListLayer base trackNo ss = Layer file trackNo base (summaryEntry s) (summaryExit s) enumListDouble @@ -99,7 +101,7 @@ layersFromFile path = do sListLayer :: Maybe UTCTime -> TrackNo -> RGB -> [Summary Double] -> Layer [Summary Double] - sListLayer base trackNo rgb ss = Layer path trackNo + sListLayer base trackNo rgb ss = Layer file trackNo base (summaryEntry s) (summaryExit s) (enumSummaryListDouble 1) @@ -127,7 +129,7 @@ plotLayers scope = mapM_ f layersByFile f :: ScopeRender m => [ScopeLayer] -> m () f ls = plotFileLayers (fn . head $ ls) ls scope layersByFile = groupBy ((==) `on` fn) (layers scope) - fn (ScopeLayer l) = filename l + fn (ScopeLayer l) = filename . layerFile $ l plotFileLayers :: ScopeRender m => FilePath -> [ScopeLayer] -> Scope ui -> m () plotFileLayers path layers scope = when (any visible layers) $ diff --git a/Scope/Types.hs b/Scope/Types.hs index 427f534..99dc702 100644 --- a/Scope/Types.hs +++ b/Scope/Types.hs @@ -65,6 +65,7 @@ module Scope.Types ( , ScopePlot(..) -- * Scope + , ScopeFile(..) , Scope(..) , scopeNew , scopeUpdate @@ -231,6 +232,12 @@ class (Functor m, MonadCatchIO m) => ScopeRender m where ---------------------------------------------------------------------- +data ScopeFile = ScopeFile + { filename :: FilePath + } + +---------------------------------------------------------------------- + type DrawLayer = [DrawCmd] -- | A layer plotting function which is just given the x position and x width @@ -245,7 +252,7 @@ data LayerPlot a = LayerMap (LayerMapFunc a) [DrawLayer] | forall b . LayerFold (LayerFoldFunc a b) [DrawLayer] b data Layer a = Layer - { filename :: FilePath + { layerFile :: ScopeFile , layerTrackNo :: TrackNo , layerBaseUTC :: Maybe UTCTime , startTime :: TimeStamp