ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
120 stars 77 forks source link

Add default viewer profile #1040

Closed ejeschke closed 1 year ago

ejeschke commented 1 year ago

This adds a feature called a "default viewer profile" to the ginga viewer widget. Using this, the viewer can be optionally reset to some default settings between images. This can be effectively used with the "remember" settings to have the viewer automatically recall the exact way an image was viewed previously (when viewed again), but have the settings restored to some reasonable default when viewing a new image. The default viewer profile is considered to be the state of the viewer just after creation and initializing with any saved settings.

This also separates out the color distribution algorithm and contrast settings as "remember-able" and "default settable" items separate from the color map settings.

The way the settings are applied when changing to an image is as follows:

  1. the viewer is reset to the default viewer profile, from any items that are desired
  2. any remembered items from the image profile are applied, if any
  3. any auto adjustments cuts/zoom/center are applied, if they were not overridden by a remembered setting
ejeschke commented 1 year ago

Default behavior is unchanged because all "reset" preferences are False by default.

ejeschke commented 1 year ago

Screenshot of the changes to Preferences plugin: prefs_screenshot

ejeschke commented 1 year ago

Note to self: need to update Preferences screenshot, add notes in user manual

ejeschke commented 1 year ago

New preferences screenshot: preferences

Now the sections are in the order the items are applied: reset, remember, new/auto

ejeschke commented 1 year ago

@pllim, do you want to have a look at this? If you want to mostly review the documentation, take a look at the docstring for the Preferences plugin.

Quick explanation from the doc:

As an example of using the Reset and Remember settings, suppose that you frequently use the contrast adjustment. You would like the contrast that you set with a particular image to be restored when that image is viewed again. However, when you view a new image, you would like the contrast to start out at some normal setting.

To accomplish this, manually reset the contrast to the desired default setting. Check “Reset Contrast” and then press “Update Viewer Profile”. Finally, check “Remember Contrast”. Click “Save Settings” to make the channel settings persistent.

There is no change from the regular behavior if you don't check any of the "Reset" or "Remember" settings.

ejeschke commented 1 year ago

Thanks! Seems useful.

Some of the screenshots not really changing but getting larger in file size; is that really necessary?

I can try to make them smaller. My display is 4K and there is a stretch factor that is applied in the OS to make applications not look so tiny (because the pixels are really tiny on a desktop-sized 4K display). This results in a larger screenshot because a given GUI feature actually takes more pixels. Rescaling down usually makes the screenshots look worse, so my only alternative is trying to find an old display (increasingly difficult, these days) or running the application in a VNC window.

Also, it is not clear from the docs where this preference file is saved; somewhere in ~/.ginga? I guess the saved preferences will be invalid when user renames or moves the file afterwards, so eventually they might want to clear all the outdated saved preferences?

Yes, this doesn't change the name or location of the settings files--$HOME/.ginga (or $GINGAHOME if the user wants a custom location). It's just the normal "channel.cfg" file. I'll add a note about the location where these are saved to the docstring.

ejeschke commented 1 year ago

Existing comment: "If "Save Settings" is pressed, it will save the settings to the user's home Ginga folder so that when a channel with the same name is created in future Ginga sessions it will obtain the same settings."

Suggested edit: "If "Save Settings" is pressed, it will save the settings to the user's $HOME/.ginga folder (a "channel_NAME.cfg" file for each channel NAME) so that when a channel with the same name is created in future Ginga sessions it will obtain the same settings."

Sound ok?

ejeschke commented 1 year ago

@pllim, what do you think of the sizes in the doc now?

I used the width attribute for the figures to make it similar in size to the old figures.

pllim commented 1 year ago

Figures look good over at https://ginga--1040.org.readthedocs.build/en/1040/manual/plugins_local/preferences.html . Thanks!

ejeschke commented 1 year ago

Thanks for the review, @pllim!