cga/Graphics/Diagram/Gtk.hs

51 lines
1.6 KiB
Haskell
Raw Normal View History

2014-10-10 15:40:08 +00:00
{-# 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 =
2014-10-25 18:39:34 +00:00
mkDiag (mconcat [coordPointsText, coordPoints, plotterBG])
p obj
| alg p == 1 =
2014-10-25 18:39:34 +00:00
mkDiag (mconcat [convexHPText, convexHP, convexHLs, coordPoints, plotterBG])
p obj
2014-11-13 22:05:56 +00:00
| alg p == 4 =
mkDiag (mconcat [quadPathSquare, squares, coordPointsText,
coordPoints, polyLines, plotterBG])
2014-11-13 22:05:56 +00:00
p obj
| otherwise = mempty
diag p objs@(Objects _)
| alg p == 2 =
2014-10-25 18:39:34 +00:00
mkDiag (mconcat [polyLines, coordPointsText, coordPoints, plotterBG])
p objs
| alg p == 3 =
mkDiag (mconcat [polyIntersectionText, polyIntersection,
2014-10-25 18:39:34 +00:00
coordPoints, polyLines, plotterBG])
p objs
| otherwise = mempty
2014-10-10 15:40:08 +00:00
-- |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
2014-10-25 18:39:34 +00:00
| 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