graph-rewriting-gl-0.7.9: OpenGL interface for interactive port graph rewriting
Safe HaskellSafe-Inferred
LanguageHaskell2010

GraphRewriting.GL.UI

Description

This module provides an easy-to-use interface to create an interactive, graphical front-end for you graph rewriting system. The controls of the GUI are as follows:

  • Left-click on a menu entry to select a rewriting rule. At all times all redexes with respect to the selected rule are marked red in the graph. Note that the menu is hierarchical, which means that selecting a rule that has subordinate entries has the effect of all these entries being selected.
  • Right-click on a menu entry to apply the corresponding rule at every applicable position in the graph simultaneously (in no particular order). Redexes that are destroyed (or created) by prior contractions in this process are not reduced, thus if single applications of the rule terminate, so does its simultaneous application. Right-clicking does not select the rule.
  • Right-click on a node of the graph to apply the selected rewriting rule at that position. You know before whether it is a applicable, since all redexes in the graph with respect to the selected rule are marked red. Right-clicking on a non-redex node has no effect. The layouting stops while the right mouse-button is pressed.
  • Drag the background of the canvas to scroll around.
  • Drag individual nodes of the graph around to manually change the layouting of the graph.
  • Use your mouse-wheel to zoom in/out. Make sure to keep the mouse curser in the canvas area and not the menu while zooming.
  • Press space to pause/resume layouting. Currently layouting is automatically resumed when the graph is rewritten by right-clicking on an individual node and not when right-clicking on a menu entry. This also requires the mouse cursor to be positioned in the canvas area.

Please have a look the graph-rewriting-ski package for an example application that makes use of this library.

Synopsis

Documentation

run Source #

Arguments

:: (View Position n, Render n', View Position n', View Rotation n', PortSpec n', View [Port] n') 
=> Int

The number of initial layout steps to apply before displaying the graph

-> (Graph n -> Graph n')

A projection function that is applied just before displaying the graph

-> (Node -> Rewrite n a)

The monadic graph transformation code for a layout step

-> Graph n 
-> LabelledTree (Rule n)

The rule menu given as a tree of named rules

-> IO () 

initialise :: IO (String, [String]) Source #

Initialises GLUT. Returns program name and command line arguments.

data LabelledTree a Source #

Constructors

Branch String [LabelledTree a] 
Leaf String a 

Instances

Instances details
Foldable LabelledTree Source # 
Instance details

Defined in GraphRewriting.GL.Global

Methods

fold :: Monoid m => LabelledTree m -> m #

foldMap :: Monoid m => (a -> m) -> LabelledTree a -> m #

foldMap' :: Monoid m => (a -> m) -> LabelledTree a -> m #

foldr :: (a -> b -> b) -> b -> LabelledTree a -> b #

foldr' :: (a -> b -> b) -> b -> LabelledTree a -> b #

foldl :: (b -> a -> b) -> b -> LabelledTree a -> b #

foldl' :: (b -> a -> b) -> b -> LabelledTree a -> b #

foldr1 :: (a -> a -> a) -> LabelledTree a -> a #

foldl1 :: (a -> a -> a) -> LabelledTree a -> a #

toList :: LabelledTree a -> [a] #

null :: LabelledTree a -> Bool #

length :: LabelledTree a -> Int #

elem :: Eq a => a -> LabelledTree a -> Bool #

maximum :: Ord a => LabelledTree a -> a #

minimum :: Ord a => LabelledTree a -> a #

sum :: Num a => LabelledTree a -> a #

product :: Num a => LabelledTree a -> a #

Traversable LabelledTree Source # 
Instance details

Defined in GraphRewriting.GL.Global

Methods

traverse :: Applicative f => (a -> f b) -> LabelledTree a -> f (LabelledTree b) #

sequenceA :: Applicative f => LabelledTree (f a) -> f (LabelledTree a) #

mapM :: Monad m => (a -> m b) -> LabelledTree a -> m (LabelledTree b) #

sequence :: Monad m => LabelledTree (m a) -> m (LabelledTree a) #

Functor LabelledTree Source # 
Instance details

Defined in GraphRewriting.GL.Global

Methods

fmap :: (a -> b) -> LabelledTree a -> LabelledTree b #

(<$) :: a -> LabelledTree b -> LabelledTree a #

Show a => Show (LabelledTree a) Source # 
Instance details

Defined in GraphRewriting.GL.Global

showLabelledTree :: Show a => Int -> a -> (a -> a -> a) -> LabelledTree a -> String Source #