mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 15:37:56 +01:00
Fix issue deleting multiple relationships.
This commit is contained in:
parent
2ec9e70245
commit
ce932e57e0
@ -43,7 +43,9 @@ mindplot.RelationshipPivot = new Class({
|
||||
|
||||
this._pivot = new web2d.CurvedLine();
|
||||
this._pivot.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
this._pivot.setFrom(sourcePos.x, sourcePos.y);
|
||||
|
||||
var fromPos = this._calculateFromPosition(sourcePos);
|
||||
this._pivot.setFrom(fromPos.x, fromPos.y);
|
||||
|
||||
this._pivot.setTo(targetPos.x, targetPos.y);
|
||||
this._pivot.setStroke(2, 'solid', strokeColor);
|
||||
@ -54,7 +56,6 @@ mindplot.RelationshipPivot = new Class({
|
||||
this._startArrow.setStrokeWidth(2);
|
||||
this._startArrow.setFrom(sourcePos.x, sourcePos.y);
|
||||
|
||||
|
||||
this._workspace.appendChild(this._pivot);
|
||||
this._workspace.appendChild(this._startArrow);
|
||||
|
||||
@ -102,12 +103,7 @@ mindplot.RelationshipPivot = new Class({
|
||||
var sourcePosition = this._sourceTopic.getPosition();
|
||||
var gapDistance = Math.sign(pos.x - sourcePosition.x) * 5;
|
||||
|
||||
// Calculate origin position ...
|
||||
var controPoint = mindplot.util.Shape.calculateDefaultControlPoints(sourcePosition, pos);
|
||||
var spoint = new core.Point();
|
||||
spoint.x = parseInt(controPoint[0].x) + parseInt(sourcePosition.x);
|
||||
spoint.y = parseInt(controPoint[0].y) + parseInt(sourcePosition.y);
|
||||
var sPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(this._sourceTopic, spoint);
|
||||
var sPos = this._calculateFromPosition(pos);
|
||||
this._pivot.setFrom(sPos.x, sPos.y);
|
||||
|
||||
// Update target position ...
|
||||
@ -128,6 +124,21 @@ mindplot.RelationshipPivot = new Class({
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
_calculateFromPosition:function (toPosition) {
|
||||
|
||||
// Calculate origin position ...
|
||||
var sourcePosition = this._sourceTopic.getPosition();
|
||||
if (this._sourceTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
sourcePosition = mindplot.util.Shape.workoutIncomingConnectionPoint(this._sourceTopic, toPosition);
|
||||
}
|
||||
var controlPoint = mindplot.util.Shape.calculateDefaultControlPoints(sourcePosition, toPosition);
|
||||
|
||||
var spoint = new core.Point();
|
||||
spoint.x = parseInt(controlPoint[0].x) + parseInt(sourcePosition.x);
|
||||
spoint.y = parseInt(controlPoint[0].y) + parseInt(sourcePosition.y);
|
||||
return mindplot.util.Shape.calculateRelationShipPointCoordinates(this._sourceTopic, spoint);
|
||||
},
|
||||
|
||||
_connectOnFocus:function (targetTopic) {
|
||||
var sourceTopic = this._sourceTopic;
|
||||
var mindmap = this._designer.getMindmap();
|
||||
|
@ -149,7 +149,18 @@ mindplot.commands.DeleteCommand = new Class({
|
||||
return this._collectInDepthRelationships(topic);
|
||||
}, this);
|
||||
result.append(rels.flatten());
|
||||
return result;
|
||||
|
||||
// Filter for unique ...
|
||||
result = result.sort(function (a, b) {
|
||||
return a.getModel().getId() - b.getModel().getId();
|
||||
});
|
||||
var ret = [result[0]];
|
||||
for (var i = 1; i < result.length; i++) { // start loop at 1 as element 0 can never be a duplicate
|
||||
if (result[i - 1] !== result[i]) {
|
||||
ret.push(result[i]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
});
|
@ -46,15 +46,16 @@ mindplot.util.Shape =
|
||||
calculateRelationShipPointCoordinates:function (topic, controlPoint) {
|
||||
var size = topic.getSize();
|
||||
var position = topic.getPosition();
|
||||
var div = (position.x - controlPoint.x);
|
||||
div = (Math.abs(div) > 0.1 ? div : 0.1); // Prevent division by 0.
|
||||
var m;
|
||||
var yGap = position.y - controlPoint.y;
|
||||
var xGap = position.x - controlPoint.x;
|
||||
var disable = Math.abs(yGap) < 5 || Math.abs(xGap) < 5 || Math.abs(yGap - xGap) < 5;
|
||||
|
||||
var m = (position.y - controlPoint.y) / div;
|
||||
var y, x;
|
||||
var gap = 5;
|
||||
if (controlPoint.y > position.y + (size.height / 2)) {
|
||||
y = position.y + (size.height / 2) + gap;
|
||||
x = position.x - ((position.y - y) / m);
|
||||
x = !disable ? position.x - ((position.y - y) / (yGap / xGap)) : position.x;
|
||||
if (x > position.x + (size.width / 2)) {
|
||||
x = position.x + (size.width / 2);
|
||||
} else if (x < position.x - (size.width / 2)) {
|
||||
@ -62,7 +63,7 @@ mindplot.util.Shape =
|
||||
}
|
||||
} else if (controlPoint.y < position.y - (size.height / 2)) {
|
||||
y = position.y - (size.height / 2) - gap;
|
||||
x = position.x - ((position.y - y) / m);
|
||||
x = !disable ? position.x - ((position.y - y) / (yGap / xGap)) : position.x;
|
||||
if (x > position.x + (size.width / 2)) {
|
||||
x = position.x + (size.width / 2);
|
||||
} else if (x < position.x - (size.width / 2)) {
|
||||
@ -70,10 +71,10 @@ mindplot.util.Shape =
|
||||
}
|
||||
} else if (controlPoint.x < (position.x - size.width / 2)) {
|
||||
x = position.x - (size.width / 2) - gap;
|
||||
y = position.y - (m * (position.x - x));
|
||||
y = !disable ? position.y - ((yGap / xGap) * (position.x - x)) : position.y;
|
||||
} else {
|
||||
x = position.x + (size.width / 2) + gap;
|
||||
y = position.y - (m * (position.x - x));
|
||||
y = !disable ? position.y - ((yGap / xGap) * (position.x - x)) : position.y;
|
||||
}
|
||||
|
||||
return new core.Point(x, y);
|
||||
|
Loading…
Reference in New Issue
Block a user