mirror of
https://github.com/rgleichman/glance.git
synced 2024-11-30 14:22:20 +03:00
Extract the Graphviz parameters in Rendering.hs so they can be reused by renderFglGraph.
This commit is contained in:
parent
7ceb5977e4
commit
cab045da4b
@ -1,7 +1,8 @@
|
|||||||
{-# LANGUAGE NoMonomorphismRestriction, FlexibleContexts, TypeFamilies, PartialTypeSignatures #-}
|
{-# LANGUAGE NoMonomorphismRestriction, FlexibleContexts, TypeFamilies, PartialTypeSignatures #-}
|
||||||
|
|
||||||
module Rendering (
|
module Rendering (
|
||||||
renderDrawing
|
renderDrawing,
|
||||||
|
customLayoutParams
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Diagrams.Prelude hiding ((#), (&))
|
import Diagrams.Prelude hiding ((#), (&))
|
||||||
@ -232,6 +233,25 @@ placeNodes layoutResult nameDiagramMap edges = mconcat placedNodes
|
|||||||
-- todo: Not sure if the diagrams should already be centered at this point.
|
-- todo: Not sure if the diagrams should already be centered at this point.
|
||||||
placeNode (name, diagram) = place (centerXY diagram) (scaleFactor *^ (positionMap Map.! name))
|
placeNode (name, diagram) = place (centerXY diagram) (scaleFactor *^ (positionMap Map.! name))
|
||||||
|
|
||||||
|
customLayoutParams :: GV.GraphvizParams n v e () v
|
||||||
|
customLayoutParams = GV.defaultParams{
|
||||||
|
GV.globalAttributes = [
|
||||||
|
GV.NodeAttrs [GVA.Shape GVA.BoxShape]
|
||||||
|
--GV.NodeAttrs [GVA.Shape GVA.Circle]
|
||||||
|
, GV.GraphAttrs
|
||||||
|
[
|
||||||
|
--GVA.Overlap GVA.KeepOverlaps,
|
||||||
|
--GVA.Overlap GVA.ScaleOverlaps,
|
||||||
|
GVA.Overlap $ GVA.PrismOverlap (Just 5000),
|
||||||
|
GVA.Splines GVA.LineEdges,
|
||||||
|
GVA.OverlapScaling 8,
|
||||||
|
--GVA.OverlapScaling 4,
|
||||||
|
GVA.OverlapShrink True
|
||||||
|
]
|
||||||
|
],
|
||||||
|
GV.fmtEdge = const [GV.arrowTo GV.noArrow]
|
||||||
|
}
|
||||||
|
|
||||||
doGraphLayout :: SpecialBackend b =>
|
doGraphLayout :: SpecialBackend b =>
|
||||||
Gr Name e
|
Gr Name e
|
||||||
-> [(Name, Bool -> Double -> SpecialQDiagram b)]
|
-> [(Name, Bool -> Double -> SpecialQDiagram b)]
|
||||||
@ -244,22 +264,7 @@ doGraphLayout graph nameDiagramMap edges = do
|
|||||||
where
|
where
|
||||||
layoutParams :: GV.GraphvizParams Int v e () v
|
layoutParams :: GV.GraphvizParams Int v e () v
|
||||||
--layoutParams :: GV.GraphvizParams Int l el Int l
|
--layoutParams :: GV.GraphvizParams Int l el Int l
|
||||||
layoutParams = GV.defaultParams{
|
layoutParams = customLayoutParams{
|
||||||
GV.globalAttributes = [
|
|
||||||
GV.NodeAttrs [GVA.Shape GVA.BoxShape]
|
|
||||||
--GV.NodeAttrs [GVA.Shape GVA.Circle]
|
|
||||||
, GV.GraphAttrs
|
|
||||||
[
|
|
||||||
--GVA.Overlap GVA.KeepOverlaps,
|
|
||||||
--GVA.Overlap GVA.ScaleOverlaps,
|
|
||||||
GVA.Overlap $ GVA.PrismOverlap (Just 5000),
|
|
||||||
GVA.Splines GVA.LineEdges,
|
|
||||||
GVA.OverlapScaling 8,
|
|
||||||
--GVA.OverlapScaling 4,
|
|
||||||
GVA.OverlapShrink True
|
|
||||||
]
|
|
||||||
],
|
|
||||||
GV.fmtEdge = const [GV.arrowTo GV.noArrow],
|
|
||||||
GV.fmtNode = nodeAttribute
|
GV.fmtNode = nodeAttribute
|
||||||
}
|
}
|
||||||
nodeAttribute :: (Int, l) -> [GV.Attribute]
|
nodeAttribute :: (Int, l) -> [GV.Attribute]
|
||||||
|
@ -10,7 +10,7 @@ import qualified Data.Graph.Inductive.Graph as ING
|
|||||||
import qualified Data.Graph.Inductive.PatriciaTree as FGR
|
import qualified Data.Graph.Inductive.PatriciaTree as FGR
|
||||||
|
|
||||||
import Icons(textBox, colorScheme, ColorStyle(..), coloredTextBox)
|
import Icons(textBox, colorScheme, ColorStyle(..), coloredTextBox)
|
||||||
import Rendering(renderDrawing)
|
import Rendering(renderDrawing, customLayoutParams)
|
||||||
import Util(toNames, portToPort, iconToPort, iconToIcon,
|
import Util(toNames, portToPort, iconToPort, iconToIcon,
|
||||||
iconToIconEnds, iconTailToPort)
|
iconToIconEnds, iconTailToPort)
|
||||||
import Types(Icon(..), Drawing(..), EdgeEnd(..), SgNamedNode, Edge)
|
import Types(Icon(..), Drawing(..), EdgeEnd(..), SgNamedNode, Edge)
|
||||||
@ -417,7 +417,7 @@ graphTests = do
|
|||||||
nodeFunc (name, syntaxNode) =
|
nodeFunc (name, syntaxNode) =
|
||||||
place (coloredTextBox white (opaque white) (show syntaxNode) :: Diagram B)
|
place (coloredTextBox white (opaque white) (show syntaxNode) :: Diagram B)
|
||||||
|
|
||||||
-- TODO Refactor with doGraphLayout in Rendering.hs
|
|
||||||
renderFglGraph :: FGR.Gr SgNamedNode Edge -> IO (Diagram B)
|
renderFglGraph :: FGR.Gr SgNamedNode Edge -> IO (Diagram B)
|
||||||
renderFglGraph fglGraph = do
|
renderFglGraph fglGraph = do
|
||||||
layedOutGraph <- DiaGV.layoutGraph' layoutParams GVA.Neato fglGraph
|
layedOutGraph <- DiaGV.layoutGraph' layoutParams GVA.Neato fglGraph
|
||||||
@ -429,23 +429,8 @@ renderFglGraph fglGraph = do
|
|||||||
nodeFunc (name, syntaxNode) =
|
nodeFunc (name, syntaxNode) =
|
||||||
place (coloredTextBox white (opaque white) (show syntaxNode) :: Diagram B)
|
place (coloredTextBox white (opaque white) (show syntaxNode) :: Diagram B)
|
||||||
layoutParams :: GV.GraphvizParams Int v e () v
|
layoutParams :: GV.GraphvizParams Int v e () v
|
||||||
layoutParams = GV.defaultParams{
|
layoutParams = customLayoutParams{
|
||||||
GV.globalAttributes = [
|
GV.fmtNode = nodeAttribute
|
||||||
GV.NodeAttrs [GVA.Shape GVA.BoxShape]
|
|
||||||
--GV.NodeAttrs [GVA.Shape GVA.Circle]
|
|
||||||
, GV.GraphAttrs
|
|
||||||
[
|
|
||||||
--GVA.Overlap GVA.KeepOverlaps,
|
|
||||||
--GVA.Overlap GVA.ScaleOverlaps,
|
|
||||||
GVA.Overlap $ GVA.PrismOverlap (Just 5000),
|
|
||||||
GVA.Splines GVA.LineEdges,
|
|
||||||
GVA.OverlapScaling 8,
|
|
||||||
--GVA.OverlapScaling 4,
|
|
||||||
GVA.OverlapShrink True
|
|
||||||
]
|
|
||||||
],
|
|
||||||
GV.fmtEdge = const [GV.arrowTo GV.noArrow],
|
|
||||||
GV.fmtNode = nodeAttribute
|
|
||||||
}
|
}
|
||||||
nodeAttribute :: (Int, l) -> [GV.Attribute]
|
nodeAttribute :: (Int, l) -> [GV.Attribute]
|
||||||
nodeAttribute (nodeInt, _) =
|
nodeAttribute (nodeInt, _) =
|
||||||
|
Loading…
Reference in New Issue
Block a user