{selection ?
@@ -44,3 +47,7 @@ export default class SingleEntity extends React.Component {
;
}
}
+
+SingleEntity.defaultProps = {
+ selectionIndex: 0
+};
\ No newline at end of file
diff --git a/web/app/cad/craft/wizard/wizardSelectionModeSwitcherPlugin.js b/web/app/cad/craft/wizard/wizardSelectionModeSwitcherPlugin.js
new file mode 100644
index 00000000..c50168c7
--- /dev/null
+++ b/web/app/cad/craft/wizard/wizardSelectionModeSwitcherPlugin.js
@@ -0,0 +1,13 @@
+
+export function activate(ctx) {
+ ctx.streams.wizard.workingRequest.attach(({type}) => {
+ if (type) {
+ let operation = ctx.services.operation.get(type);
+ if (operation.selectionMode) {
+ ctx.services.pickControl.setSelectionMode(operation.selectionMode);
+ }
+ } else {
+ ctx.services.pickControl.switchToDefaultSelectionMode();
+ }
+ });
+}
\ No newline at end of file
diff --git a/web/app/cad/init/startApplication.js b/web/app/cad/init/startApplication.js
index fb564c4c..d14b97b1 100644
--- a/web/app/cad/init/startApplication.js
+++ b/web/app/cad/init/startApplication.js
@@ -10,6 +10,7 @@ import * as UiPlugin from '../dom/uiPlugin';
import * as MenuPlugin from '../dom/menu/menuPlugin';
import * as KeyboardPlugin from '../keyboard/keyboardPlugin';
import * as WizardPlugin from '../craft/wizard/wizardPlugin';
+import * as WizardSelectionModeSwitcherPlugin from '../craft/wizard/wizardSelectionModeSwitcherPlugin';
import * as PreviewPlugin from '../preview/previewPlugin';
import * as OperationPlugin from '../craft/operationPlugin';
import * as ExtensionsPlugin from '../craft/extensionsPlugin';
@@ -63,7 +64,8 @@ export default function startApplication(callback) {
SelectionMarkerPlugin,
SketcherPlugin,
...applicationPlugins,
- ViewSyncPlugin
+ ViewSyncPlugin,
+ WizardSelectionModeSwitcherPlugin
];
let allPlugins = [...preUIPlugins, ...plugins];
diff --git a/web/app/cad/part/menuConfig.js b/web/app/cad/part/menuConfig.js
index f9470840..b00c9659 100644
--- a/web/app/cad/part/menuConfig.js
+++ b/web/app/cad/part/menuConfig.js
@@ -22,14 +22,14 @@ export default [
label: 'bool',
cssIcons: ['pie-chart'],
info: 'set of available boolean operations',
- actions: ['INTERSECTION', 'DIFFERENCE', 'UNION']
+ actions: ['INTERSECTION', 'SUBTRACT', 'UNION']
},
{
id: 'main',
label: 'start',
cssIcons: ['rocket'],
info: 'common set of actions',
- actions: ['EXTRUDE', 'CUT', 'SHELL', '-', 'INTERSECTION', 'DIFFERENCE', 'UNION', '-', 'PLANE', 'BOX', 'SPHERE', '-',
+ actions: ['EXTRUDE', 'CUT', 'SHELL', '-', 'INTERSECTION', 'SUBTRACT', 'UNION', '-', 'PLANE', 'BOX', 'SPHERE', '-',
'EditFace', '-', 'DeselectAll', 'RefreshSketches']
},
{
diff --git a/web/app/cad/part/partOperationsPlugin.js b/web/app/cad/part/partOperationsPlugin.js
index e42f23f2..afaf18f2 100644
--- a/web/app/cad/part/partOperationsPlugin.js
+++ b/web/app/cad/part/partOperationsPlugin.js
@@ -12,6 +12,7 @@ import sphereOperation from '../craft/primitives/sphere/sphereOperation';
import cylinderOperation from '../craft/primitives/cylinder/cylinderOperation';
import torusOperation from '../craft/primitives/torus/torusOperation';
import coneOperation from '../craft/primitives/cone/coneOperation';
+import {intersectionOperation, subtractOperation, unionOperation} from '../craft/boolean/booleanOperation';
export function activate({services}) {
services.operation.registerOperations([
@@ -28,6 +29,9 @@ export function activate({services}) {
sphereOperation,
cylinderOperation,
torusOperation,
- coneOperation
+ coneOperation,
+ intersectionOperation,
+ subtractOperation,
+ unionOperation
])
}
\ No newline at end of file
diff --git a/web/app/cad/part/uiConfigPlugin.js b/web/app/cad/part/uiConfigPlugin.js
index 268778b5..8a0b2ab8 100644
--- a/web/app/cad/part/uiConfigPlugin.js
+++ b/web/app/cad/part/uiConfigPlugin.js
@@ -15,7 +15,7 @@ export function activate({services, streams}) {
['ShowSketches', {label: 'sketches'}], ['DeselectAll', {label: null}], ['ToggleCameraMode', {label: null}]
];
- streams.ui.toolbars.headsUp.value = ['PLANE', 'EditFace', 'EXTRUDE', 'CUT', 'REVOLVE', 'FILLET', 'INTERSECTION', 'DIFFERENCE', 'UNION'];
+ streams.ui.toolbars.headsUp.value = ['PLANE', 'EditFace', 'EXTRUDE', 'CUT', 'REVOLVE', 'FILLET', 'INTERSECTION', 'SUBTRACT', 'UNION'];
streams.ui.toolbars.auxiliary.value = ['Save', 'StlExport'];
services.action.registerActions(CoreActions);
diff --git a/web/app/cad/scene/controls/pickControlPlugin.js b/web/app/cad/scene/controls/pickControlPlugin.js
index b88b919a..7c6140d8 100644
--- a/web/app/cad/scene/controls/pickControlPlugin.js
+++ b/web/app/cad/scene/controls/pickControlPlugin.js
@@ -1,7 +1,8 @@
import * as mask from 'gems/mask'
import {getAttribute, setAttribute} from 'scene/objectData';
-import {FACE, EDGE, SKETCH_OBJECT, DATUM} from '../entites';
+import {FACE, EDGE, SKETCH_OBJECT, DATUM, SHELL} from '../entites';
import {state} from 'lstream';
+import {distinctState} from '../../../../../modules/lstream';
export const PICK_KIND = {
FACE: mask.type(1),
@@ -9,7 +10,16 @@ export const PICK_KIND = {
EDGE: mask.type(3)
};
-const SELECTABLE_ENTITIES = [FACE, EDGE, SKETCH_OBJECT, DATUM];
+const SELECTABLE_ENTITIES = [FACE, EDGE, SKETCH_OBJECT, DATUM, SHELL];
+
+const DEFAULT_SELECTION_MODE = Object.freeze({
+ shell: false,
+ vertex: false,
+ face: true,
+ edge: true,
+ sketchObject: true,
+ datum: true
+});
export function activate(context) {
const {services, streams} = context;
@@ -48,11 +58,18 @@ export function activate(context) {
function handlePick(event) {
raycastObjects(event, PICK_KIND.FACE | PICK_KIND.SKETCH | PICK_KIND.EDGE, (view, kind) => {
+ let selectionMode = streams.pickControl.selectionMode.value;
let modelId = view.model.id;
if (kind === PICK_KIND.FACE) {
- if (dispatchSelection(streams.selection.face, modelId, event)) {
- services.cadScene.showGlobalCsys(view.model.csys);
- return false;
+ if (selectionMode.shell) {
+ if (dispatchSelection(streams.selection.shell, view.model.shell.id, event)) {
+ return false;
+ }
+ } else {
+ if (dispatchSelection(streams.selection.face, modelId, event)) {
+ services.cadScene.showGlobalCsys(view.model.csys);
+ return false;
+ }
}
} else if (kind === PICK_KIND.SKETCH) {
if (dispatchSelection(streams.selection.sketchObject, modelId, event)) {
@@ -132,10 +149,35 @@ export function defineStreams({streams}) {
SELECTABLE_ENTITIES.forEach(entity => {
streams.selection[entity] = state([]);
});
+ streams.pickControl = {
+ selectionMode: distinctState(DEFAULT_SELECTION_MODE)
+ }
}
function initStateAndServices({streams, services}) {
+ streams.pickControl.selectionMode.pairwise().attach(([prev, curr]) => {
+ SELECTABLE_ENTITIES.forEach(entity => {
+ if (prev[entity] !== curr[entity]) {
+ streams.selection[entity].next([]);
+ }
+ });
+ });
+
+ function setSelectionMode(selectionMode) {
+ streams.pickControl.selectionMode.next({
+ ...DEFAULT_SELECTION_MODE, ...selectionMode
+ });
+ }
+
+ function switchToDefaultSelectionMode() {
+ streams.pickControl.selectionMode.next(DEFAULT_SELECTION_MODE);
+ }
+
+ services.pickControl = {
+ setSelectionMode, switchToDefaultSelectionMode
+ };
+
services.selection = {};
SELECTABLE_ENTITIES.forEach(entity => {
diff --git a/web/app/cad/scene/selectionMarker/selectionMarkerPlugin.js b/web/app/cad/scene/selectionMarker/selectionMarkerPlugin.js
index 781b084f..9edf18fc 100644
--- a/web/app/cad/scene/selectionMarker/selectionMarkerPlugin.js
+++ b/web/app/cad/scene/selectionMarker/selectionMarkerPlugin.js
@@ -1,4 +1,4 @@
-import {EDGE, FACE, SKETCH_OBJECT} from '../entites';
+import {EDGE, FACE, SHELL, SKETCH_OBJECT} from '../entites';
import {findDiff} from '../../../../../modules/gems/iterables';
export function activate({streams, services}) {
@@ -20,10 +20,8 @@ export function activate({streams, services}) {
};
streams.selection.face.pairwise([]).attach(selectionSync(FACE));
+ streams.selection.shell.pairwise([]).attach(selectionSync(SHELL));
streams.selection.edge.pairwise([]).attach(selectionSync(EDGE));
streams.selection.sketchObject.pairwise([]).attach(selectionSync(SKETCH_OBJECT));
- // new SelectionMarker(context, 0xFAFAD2, 0xFF0000, null);
- // new SketchSelectionMarker(context, createLineMaterial(0xFF0000, 6 / DPR));
- // new EdgeSelectionMarker(context, 0xFA8072);
}
diff --git a/web/app/cad/scene/views/shellView.js b/web/app/cad/scene/views/shellView.js
index 032ec2cd..e0be6ab3 100644
--- a/web/app/cad/scene/views/shellView.js
+++ b/web/app/cad/scene/views/shellView.js
@@ -2,7 +2,7 @@ import {View} from './view';
import * as SceneGraph from '../../../../../modules/scene/sceneGraph';
import {setAttribute} from '../../../../../modules/scene/objectData';
import {createSolidMaterial} from '../wrappers/sceneObject';
-import {FaceView} from './faceView';
+import {FaceView, SELECTION_COLOR} from './faceView';
import {EdgeView} from './edgeView';
import {SHELL} from '../entites';
@@ -44,8 +44,16 @@ export class ShellView extends View {
SceneGraph.addToGroup(this.edgeGroup, edgeView.rootGroup);
this.edgeViews.push(edgeView);
}
- }
-
+ }
+
+ mark(color) {
+ this.faceViews.forEach(faceView => faceView.setColor(color || SELECTION_COLOR));
+ }
+
+ withdraw(color) {
+ this.faceViews.forEach(faceView => faceView.setColor(null));
+ }
+
dispose() {
for (let faceView of this.faceViews) {
faceView.dispose();
diff --git a/web/img/cad/difference32.png b/web/img/cad/subtract32.png
similarity index 100%
rename from web/img/cad/difference32.png
rename to web/img/cad/subtract32.png
diff --git a/web/img/cad/difference96.png b/web/img/cad/subtract96.png
similarity index 100%
rename from web/img/cad/difference96.png
rename to web/img/cad/subtract96.png