mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-14 12:23:03 +01:00
backward compatibility for equals constraint
This commit is contained in:
parent
d5b35d1740
commit
b5f6a45d11
2 changed files with 18 additions and 9 deletions
|
|
@ -27,21 +27,25 @@ export function matchAvailableActions(selection) {
|
|||
return matched;
|
||||
}
|
||||
|
||||
export function getSketcherAction(actionId) {
|
||||
return index[actionId];
|
||||
}
|
||||
|
||||
//For backward compatibility
|
||||
export function runActionOrToastWhyNot(actionId, selection, ctx) {
|
||||
export function runActionOrToastWhyNot(actionId, selection, ctx, silent) {
|
||||
const action = index[actionId];
|
||||
if (action) {
|
||||
const matched = matchSelection(action.selectionMatcher, new MatchIndex(selection), false);
|
||||
if (matched) {
|
||||
action.invoke(ctx, matched)
|
||||
} else {
|
||||
toast('The action "' + action.shortName + ' ' + action.kind + '" requires selection of ' + getDescription(action.selectionMatcher));
|
||||
|
||||
const msg = 'The action "' + action.shortName + ' ' + action.kind + '" requires selection of ' + getDescription(action.selectionMatcher);
|
||||
if (silent) {
|
||||
return msg;
|
||||
} else {
|
||||
toast(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
matchAvailableActions(selection).forEach(a => {
|
||||
if (a.id === actionId) {
|
||||
cb(a);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ import genSerpinski from '../utils/genSerpinski';
|
|||
import React from "react";
|
||||
import {runActionOrToastWhyNot} from "./actions";
|
||||
import {stream} from "../../../modules/lstream";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
function App2D() {
|
||||
var app = this;
|
||||
|
|
@ -230,11 +231,15 @@ function App2D() {
|
|||
});
|
||||
|
||||
this.registerAction('RadiusConstraint', "Radius Constraint", function () {
|
||||
app.viewer.parametricManager.radius(app.viewer.selected, prompt);
|
||||
runActionOrToastWhyNot('RadiusLength', app.viewer.selected, app.context);
|
||||
});
|
||||
|
||||
this.registerAction('EntityEqualityConstraint', "Radius Equals Constraint", function () {
|
||||
app.viewer.parametricManager.entityEquality(app.viewer.selected);
|
||||
const fail1 = runActionOrToastWhyNot('EqualRadius', app.viewer.selected, app.context, true);
|
||||
const fail2 = runActionOrToastWhyNot('EqualLength', app.viewer.selected, app.context, true);
|
||||
if (fail1 && fail2) {
|
||||
toast('Requires selection of either segments or circles and arcs');
|
||||
}
|
||||
});
|
||||
|
||||
this.registerAction('tangentConstraint', "Tangent Constraint", function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue