mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-13 03:43:01 +01:00
multiline
This commit is contained in:
parent
d5d9928cb0
commit
f877ced410
3 changed files with 24 additions and 8 deletions
|
|
@ -81,9 +81,19 @@ TCAD.TWO.Viewer.prototype.addSegment = function(x1, y1, x2, y2, layer) {
|
|||
var b = new TCAD.TWO.EndPoint(x2, y2);
|
||||
var line = new TCAD.TWO.Segment(a, b);
|
||||
layer.objects.push(line);
|
||||
line.layer = layer;
|
||||
return line;
|
||||
};
|
||||
|
||||
TCAD.TWO.Viewer.prototype.remove = function(obj) {
|
||||
if (obj.layer != null) {
|
||||
var idx = obj.layer.objects.indexOf(obj);
|
||||
if (idx != -1) {
|
||||
obj.layer.objects.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TCAD.TWO.Viewer.prototype.search = function(x, y, buffer, deep, onlyPoints) {
|
||||
|
||||
buffer *= 0.5;
|
||||
|
|
@ -314,6 +324,7 @@ TCAD.TWO.SketchObject = function() {
|
|||
this.visible = true;
|
||||
this.children = [];
|
||||
this.linked = [];
|
||||
this.layer = null;
|
||||
};
|
||||
|
||||
TCAD.TWO.SketchObject.prototype.visit = function(onlyVisible, h) {
|
||||
|
|
@ -514,13 +525,13 @@ TCAD.TWO.ToolManager = function(viewer, defaultTool) {
|
|||
}, false);
|
||||
|
||||
window.addEventListener("keydown", function (e) {
|
||||
tm.getTool().mousewheel(e);
|
||||
tm.getTool().keydown(e);
|
||||
}, false);
|
||||
window.addEventListener("keypress", function (e) {
|
||||
tm.getTool().mousewheel(e);
|
||||
tm.getTool().keydown(e);
|
||||
}, false);
|
||||
window.addEventListener("keyup", function (e) {
|
||||
tm.getTool().mousewheel(e);
|
||||
tm.getTool().keydown(e);
|
||||
}, false);
|
||||
};
|
||||
|
||||
|
|
@ -532,7 +543,7 @@ TCAD.TWO.ToolManager.prototype.releaseControl = function() {
|
|||
if (this.stack.length == 1) {
|
||||
return;
|
||||
}
|
||||
this.stack.pop().cleanup();;
|
||||
this.stack.pop().cleanup();
|
||||
};
|
||||
|
||||
TCAD.TWO.ToolManager.prototype.getTool = function() {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ TCAD.App2D = function() {
|
|||
var actionsF = gui.addFolder('Add Object');
|
||||
var actions = {
|
||||
addSegment : function () {
|
||||
app.viewer.toolManager.takeControl(new TCAD.TWO.AddSegmentTool(app.viewer, layer));
|
||||
app.viewer.toolManager.takeControl(new TCAD.TWO.AddSegmentTool(app.viewer, layer, false));
|
||||
},
|
||||
|
||||
addMultiSegment : function () {
|
||||
app.viewer.toolManager.takeControl(new TCAD.TWO.AddSegmentTool(app.viewer, layer, true));
|
||||
},
|
||||
|
||||
addArc : function () {
|
||||
|
|
@ -133,8 +137,9 @@ TCAD.App2D = function() {
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
actionsF.add(actions, 'addSegment');
|
||||
actionsF.add(actions, 'addMultiSegment');
|
||||
actionsF.add(actions, 'addArc');
|
||||
actionsF.add(actions, 'addCircle');
|
||||
actionsF.add(actions, 'pan');
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ TCAD.TWO.AddSegmentTool.prototype.mousewheel = function(e) {
|
|||
};
|
||||
|
||||
TCAD.TWO.AddSegmentTool.prototype.keydown = function(e) {
|
||||
if (this.multi && e.keyCode == 13) {
|
||||
this.line = null;
|
||||
if (this.multi && e.keyCode == 27) {
|
||||
this.viewer.remove(this.line);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue