Skip to content

Commit

Permalink
Merge pull request #82 from equinor/fix_for_bounding_box_on_initially…
Browse files Browse the repository at this point in the history
…_disabled_labels

Fixed an issue that caused bounding boxes to be updated when appended to wellbores, even if labels were diabled
  • Loading branch information
olems authored Aug 18, 2023
2 parents bc2a6ef + 539de6d commit 2740348
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 59 deletions.
107 changes: 56 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/videx-map",
"version": "1.14.2",
"version": "1.14.3",
"description": "Component for Pixi-overlay in Leaflet.",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand Down Expand Up @@ -67,11 +67,11 @@
"rollup": "^2.45.2",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-typescript2": "^0.35.0",
"simplex-noise": "^2.4.0",
"ts-jest": "^26.3.0",
"ts-loader": "^9.4.2",
"tslib": "^2.4.1",
"tslib": "^2.6.1",
"typedoc": "^0.23.23",
"typescript": "^4.9.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/WellboreModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export default class WellboreModule extends ModuleInterface {
this.containers.labels.visible = labelVisible; // set label visibility

// Only update labels on resize if labels and container is visible
if (labelVisible && Label.state.visible) {
if (labelVisible) {
this.roots.forEach(root => {
root.updateLabels();
});
Expand Down
12 changes: 8 additions & 4 deletions src/utils/wellbores/data/RootData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class RootData {
}
}

/** Position wellbore label along wellbore. Should never be called if labels are disabled. */
private positionLabel(wellbore: WellboreData) : void {
if (wellbore.label.attachToRoot) {
const index = this.labelIndex++;
Expand All @@ -63,7 +64,7 @@ export class RootData {
if (!wellbore.active) return; // No need to recalculte if inactive wellbore
if (!this.target) this.recalculate(true); // Recalculate if first target
else if (wellbore.order < this.target.order && wellbore.status > this.target.status) this.recalculate(true);
else this.positionLabel(wellbore); // Position label if lower order
else if (Label.state.visible) this.positionLabel(wellbore); // Position label if lower order and visible
}

/** Recalculate target and update uniforms */
Expand Down Expand Up @@ -118,9 +119,12 @@ export class RootData {
updateLabels(): void {
this.labelIndex = 0;
this.rootLabelsBBox = null;
this.wellbores.forEach(wellbore => {
if (wellbore.active) this.positionLabel(wellbore);
});

if (Label.state.visible) {
this.wellbores.forEach(wellbore => {
if (wellbore.active) this.positionLabel(wellbore);
});
}
}

setLabelVisibility(visible: boolean) {
Expand Down

0 comments on commit 2740348

Please sign in to comment.