/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : LinksCreation.pkg */ /* Version : 27 juin 2000 */ /* Modules Graph links creations */ /* */ /***************************************************************************************/ /* ************************************************************** */ /* internal drawing utilities functions */ /* ************************************************************** */ fun LINKS_DrawLine( bitmap, x1, y1, x2, y2, color, width )= _DRAWline bitmap x1 y1 x2 y2 DRAW_SOLID width color ;; /* handles link creation line drawing */ fun LINKS_LinksCreationDrawLine( buffer, node, mousex, mousey )= let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKCREATION_COLOR" -> [c1 [c2 [c3 _]]] in let make_rgb atoi c1 atoi c2 atoi c3 -> GraphLinkCreateColor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKCREATION_WIDTH" -> [p1 _] in let atoi p1 -> GraphLinkCreatWidht in let if node == nil then if mousex > mousey then [mousex 0] else [0 mousey] else let _GETobjNodePositionSizeInContainerRef node -> [x y w h] in [x+w/2 y+h/2] -> [fromx fromy] in LINKS_DrawLine buffer fromx fromy mousex mousey GraphLinkCreateColor GraphLinkCreatWidht ;; fun LINKS_LinksCreationDrawLines( buffer, nodes, mousex, mousey )= if nodes == nil then buffer else let nodes -> [node next] in LINKS_LinksCreationDrawLines LINKS_LinksCreationDrawLine buffer node mousex mousey next mousex mousey ;; fun LINKS_LinksCreationDrawing( buffer, ModulesViewed, mousex, mousey )= /* let ModulesViewed.MODVIEWlinksLines -> [alphaBmp _] in let _GETalphaBitmaps alphaBmp -> [buffer _] in let _GETalphaBitmapTransparency alphaBmp -> transparency in */ let ModulesViewed.MODVIEWlinksCreation -> [nodes _] in if nodes != nil then LINKS_LinksCreationDrawLines buffer /* _FILLbitmap buffer transparency */ nodes mousex mousey else nil ;; /* handles links lines drawing */ var LINK = 0;; var LINK_HOVER = 1;; var LINK_SELECT = 2;; /* MAT ICI ecrire ca mieux */ fun LINKS_DrawLinkGetColor( linkType )= let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_COLOR" -> [c1 [c2 [c3 _]]] in let make_rgb atoi c1 atoi c2 atoi c3 -> GraphLinkcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_HOVER_SELECTED_COLOR" -> [c4 [c5 [c6 _]]] in let make_rgb atoi c4 atoi c5 atoi c6 -> GraphLinkHoverSelectcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_SELECTED_COLOR" -> [c7 [c8 [c9 _]]] in let make_rgb atoi c7 atoi c8 atoi c9 -> GraphLinkSelectcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_HOVER_COLOR" -> [c10 [c11 [c12 _]]] in let make_rgb atoi c10 atoi c11 atoi c12 -> GraphLinkHovercolor in if linkType == LINK then GraphLinkcolor else if linkType & LINK_SELECT then if linkType & LINK_HOVER then GraphLinkHoverSelectcolor else GraphLinkSelectcolor else if linkType & LINK_HOVER then GraphLinkHovercolor else nil /* never happens */ ;; fun LINKS_ComputeBrotherModulesPoints( x1, y1, w1, h1, x2, y2, w2, h2 )= if (abs (x1 - x2)) > (abs (y1 - y2 )) then if x1 < x2 then [ x1+w1 y1+h1/2 x2-1 y2+h2/2 ] else [ x1-1 y1+h1/2 x2+w2 y2+h2/2 ] else if y1 < y2 then [ x1+w1/2 y1+h1 x2+w2/2 y2-1 ] else [ x1+w1/2 y1-1 x2+w2/2 y2+h2 ] ;; fun LINKS_ComputeFatherSonModulesPoints( x, y, w, h )= if x < y then [ 0 y+h/2 x y+h/2 ] else [ x+w/2 0 x+w/2 y ] ;; fun LINKS_DrawLink( bitmap, check1, check2, linkType, mode )= if ((linkType != LINK) || !mode) then let _GETobjNodePositionSizeInFatherRef _CONVERTcompCheckToObjNode check1 -> [x1 y1 w1 h1] in let _GETobjNodePositionSizeInFatherRef _CONVERTcompCheckToObjNode check2 -> [x2 y2 w2 h2] in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_WIDTH" -> [p1 _] in let atoi p1 -> GraphLinkWidht in let if check1 == nil then LINKS_ComputeFatherSonModulesPoints x2 y2 w2 h2 else if check2 == nil then LINKS_ComputeFatherSonModulesPoints x1 y1 w1 h1 else LINKS_ComputeBrotherModulesPoints x1 y1 w1 h1 x2 y2 w2 h2 -> [fromX fromY destX destY] in LINKS_DrawLine bitmap fromX fromY destX destY LINKS_DrawLinkGetColor linkType GraphLinkWidht else bitmap ;; fun LINKS_DetectType( module1, module2, hoverModule, selectedModules )= ( if (module1 == hoverModule) || (module2 == hoverModule) then LINK_HOVER else LINK ) | ( if (is_in_list selectedModules module1) || (is_in_list selectedModules module2) then LINK_SELECT else LINK ) ;; /* ************************************************************** */ /* external usable functions */ /* ************************************************************** */ fun LINKS_DrawLinks( bitmap, check1, module1, modules, hoverModule, selectedModules )= if modules == nil then bitmap else let modules -> [[linkCheck check2 module2] next] in ( LINKS_DrawLinks if linkCheck == nil /* MAT ICI TMP: pour gerer les liens detruits il vaudrait mieux supprimer de la liste */ then bitmap else LINKS_DrawLink bitmap check1 check2 LINKS_DetectType module1 module2 hoverModule selectedModules PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" check1 module1 next hoverModule selectedModules ) ;; /* draws all visible links bitmap : ObjBitmap destination modules : [[CompCheck Module [[CompCheck CompCheck Module] r1] r1] description of what to draw (see ModulesView.pkg) hoverModule : Module, if a module should be considered as hovered by user mouse selectedModules : [Module r1], list of currently selected modules */ fun LINKS_DrawAllLinks( bitmap, modules, hoverModule, selectedModules )= if modules == nil then bitmap else let modules -> [[check1 module1 links] next] in LINKS_DrawAllLinks LINKS_DrawLinks bitmap check1 module1 links hoverModule selectedModules next hoverModule selectedModules ;;