Skip to content

Commit

Permalink
Layer: add ScopeFile record
Browse files Browse the repository at this point in the history
  • Loading branch information
kfish committed Jan 13, 2012
1 parent 36e65b3 commit 26d1ec5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Scope/Layer.hs
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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) $
Expand Down
9 changes: 8 additions & 1 deletion Scope/Types.hs
Expand Up @@ -65,6 +65,7 @@ module Scope.Types (
, ScopePlot(..)

-- * Scope
, ScopeFile(..)
, Scope(..)
, scopeNew
, scopeUpdate
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 26d1ec5

Please sign in to comment.