mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-10-25 21:40:12 +00:00
fix reset edge bend on change weight.
This commit is contained in:
1 parent
e8a985c91b
commit
2394894f72
4 files changed
+118
-105
No files matched your search
+97
-93
@@ -423,13 +423,7 @@ Application.prototype.CreateNewGraphEx = function(x, y, vertexEnume)
|
|||||||
|
|
||||||
Application.prototype.CreateNewArc = function(graph1, graph2, isDirect, weight)
|
Application.prototype.CreateNewArc = function(graph1, graph2, isDirect, weight)
|
||||||
{
|
{
|
||||||
var useWeight = false;
|
var edge = this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight));
|
||||||
if (!isNaN(parseInt(weight, 10)))
|
|
||||||
{
|
|
||||||
useWeight = true;
|
|
||||||
}
|
|
||||||
weight = (!isNaN(parseInt(weight, 10)) && weight >= 0) ? weight : 1;
|
|
||||||
var edge = this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight, useWeight));
|
|
||||||
|
|
||||||
// Make cruvled for pair.
|
// Make cruvled for pair.
|
||||||
var edgeObject = this.graph.edges[edge];
|
var edgeObject = this.graph.edges[edge];
|
||||||
@@ -1110,92 +1104,6 @@ Application.prototype.GetFindPathReport = function ()
|
|||||||
return this.findPathReport;
|
return this.findPathReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Application.prototype.CalculateAlgorithm = function(queryString, callbackObject)
|
|
||||||
{
|
|
||||||
var app = this;
|
|
||||||
var creator = new GraphMLCreater(app.graph.vertices, app.graph.edges);
|
|
||||||
var pathObjects = [];
|
|
||||||
var properties = {};
|
|
||||||
var result = [];
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "/cgi-bin/GraphCGI.exe?" + queryString,
|
|
||||||
data: creator.GetXMLString(),
|
|
||||||
dataType: "text",
|
|
||||||
})
|
|
||||||
.done(function( msg )
|
|
||||||
{
|
|
||||||
console.log(msg);
|
|
||||||
$('#debug').text(msg);
|
|
||||||
xmlDoc = $.parseXML( msg );
|
|
||||||
var $xml = $( xmlDoc );
|
|
||||||
|
|
||||||
$results = $xml.find( "result" );
|
|
||||||
|
|
||||||
$results.each(function(){
|
|
||||||
$values = $(this).find( "value" );
|
|
||||||
|
|
||||||
$values.each(function(){
|
|
||||||
var type = $(this).attr('type');
|
|
||||||
var value = $(this).text();
|
|
||||||
var res = {};
|
|
||||||
res.type = type;
|
|
||||||
res.value = value;
|
|
||||||
result.push(res);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$nodes = $xml.find( "node" );
|
|
||||||
|
|
||||||
$nodes.each(function(){
|
|
||||||
var id = $(this).attr('id');
|
|
||||||
$data = $(this).find("data");
|
|
||||||
$data.each(function(){
|
|
||||||
if ("hightlightNode" == $(this).attr('key') && $(this).text() == "1")
|
|
||||||
{
|
|
||||||
pathObjects.push(app.FindVertex(id));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!properties[id])
|
|
||||||
{
|
|
||||||
properties[id] = {};
|
|
||||||
}
|
|
||||||
properties[id][$(this).attr('key')] = $(this).text();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$edges = $xml.find( "edge" );
|
|
||||||
|
|
||||||
$edges.each(function(){
|
|
||||||
var source = $(this).attr('source');
|
|
||||||
var target = $(this).attr('target');
|
|
||||||
var edge = app.FindEdge(source, target);
|
|
||||||
pathObjects.push(edge);
|
|
||||||
|
|
||||||
$data = $(this).find("data");
|
|
||||||
$data.each(function(){
|
|
||||||
if (!properties[edge.id])
|
|
||||||
{
|
|
||||||
properties[edge.id] = {};
|
|
||||||
}
|
|
||||||
properties[edge.id][$(this).attr('key')] = $(this).text();
|
|
||||||
console.log("Data edge " + $(this).text());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(result);
|
|
||||||
|
|
||||||
callbackObject.CalculateAlgorithmCallback(pathObjects, properties, result);
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Application.prototype.GetRealWidth = function ()
|
Application.prototype.GetRealWidth = function ()
|
||||||
{
|
{
|
||||||
return this.canvas.width / this.canvasScale;
|
return this.canvas.width / this.canvasScale;
|
||||||
@@ -1334,3 +1242,99 @@ Application.prototype.IsUndoStackEmpty = function()
|
|||||||
{
|
{
|
||||||
return (this.undoStack.length <= 0);
|
return (this.undoStack.length <= 0);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
Application.prototype.SaveUserSettings = function()
|
||||||
|
{
|
||||||
|
var res = "{";
|
||||||
|
|
||||||
|
var needEnd = false;
|
||||||
|
var checkValue = [];
|
||||||
|
|
||||||
|
checkValue.push({check: !CommonEdgeStyle.prototype.isPrototypeOf(this.edgeCommonStyle),
|
||||||
|
field: "edgeCommonStyle",
|
||||||
|
value: this.edgeCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({check: this.edgeSelectedStyles != DefaultSelectedEdgeStyles,
|
||||||
|
field: "edgeSelectedStyles",
|
||||||
|
value: this.edgeSelectedStyles});
|
||||||
|
|
||||||
|
checkValue.push({check: !CommonPrintEdgeStyle.prototype.isPrototypeOf(this.edgePrintCommonStyle),
|
||||||
|
field: "edgePrintCommonStyle",
|
||||||
|
value: this.edgePrintCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({check: this.edgePrintSelectedStyles != DefaultPrintSelectedEdgeStyles,
|
||||||
|
field: "edgePrintSelectedStyles",
|
||||||
|
value: this.edgePrintSelectedStyles});
|
||||||
|
|
||||||
|
checkValue.push({check: !CommonVertexStyle.prototype.isPrototypeOf(this.vertexCommonStyle),
|
||||||
|
field: "vertexCommonStyle",
|
||||||
|
value: this.vertexCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({check: this.vertexSelectedVertexStyles != DefaultSelectedGraphStyles,
|
||||||
|
field: "vertexSelectedVertexStyles",
|
||||||
|
value: this.vertexSelectedVertexStyles});
|
||||||
|
|
||||||
|
checkValue.push({check: !CommonPrintVertexStyle.prototype.isPrototypeOf(this.vertexPrintCommonStyle),
|
||||||
|
field: "vertexPrintCommonStyle",
|
||||||
|
value: this.vertexPrintCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({check: this.vertexPrintSelectedVertexStyles != DefaultPrintSelectedGraphStyles,
|
||||||
|
field: "vertexPrintSelectedVertexStyles",
|
||||||
|
value: this.vertexPrintSelectedVertexStyles});
|
||||||
|
|
||||||
|
checkValue.forEach(function(entry) {
|
||||||
|
if (entry.check)
|
||||||
|
{
|
||||||
|
if (needEnd)
|
||||||
|
res = res + ",";
|
||||||
|
|
||||||
|
res = res + entry.field + ":" + JSON.stringify(entry.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
res = res + "}";
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
Application.prototype.LoadUserSettings = function()
|
||||||
|
{
|
||||||
|
var checkValue = [];
|
||||||
|
|
||||||
|
checkValue.push({field: "edgeCommonStyle",
|
||||||
|
value: this.edgeCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({field: "edgeSelectedStyles",
|
||||||
|
value: this.edgeSelectedStyles});
|
||||||
|
|
||||||
|
checkValue.push({field: "edgePrintCommonStyle",
|
||||||
|
value: this.edgePrintCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({field: "edgePrintSelectedStyles",
|
||||||
|
value: this.edgePrintSelectedStyles});
|
||||||
|
|
||||||
|
checkValue.push({field: "vertexCommonStyle",
|
||||||
|
value: this.vertexCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({field: "vertexSelectedVertexStyles",
|
||||||
|
value: this.vertexSelectedVertexStyles});
|
||||||
|
|
||||||
|
checkValue.push({field: "vertexPrintCommonStyle",
|
||||||
|
value: this.vertexPrintCommonStyle});
|
||||||
|
|
||||||
|
checkValue.push({field: "vertexPrintSelectedVertexStyles",
|
||||||
|
value: this.vertexPrintSelectedVertexStyles});
|
||||||
|
|
||||||
|
var parsedSave = JSON.parse(json);
|
||||||
|
|
||||||
|
var app = this;
|
||||||
|
|
||||||
|
checkValue.forEach(function(entry) {
|
||||||
|
if (parsedSave.hasOwnProperty(entry.field))
|
||||||
|
{
|
||||||
|
for(var k in parsedSave[entry.field])
|
||||||
|
entry.value[k] = parsedSave[entry.field][k];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*/
|
||||||
+19
-3
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function BaseEdge(vertex1, vertex2, isDirect, weight, useWeight)
|
function BaseEdge(vertex1, vertex2, isDirect, weight)
|
||||||
{
|
{
|
||||||
this.vertex1 = vertex1;
|
this.vertex1 = vertex1;
|
||||||
this.vertex2 = vertex2;
|
this.vertex2 = vertex2;
|
||||||
@@ -12,13 +12,16 @@ function BaseEdge(vertex1, vertex2, isDirect, weight, useWeight)
|
|||||||
this.arrayStyleFinish = "";
|
this.arrayStyleFinish = "";
|
||||||
|
|
||||||
this.isDirect = isDirect;
|
this.isDirect = isDirect;
|
||||||
this.weight = Number(weight);
|
this.weight = 0;
|
||||||
this.text = "";
|
this.text = "";
|
||||||
// For direct graph, has pair edge or not.
|
// For direct graph, has pair edge or not.
|
||||||
this.hasPair = false;
|
this.hasPair = false;
|
||||||
this.useWeight = useWeight;
|
this.useWeight = false;
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.model = new EdgeModel();
|
this.model = new EdgeModel();
|
||||||
|
|
||||||
|
if (weight !== undefined)
|
||||||
|
this.SetWeight(weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEdge.prototype.SaveToXML = function ()
|
BaseEdge.prototype.SaveToXML = function ()
|
||||||
@@ -161,3 +164,16 @@ BaseEdge.prototype.GetEdgePositions = function()
|
|||||||
res.push(position2.subtract(direction2.multiply(d2)));
|
res.push(position2.subtract(direction2.multiply(d2)));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseEdge.prototype.SetWeight = function(weight)
|
||||||
|
{
|
||||||
|
var useWeight = false;
|
||||||
|
if (!isNaN(parseInt(weight, 10)))
|
||||||
|
{
|
||||||
|
useWeight = true;
|
||||||
|
}
|
||||||
|
weight = (!isNaN(parseInt(weight, 10)) && weight >= 0) ? weight : 1;
|
||||||
|
|
||||||
|
this.weight = Number(weight);
|
||||||
|
this.useWeight = useWeight;
|
||||||
|
}
|
||||||
@@ -305,8 +305,7 @@ DefaultHandler.prototype.MouseUp = function(pos)
|
|||||||
|
|
||||||
dialogButtons[g_save] = function() {
|
dialogButtons[g_save] = function() {
|
||||||
|
|
||||||
handler.app.DeleteObject(handler.selectedObject);
|
handler.selectedObject.SetWeight(document.getElementById('EdgeWeight').value);
|
||||||
handler.selectedObject = handler.app.graph.edges[handler.app.CreateNewArc(handler.selectedObject.vertex1, handler.selectedObject.vertex2, handler.selectedObject.isDirect, document.getElementById('EdgeWeight').value)];
|
|
||||||
|
|
||||||
handler.needRedraw = true;
|
handler.needRedraw = true;
|
||||||
handler.app.redrawGraph();
|
handler.app.redrawGraph();
|
||||||
|
|||||||
+1
-7
@@ -34,13 +34,7 @@ Graph.prototype.AddNewVertex = function(vertex)
|
|||||||
|
|
||||||
Graph.prototype.AddNewEdgeSafe = function(graph1, graph2, isDirect, weight)
|
Graph.prototype.AddNewEdgeSafe = function(graph1, graph2, isDirect, weight)
|
||||||
{
|
{
|
||||||
var useWeight = false;
|
return this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight));
|
||||||
if (!isNaN(parseInt(weight, 10)))
|
|
||||||
{
|
|
||||||
useWeight = true;
|
|
||||||
}
|
|
||||||
weight = (!isNaN(parseInt(weight, 10)) && weight >= 0) ? weight : 1;
|
|
||||||
return this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight, useWeight, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Graph.prototype.AddNewEdge = function(edge)
|
Graph.prototype.AddNewEdge = function(edge)
|
||||||
|
|||||||
Reference in new issue
Block a user