Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. getOriginBox : function (originId, arbreData) {
  2. var finalBoxInfos = {};
  3.  
  4. /**
  5. * On récupère les opérateurs en terminus de chemins
  6. */
  7. $.each(arbreData["operators"], function (operatorId) {
  8. var currentBox = operatorId;
  9.  
  10. /** 0 : left ; 1 : right ; 2 : middle**/
  11. var currentBoxRoads = [0, 0, 0];
  12.  
  13. /**
  14. * On remonte un opérateur terminus jusqu'à l'origin
  15. */
  16. while (!isNullOrEmpty(currentBox) && currentBox !== originId) {
  17. var upBoxId = arbreCore.getFromOperatorLink(currentBox, "input_1", arbreData["links"]);
  18. var upBoxConnector = arbreCore.getFromConnectorLink(upBoxId, currentBox, arbreData["links"]);
  19.  
  20. currentBox = upBoxId;
  21.  
  22. if (!arbreCore.isBoxMultipleOutputs(upBoxId, arbreData))
  23. currentBoxRoads[2] += 1;
  24. else if (upBoxConnector === arbreCore._leftOut)
  25. currentBoxRoads[0] += 1;
  26. else
  27. currentBoxRoads[1] += 1;
  28. }
  29. finalBoxInfos[operatorId] = currentBoxRoads;
  30. });
  31.  
  32.  
  33. /** 0 : operatorId ; 1 : left roads ; 2 : right roads ; 3 : final max height ; 4 : middle road**/
  34. var highestInfos = ["", 0, 0, 0, 0];
  35. var highestHeight = 0;
  36.  
  37. /**
  38. * On récupère l'operator Id
  39. * le plus en bas à gauche
  40. */
  41. $.each(finalBoxInfos, function (operatorId) {
  42. var boxInfos = finalBoxInfos[operatorId];
  43.  
  44. if (boxInfos[0] - boxInfos[1] > highestInfos[1] - highestInfos[2])
  45. highestInfos = [operatorId, boxInfos[0], boxInfos[1], 0, boxInfos[2]];
  46. else if (boxInfos[0] - boxInfos[1] === highestInfos[1] - highestInfos[2] && boxInfos[0] === highestInfos[1])
  47. highestInfos = boxInfos[2] > highestInfos[4] ? [operatorId, boxInfos[0], boxInfos[1], 0, boxInfos[2]] : highestInfos;
  48. else if (boxInfos[0] - boxInfos[1] === highestInfos[1] - highestInfos[2])
  49. highestInfos = boxInfos[0] > highestInfos[1] ? [operatorId, boxInfos[0], boxInfos[1], 0, boxInfos[2]] : highestInfos;
  50.  
  51. var currentHeight = (boxInfos[0] + boxInfos[1] + boxInfos[2]) * (arbreCore._hEcart + arbreCore._boxHeight) + (arbreCore._plusHeight * 2) + arbreCore._boxHeight;
  52. highestHeight = currentHeight > highestHeight ? currentHeight : highestHeight;
  53. });
  54.  
  55. /** Calcul du max height **/
  56. highestHeight = !highestHeight ? (arbreCore._boxHeight + (2 * arbreCore._plusHeight)) : highestHeight;
  57. highestInfos[3] = highestHeight;
  58.  
  59. /**
  60. * Si il n'y pas de chemin sur l'arbre
  61. */
  62. if (isNullOrEmpty(highestInfos[0]))
  63. highestInfos = [originId, 0, 0, highestHeight, 0];
  64.  
  65. return (highestInfos);
  66. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement