Skip to content

Commit

Permalink
Merge pull request #1301 from girder/preset-defaults
Browse files Browse the repository at this point in the history
Preset defaults
  • Loading branch information
annehaley authored Sep 18, 2023
2 parents 662b53e + 6025636 commit ea87ca8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
36 changes: 35 additions & 1 deletion docs/girder_config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ By default, item metadata can contain any keys and values. These can be given b
Image Frame Presets
....................

This is used to specify a list of default presets for viewing images in the folder.
This is used to specify a list of presets for viewing images in the folder.
Presets can be customized and saved in the GeoJS Image Viewer.
To retrieve saved presets, use http://[serverURL]/api/v1/item/[itemID]/internal_metadata/presets.
You can convert the response to YAML and paste it into the ``imageFramePresets`` key in your config file.
Expand Down Expand Up @@ -340,6 +340,40 @@ The YAML below includes some example presets.
palette: "#FF8000"


Image Frame Preset Defaults
...........................
This is used to specify a list of preset defaults, in order of precedence.
These presets are to be automatically applied to an image in this folder if they are applicable.
In the case that a preset is not applicable to an image, the next item in this list will be used.

** Important: the presets named in this list must have corresponding entries in the `imageFramePresets` configuration, else this configuration will have no effect. **

::

---
# The preset named "Primary Preset" will be applied to all images in this folder.
# Any images for which "Primary Preset" does not apply will have "Secondary Preset" applied.
# Any images for which neither "Primary Preset" nor "Secondary Preset" apply will have "Tertiary Preset" applied.
imageFramePresetDefaults:
- name: Primary Preset
- name: Secondary Preset
- name: Tertiary Preset

::

---
# This example would be used with the example for `imageFramePresets` shown above.
# Images with 7 or more channels would use "Auto Ranged Channels"
# Images with fewer than 7 but at least 4 channels would use "Channels with Min and Max"
# Images with 3 channels would use "3 channels"
# Images with fewer than 3 channels would not have a default preset applied.
imageFramePresetDefaults:
- name: Auto Ranged Channels
- name: Channels with Min and Max
- name: 3 channels



Editing Configuration Files
---------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,23 @@ export default {
!this.availableModes.includes(preset.mode.id)
) {
return false;
} else if (
preset.style && preset.style.bands &&
this.imageMetadata.IndexRange &&
this.imageMetadata.IndexRange.IndexC &&
preset.style.bands.some((b) => b.framedelta > this.imageMetadata.IndexRange.IndexC)
) {
return false;
} else if (preset.style && preset.style.bands) {
if (preset.mode.id === 2) {
// Channel compositing, compare to num channels
if (this.imageMetadata.IndexRange &&
this.imageMetadata.IndexRange.IndexC &&
preset.style.bands.some((b) => b.framedelta >= this.imageMetadata.IndexRange.IndexC)
) {
return false;
}
} else if (preset.mode.id === 3) {
// Band compositing, compare to num bands
if (this.imageMetadata.bandCount &&
preset.style.bands.some((b) => b.band >= this.imageMetadata.bandCount)
) {
return false;
}
}
}
return true;
Expand All @@ -94,6 +104,18 @@ export default {
}
if (this.liConfig.imageFramePresets) {
this.folderPresets = this.liConfig.imageFramePresets.filter(this.presetApplicable);
if (this.liConfig.imageFramePresetDefaults) {
this.liConfig.imageFramePresetDefaults.every(({name}) => {
const presetMatch = this.folderPresets.find((p) => p.name === name);
if (presetMatch) {
// found applicable preset in defaults list
// set as selected then return
this.selectedPreset = name;
return false;
}
return true;
});
}
}
return undefined;
});
Expand Down

0 comments on commit ea87ca8

Please sign in to comment.