2014-10-10 15:40:08 +00:00
|
|
|
{-# OPTIONS_HADDOCK ignore-exports #-}
|
|
|
|
|
|
|
|
module Graphics.Diagram.Gtk where
|
|
|
|
|
2014-11-21 03:49:17 +00:00
|
|
|
import qualified Data.ByteString.Char8 as B
|
2014-10-10 15:40:08 +00:00
|
|
|
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 _)
|
2014-11-15 23:10:57 +00:00
|
|
|
| algo p == 0 =
|
2014-10-25 18:39:34 +00:00
|
|
|
mkDiag (mconcat [coordPointsText, coordPoints, plotterBG])
|
|
|
|
p obj
|
2014-11-15 23:10:57 +00:00
|
|
|
| algo p == 1 =
|
2014-10-25 18:39:34 +00:00
|
|
|
mkDiag (mconcat [convexHPText, convexHP, convexHLs, coordPoints, plotterBG])
|
|
|
|
p obj
|
2014-11-15 23:10:57 +00:00
|
|
|
| algo p == 4 =
|
2014-11-14 20:28:56 +00:00
|
|
|
mkDiag (mconcat [quadPathSquare, squares, coordPointsText,
|
|
|
|
coordPoints, polyLines, plotterBG])
|
2014-11-13 22:05:56 +00:00
|
|
|
p obj
|
2014-10-25 13:40:10 +00:00
|
|
|
| otherwise = mempty
|
|
|
|
diag p objs@(Objects _)
|
2014-11-15 23:10:57 +00:00
|
|
|
| algo p == 2 =
|
2014-10-25 18:39:34 +00:00
|
|
|
mkDiag (mconcat [polyLines, coordPointsText, coordPoints, plotterBG])
|
|
|
|
p objs
|
2014-11-15 23:10:57 +00:00
|
|
|
| algo 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.
|
2014-11-21 03:49:17 +00:00
|
|
|
diagS :: DiagProp -> B.ByteString -> Diagram Cairo R2
|
2014-10-25 13:40:10 +00:00
|
|
|
diagS p mesh
|
2014-11-16 15:44:26 +00:00
|
|
|
| algo p == 2 || algo p == 3 =
|
|
|
|
diag p
|
|
|
|
. Objects
|
|
|
|
. fmap (filterValidPT p)
|
|
|
|
. facesToArr
|
|
|
|
$ mesh
|
|
|
|
| otherwise = (diag p . Object . filterValidPT p . meshToArr $ mesh) # bg white
|
2014-11-15 02:58:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- |Create the tree diagram from a String which is supposed to be the contents
|
|
|
|
-- of an obj file.
|
2014-11-21 03:49:17 +00:00
|
|
|
diagTreeS :: DiagProp -> B.ByteString -> Diagram Cairo R2
|
2014-11-15 02:58:38 +00:00
|
|
|
diagTreeS p mesh
|
2014-11-16 15:44:26 +00:00
|
|
|
| algo p == 4 = mkDiag treePretty p (Object
|
|
|
|
. filterValidPT p
|
|
|
|
. meshToArr
|
|
|
|
$ mesh)
|
2014-11-15 02:58:38 +00:00
|
|
|
| otherwise = mempty
|