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.
|
2014-10-25 13:40:10 +00:00
|
|
|
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
|
2014-10-25 13:40:10 +00:00
|
|
|
| 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 [squares, coordPointsText, coordPoints, polyLines,
|
|
|
|
plotterBG])
|
|
|
|
p obj
|
2014-10-25 13:40:10 +00:00
|
|
|
| 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
|
2014-10-25 13:40:10 +00:00
|
|
|
| alg p == 3 =
|
2014-10-28 17:51:19 +00:00
|
|
|
mkDiag (mconcat [polyIntersectionText, polyIntersection,
|
2014-10-25 18:39:34 +00:00
|
|
|
coordPoints, polyLines, plotterBG])
|
|
|
|
p objs
|
2014-10-25 13:40:10 +00:00
|
|
|
| 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
|
2014-10-25 13:40:10 +00:00
|
|
|
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
|