diff --git a/core/config/main.php b/core/config/main.php index bf6dfd2..9a7603c 100755 --- a/core/config/main.php +++ b/core/config/main.php @@ -94,5 +94,5 @@ $g_config['vote'] = "./tmp/vote/vote.txt"; $g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_"; $g_config['use_js_cache'] = true; - $g_config['engine_version'] = 109; + $g_config['engine_version'] = 110; ?> diff --git a/i/css/home.css b/i/css/home.css index 0ebb6c1..3a8d06d 100755 --- a/i/css/home.css +++ b/i/css/home.css @@ -554,6 +554,31 @@ label.switcherText { padding: 6px; } +.incidence-matrix-controls { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; + margin-top: 8px; +} + +.incidence-matrix-controls label { + margin: 0; + white-space: nowrap; +} + +#incidenceEdgeEnumeration { + flex: 1 1 150px; + width: auto; + min-width: 150px; +} + +#incidenceEdgeNamesList { + width: 100%; + min-width: 300px; + resize: vertical; +} + /* Left text */ .side-text-wrap { width: 40px; diff --git a/lang/bg/home.php b/lang/bg/home.php index 37fdee8..cb896fc 100644 --- a/lang/bg/home.php +++ b/lang/bg/home.php @@ -176,6 +176,9 @@ $g_lang["greek_add"] = " We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang["text_above_edge"] = "Текст над ребро"; + $g_lang["edge_enumeration"] = "Номериране на ребрата"; + $g_lang["no_enumeration"] = "Без номериране"; + $g_lang["edit_edge_names"] = "Редактиране на текстовете"; $g_lang["select_groupe_mac"] = "Използвайте Cmd⌘ за да изберете няколко обекта."; $g_lang["select_groupe_win"] = "Използвайте Ctrl за да изберете няколко обекта."; diff --git a/lang/ch/home.php b/lang/ch/home.php index ad67068..6a5d36d 100644 --- a/lang/ch/home.php +++ b/lang/ch/home.php @@ -178,6 +178,9 @@ $g_lang["greek_add"] = " 我们添加了中文翻译 🇳🇱. 感谢 Xingyi Zhang"; $g_lang["text_above_edge"] = "边上的文本"; + $g_lang["edge_enumeration"] = "边编号"; + $g_lang["no_enumeration"] = "不编号"; + $g_lang["edit_edge_names"] = "编辑边文本"; $g_lang["select_groupe_mac"] = "使用 Cmd⌘ 选择数个对象."; $g_lang["select_groupe_win"] = "使用 Ctrl 选择数个对象."; diff --git a/lang/cs/home.php b/lang/cs/home.php index 058ea2e..9ed63bd 100644 --- a/lang/cs/home.php +++ b/lang/cs/home.php @@ -177,6 +177,9 @@ $g_lang["greek_add"] = " Přidali jsme překlad do češtiny 🇨🇿. Děkujeme Jakubovi Mazuchovi!"; $g_lang["text_above_edge"] = "Text nad hranou"; + $g_lang["edge_enumeration"] = "Číslování hran"; + $g_lang["no_enumeration"] = "Bez číslování"; + $g_lang["edit_edge_names"] = "Upravit texty hran"; $g_lang["select_groupe_mac"] = "Pro označení více objektů použijte klávesy Cmd⌘."; $g_lang["select_groupe_win"] = "Pro označení více objektů použijte klávesy Ctrl."; diff --git a/lang/de/home.php b/lang/de/home.php index 9f49cd4..a474c3d 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -143,6 +143,9 @@ $g_lang["replace_edge"] = "aktulle ersetzen"; $g_lang["add_edge"] = "Einfügen (Multigraph)"; $g_lang["text_above_edge"] = "Text an der Kante"; + $g_lang["edge_enumeration"] = "Kantennummerierung"; + $g_lang["no_enumeration"] = "Keine Nummerierung"; + $g_lang["edit_edge_names"] = "Kantentexte bearbeiten"; $g_lang["select_groupe_mac"] = "Nutzen Sie Cmd⌘ um mehrere Objekten zu wählen."; $g_lang["select_groupe_win"] = "Nutzen Sie Strg um mehrere Objekten zu wählen."; $g_lang["drag_select_group"] = "Gruppe ziehen"; diff --git a/lang/el/home.php b/lang/el/home.php index b5d9add..f81843b 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -179,6 +179,9 @@ $g_lang["french_add"] = "Προσθέσαμε γαλλική μετάφραση 🇫🇷"; $g_lang["greece_add"] = "Προσθέσαμε ελληνική μετάφραση GR"; $g_lang["text_above_edge"] = "Κείμενο πάνω από την άκρη"; + $g_lang["edge_enumeration"] = "Αρίθμηση ακμών"; + $g_lang["no_enumeration"] = "Χωρίς αρίθμηση"; + $g_lang["edit_edge_names"] = "Επεξεργασία κειμένων ακμών"; $g_lang["select_groupe_mac"] = "Χρησιμοποιήστε Cmd⌘ για να επιλέξετε πολλαπλά αντικείμενα."; $g_lang["select_groupe_win"] = "Χρησιμοποιήστε Ctrl για να επιλέξετε πολλαπλά αντικείμενα."; diff --git a/lang/en/home.php b/lang/en/home.php index 74ac561..c74ebc3 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -178,6 +178,9 @@ $g_lang["greek_add"] = " We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang["text_above_edge"] = "Text above edge"; + $g_lang["edge_enumeration"] = "Edge enumeration"; + $g_lang["no_enumeration"] = "No enumeration"; + $g_lang["edit_edge_names"] = "Edit edge text"; $g_lang["select_groupe_mac"] = "Use Cmd⌘ to select several objects."; $g_lang["select_groupe_win"] = "Use Ctrl to select several objects."; diff --git a/lang/es/home.php b/lang/es/home.php index d433009..cab727e 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -178,6 +178,9 @@ $g_lang["greek_add"] = " Tenemos traducciones en griego 🇬🇷. Gracias KyriakosG78"; $g_lang["text_above_edge"] = "Textos sobre arista"; + $g_lang["edge_enumeration"] = "Numeración de aristas"; + $g_lang["no_enumeration"] = "Sin numeración"; + $g_lang["edit_edge_names"] = "Editar textos de aristas"; $g_lang["select_groupe_mac"] = "Usa Cmd⌘ para seleccionar varios objetos."; $g_lang["select_groupe_win"] = "Usa Ctrl para seleccionar varios objetos."; diff --git a/lang/fr/home.php b/lang/fr/home.php index 953a3b5..844f05a 100644 --- a/lang/fr/home.php +++ b/lang/fr/home.php @@ -145,6 +145,9 @@ $g_lang["replace_edge"] = "remplacer l'actuel"; $g_lang["add_edge"] = "ajout (multigraphe)"; $g_lang["text_above_edge"] = "Texte au-dessus du bord"; + $g_lang["edge_enumeration"] = "Numérotation des arêtes"; + $g_lang["no_enumeration"] = "Sans numérotation"; + $g_lang["edit_edge_names"] = "Modifier les textes des arêtes"; $g_lang["select_groupe_mac"] = "Utiliser Cmd⌘ pour sélectionner plusieurs objets."; $g_lang["select_groupe_win"] = "Utiliser Ctrl pour sélectionner plusieurs objets."; diff --git a/lang/nl/home.php b/lang/nl/home.php index caf5c4c..7599585 100644 --- a/lang/nl/home.php +++ b/lang/nl/home.php @@ -143,6 +143,9 @@ $g_lang["replace_edge"] = "vervang huidige"; $g_lang["add_edge"] = "Toevoegen (multigraaf)"; $g_lang["text_above_edge"] = "Tekst boven de lijn"; + $g_lang["edge_enumeration"] = "Lijnnummering"; + $g_lang["no_enumeration"] = "Geen nummering"; + $g_lang["edit_edge_names"] = "Lijnteksten bewerken"; $g_lang["select_groupe_mac"] = "Gebruik Cmd⌘ om meerdere objecten te selecteren."; $g_lang["select_groupe_win"] = "Gebruik Ctrl om meerdere objecten te selecteren."; $g_lang["drag_select_group"] = "Sleep groep"; diff --git a/lang/pl/home.php b/lang/pl/home.php index 81b0c0a..e573b16 100644 --- a/lang/pl/home.php +++ b/lang/pl/home.php @@ -178,6 +178,9 @@ $g_lang["greek_add"] = " Dodaliśmy polskie tłumaczenie, Patryk"; $g_lang["text_above_edge"] = "Tekst nad krawędzią"; + $g_lang["edge_enumeration"] = "Numerowanie krawędzi"; + $g_lang["no_enumeration"] = "Bez numerowania"; + $g_lang["edit_edge_names"] = "Edytuj teksty krawędzi"; $g_lang["select_groupe_mac"] = "Użyj Cmd⌘ by wybrać dane obiekty."; $g_lang["select_groupe_win"] = "Użyj Ctrl by wybrać dane obiekty."; diff --git a/lang/pt/home.php b/lang/pt/home.php index 289c5c2..23bdaf3 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -142,6 +142,9 @@ $g_lang["graph_is_general_message"] = ""; $g_lang["text_above_edge"] = "Text above edge"; + $g_lang["edge_enumeration"] = "Numeração das arestas"; + $g_lang["no_enumeration"] = "Sem numeração"; + $g_lang["edit_edge_names"] = "Editar textos das arestas"; $g_lang["select_groupe_mac"] = "Use Cmd⌘ to select several objects."; $g_lang["select_groupe_win"] = "Use Ctrl to select several objects."; diff --git a/lang/ru/home.php b/lang/ru/home.php index fe0d849..79ec0a6 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -181,6 +181,9 @@ $g_lang["graph_is_multi_message"] = "Мультиграф не поддерживает все алгоритмы"; $g_lang["graph_is_general_message"] = ""; $g_lang["text_above_edge"] = "Текст над дугой"; + $g_lang["edge_enumeration"] = "Нумерация дуг"; + $g_lang["no_enumeration"] = "Без нумерации"; + $g_lang["edit_edge_names"] = "Редактировать подписи дуг"; $g_lang["select_groupe_mac"] = "Выделите несколько объектов используя Cmd⌘."; $g_lang["select_groupe_win"] = "Выделите несколько объектов используя Ctrl."; diff --git a/lang/sv/home.php b/lang/sv/home.php index 2702335..eb08941 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -77,6 +77,9 @@ $g_lang["zoom_out"] = "Zooma ut"; $g_lang["move_workspace"] = "Flytta arbetsytan"; $g_lang["custom"] = "Anpassad text"; + $g_lang["edge_enumeration"] = "Kantnumrering"; + $g_lang["no_enumeration"] = "Ingen numrering"; + $g_lang["edit_edge_names"] = "Redigera kanttexter"; $g_lang["enter_vertex_title"] = "Ange text"; $g_lang["rename_vertex"] = "Byt namn på nod"; $g_lang["rename_text"] = "Byt namn "; diff --git a/lang/ua/home.php b/lang/ua/home.php index d893829..ff39669 100644 --- a/lang/ua/home.php +++ b/lang/ua/home.php @@ -179,6 +179,9 @@ $g_lang["graph_is_multi_message"] = "Мультиграф не підтримує всі алгоритми"; $g_lang["graph_is_general_message"] = ""; $g_lang["text_above_edge"] = "Текст над дугою"; + $g_lang["edge_enumeration"] = "Нумерація дуг"; + $g_lang["no_enumeration"] = "Без нумерації"; + $g_lang["edit_edge_names"] = "Редагувати підписи дуг"; $g_lang["select_groupe_mac"] = "Виділіть декілька обʼєктів використовуючи Cmd⌘."; $g_lang["select_groupe_win"] = "Виділіть декілька обʼєктів використовуючи Ctrl."; diff --git a/script/entities/graph/model/Graph.js b/script/entities/graph/model/Graph.js index bd24de2..5859658 100644 --- a/script/entities/graph/model/Graph.js +++ b/script/entities/graph/model/Graph.js @@ -869,7 +869,7 @@ Graph.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj, separa if (bGoodFormat) { - for (var i = 0; i < colsObj.cols[0].length; i++) + for (var i = 0; i < columnCount; i++) { var values = []; for (j = 0; j < colsObj.cols.length; ++j) @@ -908,7 +908,8 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum } var newVertices = []; var bWeightGraph = false; - for (var i = 0; i < cols[0].length; i++) + var columnCount = cols.length > 0 ? cols[0].length : 0; + for (var i = 0; i < columnCount; i++) { var edgeValue = []; var edgeIndex = []; @@ -965,17 +966,18 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum }); } - for (var i = cols.length; i < Math.max(this.vertices.length, cols.length); i++) + var rowCount = rows.length > 0 ? rows.length : this.vertices.length; + for (var i = rowCount; i < this.vertices.length; i++) { this.DeleteVertex(this.vertices[i]); - i--; + i--; } this.VerticesReposition(viewportSize, newVertices); } } -Graph.prototype.GetIncidenceMatrix = function () +Graph.prototype.GetIncidenceMatrix = function (res_columns_width) { var matrix = ""; let cols_width = []; @@ -1001,7 +1003,7 @@ Graph.prototype.GetIncidenceMatrix = function () for (var j = 0; j < this.edges.length; j++) { - let max_width = 0; + let max_width = Math.min(this.edges[j].GetUpText().toString().length, 2); for (var i = 0; i < this.vertices.length; i++) { let str = "" + get_edge_weight_str(i, j); @@ -1026,6 +1028,11 @@ Graph.prototype.GetIncidenceMatrix = function () matrix = matrix + "\n"; } + if (res_columns_width !== undefined) { + res_columns_width.length = 0; + res_columns_width.push(...cols_width); + } + return matrix; } diff --git a/script/features/show_incidence_matrix/index.js b/script/features/show_incidence_matrix/index.js index 94bbd71..e2fdcde 100644 --- a/script/features/show_incidence_matrix/index.js +++ b/script/features/show_incidence_matrix/index.js @@ -23,23 +23,45 @@ ShowIncidenceMatrix.prototype.show = function() { var handler = this; var dialogButtons = {}; - - $('#IncidenceMatrixField').unbind(); - $( "#IncidenceMatrixField" ).on('keyup change', function (eventObject) + let edgeNames = this.app.graph.edges.map(function(edge) { return edge.GetUpText(); }); + let edgeEnumSelect = $("#incidenceEdgeEnumeration"); + let edgeNamesDialog = $("#incidenceEdgeNamesDialog"); + let edgeNamesList = $("#incidenceEdgeNamesList"); + let currentColumns = []; + let currentColumnWidths = []; + let matrixIsValid = false; + let edgeEnumValue = this.app.currentEnumEdgesType || ""; + if (edgeEnumValue === "Custom") + { + edgeEnumValue = ""; + } + let selectedEdgeEnumValue = edgeEnumValue; + edgeEnumSelect.find("option:not(:first)").remove(); + this.app.GetEnumVerticesList().forEach(function(item) { + if (item.value !== "Custom") { - if (!handler.app.TestIncidenceMatrix($( "#IncidenceMatrixField" ).val(), [], [])) - { - $( "#BadIncidenceMatrixFormatMessage" ).show(); - } - else - { - $( "#BadIncidenceMatrixFormatMessage" ).hide(); - } - }); + edgeEnumSelect.append($("", { value: item.value, text: item.text })); + } + }); + edgeEnumSelect.val(edgeEnumValue); + $("#IncidenceMatrixField").off("keyup change input"); dialogButtons[g_save] = function() { - handler.app.PushToStack("IncidenceMatrixChanged"); - handler.app.SetIncidenceMatrixSmart($( "#IncidenceMatrixField" ).val()); + let matrix = ta.val(); + let rows = {}; + let columns = {}; + let validIncidenceMatrix = handler.app.TestIncidenceMatrix(matrix, rows, columns); + + handler.app.PushToStack("IncidenceMatrixChanged"); + handler.app.SetIncidenceMatrixSmart(matrix); + if (validIncidenceMatrix) + { + handler.app.SetEnumEdgesType(selectedEdgeEnumValue); + handler.app.graph.edges.forEach(function(edge, edgeIndex) { + edge.SetUpText(edgeNames[edgeIndex] || ""); + }); + handler.app.redrawGraph(); + } $( this ).dialog( "close" ); }; dialogButtons[g_cancel] = function() { @@ -47,13 +69,16 @@ ShowIncidenceMatrix.prototype.show = function() }; let ta = $("#IncidenceMatrixField"); + let topWrap = $("#incidenceMatrix_top_text"); let sideWrap = $("#incidenceMatrix_side_text"); + let incidenceMatrix = this.app.GetIncidenceMatrix(); ta.on("scroll", function() { + topWrap.scrollLeft(ta.scrollLeft()); sideWrap.scrollTop(ta.scrollTop()); }); - $( "#IncidenceMatrixField" ).val(this.app.GetIncidenceMatrix().trimEnd()); + $( "#IncidenceMatrixField" ).val(incidenceMatrix.trimEnd()); ta.focus()[0].setSelectionRange(0, 0); $( "#BadIncidenceMatrixFormatMessage" ).hide(); @@ -67,6 +92,138 @@ ShowIncidenceMatrix.prototype.show = function() } $("#incidenceMatrix_side_text_text").html(sideText + "\n"); + let topText = $("#incidenceMatrix_top_text_text"); + let renderEdgeNames = function(columns) { + topText.empty(); + let columnCount = columns.length > 0 ? columns[0].length : 0; + for (let edgeIndex = 0; edgeIndex < columnCount; edgeIndex++) + { + let edgeName = (edgeNames[edgeIndex] || "").slice(0, 2); + let columnWidth = Math.max(1, edgeName.length, currentColumnWidths[edgeIndex] || 0); + for (let rowIndex = 0; rowIndex < columns.length; rowIndex++) + { + columnWidth = Math.max(columnWidth, String(columns[rowIndex][edgeIndex]).trim().length); + } + topText.append(document.createTextNode(edgeName.slice(0, columnWidth).padStart(columnWidth, " "))); + if (edgeIndex < columnCount - 1) + { + topText.append(document.createTextNode(" ")); + } + } + }; + let getMatrixColumnWidths = function(matrix, columnCount) { + let widths = Array(columnCount).fill(1); + let rows = matrix.split(/\r?\n/).filter(function(row) { return row.trim().length > 0; }); + rows.forEach(function(row) { + let cells = row.split(","); + if (cells.length !== columnCount) + { + return; + } + cells.forEach(function(cell, columnIndex) { + let cellWidth = cell.length; + if (columnIndex > 0 && cell.startsWith(" ")) + { + cellWidth--; + } + widths[columnIndex] = Math.max(widths[columnIndex], cellWidth); + }); + }); + return widths; + }; + let getEdgeEnumType = function(value) { + return handler.app.enumVerticesTextList.find(function(enumType) { + return enumType.GetValue() === value && value !== "Custom"; + }); + }; + let applyEdgeEnumeration = function(value) { + if (!matrixIsValid) + { + return; + } + selectedEdgeEnumValue = value; + let enumType = getEdgeEnumType(value); + for (let edgeIndex = 0; edgeIndex < edgeNames.length; edgeIndex++) + { + edgeNames[edgeIndex] = enumType ? enumType.GetVertexText(edgeIndex).toString() : ""; + } + renderEdgeNames(currentColumns); + }; + + edgeEnumSelect.off("change").on("change", function() { + applyEdgeEnumeration($(this).val()); + }); + + $("#editIncidenceEdgeNames").off("click").on("click", function() { + if (!matrixIsValid) + { + return; + } + edgeNamesList.val(edgeNames.join("\n")); + edgeNamesDialog.dialog("open"); + }); + + edgeNamesDialog.dialog({ + autoOpen: false, + modal: true, + resizable: false, + width: "auto", + title: $("#EdgeLabel").text().trim(), + buttons: { + [g_save]: function() { + let editedNames = edgeNamesList.val().split(/\r?\n/); + edgeNames = Array.from({ length: edgeNames.length }, function(_, index) { + return editedNames[index] || ""; + }); + renderEdgeNames(currentColumns); + $(this).dialog("close"); + }, + [g_cancel]: function() { + $(this).dialog("close"); + } + }, + dialogClass: 'EdgeDialog' + }); + + let updateMatrixState = function() { + let rows = {}; + let columns = {}; + let isValid = handler.app.TestIncidenceMatrix(ta.val(), rows, columns); + if (isValid) + { + let columnCount = columns.cols.length > 0 ? columns.cols[0].length : 0; + currentColumns = columns.cols; + currentColumnWidths = getMatrixColumnWidths(ta.val(), columnCount); + let enumType = getEdgeEnumType(selectedEdgeEnumValue); + if (columnCount < edgeNames.length) + { + edgeNames.length = columnCount; + } + else + { + for (let edgeIndex = edgeNames.length; edgeIndex < columnCount; edgeIndex++) + { + edgeNames.push(enumType ? enumType.GetVertexText(edgeIndex).toString() : ""); + } + } + matrixIsValid = true; + edgeEnumSelect.prop("disabled", false); + $("#editIncidenceEdgeNames").prop("disabled", false); + $("#BadIncidenceMatrixFormatMessage").hide(); + renderEdgeNames(columns.cols); + } + else + { + matrixIsValid = false; + edgeEnumSelect.prop("disabled", true); + $("#editIncidenceEdgeNames").prop("disabled", true); + $("#BadIncidenceMatrixFormatMessage").show(); + } + }; + + ta.on("input", updateMatrixState); + updateMatrixState(); + $( "#incidenceMatrix" ).dialog({ resizable: false, height: "auto", @@ -77,7 +234,7 @@ ShowIncidenceMatrix.prototype.show = function() dialogClass: 'EdgeDialog', open: function(event, ui) { /* Set width for side text */ - $("#incidenceMatrix_top_text").width(ta.width()); + topWrap.width(ta.width()); $("#BadIncidenceMatrixFormatMessage").width(ta.width()); } }); diff --git a/script/pages/create_graph_by_edge_list/api/index.js.cache b/script/pages/create_graph_by_edge_list/api/index.js.cache index ae99837..2e91dea 100644 --- a/script/pages/create_graph_by_edge_list/api/index.js.cache +++ b/script/pages/create_graph_by_edge_list/api/index.js.cache @@ -1,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} {let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point) {return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point) {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function() @@ -452,7 +452,7 @@ if(i==0) if(colsObj.cols[i].length!=columnCount) {bGoodFormat=false;break;}} if(bGoodFormat) -{for(var i=0;i0?cols[0].length:0;for(var i=0;i=this.vertices.length) {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} @@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} if(!bWeightGraph) {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} -for(var i=cols.length;i0?rows.length:this.vertices.length;for(var i=rowCount;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {return this.edges[edge_index].weight.toString();} else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) @@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[ {return-this.edges[edge_index].weight.toString();} else {return"0";}};for(var j=0;j0?cols[0].length:0;for(var i=0;i=this.vertices.length) {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} @@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} if(!bWeightGraph) {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} -for(var i=cols.length;i0?rows.length:this.vertices.length;for(var i=rowCount;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {return this.edges[edge_index].weight.toString();} else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) @@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[ {return-this.edges[edge_index].weight.toString();} else {return"0";}};for(var j=0;j0?cols[0].length:0;for(var i=0;i=this.vertices.length) {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} @@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} if(!bWeightGraph) {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} -for(var i=cols.length;i0?rows.length:this.vertices.length;for(var i=rowCount;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {return this.edges[edge_index].weight.toString();} else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) @@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[ {return-this.edges[edge_index].weight.toString();} else {return"0";}};for(var j=0;j0?cols[0].length:0;for(var i=0;i=this.vertices.length) {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} @@ -514,10 +514,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} if(!bWeightGraph) {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} -for(var i=cols.length;i0?rows.length:this.vertices.length;for(var i=rowCount;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {return this.edges[edge_index].weight.toString();} else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) @@ -526,7 +526,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[ {return-this.edges[edge_index].weight.toString();} else {return"0";}};for(var j=0;j0) +{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var edgeEnumCookie=/(?:^|;\s*)edgeEnumType\s*=\s*([^;]*)/.exec(document.cookie);this.SetEnumEdgesType(edgeEnumCookie?edgeEnumCookie[1]:"");var wasLoad=false;let startAutoSave=true;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0) {if(!this.SetAdjacencyMatrixSmart(matrix,separator)) {userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);} else @@ -1863,8 +1864,8 @@ Application.prototype.SetPair=function(pair) {var res=true;var r={};var c={};if(!this.TestPair(pair)) {$.get("/"+SiteDir+"backend/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;} this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.GetIncidenceMatrix=function() -{return this.graph.GetIncidenceMatrix();} +Application.prototype.GetIncidenceMatrix=function(res_columns_width) +{return this.graph.GetIncidenceMatrix(res_columns_width);} Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj) {return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);} Application.prototype.TestPair=function(pair) @@ -1944,6 +1945,11 @@ Application.prototype.SetEnumVerticesType=function(value) {for(var i=0;i + + + + + @@ -452,11 +457,25 @@ + + = L('edge_enumeration') ?> + + = L('no_enumeration') ?> + + + = L('edit_edge_names') ?> + + + = L('incidence_matrix_bad_format')?> - + + + + +
= L('incidence_matrix_bad_format')?>