mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-14 20:33:30 +01:00
ability to change datums within operations
This commit is contained in:
parent
2c720f37b6
commit
1df6de49a5
8 changed files with 24 additions and 13 deletions
|
|
@ -5,6 +5,7 @@ import {RadioButton} from 'ui/components/controls/RadioButtons';
|
|||
|
||||
export default function RotateDatumWizard() {
|
||||
return <Group>
|
||||
<ReadOnlyValueField name='datum'/>
|
||||
<RadioButtonsField name='axis'>
|
||||
<RadioButton value='X' />
|
||||
<RadioButton value='Y' />
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ import React from 'react';
|
|||
import {Group} from '../../wizard/components/form/Form';
|
||||
import {NumberField, ReadOnlyValueField} from '../../wizard/components/form/Fields';
|
||||
import BooleanChoice from '../../wizard/components/form/BooleanChioce';
|
||||
import EntityList from '../../wizard/components/form/EntityList';
|
||||
|
||||
export default function BoxWizard() {
|
||||
return <Group>
|
||||
<ReadOnlyValueField name='datum' placeholder='origin'/>
|
||||
<EntityList name='datum' placeholder='origin'/>
|
||||
<NumberField name='width' />
|
||||
<NumberField name='height' />
|
||||
<NumberField name='depth' />
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ import * as SceneGraph from '../../../../../modules/scene/sceneGraph';
|
|||
|
||||
export default function primitivePreviewer(createThreePrimitiveGeometry, paramsToScales, shift) {
|
||||
return function previewer(ctx, initialParams) {
|
||||
let mDatum = initialParams.datum && ctx.services.cadRegistry.findDatum(initialParams.datum);
|
||||
let cs = mDatum ? mDatum.csys : CSys.ORIGIN;
|
||||
let o = cs.origin;
|
||||
|
||||
let geometry = createThreePrimitiveGeometry();
|
||||
let mesh = new Mesh(geometry, IMAGINARY_SURFACE_MATERIAL);
|
||||
|
|
@ -17,6 +14,10 @@ export default function primitivePreviewer(createThreePrimitiveGeometry, paramsT
|
|||
let auxMatrix = new Matrix4();
|
||||
|
||||
function update(params) {
|
||||
let mDatum = params.datum && ctx.services.cadRegistry.findDatum(params.datum);
|
||||
let cs = mDatum ? mDatum.csys : CSys.ORIGIN;
|
||||
let o = cs.origin;
|
||||
|
||||
let {dx, dy, dz} = paramsToScales(params);
|
||||
mesh.matrix.set(
|
||||
dx*cs.x.x, dy*cs.y.x, dz*cs.z.x, o.x,
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ export default class EntityList extends React.Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
let {name, label, active, setActive, value} = this.props;
|
||||
let {name, label, active, setActive, value, placeholder} = this.props;
|
||||
if (!Array.isArray(value)) {
|
||||
value = value ? asArray(value) : EMPTY_ARRAY;
|
||||
}
|
||||
return <Field active={active} onClick={setActive}>
|
||||
<Label>{label||camelCaseSplitToStr(name)}:</Label>
|
||||
<div>{value.length === 0 ?
|
||||
<span className={ls.emptySelection}>{'<not selected>'}</span> :
|
||||
<span className={ls.emptySelection}>{placeholder || '<not selected>'}</span> :
|
||||
value.map((entity, i) => <span className={ls.entityRef} key={i}>
|
||||
{entity} <span className={ls.rm} onClick={() => this.deselect(entity)}> <Fa icon='times'/></span>
|
||||
</span>)}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {EDGE, FACE, SHELL, SKETCH_OBJECT} from '../../scene/entites';
|
||||
import {DATUM, EDGE, FACE, SHELL, SKETCH_OBJECT} from '../../scene/entites';
|
||||
|
||||
export function activate(ctx) {
|
||||
const wizardPickHandler = createPickHandlerFromSchema(ctx);
|
||||
|
|
@ -142,6 +142,12 @@ function createPickHandlerFromSchema(ctx) {
|
|||
} else {
|
||||
selectToFirst(EDGE, model.id);
|
||||
}
|
||||
} else if (modelType === DATUM) {
|
||||
if (activeEntity === DATUM) {
|
||||
selectActive(model.id);
|
||||
} else {
|
||||
selectToFirst(DATUM, model.id);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ export function activate(context) {
|
|||
if (dispatchSelection(EDGE, modelId, event)) {
|
||||
return false;
|
||||
}
|
||||
} else if (type === DATUM) {
|
||||
if (dispatchSelection(DATUM, modelId, event)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export function activate(context) {
|
|||
streams.sketcher.update.attach(mFace => mFace.ext.view.updateSketch());
|
||||
}
|
||||
|
||||
function sceneSynchronizer({services: {cadScene, cadRegistry, viewer, wizard, action, selection}}) {
|
||||
function sceneSynchronizer({services: {cadScene, cadRegistry, viewer, wizard, action, pickControl}}) {
|
||||
return function() {
|
||||
let wgChildren = cadScene.workGroup.children;
|
||||
let existent = new Set();
|
||||
|
|
@ -44,7 +44,7 @@ function sceneSynchronizer({services: {cadScene, cadRegistry, viewer, wizard, ac
|
|||
} else if (model instanceof MDatum) {
|
||||
modelView = new DatumView(model, viewer,
|
||||
wizard.open,
|
||||
datumId => selection.datum.select([datumId]),
|
||||
datum => pickControl.pick(datum),
|
||||
e => action.run('menu.datum', e));
|
||||
} else {
|
||||
console.warn('unsupported model ' + model);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import {DATUM} from '../entites';
|
|||
import {setAttribute} from 'scene/objectData';
|
||||
import {Mesh, MeshBasicMaterial, PolyhedronGeometry, SphereGeometry} from 'three';
|
||||
import {CSYS_SIZE_MODEL} from '../../craft/datum/csysObject';
|
||||
import {NOOP} from '../../../../../modules/gems/func';
|
||||
|
||||
export default class DatumView extends View {
|
||||
|
||||
|
|
@ -55,7 +54,7 @@ export default class DatumView extends View {
|
|||
}
|
||||
|
||||
onMouseClick(e) {
|
||||
selectDatum(datum.id);
|
||||
selectDatum(datum);
|
||||
showDatumMenu({
|
||||
x: e.offsetX,
|
||||
y: e.offsetY
|
||||
|
|
@ -103,9 +102,8 @@ export default class DatumView extends View {
|
|||
|
||||
dragStart(e, axis) {
|
||||
if (!this.operationStarted) {
|
||||
selectDatum(datum.id);
|
||||
selectDatum(datum);
|
||||
beginOperation('DATUM_MOVE');
|
||||
this.beginOperation();
|
||||
}
|
||||
super.dragStart(e, axis);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue