Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show 2d widgets in 3d view #469

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/tools/MeasurementTools/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</span>
</div>
<div :class="$style.action">
<v-tooltip bottom>
<v-tooltip v-if="tool.data && tool.data.axis !== null" bottom>
<template v-slot:activator="{ on }">
<v-btn
small
Expand Down Expand Up @@ -144,6 +144,13 @@
@input="toolState.setTextSize"
/>
</v-flex>
<v-flex v-if="tool.data.axis !== null" xs9>
<v-checkbox
label="Show in 3D View"
:input-value="toolState.show3d"
@change="toolState.setShow3d"
/>
</v-flex>
</v-layout>
<v-divider :class="$style.divider" />
<v-layout align-center>
Expand Down
25 changes: 23 additions & 2 deletions src/components/tools/MeasurementTools/tools/ToolTemplate2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default (toolName, extraComponent = {}) => ({
targetViewId: -1,
color: WIDGETS[0],
textSize: 16,
show3d: false,
measurements: this.initialMeasurements(),
measurementLabels: this.getMeasurementLabels(),
};
Expand Down Expand Up @@ -128,12 +129,13 @@ export default (toolName, extraComponent = {}) => ({
this.widgetPid = proxy.getProxyId();

if (this.toolData) {
const { name, lockToSlice, points, color, textSize, axis } =
const { name, lockToSlice, points, color, textSize, axis, show3d } =
this.toolData;
this.name = name;
this.lockToSlice = lockToSlice;
this.color = color;
this.textSize = textSize;
this.show3d = show3d;

const view = this.$proxyManager
.getViews()
Expand Down Expand Up @@ -173,7 +175,10 @@ export default (toolName, extraComponent = {}) => ({
}

const view3dHandler = (view, widgetManager, viewWidget) => {
widgetManager.removeWidget(viewWidget);
this.setupViewWidget(viewWidget);
this.setWidgetColor(viewWidget, this.color);
this.setWidgetTextSize(viewWidget, this.textSize);
viewWidget.setVisibility(this.show3d);
};

const view2dHandler = (view, widgetManager, viewWidget) => {
Expand Down Expand Up @@ -297,6 +302,19 @@ export default (toolName, extraComponent = {}) => ({
this.renderViewWidgets();
this.saveData();
},
setShow3d(show) {
this.show3d = show;
const view3d = this.$proxyManager
.getViews()
.find((view) => view.getProxyName() === 'View3D');
const vw = this.widgetProxy.getViewWidget(view3d);

vw.setVisibility(show);

this.renderViewWidgets();
this.$proxyManager.renderAllViews();
this.saveData();
},
renderViewWidgets() {
this.$proxyManager.getViews().forEach((view) => {
const manager = view.getReferenceByName('widgetManager');
Expand All @@ -314,6 +332,7 @@ export default (toolName, extraComponent = {}) => ({
points: state.getHandleList().map((handle) => handle.getOrigin()),
color: this.color,
textSize: this.textSize,
show3d: this.show3d,
axis: this.targetView.getAxis(),
};
this.$emit('saveData', data);
Expand Down Expand Up @@ -362,13 +381,15 @@ export default (toolName, extraComponent = {}) => ({
:tool-name="name"
:color="color"
:text-size="textSize"
:show-3d="show3d"
:measurements="displayedMeasurements"
:labels="measurementLabels"
:toggle-lock="toggleLock"
:remove="emitRemove"
:set-name="setName"
:set-color="setColor"
:set-text-size="setTextSize"
:set-show-3d="setShow3d"
>
</slot>
</div>
Expand Down