cga/Graphics/Diagram/Gtk.hs
hasufell f3cabab280
Implement visualizing the quad tree in a separate window
This window creation still sucks a bit, we should realize it
without actually showing it.
2014-11-15 03:58:38 +01:00

51 lines
1.6 KiB
Haskell

{-# OPTIONS_HADDOCK ignore-exports #-}
module Graphics.Diagram.Gtk where
import Diagrams.Backend.Cairo
import Diagrams.Prelude
import Graphics.Diagram.Plotter
import Graphics.Diagram.Types
import Parser.Meshparser
-- |Create the Diagram from the points.
diag :: DiagProp -> Object -> Diagram Cairo R2
diag p obj@(Object _)
| alg p == 0 =
mkDiag (mconcat [coordPointsText, coordPoints, plotterBG])
p obj
| alg p == 1 =
mkDiag (mconcat [convexHPText, convexHP, convexHLs, coordPoints, plotterBG])
p obj
| alg p == 4 =
mkDiag (mconcat [quadPathSquare, squares, coordPointsText,
coordPoints, polyLines, plotterBG])
p obj
| otherwise = mempty
diag p objs@(Objects _)
| alg p == 2 =
mkDiag (mconcat [polyLines, coordPointsText, coordPoints, plotterBG])
p objs
| alg p == 3 =
mkDiag (mconcat [polyIntersectionText, polyIntersection,
coordPoints, polyLines, plotterBG])
p objs
| otherwise = mempty
-- |Create the Diagram from a String which is supposed to be the contents
-- of an obj file.
diagS :: DiagProp -> MeshString -> Diagram Cairo R2
diagS p mesh
| alg p == 2 || alg p == 3 = diag p. Objects . facesToArr $ mesh
| otherwise = (diag p . Object . meshToArr $ mesh) # bg white
-- |Create the tree diagram from a String which is supposed to be the contents
-- of an obj file.
diagTreeS :: DiagProp -> MeshString -> Diagram Cairo R2
diagTreeS p mesh
| alg p == 4 = mkDiag treePretty p (Object . meshToArr $mesh)
| otherwise = mempty