{"id":3871,"date":"2012-10-05T09:00:37","date_gmt":"2012-10-05T13:00:37","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=3871"},"modified":"2012-10-04T18:50:14","modified_gmt":"2012-10-04T22:50:14","slug":"make-simulink-line-crossing-more-distinct","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2012\/10\/05\/make-simulink-line-crossing-more-distinct\/","title":{"rendered":"Make Simulink Line Crossing More Distinct"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620\">Greg's<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37954-better-line-crossings-in-simulink-models\">Better line crossings in Simulink models<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/274012\">Josef Rieger<\/a>,\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Make It Easier to Follow Signal Lines that Cross<\/a><\/li>\r\n         <li><a href=\"#2\">But Doesn&#8217;t Simulink Already Distinguish Between Line Connections and Crossings?<\/a><\/li>\r\n         <li><a href=\"#3\">So How Does Josef Do It?<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Make It Easier to Follow Signal Lines that Cross<a name=\"1\"><\/a><\/h3>\r\n   <p>For those of you who have developed electrical circuit schematics, you are no doubt familiar with the concept of &#8220;line hops&#8221;. You apply these to distinctly demonstrate that two wires that may cross on the schematic do not represent an electrical connection.\r\n   <\/p>\r\n   <p>Josef applies the same concept to Simulink diagrams.<\/p>\r\n   <p>\r\n      <table width=\"100%\">\r\n      <tr style=\"background-color: #FFFFFF; text-align: center; color: #FFFFFF\">\r\n      <td><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/BetterLineCrossing_Writeup\/crossing_lines.png\" width = 300><\/td>\r\n      <td><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/BetterLineCrossing_Writeup\/line_hop.png\" width = 300><\/td>\r\n      <\/tr>\r\n      <\/table>\r\n      \r\n   <\/p>\r\n   <h3>But Doesn&#8217;t Simulink Already Distinguish Between Line Connections and Crossings?<a name=\"2\"><\/a><\/h3>\r\n   <p>Simulink does distinctly show when two signal lines are connected by the use of a &#8220;solder joint&#8221;.  Many people who develop electrical schematics apply this syntax as well to signify an electrical connection.\r\n   <\/p>\r\n   <p>\r\n      <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/BetterLineCrossing_Writeup\/solder_joint.png\" width = 300>\r\n      \r\n   <\/p>\r\n   <p>However, it is possible to have two signal lines meet, to look like a line crossing, but do not actually cross, making it difficult to distinguish which path goes where.\r\n   <\/p>\r\n   <p>\r\n      <table width=\"100%\">\r\n      <tr style=\"background-color: #FFFFFF; text-align: center; color: #FFFFFF\">\r\n      <td><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/BetterLineCrossing_Writeup\/corner_connection_lines.png\" width = 300><\/td>\r\n      <td><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/BetterLineCrossing_Writeup\/corner_connection_lines_hilite.png\" width = 300><\/td>\r\n      <\/tr>\r\n      <\/table>\r\n   <\/p>\r\n   <p>The use of line hops would prevent confusion in cases like this.  Having said that, you should probably avoid these types of potential confusing diagrams in the first place.\r\n   <\/p>\r\n   <p>In the latest version of <a title=\"https:\/\/www.mathworks.com\/products\/simulink\/whatsnew.html (link no longer works)\">Simulink in Release R2012b<\/a>, the new line routing algorithms are much better at avoiding these types of potentially confusing depictions. For this example I had to explicitly modify the lines so they appear to cross.\r\n   <\/p>\r\n   <h3>So How Does Josef Do It?<a name=\"3\"><\/a><\/h3>\r\n   <p>Josef relies on the default grid size used when drawing out Simulink signal lines as a means to distinguish between line hops and other types of line crossings.  That way it is possible to:<\/p>\r\n   <ul>\r\n   <li>Toggle line hops &#8220;on&#8221; and &#8220;off&#8221;<\/li>\r\n   <li>Prevent the creation of line hops on top of existing line hops<\/li>\r\n   <\/ul>\r\n   <p><\/p>\r\n   <p>He applies the use of the MATLAB application programming interface (API) for Simulink to determine what lines exist in Simulink, their respective coordinates on the Simulink diagram, and to apply the line hops to the existing Simulink signals.\r\n   <\/p>\r\n   <p>For more information on the MATLAB API for Simulink, see the documentation for <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012b\/simulink\/slref\/get_param.html\">get_param<\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012b\/simulink\/slref\/set_param.html\">set_param<\/a>.\r\n   <\/p>\r\n   <p><b>Comments<\/b><\/p>\r\n   <p>If you would like to leave any comments regarding this post, please click <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=3871#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_c8b537e82eef40bb882b10ddee13b804() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='c8b537e82eef40bb882b10ddee13b804 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' c8b537e82eef40bb882b10ddee13b804';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Greg Wolff';\r\n        copyright = 'Copyright 2012 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_c8b537e82eef40bb882b10ddee13b804()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 8.0<br><\/p>\r\n<\/div>\r\n<!--\r\nc8b537e82eef40bb882b10ddee13b804 ##### SOURCE BEGIN #####\r\n%% Make Simulink Line Crossing More Distinct\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620 Greg's>\r\n% pick this week is \r\n% \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37954-better-line-crossings-in-simulink-models Better line crossings in Simulink models>\r\n% by <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/274012 \r\n% Josef Rieger>, \r\n%\r\n%% Make It Easier to Follow Signal Lines that Cross\r\n% For those of you who have developed electrical circuit schematics, you are no doubt familiar with the concept of \u00e2\u20ac\u0153line hops\u00e2\u20ac\ufffd. You apply these to distinctly demonstrate that two wires that may cross on the schematic do not represent an electrical connection.\r\n% \r\n% Josef applies the same concept to Simulink diagrams.\r\n%\r\n% <html>\r\n% <table width=\"100%\">\r\n%     <tr style=\"background-color: #FFFFFF; text-align: center; color: #FFFFFF\">\r\n%         <td><img decoding=\"async\" src=\"crossing_lines.png\" width = 300><\/td>\r\n%         <td><img decoding=\"async\" src=\"line_hop.png\" width = 300><\/td>\r\n%     <\/tr>\r\n% <\/table>\r\n% <\/html>\r\n%\r\n%% But Doesn\u00e2\u20ac\u2122t Simulink Already Distinguish Between Line Connections and Crossings?\r\n% Simulink does distinctly show when two signal lines are connected by the use of a \u00e2\u20ac\u0153solder joint\u00e2\u20ac\ufffd.  Many people who develop electrical schematics apply this syntax as well to signify an electrical connection.\r\n%\r\n% <html>\r\n% <img decoding=\"async\" src=\"solder_joint.png\" width = 300>\r\n% <\/html>\r\n%\r\n% However, it is possible to have two signal lines meet, to look like a line crossing, but do not actually cross, making it difficult to distinguish which path goes where.\r\n%\r\n% <html>\r\n% <table width=\"100%\">\r\n%     <tr style=\"background-color: #FFFFFF; text-align: center; color: #FFFFFF\">\r\n%         <td><img decoding=\"async\" src=\"corner_connection_lines.png\" width = 300><\/td>\r\n%         <td><img decoding=\"async\" src=\"corner_connection_lines_hilite.png\" width = 300><\/td>\r\n%     <\/tr>\r\n% <\/table>\r\n% <\/html>\r\n%\r\n% The use of line hops would prevent confusion in cases like this.  Having said that, you should probably avoid these types of potential confusing diagrams in the first place.  \r\n%\r\n% In the latest version of Simulink in Release R2012b, the new line routing algorithms are much better at avoiding these types of potentially confusing depictions. For this example I had to explicitly modify the lines so they appear to cross.\r\n\r\n%% So How Does Josef Do It?\r\n% Josef relies on the default grid size used when drawing out Simulink signal lines as a means to distinguish between line hops and other types of line crossings.  That way it is possible to:\t\r\n% \r\n% # Toggle line hops \u00e2\u20ac\u0153on\u00e2\u20ac\ufffd and \u00e2\u20ac\u0153off\u00e2\u20ac\ufffd\r\n% # Prevent the creation of line hops on top of existing line hops\r\n% \r\n% He applies the use of the MATLAB application programming interface (API) \r\n% for Simulink to determine what lines exist in Simulink, their respective \r\n% coordinates on the Simulink diagram, and to apply the line hops to the \r\n% existing Simulink signals. \r\n%\r\n% For more information on the MATLAB API for Simulink, see the \r\n% documentation for <https:\/\/www.mathworks.com\/help\/releases\/R2012b\/simulink\/slref\/get_param.html get_param> and <https:\/\/www.mathworks.com\/help\/releases\/R2012b\/simulink\/slref\/set_param.html set_param>.\r\n\r\n%%\r\n% *Comments*\r\n%\r\n% If you would like to leave any comments regarding this post, please click \r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=?????#respond here>. \r\n##### SOURCE END ##### c8b537e82eef40bb882b10ddee13b804\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Greg's pick this week is Better line crossings in Simulink models by Josef Rieger,\r\n      \r\n   \r\n   Contents\r\n   \r\n      \r\n     ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2012\/10\/05\/make-simulink-line-crossing-more-distinct\/\">read more >><\/a><\/p>","protected":false},"author":44,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3871"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=3871"}],"version-history":[{"count":11,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3871\/revisions"}],"predecessor-version":[{"id":3888,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3871\/revisions\/3888"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=3871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=3871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=3871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}