plot-gtk-ui 0.0.1.0 → 0.0.2.0
raw patch · 4 files changed
+34/−19 lines, 4 files
Files
- README.md +1/−1
- lib/Graphics/Rendering/Plot/Gtk/UI.hs +24/−16
- lib/Graphics/Rendering/Plot/Gtk/UI/PlotWindow.hs +1/−1
- plot-gtk-ui.cabal +8/−1
README.md view
@@ -70,7 +70,7 @@ - Invalid ranges, e.g. X-Range = `(1, -1)` - Automatic-determination of ranges resulting in unplottable ranges, e.g. `(0, 0)` -If you land on the "grey screen of on plots" or any other incorrect error message, please raise an issue here.+If you land on the "Gray screen of no plots" or any other incorrect error message, please raise an issue here. ## Implementation
lib/Graphics/Rendering/Plot/Gtk/UI.hs view
@@ -24,6 +24,7 @@ module Graphics.Rendering.Plot.Gtk.UI ( plotStatic , plotDynamic+ , plotWithArity ) where --------------------------------------------------------------------------------@@ -47,11 +48,6 @@ -------------------------------------------------------------------------------- -defSet :: FigureSettings-defSet = defaultFigureSettings----------------------------------------------------------------------------------- -- | Quickly create AdjustmentSettings argRange :: (Double, Double) -- ^ Lower and upper range -> AdjustmentSettings@@ -60,15 +56,15 @@ -------------------------------------------------------------------------------- -- | Plots functions of multiple arguments, provided all arguments--- have specified ranges.-plot :: ([Double] -> Double -> Double) -- ^ Function- -> [(Double, Double)] -- ^ Ranges for all but the primary arg- -> FigureSettings -- ^ Should contain the primary range- -> IO ()-plot func rangeTail fset = do- iofset <- newIORef fset+-- have specified ranges. FOR INTERNAL USE, use 'plotWithArity' instead.+plotUnsafe :: ([Double] -> Double) -- ^ Function to plot+ -> [(Double, Double)] -- ^ Ranges for all args+ -> IO ()+plotUnsafe func ranges = do+ iofset <- newIORef defaultFigureSettings { xRange = Just . head $ ranges } plotGlade <- getDataFileName "plot-window.glade"- plotWindow plotGlade iofset (map argRange rangeTail) func+ let f xs x = func (x:xs)+ plotWindow plotGlade iofset (map argRange (tail ranges)) f -------------------------------------------------------------------------------- @@ -89,8 +85,20 @@ => (u Double -> Double) -> v (Double, Double) -> IO ()-plotDynamic func ranges = let (x:xs) = V.toList ranges- f zs z = func . V.fromList $ (z:zs)- in plot f xs defSet { xRange = Just x }+plotDynamic func = plotUnsafe (func . V.fromList) . V.toList++--------------------------------------------------------------------------------++-- | Possibly returns an IO action that creates a plot assuming that+-- it's executing in a GTK environment (after initGUI). Returns+-- Nothing if no. of arguments does not match.+plotWithArity :: Int -- ^ Arity of function to plot+ -> ([Double] -> Double) -- ^ Function to plot+ -> [(Double, Double)] -- ^ Ranges for all args+ -> Maybe (IO ())+plotWithArity n func ranges =+ if length ranges /= n+ then Nothing+ else Just $ plotUnsafe func ranges --------------------------------------------------------------------------------
lib/Graphics/Rendering/Plot/Gtk/UI/PlotWindow.hs view
@@ -67,7 +67,7 @@ newAdjList = mapM newAdj newHScaleList = mapM hScaleNew - adjs <- newAdjList conf+ adjs <- newAdjList . reverse $ conf sliders <- newHScaleList adjs mapM_ (`scaleSetValuePos` PosRight) sliders mapM_ (`scaleSetDigits` 2) sliders
plot-gtk-ui.cabal view
@@ -1,5 +1,12 @@ Name: plot-gtk-ui-Version: 0.0.1.0++-- The package version. See the Haskell package versioning policy (PVP)+-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary: +-+------- breaking API changes+-- | | +----- non-breaking API additions+-- | | | +--- code changes with no API change+Version: 0.0.2.0 License: GPL-2 License-file: LICENSE Author: Sumit Sahrawat