mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-15 21:05:22 +01:00
Snap for circle
This commit is contained in:
parent
1ac5417ae9
commit
25e7efd77b
1 changed files with 11 additions and 4 deletions
|
|
@ -49,18 +49,23 @@ TCAD.TWO.EditCircleTool = function(viewer) {
|
|||
TCAD.TWO.EditCircleTool.prototype.keydown = function(e) {};
|
||||
TCAD.TWO.EditCircleTool.prototype.keypress = function(e) {};
|
||||
TCAD.TWO.EditCircleTool.prototype.keyup = function(e) {};
|
||||
TCAD.TWO.EditCircleTool.prototype.cleanup = function(e) {};
|
||||
|
||||
TCAD.TWO.EditCircleTool.prototype.cleanup = function(e) {
|
||||
this.viewer.cleanSnap();
|
||||
};
|
||||
|
||||
TCAD.TWO.EditCircleTool.prototype.mousemove = function(e) {
|
||||
var p = this.viewer.screenToModel(e);
|
||||
if (this.circle != null) {
|
||||
var p = this.viewer.screenToModel(e);
|
||||
var r = TCAD.math.distance(p.x, p.y, this.circle.c.x, this.circle.c.y);
|
||||
this.circle.r.set(r);
|
||||
if (!e.shiftKey) {
|
||||
this.solveRequest(true);
|
||||
}
|
||||
this.viewer.refresh();
|
||||
} else {
|
||||
this.viewer.snap(p.x, p.y, []);
|
||||
}
|
||||
this.viewer.refresh();
|
||||
};
|
||||
|
||||
TCAD.TWO.EditCircleTool.prototype.solveRequest = function(rough) {
|
||||
|
|
@ -72,10 +77,12 @@ TCAD.TWO.EditCircleTool.prototype.solveRequest = function(rough) {
|
|||
TCAD.TWO.EditCircleTool.prototype.mouseup = function(e) {
|
||||
if (this.circle == null) {
|
||||
this.viewer.historyManager.checkpoint();
|
||||
var p = this.viewer.screenToModel(e);
|
||||
var needSnap = this.viewer.snapped.length != 0;
|
||||
var p = needSnap ? this.viewer.snapped.pop() : this.viewer.screenToModel(e);
|
||||
this.circle = new TCAD.TWO.Circle(
|
||||
new TCAD.TWO.EndPoint(p.x, p.y)
|
||||
);
|
||||
if (needSnap) this.viewer.parametricManager.linkObjects([this.circle.c, p]);
|
||||
this.viewer.activeLayer().objects.push(this.circle);
|
||||
this.viewer.refresh();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue