2014-10-01 00:05:29 +02:00
|
|
|
module Diagram where
|
|
|
|
|
|
2014-10-05 15:50:42 +02:00
|
|
|
import Defaults
|
2014-10-01 00:05:29 +02:00
|
|
|
import Diagrams.Prelude
|
|
|
|
|
import Diagrams.Backend.Cairo
|
|
|
|
|
import Meshparser
|
|
|
|
|
import Util
|
|
|
|
|
|
|
|
|
|
|
2014-10-05 15:50:42 +02:00
|
|
|
instance Def DiagProp where
|
|
|
|
|
def = defaultProp
|
|
|
|
|
|
|
|
|
|
|
2014-10-01 23:02:43 +02:00
|
|
|
-- |Holds the properties for a Diagram, like thickness of 2d points etc.
|
2014-10-01 21:48:31 +02:00
|
|
|
data DiagProp = MkProp {
|
|
|
|
|
-- |Get the thickness of the dot.
|
2014-10-05 15:50:42 +02:00
|
|
|
t :: Double
|
2014-10-01 21:48:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-10-05 15:50:42 +02:00
|
|
|
-- |The default properties of the Diagram.
|
|
|
|
|
defaultProp :: DiagProp
|
|
|
|
|
defaultProp = MkProp 2
|
|
|
|
|
|
|
|
|
|
|
2014-10-01 00:05:29 +02:00
|
|
|
-- |Create the Diagram from the VTable.
|
2014-10-01 21:48:31 +02:00
|
|
|
diagFromVTable :: DiagProp -> VTable -> Diagram Cairo R2
|
2014-10-02 14:30:08 +02:00
|
|
|
diagFromVTable prop vt
|
|
|
|
|
= position (zip (map mkPoint . filter (inRange 0 500) $ vt)
|
2014-10-02 13:13:58 +02:00
|
|
|
(repeat dot)) # moveTo (p2(-250, -250))
|
2014-10-02 20:07:23 +02:00
|
|
|
`atop` hrule 500 # centerX # moveTo (p2(0, -250))
|
|
|
|
|
`atop` vrule 500 # centerY # moveTo (p2(-250, 0))
|
|
|
|
|
`atop` square 550 # lwG 0.00 # bg white
|
2014-10-02 13:13:58 +02:00
|
|
|
where dot = (circle $
|
2014-10-05 15:50:42 +02:00
|
|
|
t prop :: Diagram Cairo R2) # fc black
|
2014-10-02 13:13:58 +02:00
|
|
|
mkPoint (x,y) = p2 (x,y)
|
2014-10-01 00:05:29 +02:00
|
|
|
|
2014-10-05 15:50:52 +02:00
|
|
|
|
2014-10-01 00:05:29 +02:00
|
|
|
-- |Create the Diagram from a String.
|
2014-10-01 21:48:31 +02:00
|
|
|
diagFromString :: DiagProp -> String -> Diagram Cairo R2
|
|
|
|
|
diagFromString prop mesh
|
|
|
|
|
= diagFromVTable prop .
|
|
|
|
|
meshToArr $
|
|
|
|
|
mesh
|