displayDependencyGraph.hs revision aef82b7f1af220ffd131169e5105ed392e8ff815
fb69cd512eab767747f109e40322df7cae2f7bdfChristian Maeder{- |
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederModule : $Header$
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederDescription : create a slightly faked dependency graph of the hets directories
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederCopyright : (c) jianchun wang and Uni Bremen 2006
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
fb69cd512eab767747f109e40322df7cae2f7bdfChristian Maeder
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederMaintainer : wjch868@tzi.de
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederStability : provisional
fb69cd512eab767747f109e40322df7cae2f7bdfChristian MaederPortability : portable
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder
fb69cd512eab767747f109e40322df7cae2f7bdfChristian Maederin order to generate the graph, hets needs to be created with
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder-ddump-minimal-imports first. Start the GUI\/displayDependencyGraph
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maederbinary that reads in the .imports files in the top-level directory and
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maedersave the graph as postscript. Suitably convert the postscript file to
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maedera .png file and upload it.
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder
30203b61afb4393c8e459470b3a16d1fe26acc7fChristian Maeder-}
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder
712f5e5ca1c3a5cfdd28518154ecf2dd0994cdb5Christian Maedermodule Main where
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder-- for graph display
f71a8dcf94fd9eb3c9800e16dcdc5e5ff74e5c22Christian Maederimport DaVinciGraph
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maederimport GraphDisp
024621f43239cfe9629e35d35a8669fad7acbba2Christian Maederimport GraphConfigure
c00adad2e9459b422dee09e3a2bddba66b433bb7Christian Maeder
c39be436ee9b0c08f9cb0c08988fcf5a5b147db9Christian Maeder-- for windows display
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maederimport TextDisplay
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maederimport Configuration
c39be436ee9b0c08f9cb0c08988fcf5a5b147db9Christian Maederimport Events
c39be436ee9b0c08f9cb0c08988fcf5a5b147db9Christian Maederimport Destructible
c39be436ee9b0c08f9cb0c08988fcf5a5b147db9Christian Maederimport qualified HTk
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maederimport qualified Data.Map as Map
024621f43239cfe9629e35d35a8669fad7acbba2Christian Maederimport qualified Data.Set as Set
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maederimport qualified Common.Lib.Rel as Rel
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder
ac07a6558423dae7adc488ed9092cd8e9450a29dChristian Maederimport System.Directory
51281dddda866c0cda9fca22bf6bc4eea7128112Christian Maederimport Data.List
51281dddda866c0cda9fca22bf6bc4eea7128112Christian Maeder
300ce2662e9abb115f7aa4e0a99c172a05ba454dChristian Maedermain :: IO ()
ac07a6558423dae7adc488ed9092cd8e9450a29dChristian Maedermain = do
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder fs <- getDirectoryContents "."
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder let suf = ".imports"
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder fn = filter (isSuffixOf suf) fs
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder ffn = map ( \ s -> take (length s - length suf) s) fn
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder ffnn = filter exclude $ filter (elem '.') ffn
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder fln = map (fst . break (== '.')) ffnn
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder fln' = nub fln
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder lfs <- mapM (readFile . (++ suf)) ffnn
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder let ss = map (filter (isPrefixOf "import") . lines) lfs
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder sss = getContent6 ss
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder ssss' = map (filter exclude) sss
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder ssss = map (map $ fst . break (== '.')) ssss'
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder sss' = map nub ssss
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder graphParms = GraphTitle "Dependency Graph" $$
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder OptimiseLayout True $$
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder AllowClose (return True) $$
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder emptyGraphParms
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder wishInst <- HTk.initHTk [HTk.withdrawMainWin]
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder depG <- newGraph daVinciSort graphParms
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder let flln = nub $ fln' ++ concat sss'
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder subNodeMenu = LocalMenu (Menu (Just "Info") [
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder Button "Contents" (\lg -> createTextDisplay
fb50920e621bfc152c19147cb52077ff06b3526bChristian Maeder ("Contents of " ++ lg)
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder (showCon lg) [size(80,25)])])
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder showCon lg = unlines (filter (isPrefixOf (lg++".")) ffnn)
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder subNodeTypeParms =
df638d53c2d5fe5e80b943a58609c8936848ed82Christian Maeder subNodeMenu $$$
fb69cd512eab767747f109e40322df7cae2f7bdfChristian Maeder Ellipse $$$
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder ValueTitle return $$$
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder Color "yellow" $$$
14b47f7dabb39996a31c7286810a5897587aed3aChristian Maeder emptyNodeTypeParms
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder subNodeType <- newNodeType depG subNodeTypeParms
14b47f7dabb39996a31c7286810a5897587aed3aChristian Maeder subNodeList <- mapM (newNode depG subNodeType) flln
ac07a6558423dae7adc488ed9092cd8e9450a29dChristian Maeder let slAndNodes = Map.fromList $ zip flln subNodeList
fb69cd512eab767747f109e40322df7cae2f7bdfChristian Maeder lookup' g_sl = Map.findWithDefault
35c0aa86aea351053f66b9d373148d0bdd4a1fe3Christian Maeder (error "lookup': node not found")
14b47f7dabb39996a31c7286810a5897587aed3aChristian Maeder g_sl slAndNodes
35c0aa86aea351053f66b9d373148d0bdd4a1fe3Christian Maeder subArcMenu = LocalMenu( Menu Nothing [])
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder subArcTypeParms = subArcMenu $$$
14b47f7dabb39996a31c7286810a5897587aed3aChristian Maeder ValueTitle id $$$
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder Color "green" $$$
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder emptyArcTypeParms
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder subArcType <- newArcType depG subArcTypeParms
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder let insertSubArc = \ (node1, node2) ->
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder newArc depG subArcType (return "")
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder (lookup' node1)
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder (lookup' node2)
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder mapM_ insertSubArc $
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder Rel.toList $ Rel.intransKernel $ Rel.transClosure $
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder Rel.fromList
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder $ isIn3 $ concat $ zipWith getContent2 fln sss'
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder redraw depG
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder sync(destroyed depG)
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder destroy wishInst
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder HTk.finishHTk
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder
712f5e5ca1c3a5cfdd28518154ecf2dd0994cdb5Christian Maederexclude :: String -> Bool
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maederexclude s = not $
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder isPrefixOf "ATC." s || isPrefixOf ".ATC_" (dropWhile (/= '.') s)
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder || isPrefixOf "Comorphisms." s
628310b42327ad76ce471caf0dde6563d6fa6307Christian Maeder || isPrefixOf "Logic_" (dropWhile (/= '.') s)
f0742398d4587242b1a115de113cd17f63dcb6d0Christian Maeder || Set.member s (Set.fromList
f0742398d4587242b1a115de113cd17f63dcb6d0Christian Maeder [ "Isabelle.CreateTheories"
f0742398d4587242b1a115de113cd17f63dcb6d0Christian Maeder , "OWL_DL.ToHaskellAS", "OWL_DL.StructureAna", "OWL_DL.OWLAnalysis"
f0742398d4587242b1a115de113cd17f63dcb6d0Christian Maeder , "Haskell.Haskell2DG", "Haskell.CreateModules"
f0742398d4587242b1a115de113cd17f63dcb6d0Christian Maeder , "Comorphisms.KnownProvers", "GUI.GenericATPState", "PGIP.Utils"
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder , "GUI.Utils", "GUI.ProofManagement" -- Proofs
f71a8dcf94fd9eb3c9800e16dcdc5e5ff74e5c22Christian Maeder , "Proofs.Automatic", "Driver.Options" -- Static
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder , "Proofs.EdgeUtils", "Proofs.StatusUtils" -- Driver
f71a8dcf94fd9eb3c9800e16dcdc5e5ff74e5c22Christian Maeder , "SoftFOL.Utils", "Proofs.BatchProcessing", "GUI.GenericATPState"
c39be436ee9b0c08f9cb0c08988fcf5a5b147db9Christian Maeder , "GUI.GenericATP", "SoftFOL.CreateDFGDoc"
cf3232cec840a6945667bdb06f5b47b22243bc8fChristian Maeder , "Static.DevGraph", "Syntax.AS_Library", "Static.AnalysisLibrary"
fb69cd512eab767747f109e40322df7cae2f7bdfChristian Maeder , "OMDoc.HetsInterface", "OMDoc.OMDocOutput", "Debug.Trace"
4954b30d3c209d7dee4e43016cee8189daf646e8Christian Maeder ])
4954b30d3c209d7dee4e43016cee8189daf646e8Christian Maeder
4954b30d3c209d7dee4e43016cee8189daf646e8Christian MaedergetContent2 :: String -> [String] -> [(String, String)]
4954b30d3c209d7dee4e43016cee8189daf646e8Christian MaedergetContent2 x = map (\ m -> (x, m))
4954b30d3c209d7dee4e43016cee8189daf646e8Christian Maeder
4954b30d3c209d7dee4e43016cee8189daf646e8Christian MaedergetContent4 :: [String] -> [String]
4954b30d3c209d7dee4e43016cee8189daf646e8Christian MaedergetContent4 s = map ((!! 1) . words) s
4954b30d3c209d7dee4e43016cee8189daf646e8Christian Maeder
4954b30d3c209d7dee4e43016cee8189daf646e8Christian MaedergetContent5 :: [String] -> [String]
5ea4161a514362065110614dd0d92adb13bf7cc3Christian MaedergetContent5 = map $ fst . break (== '(')
4954b30d3c209d7dee4e43016cee8189daf646e8Christian Maeder
5ea4161a514362065110614dd0d92adb13bf7cc3Christian MaedergetContent6 :: [[String]] ->[[String]]
4954b30d3c209d7dee4e43016cee8189daf646e8Christian MaedergetContent6 = map $ (filter (elem '.')) . getContent5 . getContent4
4954b30d3c209d7dee4e43016cee8189daf646e8Christian Maeder
isIn3 :: (Eq a)=> [(a, a)] -> [(a, a)]
isIn3 = filter (\(x,y) -> x /= y)