mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-02-16 02:30:51 +00:00
Fix edge selection.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=91","/script/shared/gzip.js?v=91","/script/entities/graph/api/index.js?v=91","/script/shared/point.js?v=91","/script/entities/edge/api/index.js?v=91","/script/entities/edge/model/BaseEdge.js?v=91","/script/entities/edge/model/EdgeModel.js?v=91","/script/entities/vertex/api/index.js?v=91","/script/entities/vertex/model/BaseVertex.js?v=91","/script/entities/vertex/model/VertexModel.js?v=91","/script/entities/graph/model/Graph.js?v=91","/script/features/draw_graph/api/index.js?v=91","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=91","/script/features/draw_graph/model/EdgeStyle.js?v=91","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=91","/script/features/draw_graph/model/VertexShape.js?v=91","/script/features/draw_graph/model/VertexStyle.js?v=91","/script/features/draw_graph/model/BaseVertexDrawer.js?v=91","/script/features/draw_graph/model/GraphFullStyle.js?v=91","/script/features/algorithms/api/index.js?v=91","/script/features/algorithms/model/Algorithms.js?v=91","/script/features/algorithms/model/BaseTraversal.js?v=91","/script/features/base_handler/index.js?v=91","/script/features/default_handler/index.js?v=91","/script/features/add_vertices_handler/index.js?v=91","/script/features/connect_vertices_handler/index.js?v=91","/script/features/delete_objects_handler/index.js?v=91","/script/features/algorithm_handler/index.js?v=91","/script/features/select_auto_save_graph_or_not/index.js?v=91","/script/features/graph_preview/index.js?v=91","/script/features/serialization/api/index.js?v=91","/script/features/serialization/model/GraphMLCreator.js?v=91","/script/features/enum_vertices/EnumVertices.js?v=91","/script/pages/editor/model/texts.js?v=91","/script/pages/editor/model/UndoStack.js?v=91","/script/pages/editor/model/DiskSaveLoad.js?v=91","/script/pages/editor/model/Application.js?v=91","/script/pages/editor/ui/ya_metrika.js?v=91","/script/pages/editor/ui/editor.js?v=91","/script/pages/editor/ui/main.js?v=91",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
|
||||
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=92","/script/shared/gzip.js?v=92","/script/entities/graph/api/index.js?v=92","/script/shared/point.js?v=92","/script/entities/edge/api/index.js?v=92","/script/entities/edge/model/BaseEdge.js?v=92","/script/entities/edge/model/EdgeModel.js?v=92","/script/entities/vertex/api/index.js?v=92","/script/entities/vertex/model/BaseVertex.js?v=92","/script/entities/vertex/model/VertexModel.js?v=92","/script/entities/graph/model/Graph.js?v=92","/script/features/draw_graph/api/index.js?v=92","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=92","/script/features/draw_graph/model/EdgeStyle.js?v=92","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=92","/script/features/draw_graph/model/VertexShape.js?v=92","/script/features/draw_graph/model/VertexStyle.js?v=92","/script/features/draw_graph/model/BaseVertexDrawer.js?v=92","/script/features/draw_graph/model/GraphFullStyle.js?v=92","/script/features/algorithms/api/index.js?v=92","/script/features/algorithms/model/Algorithms.js?v=92","/script/features/algorithms/model/BaseTraversal.js?v=92","/script/features/base_handler/index.js?v=92","/script/features/default_handler/index.js?v=92","/script/features/add_vertices_handler/index.js?v=92","/script/features/connect_vertices_handler/index.js?v=92","/script/features/delete_objects_handler/index.js?v=92","/script/features/algorithm_handler/index.js?v=92","/script/features/select_auto_save_graph_or_not/index.js?v=92","/script/features/graph_preview/index.js?v=92","/script/features/serialization/api/index.js?v=92","/script/features/serialization/model/GraphMLCreator.js?v=92","/script/features/enum_vertices/EnumVertices.js?v=92","/script/pages/editor/model/texts.js?v=92","/script/pages/editor/model/UndoStack.js?v=92","/script/pages/editor/model/DiskSaveLoad.js?v=92","/script/pages/editor/model/Application.js?v=92","/script/pages/editor/ui/ya_metrika.js?v=92","/script/pages/editor/ui/editor.js?v=92","/script/pages/editor/ui/main.js?v=92",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
|
||||
let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("shared/gzip.js"),include("entities/graph/api/index.js"),include("features/draw_graph/api/index.js"),include("features/algorithms/api/index.js"),include("features/base_handler/index.js"),include("features/default_handler/index.js"),include("features/add_vertices_handler/index.js"),include("features/connect_vertices_handler/index.js"),include("features/delete_objects_handler/index.js"),include("features/algorithm_handler/index.js"),include("features/select_auto_save_graph_or_not/index.js"),include("features/serialization/api/index.js"),include("features/enum_vertices/EnumVertices.js"),include("model/texts.js",modulDir),include("model/UndoStack.js",modulDir),include("model/DiskSaveLoad.js",modulDir),include("model/Application.js",modulDir),include("ui/ya_metrika.js",modulDir),include("ui/editor.js",modulDir),include("ui/main.js",modulDir)],onloadEditor);}
|
||||
function gEncodeToHTML(str)
|
||||
{if(typeof str!=='string')
|
||||
@@ -155,12 +155,12 @@ EdgeModel.prototype.GetBezierPoints=function(position1,position2)
|
||||
{var direction=position2.subtract(position1);var delta=direction.length();direction.normalize(1.0);var normal=direction.normal();var deltaOffsetPixels=delta*this.curveValue;var yOffset=normal.multiply(deltaOffsetPixels);var firstBezierPointShift=(direction.multiply(delta*0.2)).add(yOffset);var secondBezierPointShift=(direction.multiply(-delta*0.2)).add(yOffset);var firstBezierPoint=position1.add(firstBezierPointShift);var secondBezierPoint=position2.add(secondBezierPointShift);return[firstBezierPoint,secondBezierPoint];}
|
||||
EdgeModel.prototype.HitTest=function(position1,position2,mousePos)
|
||||
{if(this.type==EdgeModels.line)
|
||||
return this.HitTestLine(position1,position2,mousePos);else if(this.type==EdgeModels.curve)
|
||||
return this.HitTestLine(position1,position2,mousePos,1.0,false);else if(this.type==EdgeModels.curve)
|
||||
return this.HitTestCurve(position1,position2,mousePos);return false;}
|
||||
EdgeModel.prototype.HitTestLine=function(position1,position2,mousePos,factor)
|
||||
EdgeModel.prototype.HitTestLine=function(position1,position2,mousePos,factor,ignoreSelfLoop)
|
||||
{if(factor===undefined)
|
||||
{factor=1.0;}
|
||||
var pos1=position1;var pos2=position2;var pos0=mousePos;if(pos1.equals(pos2))
|
||||
var pos1=position1;var pos2=position2;var pos0=mousePos;if(pos1.equals(pos2)&&!ignoreSelfLoop)
|
||||
{var xCenter=pos1.x-Math.cos(this.GetLoopShiftAngel())*this.GetLoopSize();var yCenter=pos1.y-Math.sin(this.GetLoopShiftAngel())*this.GetLoopSize();return Math.abs((Point.distance(new Point(xCenter,yCenter),pos0))-this.GetLoopSize())<=this.width*1.5*factor;}
|
||||
var r1=pos0.distance(pos1);var r2=pos0.distance(pos2);var r12=pos1.distance(pos2);if(r1>=(new Point(r2,r12)).length()||r2>=(new Point(r1,r12)).length())
|
||||
{}
|
||||
@@ -172,7 +172,7 @@ EdgeModel.prototype.HitTestCurve=function(position1,position2,mousePos)
|
||||
{var pos1=position1;var pos2=position2;var pos0=mousePos;if(pos1.equals(pos2))
|
||||
{var xCenter=pos1.x-Math.cos(this.GetLoopShiftAngel())*this.GetLoopSize();var yCenter=pos1.y-Math.sin(this.GetLoopShiftAngel())*this.GetLoopSize();return Math.abs((Point.distance(new Point(xCenter,yCenter),pos0))-this.GetLoopSize())<=this.width*1.5;}
|
||||
var interval_count=position1.distance(position2)/100*30;var start=position1;for(var i=0;i<interval_count;i++)
|
||||
{var finish=this.GetCurvePoint(position1,position2,i/interval_count);if(this.HitTestLine(start,finish,mousePos,2.0))
|
||||
{var finish=this.GetCurvePoint(position1,position2,i/interval_count);if(this.HitTestLine(start,finish,mousePos,2.0,true))
|
||||
return true;start=finish;}
|
||||
return false;}
|
||||
EdgeModel.prototype.ChangeCurveValue=function(delta)
|
||||
@@ -1012,10 +1012,10 @@ BaseHandler.prototype.GetSelectedGraph=function(pos)
|
||||
{res=this.app.graph.vertices[i];}}
|
||||
return res;}
|
||||
BaseHandler.prototype.GetSelectedArc=function(pos)
|
||||
{for(var i=0;i<this.app.graph.edges.length;i++)
|
||||
{let res=null;for(var i=0;i<this.app.graph.edges.length;i++)
|
||||
{var edge=this.app.graph.edges[i];if(edge.HitTest(new Point(pos.x,pos.y)))
|
||||
return edge;}
|
||||
return null;}
|
||||
res=edge;}
|
||||
return res;}
|
||||
BaseHandler.prototype.GetSelectedObject=function(pos)
|
||||
{var graphObject=this.GetSelectedGraph(pos);if(graphObject)
|
||||
{return graphObject;}
|
||||
|
||||
Reference in New Issue
Block a user