{-# LANGUAGE  CApiFFI #-}
module OpenCascade.Font.BRepTextBuilder
( BRepTextBuilder
, new
, perform
) where

import OpenCascade.Font.Types
import OpenCascade.Font.Internal.Destructors
import Foreign.Ptr
import Foreign.C
import Data.Acquire
import qualified OpenCascade.Graphic3D.VerticalTextAlignment as VTA
import qualified OpenCascade.Graphic3D.HorizontalTextAlignment as HTA
import qualified OpenCascade.TopoDS as TopoDS
import qualified OpenCascade.GP as GP
import OpenCascade.TopoDS.Internal.Destructors (deleteShape)

foreign import capi unsafe "hs_Font_BRepTextBuilder.h hs_new_Font_BRepTextBuilder" rawNew :: IO (Ptr BRepTextBuilder)

new :: Acquire (Ptr BRepTextBuilder)
new :: Acquire (Ptr BRepTextBuilder)
new = IO (Ptr BRepTextBuilder)
-> (Ptr BRepTextBuilder -> IO ()) -> Acquire (Ptr BRepTextBuilder)
forall a. IO a -> (a -> IO ()) -> Acquire a
mkAcquire IO (Ptr BRepTextBuilder)
rawNew Ptr BRepTextBuilder -> IO ()
deleteBRepTextBuilder


foreign import capi unsafe "hs_Font_BRepTextBuilder.h hs_Font_BRepTextBuilder_perform" rawPerform :: Ptr BRepTextBuilder -> Ptr BRepFont -> CString -> Ptr GP.Ax3 -> CInt -> CInt -> IO (Ptr TopoDS.Shape)

perform :: Ptr BRepTextBuilder -> Ptr BRepFont -> String -> Ptr GP.Ax3 -> HTA.HorizontalTextAlignment -> VTA.VerticalTextAlignment -> Acquire (Ptr TopoDS.Shape)
perform :: Ptr BRepTextBuilder
-> Ptr BRepFont
-> String
-> Ptr Ax3
-> HorizontalTextAlignment
-> VerticalTextAlignment
-> Acquire (Ptr Shape)
perform Ptr BRepTextBuilder
builder Ptr BRepFont
font String
str Ptr Ax3
axis HorizontalTextAlignment
hAlign VerticalTextAlignment
vAlign =
     IO (Ptr Shape) -> (Ptr Shape -> IO ()) -> Acquire (Ptr Shape)
forall a. IO a -> (a -> IO ()) -> Acquire a
mkAcquire 
        (String -> (CString -> IO (Ptr Shape)) -> IO (Ptr Shape)
forall a. String -> (CString -> IO a) -> IO a
withCString String
str ((CString -> IO (Ptr Shape)) -> IO (Ptr Shape))
-> (CString -> IO (Ptr Shape)) -> IO (Ptr Shape)
forall a b. (a -> b) -> a -> b
$ \CString
s -> Ptr BRepTextBuilder
-> Ptr BRepFont
-> CString
-> Ptr Ax3
-> CInt
-> CInt
-> IO (Ptr Shape)
rawPerform Ptr BRepTextBuilder
builder Ptr BRepFont
font CString
s Ptr Ax3
axis (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (HorizontalTextAlignment -> Int)
-> HorizontalTextAlignment
-> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HorizontalTextAlignment -> Int
forall a. Enum a => a -> Int
fromEnum (HorizontalTextAlignment -> CInt)
-> HorizontalTextAlignment -> CInt
forall a b. (a -> b) -> a -> b
$ HorizontalTextAlignment
hAlign) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (VerticalTextAlignment -> Int) -> VerticalTextAlignment -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerticalTextAlignment -> Int
forall a. Enum a => a -> Int
fromEnum (VerticalTextAlignment -> CInt) -> VerticalTextAlignment -> CInt
forall a b. (a -> b) -> a -> b
$ VerticalTextAlignment
vAlign)) 
        Ptr Shape -> IO ()
deleteShape