PrintAs.hs revision 239330cd665aac95fcf9cf95449594c96667cbc2
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettModule : $Header$
e071fb22ea9923a2a4ff41184d80ca46b55ee932Till MossakowskiDescription : print the abstract syntax of FreeCAD terms
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettCopyright : (c) Robert Savu and Uni Bremen 2011
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettLicense : GPLv2 or higher, see LICENSE.txt
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettMaintainer : Robert.Savu@dfki.de
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettStability : experimental
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettPortability : portable
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy GimblettPrinting of the abstract syntax of FreeCAD terms
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett-- | Pretty printing 'Double'
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettinstance Pretty Double where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett pretty = sidDoc . mkSimpleId . show
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettinstance Pretty Vector3 where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett pretty v = pretty (x v, y v, z v)
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettinstance Pretty Matrix33 where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett pretty m = vcat [lparen <+> rows, rparen] where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett rows = vcat [row1, row2, row3]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett row a b c = sepByCommas $ map pretty [a m, b m, c m]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett row1 = row a11 a12 a13
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett row2 = row a21 a22 a23
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett row3 = row a31 a32 a33
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettinstance Pretty Vector4 where
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett pretty v = parens $ sepByCommas $ map pretty [q0 v, q1 v, q2 v, q3 v]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettinstance Pretty Placement where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett brackets $ sepBySemis [pretty $ position p1, pretty $ orientation p1]
020cdb5dad6b871aba61136a0e1567c00426de87Andy GimblettprintBO:: BaseObject -> Doc
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy GimblettprintBO (Box h w l) = text "Box" <+> (vcat[hrow, wrow, lrow]) where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett hrow = hcat [ text "Height ", pretty h]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett wrow = hcat [ text "Width ", pretty w]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett lrow = hcat [ text "Length ", pretty l]
020cdb5dad6b871aba61136a0e1567c00426de87Andy GimblettprintBO (Cylinder a h r) = text "Cylinder" <+> (vcat[arow, hrow, rrow]) where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett arow = hcat [ text "Angle ", pretty a]
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett hrow = hcat [ text "Heigth ", pretty h]
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett rrow = hcat [ text "Radius ", pretty r]
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy GimblettprintBO (Sphere a1 a2 a3 r)=text "Sphere" <+>
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett (vcat[a1row, a2row, a3row, rrow]) where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett a1row = hcat [ text "Angle1 ", pretty a1]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett a2row = hcat [ text "Angle2 ", pretty a2]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett a3row = hcat [ text "Angle3 ", pretty a3]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett rrow = hcat [ text "Radius ", pretty r]
020cdb5dad6b871aba61136a0e1567c00426de87Andy GimblettprintBO (Cone a r1 r2 h) = text "Cone" <+> (vcat[arow, brow, hrow, rrow]) where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett arow = hcat [ text "Angle ", pretty a]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett brow = hcat [ text "Radius1 ", pretty r1]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett hrow = hcat [ text "Radius2 ", pretty r2]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett rrow = hcat [ text "Heigth ", pretty h]
020cdb5dad6b871aba61136a0e1567c00426de87Andy GimblettprintBO (Torus t1 t2 t3 t4 t5) = text "Torus" <+>
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett (vcat[t1r, t2r, t3r, t4r, t5r]) where
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett t1r = hcat [ text "Angle1 ", pretty t1]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett t2r = hcat [ text "Angle2 ", pretty t2]
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett t3r = hcat [ text "Angle3 ", pretty t3]