/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : MainModulesWindow.pkg */ /* Version : 27 juin 2000 */ /* Modules Graph handling functions */ /* */ /***************************************************************************************/ /* ************************************************************** */ /* functions to handle all modules at a time */ /* ************************************************************** */ fun MODULES_UpdateLink( links, check1, module1, check2, module2, linkCheck )= if module1 == module2 then links else let search_in_list links @MODULESVIEW_SearchByButton _CONVERTcompCheckToObjNode check1 -> oldlinks in if oldlinks != nil then let oldlinks -> [_ _ next] in ( mutate oldlinks <- [_ _ [linkCheck check2 module2]::next]; links ) else [check1 module1 [linkCheck check2 module2]::nil]::links ;; fun MODULES_UpdateLinks( links, newlinks, check2, module2 )= if newlinks == nil then links else let newlinks -> [[linkCheck check1 module1] next] in MODULES_UpdateLinks MODULES_UpdateLink links check1 module1 check2 module2 linkCheck next check2 module2 ;; fun MODULES_CreateModules( module, param )= let param -> [Channel cont ModulesViewed] in if ((SITE_GetModuleCurrentBlackBox SELECT_GetSite) != module) && ((SITE_GetModuleCurrentBlackBox SELECT_GetSite) != MODULE_GetFather SELECT_GetSite module) then nil else let if ((SITE_GetModuleCurrentBlackBox SELECT_GetSite) == module) then nil else MODULES_CreateModule Channel cont ModulesViewed module -> check in let LINKS_CreateLinks Channel cont ModulesViewed ModulesViewed.MODVIEWrootNode check module ModulesViewed.MODVIEWmodules -> newlinks in ( /* add links references */ set ModulesViewed.MODVIEWmodules = [ check module newlinks ]:: ModulesViewed.MODVIEWmodules; /* update links reversed references */ set ModulesViewed.MODVIEWreversedModules = MODULES_UpdateLinks ModulesViewed.MODVIEWreversedModules newlinks check module ); 0 ;; /* destructions */ fun MODULES_DestroyAllLinks( modules )= if modules == nil then nil else let modules -> [[btn _ _] next] in ( MODULES_DestroyAllLinks next; _DScompCheck btn ) ;; fun MODULES_DestroyAllModules( modules )= if modules == nil then modules else let modules -> [[btn _ links] next] in ( _DScompCheck btn; MODULES_DestroyAllLinks links; MODULES_DestroyAllModules next ) ;; fun MODULES_DestroyModule( module, param )= let param -> [cont ModulesViewed] in ( if ModulesViewed.MODVIEWhoverModule == module then ( _CBcontainerClick cont nil nil; _CBcontainerDblClick cont @MODULESVIEW_BgDblClick nil ) else nil; MODULESVIEW_RemModule ModulesViewed module ) ;; /* destroy graphical resources */ /* MAT ICI s'assurer que tout est bien detruit */ fun MODULES_HideModules( ModulesViewed )= set ModulesViewed.MODVIEWmodules = MODULES_DestroyAllModules ModulesViewed.MODVIEWmodules; set ModulesViewed.MODVIEWreversedModules = nil; set ModulesViewed.MODVIEWlinksCreation = nil; ModulesViewed ;; /* displays modules graph for current memorized black box (creates graphical resources) */ fun MODULES_ShowModules( Channel, cont, ModulesViewed )= let SELECT_GetSite -> site in let SITE_GetModuleCurrentBlackBox site -> root in ( let MODULE_GetChildren site root -> children in apply_on_list root::children @MODULES_CreateModules [ Channel cont ModulesViewed ]; _CBcontainerDblClick cont @MODULESVIEW_BgDblClick nil; _CBcontainerClick cont @MODULESMOVE_ContainerClick [cont ModulesViewed root nil] ); MODULESMOVE_DrawLinks ModulesViewed nil 1; _PAINTcontainer cont; ModulesViewed ;; /* callbacks definitions and initialization functions */ fun MODULES_ModuleSelected( module, param )= /*_showconsole; MAT ICI CURRENT bug suppression module + hover sur un autre */ let param -> [type ModulesViewed Channel cont drawmode] in let MODULESVIEW_GetButton ModulesViewed module -> button in ( if type & REFLEX_UNSELECTION then ( /* MAT ICI optimisation possible sur les recherches dans ModulesViewed en les regroupant (LINKS_SetLinksStateByModule et MODULESVIEW_GetButton) */ /* Update links buttons */ let SELECT_GetModule REFLEX_PRIORITY_ONE -> modules in LINKS_SetLinksStateByModule ModulesViewed Channel cont module modules CHK_UNCHECKED 0 drawmode LINK_HOVER 0 REFLEX_UNSELECTION; /* Module button is set to normal */ _SETcompCheckState button CHK_UNCHECKED; /* to redraw links */ if !drawmode then MODULESMOVE_DrawLinksModule ModulesViewed button module nil SELECT_GetModule REFLEX_PRIORITY_ONE else nil; ) else /* REFLEX_SELECTION */ ( if button != nil then MODULESMOVE_CheckWorkspaceScroll cont ModulesViewed _CONVERTcompCheckToObjNode button else nil; /* Set all round links to selected */ let if (ModulesViewed.MODVIEWhoverModule == nil) || (module != ModulesViewed.MODVIEWhoverModule) then CHK_UNCHECKED else CHK_CHECKED -> checkmode in LINKS_SetLinksStateByModule ModulesViewed Channel cont module SELECT_GetModule REFLEX_PRIORITY_ONE checkmode 1 drawmode LINK_SELECT 1 REFLEX_SELECTION; /* Module button is set to selected */ _SETcompCheckState button CHK_CHECKED; _TOPobjNode _CONVERTcompCheckToObjNode button; /* to redraw links */ MODULESMOVE_DrawLinksModule ModulesViewed button module ModulesViewed.MODVIEWhoverModule SELECT_GetModule REFLEX_PRIORITY_ONE; ) ) ;; fun MODULES_ModulesSelected (modules, param, Channel, cont, ModulesViewed) = let PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" -> drawmode in ( apply_on_list modules @MODULES_ModuleSelected [param ModulesViewed Channel cont drawmode]; /* to redraw links */ if drawmode && (param & REFLEX_UNSELECTION) then MODULESMOVE_DrawLinks ModulesViewed ModulesViewed.MODVIEWhoverModule 0 else nil; _PAINTcontainer cont; ); 1 ;; fun MODULES_BBviewChanged (param, Channel, cont, ModulesViewed) = let SITE_GetModuleCurrentBlackBox SELECT_GetSite -> currentBB in ( MODULES_HideModules ModulesViewed; MODULES_ShowModules Channel cont ModulesViewed; /* to redraw links */ let hd SELECT_GetModule REFLEX_PRIORITY_ONE -> module in LINKS_SetLinksStateByModule ModulesViewed Channel cont module module::nil CHK_UNCHECKED 1 PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" LINK_SELECT 1 REFLEX_SELECTION; _PAINTcontainer cont ); 1 ;; fun MODULES_ModulesAdded( modules, param, channel, cont, ModulesViewed )= apply_on_list modules @MODULES_CreateModules [channel cont ModulesViewed]; _PAINTcontainer cont; 1 ;; fun MODULES_ModuleModified( module, param )= if module != SITE_GetModuleCurrentBlackBox SELECT_GetSite then let param -> [Channel cont ModulesViewed] in let MODULES_CreateModule Channel cont ModulesViewed module -> newCheck in ( MODULESVIEW_MutateModule ModulesViewed module newCheck; if is_in_list SELECT_GetModule REFLEX_PRIORITY_ONE module then _SETcompCheckState newCheck CHK_CHECKED /* MAT ICI, pour eviter qu'un module selectionne ne se deselectionne au Ok/Apply sur l'editeur, un peu crade */ else nil ) else nil ;; fun MODULES_ModuleSetPosition( module, ModulesViewed )= let MODULE_GetPosition module -> [x y] in let search_in_list ModulesViewed.MODVIEWmodules @MODULESVIEW_SearchByModule module -> [check _ links] in let _CONVERTcompCheckToObjNode check -> node in ( _CHANGEobjNodeCoordinates node [x y] 0; MODULESMOVE_LinksMove links node; let MODULESVIEW_GetReversedLinksByModule ModulesViewed module -> links in MODULESMOVE_LinksMove links node ) ;; fun MODULES_ModulesModified( modules, param, Channel, cont, ModulesViewed )= /* interesting cases: name and bitmap modifications */ if (param == REFLEX_NAME) || (param == REFLEX_BITMAP) then ( apply_on_list modules @MODULES_ModuleModified [Channel cont ModulesViewed]; _PAINTcontainer cont ) else if (param == REFLEX_POSITION) then ( /* MAT ICI petit pb: en fait ce reflexe est recu meme lorsque le module a ete deplace ds le graphe, pas bien grave en pratique */ apply_on_list modules @MODULES_ModuleSetPosition ModulesViewed; /* to redraw links */ MODULESMOVE_DrawLinks ModulesViewed ModulesViewed.MODVIEWhoverModule 1; _PAINTcontainer cont; ) else nil; 1 ;; fun MODULES_ModulesRemoved( modules, param, cont, ModulesViewed )= /* MAT ICI CURRENT pb avec hoverModule lors de suppression de module */ /* if is_in_list modules ModulesViewed.MODVIEWhoverModule then ( MODULESMOVE_UnsetModule nil [cont ModulesViewed ModulesViewed.MODVIEWhoverModule] nil nil nil; /* set ModulesViewed.MODVIEWhoverModule = nil*/ ) else nil; */ apply_on_list modules @MODULES_DestroyModule [cont ModulesViewed]; MODULESMOVE_DrawLinks ModulesViewed nil 1; _PAINTcontainer cont; 1 ;; fun MODULES_SiteSelected( site, param, Channel, cont, ModulesViewed )= MODULES_HideModules ModulesViewed; if (param & REFLEX_SELECTION) then ( MODULES_ShowModules Channel cont ModulesViewed; 1 ) else 0 ;; fun MODULES_LinkAdded( link, param )= let param -> [ModulesViewed Channel cont modules drawmode] in let LINK_GetSource link -> module1 in let LINK_GetDestination link -> module2 in let SELECT_GetSite -> site in let SITE_GetModuleCurrentBlackBox site -> father in if (((MODULE_GetFather site module1) == father) || (module1 == father)) && (((MODULE_GetFather site module2) == father) || (module2 == father)) then ( LINKS_FlushLinksByModules ModulesViewed Channel cont module1 module2 modules 0 drawmode; MODULESMOVE_DrawLinks ModulesViewed nil 0 ) else nil ;; fun MODULES_LinksAdded( links, param, Channel, cont, ModulesViewed )= let PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" -> drawmode in let SELECT_GetModule REFLEX_PRIORITY_ONE -> modules in apply_on_list links @MODULES_LinkAdded [ModulesViewed Channel cont modules drawmode]; _PAINTcontainer cont; 1 ;; fun MODULES_LinkRemoved( link, param )= let param -> [ModulesViewed Channel cont modules drawmode] in let LINK_GetSource link -> module1 in let LINK_GetDestination link -> module2 in if LINKS_FlushLinksByModules ModulesViewed Channel cont module1 module2 modules 0 drawmode then MODULESMOVE_DrawLinks ModulesViewed nil 1 else nil ;; fun MODULES_LinksRemoved( links, param, Channel, cont, ModulesViewed )= let PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" -> drawmode in let SELECT_GetModule REFLEX_PRIORITY_ONE -> modules in apply_on_list links @MODULES_LinkRemoved [ModulesViewed Channel cont modules drawmode]; _PAINTcontainer cont; 1 ;; fun MODULES_LinksSelected( links, param, Channel, cont, ModulesViewed )= if param & REFLEX_SELECTION then nil else if param & REFLEX_PRIORITY_TWO then ( if (SELECT_GetLink REFLEX_PRIORITY_TWO) == nil then set ModulesViewed.MODVIEWselectedLink = nil else nil; MODULES_LinksAdded links param Channel cont ModulesViewed ) else nil; 1 ;; fun MODULES_ChangeView( view, Channel, cont, ModulesViewed )= set ModulesViewed.MODVIEWlinksCreation = nil; _PAINTcontainer ModulesViewed.MODVIEWcontainer; 0;; fun MODULES_SetModulesGraphCallBacks( Channel, cont, ModulesViewed ) = REFLEX_CBmoduleAdded mkfun3 mkfun4 mkfun5 @MODULES_ModulesAdded ModulesViewed cont Channel; REFLEX_CBmoduleModified mkfun3 mkfun4 mkfun5 @MODULES_ModulesModified ModulesViewed cont Channel; REFLEX_CBmoduleSelected mkfun3 mkfun4 mkfun5 @MODULES_ModulesSelected ModulesViewed cont Channel; REFLEX_CBmoduleRemoved mkfun3 mkfun4 @MODULES_ModulesRemoved ModulesViewed cont; REFLEX_CBlinkRemoved mkfun3 mkfun4 mkfun5 @MODULES_LinksRemoved ModulesViewed cont Channel; REFLEX_CBlinkAdded mkfun3 mkfun4 mkfun5 @MODULES_LinksAdded ModulesViewed cont Channel; REFLEX_CBlinkSelected mkfun3 mkfun4 mkfun5 @MODULES_LinksSelected ModulesViewed cont Channel; REFLEX_CBsiteSelected mkfun3 mkfun4 mkfun5 @MODULES_SiteSelected ModulesViewed cont Channel; SCSGUI_CBviewBBChange mkfun2 mkfun3 mkfun4 @MODULES_BBviewChanged ModulesViewed cont Channel; SCSGUI_CBviewChange mkfun2 mkfun3 mkfun4 @MODULES_ChangeView ModulesViewed cont Channel ;; /* main entrance point called from MainWindow procedures */ fun MODULES_Initialize( Channel, cont )= let _GETcontainerPositionSize cont -> [_ _ w h] in let EMPTYNODE_Create Channel cont -> rootNode in let mkModulesView [ cont nil nil nil LINKSMENU_Create Channel rootNode LINKS_CreateLinesBitmap Channel cont rootNode /* MAT ICI le bitmap des traits des liens a faire de la meme taille que la portion visible */ PARAMS_GetI SCSparameters "MODULES_GRAPH_WORKSPACE_WIDTH" PARAMS_GetI SCSparameters "MODULES_GRAPH_WORKSPACE_HEIGHT" nil nil ] -> ModulesViewed in ( MODULES_SetModulesGraphCallBacks Channel cont ModulesViewed; MODULES_ShowModules Channel cont ModulesViewed ); 0 ;;