Skip to content

Commit

Permalink
Merge pull request #507 from Kitware/fix-svg-rendering
Browse files Browse the repository at this point in the history
fix(tools): re-render svg on canvas size change
  • Loading branch information
floryst authored Sep 17, 2024
2 parents da8426e + 63f76a8 commit dec53fb
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/tools/MeasurementTools/svg/AngleSvg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ export default {
mounted() {
this.trackVtkSubscription(this.widgetState.onModified(this.updateLabels));
this.updateLabels();
this.resizeObserver = new ResizeObserver(() => {
this.updatePoints();
});
this.resizeObserver.observe(this.view.getContainer());
},
beforeUnmount() {
this.resizeObserver.disconnect();
},
methods: {
updateLabels() {
Expand Down
7 changes: 7 additions & 0 deletions src/components/tools/MeasurementTools/svg/RulerSvg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ export default {
mounted() {
this.trackVtkSubscription(this.widgetState.onModified(this.updateLabels));
this.updateLabels();
this.resizeObserver = new ResizeObserver(() => {
this.updatePoints();
});
this.resizeObserver.observe(this.view.getContainer());
},
beforeUnmount() {
this.resizeObserver.disconnect();
},
methods: {
updateLabels() {
Expand Down
12 changes: 10 additions & 2 deletions src/components/tools/MeasurementTools/svg/SvgCircleHandles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ export default {
},
mounted() {
this.trackVtkSubscription(this.widgetState.onModified(this.updatePoints));
this.updatePoints();
this.resizeObserver = new ResizeObserver(() => {
this.updatePoints();
});
this.resizeObserver.observe(this.view.getContainer());
},
beforeUnmount() {
this.resizeObserver.disconnect();
},
methods: {
async updatePoints() {
Expand All @@ -52,7 +58,9 @@ export default {
.filter((state) => state.isVisible())
.flatMap((state) => state.getOrigin());
this.points = await this.mapToPixelSpace(handlePoints);
const promise = this.mapToPixelSpace(handlePoints);
this.view.render();
this.points = await promise;
},
},
};
Expand Down
7 changes: 7 additions & 0 deletions src/components/tools/MeasurementTools/svg/SvgLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export default {
},
mounted() {
this.updatePoints();
this.resizeObserver = new ResizeObserver(() => {
this.updatePoints();
});
this.resizeObserver.observe(this.view.getContainer());
},
beforeUnmount() {
this.resizeObserver.disconnect();
},
methods: {
async updatePoints() {
Expand Down
7 changes: 7 additions & 0 deletions src/components/tools/MeasurementTools/svg/SvgPolyLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export default {
mounted() {
this.trackVtkSubscription(this.widgetState.onModified(this.updatePoints));
this.updatePoints();
this.resizeObserver = new ResizeObserver(() => {
this.updatePoints();
});
this.resizeObserver.observe(this.view.getContainer());
},
beforeUnmount() {
this.resizeObserver.disconnect();
},
methods: {
async updatePoints() {
Expand Down
7 changes: 7 additions & 0 deletions src/components/tools/MeasurementTools/svg/TextSvg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export default {
mounted() {
this.trackVtkSubscription(this.widgetState.onModified(this.updateLabels));
this.updateLabels();
this.resizeObserver = new ResizeObserver(() => {
this.updatePoints();
});
this.resizeObserver.observe(this.view.getContainer());
},
beforeUnmount() {
this.resizeObserver.disconnect();
},
methods: {
updateLabels() {
Expand Down

0 comments on commit dec53fb

Please sign in to comment.