Improve haddock documentation
This commit is contained in:
parent
545c5365e9
commit
5e5408422b
@ -6,6 +6,7 @@ import Meshparser
|
|||||||
import Util
|
import Util
|
||||||
|
|
||||||
|
|
||||||
|
-- |Holds the properties for a Diagram, like thickness of 2d points etc.
|
||||||
data DiagProp = MkProp {
|
data DiagProp = MkProp {
|
||||||
-- |Get the thickness of the dot.
|
-- |Get the thickness of the dot.
|
||||||
getThickness :: Double
|
getThickness :: Double
|
||||||
|
7
Gtk.hs
7
Gtk.hs
@ -10,6 +10,7 @@ import Graphics.UI.Gtk.Windows.MessageDialog
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
|
|
||||||
|
|
||||||
|
-- |Handle the whole GTK gui.
|
||||||
startGUI :: FilePath -> IO ()
|
startGUI :: FilePath -> IO ()
|
||||||
startGUI startFile = do
|
startGUI startFile = do
|
||||||
homedir <- getHomeDirectory
|
homedir <- getHomeDirectory
|
||||||
@ -84,6 +85,7 @@ startGUI startFile = do
|
|||||||
mainGUI
|
mainGUI
|
||||||
|
|
||||||
|
|
||||||
|
-- |Callback when the "Draw" Button is clicked.
|
||||||
onClickedDrawButton :: (WidgetClass widget, RangeClass scale)
|
onClickedDrawButton :: (WidgetClass widget, RangeClass scale)
|
||||||
=> FileChooserButton
|
=> FileChooserButton
|
||||||
-> widget
|
-> widget
|
||||||
@ -98,6 +100,7 @@ onClickedDrawButton fcb da scale' = do
|
|||||||
showErrorDialog "No valid Mesh file!"
|
showErrorDialog "No valid Mesh file!"
|
||||||
|
|
||||||
|
|
||||||
|
-- |Callback when the "Save" Button is clicked.
|
||||||
onClickedSaveButton :: FileChooserButton
|
onClickedSaveButton :: FileChooserButton
|
||||||
-> IO ()
|
-> IO ()
|
||||||
onClickedSaveButton fcb = do
|
onClickedSaveButton fcb = do
|
||||||
@ -109,6 +112,7 @@ onClickedSaveButton fcb = do
|
|||||||
showErrorDialog "No valid Mesh file!"
|
showErrorDialog "No valid Mesh file!"
|
||||||
|
|
||||||
|
|
||||||
|
-- |Pops up an error Dialog with the given String.
|
||||||
showErrorDialog :: String -> IO ()
|
showErrorDialog :: String -> IO ()
|
||||||
showErrorDialog str = do
|
showErrorDialog str = do
|
||||||
errorDialog <- messageDialogNew Nothing
|
errorDialog <- messageDialogNew Nothing
|
||||||
@ -120,6 +124,8 @@ showErrorDialog str = do
|
|||||||
widgetDestroy errorDialog
|
widgetDestroy errorDialog
|
||||||
|
|
||||||
|
|
||||||
|
-- |Draws a Diagram which is built from a given file to
|
||||||
|
-- the gtk DrawingArea.
|
||||||
drawDiag' :: (WidgetClass widget, RangeClass scale)
|
drawDiag' :: (WidgetClass widget, RangeClass scale)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> widget
|
-> widget
|
||||||
@ -136,6 +142,7 @@ drawDiag' fp da scale' = do
|
|||||||
renderWithDrawable dw r
|
renderWithDrawable dw r
|
||||||
|
|
||||||
|
|
||||||
|
-- |Saves a Diagram which is built from a given file as an SVG.
|
||||||
saveDiag' :: FilePath -> IO ()
|
saveDiag' :: FilePath -> IO ()
|
||||||
saveDiag' fp = do
|
saveDiag' fp = do
|
||||||
mesh <- readFile fp
|
mesh <- readFile fp
|
||||||
|
7
Util.hs
7
Util.hs
@ -11,11 +11,13 @@ inRange min' max' (x, y)
|
|||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
|
|
||||||
|
-- |Compare the extension of a file with the given String.
|
||||||
cmpExt :: String -> FilePath -> Bool
|
cmpExt :: String -> FilePath -> Bool
|
||||||
cmpExt _ [] = False
|
cmpExt _ [] = False
|
||||||
cmpExt ext fp = ext == getExt fp
|
cmpExt ext fp = ext == getExt fp
|
||||||
|
|
||||||
|
|
||||||
|
-- |Get the extension of a file.
|
||||||
getExt :: FilePath -> String
|
getExt :: FilePath -> String
|
||||||
getExt = last .
|
getExt = last .
|
||||||
splitBy (== '.') .
|
splitBy (== '.') .
|
||||||
@ -23,7 +25,10 @@ getExt = last .
|
|||||||
splitBy (== '/')
|
splitBy (== '/')
|
||||||
|
|
||||||
|
|
||||||
splitBy :: (a -> Bool) -> [a] -> [[a]]
|
-- |Split an array into subarrays depending on a given condition.
|
||||||
|
splitBy :: (a -> Bool) -- ^ condition
|
||||||
|
-> [a] -- ^ array to split
|
||||||
|
-> [[a]] -- ^ splitted array
|
||||||
splitBy f s = case dropWhile f s of
|
splitBy f s = case dropWhile f s of
|
||||||
[] -> []
|
[] -> []
|
||||||
s' -> w : splitBy f s''
|
s' -> w : splitBy f s''
|
||||||
|
Loading…
Reference in New Issue
Block a user