packages feed

AERN-RnToRm-Plot 0.1.1 → 0.1.2

raw patch · 5 files changed

+75/−74 lines, 5 filesdep +timedep −old-timedep ~AERN-Realdep ~AERN-RnToRmdep ~base

Dependencies added: time

Dependencies removed: old-time

Dependency ranges changed: AERN-Real, AERN-RnToRm, base, glade, glib, gtk, gtkglext

Files

AERN-RnToRm-Plot.cabal view
@@ -1,5 +1,5 @@ Name:           AERN-RnToRm-Plot-Version:        0.1.1+Version:        0.1.2 Cabal-Version:  >= 1.2 Build-Type:     Simple License:        BSD3@@ -10,7 +10,7 @@ Stability:      experimental Category:       Data, Math Synopsis:       GL plotting of polynomial function enclosures (PFEs)-Tested-with:    GHC ==6.8.3+Tested-with:    GHC ==6.10.1 Description:     This library extends AERN-RnToRm with support for plotting unary function enclosures     in any GL context and a Gtk window for inspecting these enclosures.@@ -20,23 +20,14 @@     tests/Demo.hs tests/FnView.glade src/FnView.glade Data-files:     ChangeLog README.glade-Flag containers-in-base-    Default: False  Library   hs-source-dirs:  src-  if flag(containers-in-base)-    Build-Depends:-      base < 3, binary >= 0.4, directory, filepath, old-time, stm,-      AERN-Real >= 0.9.8, AERN-RnToRm >= 0.4.2,-      OpenGL >= 2.2.1.1, GLUT >= 2.1.1.1,-      gtk >= 0.9.13, gtkglext >= 0.9.13, glib >= 0.9.13, glade >= 0.9.13-  else-    Build-Depends:-      base >= 3, containers, binary >= 0.4, directory, filepath, old-time, stm, -      AERN-Real >= 0.9.7.1, AERN-RnToRm >= 0.4.1, +  Build-Depends:+      base >= 3, base < 4, containers, binary >= 0.4, directory, filepath, time, stm,+      AERN-Real >= 0.9.9, AERN-RnToRm >= 0.4.9,       OpenGL >= 2.2.1.1, GLUT >= 2.1.1.1,-      gtk >= 0.9.13, gtkglext >= 0.9.13, glib >= 0.9.13, glade >= 0.9.13+      gtk >= 0.10.0, gtkglext >= 0.10.0, glib >= 0.10.0, glade >= 0.10.0   Exposed-modules:     Data.Number.ER.RnToRm.Plot.FnView,     Data.Number.ER.RnToRm.Plot.GLDrawable,
ChangeLog view
@@ -1,3 +1,7 @@+0.1.2: 23 February 2009+    * rewrote the formerly complex and sometimes incorrect+      code that assigns inspected values to dimension labels+    * adapted to AERN-RnToRm 0.4.9 and to Gtk2Hs 0.10.0 0.1.1: 1 December 2008     * moved MiscSTM from here to AERN-Real so that it can be used also in AERN-Net 0.1.0: 1 October 2008
src/Data/Number/ER/RnToRm/Plot/FnView.hs view
@@ -289,12 +289,17 @@     where     setHandlerCoordSystem =         do-        Gtk.onChanged (coorSystemCombo widgets) $+        Gtk.on  (coorSystemCombo widgets) Gtk.changed $             do             maybeCSysIx <- Gtk.comboBoxGetActive (coorSystemCombo widgets)             case maybeCSysIx of+#ifdef GTK2HS_0_9_13                 Nothing -> return ()                 Just ix ->+#else    +                -1 -> return ()+                ix ->+#endif                     do                     coordSystem <-                         atomically $@@ -412,7 +417,6 @@     IO () updateDimWidgets widgets dynWidgetsRef fndata fndataTVs stateTV =     do-    return ()     -- update the name of the domain variable:     Gtk.labelSetText (domVarLabel widgets) $ domName ++ "="     -- set the default evaluation point:@@ -421,9 +425,9 @@     children <- Gtk.containerGetChildren table     mapM (Gtk.containerRemove table) children       -- add new dim rows:-    Gtk.tableResize table (dimRows + 1) 3+    Gtk.tableResize table (dimRowCount + 1) 3     -- fill each row with widgets and return all newly created value entries:-    valueLabels <- addRows [] [] 0 (-1) 0 fnNames ([] : resultNames)+    valueLabels <- addFunctionLabels 0 $ zip3 [0..] fnNames dimNames     -- layout the table:     Gtk.widgetShowAll table     Gtk.containerResizeChildren table@@ -436,63 +440,53 @@     where     table = dimTable widgets     domName = dataDomName fndata-    dimRows = (length fnNames) + (sum $ map length resultNames)     fnNames = dataFnNames fndata-    resultNames = dataResultNames fndata-    addRows ::-        [[Gtk.Label]] -> -- accumulator for label groups-        [Gtk.Label] -> -- accumulator for labels in the current group-        Int -> -- current table row number-        Int -> -- current function index-        Int -> -- current dimension index-        [String] -> -- function names-        [[String]] -> -- variable names per result dimension-        IO ([[Gtk.Label]])-    addRows prevLabels prevLs nextRowNo fnNo dimNo [] ([]: _) = -        return $ tail $ reverse $ prevLs : prevLabels-    addRows prevLabels prevLs nextRowNo fnNo dimNo (fnName : restFnNames) ([] : resultNames) =+    dimNames = dataResultNames fndata+    dimRowCount = (length fnNames) + (sum $ map length dimNames)+    addFunctionLabels nextRowNo [] = return []+    addFunctionLabels nextRowNo ((fnNo, fnName, dimNames):rest) =         do         -- add a function label:         fnLabel <- Gtk.labelNew (Just fnName)        -        Gtk.tableAttachDefaults table fnLabel 1 2 nextRowNo nextRowNoPlus1+        Gtk.tableAttachDefaults table fnLabel 1 2 nextRowNo (nextRowNo + 1)         Gtk.set table [ Gtk.tableChildXOptions fnLabel := []]         Gtk.miscSetAlignment fnLabel 0 0.5-        -- continue:-        addRows newPrevLabels [] nextRowNoPlus1 (fnNo + 1) 0 restFnNames resultNames-        where-        nextRowNoPlus1 = nextRowNo + 1-        newPrevLabels = (reverse prevLs) : prevLabels-    addRows prevLabels prevLs nextRowNo fnNo dimNo fnNames ((dimName : dimNames) : resultNames) =+        -- add all result labels:+        labels <- addDimLabels (nextRowNo + 1) (fnNo, fnName) dimNames+        -- recurse for the following functions:+        restLabels <- addFunctionLabels (nextRowNo + 1 + (length dimNames)) rest+        return $ labels : restLabels+        +    addDimLabels nextRowNo (fnNo, fnName) dimNames =         do-        -- add variable label:-        dimLabel <- Gtk.labelNew (Just labelText)-        Gtk.tableAttachDefaults table dimLabel 1 2 nextRowNo nextRowNoPlus1-        Gtk.miscSetAlignment dimLabel 0 0.5-        -- add value label:-        valLabel <- Gtk.labelNew Nothing-        Gtk.tableAttachDefaults table valLabel 2 3 nextRowNo nextRowNoPlus1-        -- add a check button:-        showCheckButton <- Gtk.checkButtonNew-        Gtk.tableAttachDefaults table showCheckButton 0 1 nextRowNo nextRowNoPlus1-        -- make it ticked:-        Gtk.toggleButtonSetActive showCheckButton True-        -- give the check button a handler:-        Gtk.onToggled showCheckButton $-            do-            isActive <- Gtk.toggleButtonGetActive showCheckButton-            state <- atomically $ updateDimActive stateTV fnNo dimNo isActive-            fndatas <- atomically $ readBothTVars fndataTVs-            repaintCanvas (canvas widgets) fndatas state-            return ()-        -- attempt at a simpler rendering:-        Gtk.set table -            [Gtk.tableChildXOptions dimLabel := [], -             Gtk.tableChildXOptions showCheckButton := []]-        -- continue:-        addRows prevLabels (valLabel : prevLs) nextRowNoPlus1 fnNo (dimNo + 1) fnNames (dimNames : resultNames)  +        mapM addDimLabel $ zip3 [nextRowNo..] [0..] dimNames         where-        labelText = " " ++ dimName ++ "(" ++ domName ++ ")="-        nextRowNoPlus1 = nextRowNo + 1+        addDimLabel (nextRowNo, dimNo, dimName) =+            do+            -- add variable label:+            dimLabel <- Gtk.labelNew (Just labelText)+            Gtk.tableAttachDefaults table dimLabel 1 2 nextRowNo nextRowNoPlus1+            Gtk.miscSetAlignment dimLabel 0 0.5+            -- add value label:+            valLabel <- Gtk.labelNew Nothing+            Gtk.tableAttachDefaults table valLabel 2 3 nextRowNo nextRowNoPlus1+            -- add a check button:+            showCheckButton <- Gtk.checkButtonNew+            Gtk.tableAttachDefaults table showCheckButton 0 1 nextRowNo nextRowNoPlus1+            -- make it ticked:+            Gtk.toggleButtonSetActive showCheckButton True+            -- give the check button a handler:+            Gtk.onToggled showCheckButton $+                do+                isActive <- Gtk.toggleButtonGetActive showCheckButton+                state <- atomically $ updateDimActive stateTV fnNo dimNo isActive+                fndatas <- atomically $ readBothTVars fndataTVs+                repaintCanvas (canvas widgets) fndatas state+                return ()+            return dimLabel+            where+            labelText = " [" ++ show dimNo ++ "]" ++ dimName ++ "(" ++ domName ++ ")="+            nextRowNoPlus1 = nextRowNo + 1          updateView ::     (FA.ERFnApprox box varid domra ranra fa, ERFnGLDrawable box varid domra ranra fa) =>@@ -509,7 +503,7 @@     return ()  {-| -    update the values shown against variable names+    update the values shown against dimension names -} updateValueDisplay ::     (FA.ERFnApprox box varid domra ranra fa) =>
src/Data/Number/ER/RnToRm/Plot/GLDrawable.hs view
@@ -141,6 +141,7 @@ instance      (UFA.ERUnitFnApprox box varid domra ranra ufa,      DomainIntBox box varid domra,+     Show varid, Show box,      DomainBoxMappable dtrbox box varid (DomTransl domra) domra,       DomainBoxMappable box dtrbox varid domra (DomTransl domra),       Eq dtrbox, Ord dtrbox) =>
tests/Demo.hs view
@@ -37,12 +37,23 @@         FNV.dataFAs = [f1,f2]     } -f1 = AERN.cos ix $ g -- cos(10x)-f2 = AERNFunc.integrateUnary 3 f1 dom 0 [-1] -- integ(cos(10x)) - 1-ix = 16+f1 = AERNFunc.tuple [f11,f12,f13]+f2 = AERNFunc.tuple [f21,f22,f23] +ix1 = 6+ix2 = 12+ix3 = 18+ g = AERNFunc.scale 10 x+f11 = AERN.cos ix1 $ g -- cos(10x)+f12 = AERN.cos ix2 $ g -- cos(10x)+f13 = AERN.cos ix3 $ g -- cos(10x) +f21 = AERNFunc.integrateUnary 3 f11 dom 0 [-1] -- integ(cos(10x)) - 1+f22 = AERNFunc.integrateUnary 3 f12 dom 0 [-1] -- integ(cos(10x)) - 1+f23 = AERNFunc.integrateUnary 3 f13 dom 0 [-1] -- integ(cos(10x)) - 1++ x :: FA x =     AERNFunc.bisectUnbisectDepth 5 $@@ -66,8 +77,8 @@         FNV.dataFAsUpdated = True,         FNV.dataDomName = "x",         FNV.dataFnNames = ["f1","f2"],-        FNV.dataResultNames = [["y1"],["y2"]],-        FNV.dataDefaultEvalPoint = 0    +        FNV.dataResultNames = [["f11", "f12", "f13"],["f21", "f22", "f23"]],+        FNV.dataDefaultEvalPoint = 0     }  setExtents left right bot top fnData =