graph-rewriting-gl 0.7.8 → 0.7.9
raw patch · 4 files changed
+30/−31 lines, 4 filesdep ~AC-Vectordep ~GLUTdep ~OpenGLPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: AC-Vector, GLUT, OpenGL, base, containers, graph-rewriting, graph-rewriting-layout
API changes (from Hackage documentation)
Files
- GraphRewriting/GL/Canvas.hs +4/−6
- GraphRewriting/GL/Global.hs +10/−12
- GraphRewriting/GL/Menu.hs +3/−3
- graph-rewriting-gl.cabal +13/−10
GraphRewriting/GL/Canvas.hs view
@@ -14,7 +14,7 @@ import GraphRewriting.Layout.Rotation import GraphRewriting.Layout.Position import qualified Data.Set as Set-import Data.Functor+import Data.Functor () import Data.Maybe (catMaybes, listToMaybe) import Data.Vector.Class @@ -52,7 +52,7 @@ case node of Nothing → return () Just n → do- _ ← (\idx → applyLeafRules (nextIs n) idx globalVars) =<< selectedRule <$> readIORef globalVars+ _ ← (\idx → applyLeafRules (nextIs n) idx globalVars) . selectedRule =<< readIORef globalVars highlight globalVars inputCallback (GL.MouseButton GL.RightButton) GL.Up mod (GL.Position x y) = resume globalVars@@ -86,7 +86,7 @@ GL.Vertex3 fx fy _ ← unproject from GL.Vertex3 tx ty _ ← unproject to modifyIORef focus $ \(GL.Vector3 x y _) → GL.Vector3 (x + tx - fx) (y + ty - fy) 0- redisplay =<< canvas <$> readIORef globalVars+ redisplay . canvas =<< readIORef globalVars GL.addTimerCallback 40 $ GL.motionCallback $= Just (scrollCallback to) inputCallback (GL.Char 'z') GL.Up _ _ = autozoom@@ -128,9 +128,7 @@ return $ listToMaybe $ catMaybes $ evalGraph (readOnly $ withNodes $ checkPos pos) g where checkPos pos n = do npos ← examineNode position n- return $ if (vmag (pos - npos) < 1)- then Just n- else Nothing+ return $ if vmag (pos - npos) < 1 then Just n else Nothing reshape s@(GL.Size w h) = do writeIORef aspect newAspect
GraphRewriting/GL/Global.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE UnicodeSyntax #-}+{-# LANGUAGE FlexibleContexts #-} module GraphRewriting.GL.Global where import Prelude.Unicode@@ -12,7 +12,7 @@ import qualified Data.Set as Set import Data.Set (Set) import Data.List ((\\))-import Control.Monad (when, replicateM_)+import Control.Monad (when, unless, replicateM_) import Data.Foldable import Data.Functor import Data.Traversable@@ -122,23 +122,21 @@ highlight globalVars selectRule i globalVars = do- ruleListLength ← numNodes <$> getRules <$> readIORef globalVars- if 0 ≤ i ∧ i < ruleListLength- then do- modifyIORef globalVars $ \v → v {selectedRule = i}- highlight globalVars- else return ()+ ruleListLength ← numNodes . getRules <$> readIORef globalVars+ when (0 ≤ i ∧ i < ruleListLength) $ do+ modifyIORef globalVars $ \v → v {selectedRule = i}+ highlight globalVars highlight globalVars = do gv@GlobalVars {graph = g, getRules = rs, selectedRule = r, highlighted = h, canvas = c} ← readIORef globalVars- let rule = fold $ fmap snd (subtrees rs !! r)+ let rule = foldMap snd (subtrees rs !! r) let h' = Set.fromList [head match | (match,rewrite) ← runPattern rule g] writeIORef globalVars $ gv {highlighted = h'} redisplay c layoutLoop globalVars = do gv@GlobalVars {graph = g, paused = p, layoutStep = l, canvas = c} ← readIORef globalVars- when (not p) $ do+ unless p $ do examine position (head $ nodes g) `seq` return () writeIORef globalVars $ gv {graph = execGraph (mapM l =<< readNodeList) g} -- TODO: relayout all nodes at once redisplay c@@ -173,7 +171,7 @@ Just (tree,p) → do let ns = evalGraph readNodeList g -- first we mark all redexes- let rule = restriction $ fold $ fmap snd tree+ let rule = restriction $ foldMap snd tree -- then we find a non-overlapping subset let ms = head $ evalPattern (matches rule) g -- then we apply the rules in the leafs while restricting them to that subset@@ -197,4 +195,4 @@ else let (match, rewrite) = head ms g' = execGraph rewrite g- in applyLeafRules' (filter (\m → not $ any (`elem` match) m) matches, g') (n + 1, r)+ in applyLeafRules' (filter (not . any (`elem` match)) matches, g') (n + 1, r)
GraphRewriting/GL/Menu.hs view
@@ -6,8 +6,8 @@ import GraphRewriting.GL.Global import Data.IORef import Control.Monad-import Data.Functor-import Control.Applicative+import Data.Functor ()+import Control.Applicative () menuItemHeight = 20@@ -15,7 +15,7 @@ setupMenu ∷ IORef (GlobalVars n) → IO () setupMenu globalVars = do- c ← liftM canvas $ readIORef globalVars+ c ← canvas <$> readIORef globalVars ruleTree ← getRules <$> readIORef globalVars charWidth ← stringWidth font "0" let cols = fromIntegral $ maximum $ map length $ lines $ showRuleTree ruleTree
graph-rewriting-gl.cabal view
@@ -1,30 +1,32 @@ Name: graph-rewriting-gl-Version: 0.7.8+Version: 0.7.9 Copyright: (c) 2010, Jan Rochel License: BSD3 License-File: LICENSE Author: Jan Rochel Maintainer: jan@rochel.info Homepage: http://rochel.info/#graph-rewriting+Bug-Reports: https://github.com/jrochel/graph-rewriting/issues Stability: beta Build-Type: Simple Synopsis: OpenGL interface for interactive port graph rewriting Description: Once a graph rewriting system has been specified using the @graph-rewriting@ library this package can be used to create an application that allows to experiment with this system by interactively applying the rewrite rules. The usage of the interface is the same for all applications. In the center you will see the graph. It might be moving around which is due the force-directed layouting. On the top-left corner you will find a menu with the individual rewriting rules of the rewriting system. The controls are described in the "GraphRewriting.GL.UI" module. Category: Graphs, Graphics-Cabal-Version: >= 1.6+Cabal-Version: >= 1.10 Extra-Source-Files: AUTHORS Library+ Default-Language: Haskell2010 Build-Depends:- base >= 4.8 && < 4.10,+ base >= 4.9 && < 5, base-unicode-symbols >= 0.2 && < 0.3,- graph-rewriting >= 0.7.8,- graph-rewriting-layout >= 0.5.4,- GLUT >= 2.2 && < 2.8,- OpenGL >= 3.0 && < 3.1,- containers >= 0.3 && < 0.6,- AC-Vector >= 2.3 && < 2.4+ graph-rewriting >= 0.7.8 && < 0.9,+ graph-rewriting-layout >= 0.5.4 && < 0.6,+ GLUT >= 2.2 && < 3,+ OpenGL >= 3.0 && < 4,+ containers >= 0.3 && < 0.7,+ AC-Vector >= 2.3.0 && < 2.5 Exposed-Modules: GraphRewriting.GL.UI GraphRewriting.GL.Render@@ -33,8 +35,9 @@ GraphRewriting.GL.Menu GraphRewriting.GL.Canvas GraphRewriting.GL.HyperEdge- Extensions:+ Default-Extensions: UnicodeSyntax+ Other-Extensions: FlexibleInstances FlexibleContexts MultiParamTypeClasses