graph-rewriting-gl 0.5.1 → 0.6
raw patch · 5 files changed
+15/−19 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- GraphRewriting.GL.UI: run :: (View [Port] n, Render n, View Position n, PortSpec n, View Rotation n) => Int -> (Graph n -> Graph n) -> Rewrite n a -> Graph n -> LabeledTree (Rule n) -> IO ()
+ GraphRewriting.GL.UI: run :: (View [Port] n, Render n, View Position n, PortSpec n, View Rotation n) => Int -> (Graph n -> Graph n) -> (Node -> Rewrite n a) -> Graph n -> LabeledTree (Rule n) -> IO ()
Files
- GraphRewriting/GL/Canvas.hs +6/−12
- GraphRewriting/GL/Global.hs +2/−2
- GraphRewriting/GL/Menu.hs +3/−1
- GraphRewriting/GL/UI.hs +3/−3
- graph-rewriting-gl.cabal +1/−1
GraphRewriting/GL/Canvas.hs view
@@ -1,5 +1,6 @@ module GraphRewriting.GL.Canvas (setupCanvas) where +import Prelude.Unicode import qualified Graphics.UI.GLUT as GL import Graphics.Rendering.OpenGL (($=)) import GraphRewriting.Graph@@ -14,9 +15,8 @@ import GraphRewriting.Layout.Position import GraphRewriting.Layout.PortSpec import qualified Data.Set as Set-import Control.Monad (liftM, zipWithM_, replicateM_)+import Control.Monad (liftM, replicateM_) import Data.Maybe (catMaybes, listToMaybe)-import Data.List ((\\)) setupCanvas ∷ (View [Port] n, Render n, View Position n, PortSpec n, View Rotation n)@@ -54,12 +54,7 @@ Nothing → return () Just n → do (newNodes, g) ← liftM (runGraph $ apply $ nextIs n rule) (readGraph globalVars)- let fixNew = do- oldNodes ← liftM (\\ newNodes) readNodeList- oldPositions ← mapM (examineNode position) oldNodes- origLayoutStep- zipWithM_ updateNode (map Position oldPositions) oldNodes- writeGraph (execGraph (replicateM_ 5 fixNew) g) globalVars+ writeGraph (execGraph (replicateM_ 5 $ mapM origLayoutStep newNodes) g) globalVars inputCallback (GL.MouseButton GL.RightButton) GL.Up mod (GL.Position x y) = resume globalVars @@ -71,10 +66,9 @@ case node of Nothing → GL.motionCallback $= Just (scrollCallback from) Just n → do- let fixN = do- npos ← examineNode position n- origLayoutStep- updateNode (Position npos) n+ let fixN node = if n ≡ node+ then return ()+ else origLayoutStep node modifyIORef globalVars $ \v → v {layoutStep = fixN} GL.motionCallback $= Just (dragCallback n) where
GraphRewriting/GL/Global.hs view
@@ -15,7 +15,7 @@ paused ∷ Bool, selectedRule ∷ Rule n, highlighted ∷ Set Node,- layoutStep ∷ Rewrite n (),+ layoutStep ∷ Node → Rewrite n (), canvas ∷ Window} redisplay ∷ Window → IO ()@@ -42,7 +42,7 @@ gv@GlobalVars {graph = g, paused = p, layoutStep = l, canvas = c} ← readIORef globalVars when (not p) $ do examine position (head $ nodes g) `seq` return ()- writeIORef globalVars $ gv {graph = execGraph l g}+ writeIORef globalVars $ gv {graph = execGraph (mapM l =<< readNodeList) g} redisplay c addTimerCallback 40 $ layoutLoop globalVars
GraphRewriting/GL/Menu.hs view
@@ -64,5 +64,7 @@ selectRule (ruleList !! idx) globalVars postRedisplay $ Just menu menuClick menu selectedIndex RightButton idx = do- modifyGraph (execGraph $ apply $ everywhere $ ruleList !! idx) globalVars+ 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 _ _ _ _ = return ()
GraphRewriting/GL/UI.hs view
@@ -42,17 +42,17 @@ run ∷ (View [Port] n, Render n, View Position n, PortSpec n, View Rotation n) ⇒ Int -- ^ The number of layout steps to apply before displaying the graph → (Graph n → Graph n) -- ^ A projection function that is applied just before displaying the graph- → Rewrite n a -- ^ The monadic graph transformation code for a layout step+ → (Node → Rewrite n a) -- ^ The monadic graph transformation code for a layout step → Graph n → LabeledTree (Rule n) -- ^ The rule menu given as a tree of named rules → IO () run initSteps project layoutStep g rules = do globalVars ← newIORef $ GlobalVars- {graph = execGraph (replicateM_ initSteps layoutStep) g,+ {graph = execGraph (replicateM_ initSteps $ mapM layoutStep =<< readNodeList) g, paused = False, selectedRule = fail "none", highlighted = Set.empty,- layoutStep = layoutStep >> return (),+ layoutStep = \n → layoutStep n >> return (), canvas = undefined} -- print =<< get GL.sampleBuffers -- print =<< get GL.samples
graph-rewriting-gl.cabal view
@@ -1,5 +1,5 @@ Name: graph-rewriting-gl-Version: 0.5.1+Version: 0.6 Copyright: (c) 2010, Jan Rochel License: BSD3 License-File: LICENSE