mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 09:52:34 +01:00
Point on Line constraint
This commit is contained in:
parent
f99a788ee7
commit
8d19130bb9
3 changed files with 40 additions and 0 deletions
|
|
@ -152,6 +152,10 @@ TCAD.App2D = function() {
|
|||
app.viewer.parametricManager.lock(app.viewer.selected);
|
||||
});
|
||||
|
||||
this.registerAction('pointOnLine', "Point On Line", function () {
|
||||
app.viewer.parametricManager.pointOnLine(app.viewer.selected);
|
||||
});
|
||||
|
||||
this.registerAction('analyzeConstraint', "Analyze Constraint", function () {
|
||||
app.viewer.parametricManager.analyze(alert);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -196,6 +196,13 @@ TCAD.TWO.ParametricManager.prototype.p2lDistance = function(objs, promptCallback
|
|||
}
|
||||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype.pointOnLine = function(objs) {
|
||||
var pl = this._fetchPointAndLine(objs);
|
||||
var target = pl[0];
|
||||
var segment = pl[1];
|
||||
this.add(new TCAD.TWO.Constraints.PointOnLine(target, segment));
|
||||
};
|
||||
|
||||
TCAD.TWO.utils.constRef = function(value) {
|
||||
return function() {
|
||||
return value;
|
||||
|
|
@ -890,3 +897,31 @@ TCAD.TWO.Constraints.Tangent.prototype.getObjects = function() {
|
|||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------ //
|
||||
|
||||
TCAD.TWO.Constraints.PointOnLine = function(point, line) {
|
||||
this.point = point;
|
||||
this.line = line;
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.PointOnLine.prototype.NAME = 'PointOnLine';
|
||||
|
||||
TCAD.TWO.Constraints.PointOnLine.prototype.getSolveData = function() {
|
||||
var params = [];
|
||||
this.point.collectParams(params);
|
||||
this.line.collectParams(params);
|
||||
return [['P2LDistance', params, [0]]];
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.PointOnLine.prototype.serialize = function() {
|
||||
return [this.NAME, [this.point.id, this.line.id]];
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.PointOnLine.prototype.NAME] = function(refs, data) {
|
||||
return new TCAD.TWO.Constraints.PointOnLine(refs(data[0]), refs(data[1]));
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.PointOnLine.prototype.getObjects = function() {
|
||||
return [this.point, this.line];
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------ //
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@
|
|||
<button class="btn rbtn act-tangentConstraint" style="background-image: url(img/tgn.png);"></button>
|
||||
<button class="btn rbtn act-RadiusConstraint" style="background-image: url(img/rad.png);"></button>
|
||||
<button class="btn rbtn act-lockConstraint" ><i class="fa fa-lock"></i></button>
|
||||
<button class="btn rbtn act-pointOnLine" >PL</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="status" class="panel b-top" style="width: 100%; height=22px;">
|
||||
|
|
|
|||
Loading…
Reference in a new issue