ShowLibGraph.hs revision 9fe593a62ad36d8458fa7ed3e9db7905e00a4f36
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaModule : $Header$
d98fdd80331e93cd698281341360a3ce3e30afbePavel BřezinaCopyright : (c) Uni Bremen 2003-2007
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaMaintainer : raider@tzi.de
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaStability : unstable
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaPortability : non-portable
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaThis Modul provides a function to display a Library Dependency Graph. Just the ShowLibGraph function is exported.
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina (showLibGraph)
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport Driver.Options(HetcatsOpts(outtypes),putIfVerbose)
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina-- for graph display
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport DaVinciGraph
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport GraphDisp
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport GraphConfigure
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina-- for windows display
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport TextDisplay
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport Configuration
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport GUI.GraphLogic(getLibDeps, hideNodes)
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport qualified Data.Map as Map
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinaimport qualified Common.Lib.Rel as Rel
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinatype NodeArcList = ([DaVinciNode LIB_NAME],[DaVinciArc (IO String)])
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina{- | Creates a new uDrawGraph Window and shows the Library Dependency Graph of
bf6f1b3d49e17b1adf0448c0b06e94b1e52ddffdLukas Slebodnik the given LibEnv.-}
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinashowLibGraph :: LibFunc
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinashowLibGraph gInfo = do
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina depGRef <- newIORef daVinciSort
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina nodeArcRef <- newIORef (([],[])::NodeArcList)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov globalMenu = GlobalMenu (Menu Nothing [
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Button "Reload Libraries"
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina (reload gInfo depGRef nodeArcRef)
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina graphParms = globalMenu $$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina GraphTitle "Library Graph" $$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina OptimiseLayout True $$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina AllowClose (return True) $$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina emptyGraphParms
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov depG <- newGraph daVinciSort graphParms
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov addNodesAndArcs gInfo depG nodeArcRef
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina writeIORef depGRef depG
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina-- | Reloads all Libraries and the Library Dependency Graph
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinareload :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeArcList -> IO()
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březinareload gInfo@(GInfo {gi_LIB_NAME = ln,
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina gi_hetcatsOpts = opts
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina }) depGRef nodeArcRef = do
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina depG <- readIORef depGRef
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina (nodes', arcs) <- readIORef nodeArcRef
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina libfile = libNameToFile opts ln
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov m <- anaLib opts { outtypes = [] } libfile
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Nothing -> fail $
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina "Could not read original development graph from '" ++ libfile ++ "'"
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Just (_, _) -> do
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina mapM_ (deleteArc depG) arcs
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina mapM_ (deleteNode depG) nodes'
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina addNodesAndArcs gInfo depG nodeArcRef
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina writeIORef depGRef depG
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina-- | Adds the Librarys and the Dependencies to the Graph
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaaddNodesAndArcs :: GInfo -> DaVinciGraphTypeSyn -> IORef NodeArcList -> IO ()
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinaaddNodesAndArcs gInfo@(GInfo {libEnvIORef = ioRefProofStatus}) depG
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina nodeArcRef = do
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina le <- readIORef ioRefProofStatus
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina lookup' x y = Map.findWithDefault (error "lookup': node not found") y x
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subNodeMenu = LocalMenu( Menu Nothing [
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Button "Show Graph" $ showGraph gInfo,
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Button "Show spec/View Names" $ showSpec le])
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subNodeTypeParms = subNodeMenu $$$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina ValueTitle (\ x -> return (show x)) $$$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Color "green" $$$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina emptyNodeTypeParms
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subNodeType <- newNodeType depG subNodeTypeParms
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subNodeList <- mapM (newNode depG subNodeType) keys
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina nodes' = Map.fromList $ zip keys subNodeList
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subArcMenu = LocalMenu( Menu Nothing [])
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subArcTypeParms = subArcMenu $$$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina ValueTitle id $$$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Color "black" $$$
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina emptyArcTypeParms
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov subArcType <- newArcType depG subArcTypeParms
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina insertSubArc = \ (node1, node2) -> newArc depG subArcType (return "")
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov (lookup' nodes' node1) (lookup' nodes' node2)
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina subArcList <- mapM insertSubArc $ Rel.toList $ Rel.intransKernel $
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina Rel.transClosure $ Rel.fromList $ getLibDeps le
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov writeIORef nodeArcRef (subNodeList, subArcList)
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina-- | Displays the Specs of a Library in a Textwindow
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinashowGraph :: GInfo -> LIB_NAME -> IO()
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinashowGraph gInfo@(GInfo {gi_hetcatsOpts = opts,
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina gi_GraphInfo = actGraphInfo
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina putIfVerbose opts 3 "Converting Graph"
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina (_,next) <- readIORef actGraphInfo
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina let gInfo' = gInfo {gi_LIB_NAME = ln,
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina graphId = next}
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina (gid,gv,_) <- convertGraph gInfo' "Development Graph" showLibGraph
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina redisplay gid gv
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina hideNodes gInfo' True
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina redisplay gid gv
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina-- | Displays the Specs of a Library in a Textwindow
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinashowSpec :: LibEnv -> LIB_NAME -> IO()
ca261795ce61c41d7e62217ccb2ee913923040ffPavel BřezinashowSpec le ln = do
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina ge = globalEnv $ lookupGlobalContext ln le
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina sp = unlines $ map show $ Map.keys $ ge
ca261795ce61c41d7e62217ccb2ee913923040ffPavel Březina createTextDisplay ("Contents of " ++ (show ln)) sp [size(80,25)]