graph-rewriting-gl 0.6 → 0.6.2
raw patch · 4 files changed
+20/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- GraphRewriting/GL/Canvas.hs +6/−6
- GraphRewriting/GL/Global.hs +11/−0
- GraphRewriting/GL/Menu.hs +2/−5
- graph-rewriting-gl.cabal +1/−1
GraphRewriting/GL/Canvas.hs view
@@ -7,7 +7,6 @@ import GraphRewriting.Graph.Read import GraphRewriting.Graph.Write.Unsafe as Unsafe import GraphRewriting.Pattern-import GraphRewriting.Rule import GraphRewriting.GL.Render import GraphRewriting.GL.Global import Data.IORef@@ -15,7 +14,7 @@ import GraphRewriting.Layout.Position import GraphRewriting.Layout.PortSpec import qualified Data.Set as Set-import Control.Monad (liftM, replicateM_)+import Control.Monad (liftM) import Data.Maybe (catMaybes, listToMaybe) @@ -52,9 +51,7 @@ node ← nodeAt pos case node of Nothing → return ()- Just n → do- (newNodes, g) ← liftM (runGraph $ apply $ nextIs n rule) (readGraph globalVars)- writeGraph (execGraph (replicateM_ 5 $ mapM origLayoutStep newNodes) g) globalVars+ Just n → applyRule (nextIs n rule) globalVars inputCallback (GL.MouseButton GL.RightButton) GL.Up mod (GL.Position x y) = resume globalVars @@ -67,7 +64,10 @@ Nothing → GL.motionCallback $= Just (scrollCallback from) Just n → do let fixN node = if n ≡ node- then return ()+ then do+ pos ← examineNode position node+ origLayoutStep node+ updateNode (Position pos) node else origLayoutStep node modifyIORef globalVars $ \v → v {layoutStep = fixN} GL.motionCallback $= Just (dragCallback n)
GraphRewriting/GL/Global.hs view
@@ -8,6 +8,7 @@ import Data.IORef import GraphRewriting.Layout.RotPortSpec import Data.Set as Set+import Data.List ((\\)) import Control.Monad data GlobalVars n = GlobalVars@@ -27,6 +28,16 @@ modifyGraph f globalVars = do modifyIORef globalVars $ \v → v {graph = f $ graph v} highlight globalVars++applyRule r globalVars = do+ layout ← liftM layoutStep $ readIORef globalVars+ g ← readGraph globalVars+ let ns = evalGraph readNodeList g+ -- we don't use the fist element of the tuple and compute newNodes ourselves due to a bug in the graph-rewriting package (It's completely out of my hands!!!!1)+ let (_, g') = runGraph (apply r) g+ let ns' = evalGraph readNodeList g'+ let newNodes = ns' Data.List.\\ ns+ writeGraph (execGraph (replicateM_ 15 $ mapM layout newNodes) g') globalVars selectRule r globalVars = do modifyIORef globalVars $ \v → v {selectedRule = r}
GraphRewriting/GL/Menu.hs view
@@ -4,7 +4,6 @@ import Graphics.UI.GLUT as GLUT import qualified Graphics.Rendering.OpenGL as GL import GraphRewriting.GL.Global-import GraphRewriting.Graph import GraphRewriting.Rule import Data.IORef import GraphRewriting.Pattern@@ -63,8 +62,6 @@ writeIORef selectedIndex idx selectRule (ruleList !! idx) globalVars postRedisplay $ Just menu- menuClick menu selectedIndex RightButton idx = do- layout ← liftM layoutStep $ readIORef globalVars- (newNodes, g) ← liftM (runGraph $ apply $ everywhere $ ruleList !! idx) (readGraph globalVars)- writeGraph (execGraph (replicateM_ 5 $ mapM layout newNodes) g) globalVars+ menuClick menu selectedIndex RightButton idx =+ applyRule (everywhere $ ruleList !! idx) globalVars menuClick _ _ _ _ = return ()
graph-rewriting-gl.cabal view
@@ -1,5 +1,5 @@ Name: graph-rewriting-gl-Version: 0.6+Version: 0.6.2 Copyright: (c) 2010, Jan Rochel License: BSD3 License-File: LICENSE