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

Preset defaults #1301

Merged
merged 4 commits into from
Sep 18, 2023
Merged
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
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