packages feed

Plot-ho-matic 0.11.2.0 → 0.12.0.0

raw patch · 6 files changed

+59/−24 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ SetHo: SetHoConfig :: Bool -> (Double -> String) -> (Float -> String) -> SetHoConfig
+ SetHo: [enableAutoCommit] :: SetHoConfig -> Bool
+ SetHo: [showDouble] :: SetHoConfig -> Double -> String
+ SetHo: [showFloat] :: SetHoConfig -> Float -> String
+ SetHo: data SetHoConfig
+ SetHo: defaultSetHoConfig :: SetHoConfig
- SetHo: runSetter :: String -> DTree -> IO (Maybe (Int, DTree)) -> (Int -> IO ()) -> (Int -> DTree -> IO ()) -> IO ()
+ SetHo: runSetter :: Maybe SetHoConfig -> String -> DTree -> IO (Maybe (Int, DTree)) -> (Int -> IO ()) -> (Int -> DTree -> IO ()) -> IO ()

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+0.12.0.0+---+* optional configuration data (SetHo)+* configurable: allow disabling autocommit (SetHo)+* configurable: how to show Double/Float (default is now 'show') (SetHo)+* redraw plots upon resetting history (PlotHo)+ 0.11.{1,2}.0 --- * make settings aware of message counter
Plot-ho-matic.cabal view
@@ -1,5 +1,5 @@ name:                Plot-ho-matic-version:             0.11.2.0+version:             0.12.0.0 synopsis:            Real-time line plotter for generic data license:             BSD3 license-file:        LICENSE
examples/SetExample.hs view
@@ -113,4 +113,4 @@           Just _ -> putStrLn "downstream poll got msg"         return mx -  runSetter "settings" (toDData initialFoo) pollForNewMessage refresh commit+  runSetter Nothing "settings" (toDData initialFoo) pollForNewMessage refresh commit
src/PlotHo/OptionsWidget.hs view
@@ -96,13 +96,13 @@   resetXHistoryButton <- Gtk.buttonNewWithLabel "reset X range"   resetYHistoryButton <- Gtk.buttonNewWithLabel "reset Y range" -  on resetXHistoryButton Gtk.buttonActivated $ do-    void $ CC.modifyMVar_ largestRangeMVar (\xy -> return (xy {xaxis = defaultHistoryRange}))-    redraw+  void $ on resetXHistoryButton Gtk.buttonActivated $+    CC.modifyMVar_ largestRangeMVar (\xy -> return (xy {xaxis = defaultHistoryRange}))+    >> redraw -  on resetYHistoryButton Gtk.buttonActivated $ do-    void $ CC.modifyMVar_ largestRangeMVar (\xy -> return (xy {yaxis = defaultHistoryRange}))-    redraw+  void $ on resetYHistoryButton Gtk.buttonActivated $+    CC.modifyMVar_ largestRangeMVar (\xy -> return (xy {yaxis = defaultHistoryRange}))+    >> redraw    -- vbox to hold the little window on the left   vbox <- Gtk.vBoxNew False 4
src/SetHo.hs view
@@ -5,7 +5,8 @@ -- | This is an experimental and unstable interface for -- generating a GUI for getting/setting options. module SetHo-       ( runSetter+       ( SetHoConfig(..), defaultSetHoConfig+       , runSetter        ) where  import qualified GHC.Stats@@ -23,9 +24,27 @@  import SetHo.LookupTree ( newLookupTreeview ) +data SetHoConfig+  = SetHoConfig+    { enableAutoCommit :: Bool+    , showDouble :: Double -> String+    , showFloat :: Float -> String+    }++defaultSetHoConfig :: SetHoConfig+defaultSetHoConfig =+  SetHoConfig+  { enableAutoCommit = True+  , showDouble = show+  , showFloat = show+  }+ -- | fire up the the GUI-runSetter :: String -> DTree -> IO (Maybe (Int, DTree)) -> (Int -> IO ()) -> (Int -> DTree -> IO ()) -> IO ()-runSetter rootName initialValue userPollForNewMessage sendRequest userCommit = do+runSetter :: Maybe SetHoConfig -> String -> DTree -> IO (Maybe (Int, DTree)) -> (Int -> IO ()) -> (Int -> DTree -> IO ()) -> IO ()+runSetter mconfig rootName initialValue userPollForNewMessage sendRequest userCommit = do+  let config = case mconfig of+        Just r -> r+        Nothing -> defaultSetHoConfig   statsEnabled <- GHC.Stats.getGCStatsEnabled    counterRef <- newIORef 0@@ -81,20 +100,25 @@    --------------- main widget -----------------   buttonCommit <- Gtk.buttonNewWithLabel "commit"-  buttonAutoCommit <- Gtk.checkButtonNewWithLabel "auto-commit"   buttonRefresh <- Gtk.buttonNewWithLabel "refresh"   buttonTakeUpstream <- Gtk.buttonNewWithLabel "take upstream"   Gtk.widgetSetTooltipText buttonCommit     (Just "SET ME SET ME GO HEAD DO IT COME ON SET ME")-  Gtk.widgetSetTooltipText buttonAutoCommit-    (Just "Send settings upstream as soon as any value is changed") +  mbuttonAutoCommit <-+    if enableAutoCommit config+    then do buttonAutoCommit <- Gtk.checkButtonNewWithLabel "auto-commit"+            Gtk.widgetSetTooltipText buttonAutoCommit+              (Just "Send settings upstream as soon as any value is changed")+            return (Just buttonAutoCommit)+    else return Nothing+   -- the options widget   options <- Gtk.expanderNew "options"-  Gtk.set options [ Gtk.containerChild := buttonAutoCommit-                  , Gtk.expanderExpanded := True-                  ]-+  let mautocommitChild = case mbuttonAutoCommit of+        Nothing -> []+        Just buttonAutoCommit -> [Gtk.containerChild := buttonAutoCommit]+  Gtk.set options $ mautocommitChild ++ [Gtk.expanderExpanded := True]    -- how to commit   let commit val = do@@ -105,8 +129,11 @@         userCommit counter val    -- the signal selector+  let getAutoCommitStatus = case mbuttonAutoCommit of+        Nothing -> return False+        Just buttonAutoCommit -> Gtk.toggleButtonGetActive buttonAutoCommit   (treeview, getLatestStaged, receiveNewUpstream, takeLatestUpstream, loadFromFile) <--    newLookupTreeview rootName initialValue (Gtk.toggleButtonGetActive buttonAutoCommit) commit+    newLookupTreeview (showDouble config) (showFloat config) rootName initialValue getAutoCommitStatus commit    treeviewScroll <- Gtk.scrolledWindowNew Nothing Nothing   Gtk.set treeviewScroll [Gtk.widgetVExpand := True] -- make sure it expands vertically
src/SetHo/LookupTree.hs view
@@ -19,7 +19,6 @@ import qualified "gtk3" Graphics.UI.Gtk as Gtk import System.Glib.Signals ( on ) import Text.Read ( readMaybe )-import Text.Printf ( printf )  data FieldElem =   FieldElem@@ -153,12 +152,14 @@   newLookupTreeview ::-  String+  (Double -> String)+  -> (Float -> String)+  -> String   -> DTree   -> IO Bool   -> (DTree -> IO ())   -> IO (Gtk.TreeView, IO DTree, DTree -> IO (), IO (), DTree -> IO ())-newLookupTreeview rootName initialValue getAutocommit commit = do+newLookupTreeview showDouble showFloat rootName initialValue getAutocommit commit = do   treeStore <- Gtk.treeStoreNew [] :: IO (Gtk.TreeStore ListViewElement)   treeview <- Gtk.treeViewNewWithModel treeStore :: IO Gtk.TreeView @@ -222,8 +223,8 @@    -- upstream   let showField :: DField -> String-      showField (DDouble x) = printf "%.2g" x-      showField (DFloat x) = printf "%.2g" x+      showField (DDouble x) = showDouble x+      showField (DFloat x) = showFloat x       showField (DInt x) = show x       showField (DString x) = x       showField DSorry = ""