Skip to content

Commit

Permalink
Allow to set the active layer group, fixes #1455
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Oct 18, 2023
1 parent 372b4e2 commit 1fa4b44
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ export class App {
return this.#stage.getActiveLayerGroup();
}

/**
* Set the active layer group.
*
* @param {number} index The layer group index.
*/
setActiveLayerGroup(index) {
this.#stage.setActiveLayerGroup(index);
}

/**
* Get the view layers associated to a data id.
* The layer are available after the first loaded item.
Expand Down
15 changes: 15 additions & 0 deletions src/gui/stage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Point, Point3D} from '../math/point';
import {LayerGroup} from './layerGroup';
import {logger} from '../utils/logger';

// doc imports
/* eslint-disable no-unused-vars */
Expand Down Expand Up @@ -215,6 +216,20 @@ export class Stage {
return this.getLayerGroup(this.#activeLayerGroupIndex);
}

/**
* Set the active layer group.
*
* @param {number} index The layer group index.
*/
setActiveLayerGroup(index) {
if (typeof this.getLayerGroup(index) !== 'undefined') {
this.#activeLayerGroupIndex = index;
} else {
logger.warn('No layer group to set as active with index: ' +
index);
}
}

/**
* Get the view layers associated to a data id.
*
Expand Down

0 comments on commit 1fa4b44

Please sign in to comment.