Autodesk.Viewing.Private.Preferences
new Preferences(viewer,options)
Application preferences.
Optionally uses web storage.
Each preference value can have tags associated to them. Developer supported tags are:
- ‘ignore-producer’
- ‘no-storage’
- ‘2d’
- ‘3d’
Use tag ‘ignore-producer’ in extensions to avoid having developer-defined render settings overridden by the loaded file.
Use tag ‘no-storage’ in extensions to avoid having User Preferences (from Settings Panel) override default or developer-defined preferences. Useful for render settings.
Preferences may apply to all model types, only 2D models (with tag ‘2d’) or 3D models only (with tag ‘3d’).
Parameters
viewer* | Viewer instance. |
options* object | Contains configuration parameters used to do initializations. |
localStorage boolean | Whether values get stored and loaded
back from localStorage. Defaults to
true . |
prefix string | A string to prefix preference names in
web storage. Defaults to
'Autodesk.Viewing.Preferences.' . |
Methods
addListeners(name,onChangedCallback,onResetCallback)
Listen for preference changed and reset events.
Parameters
name* string | Preferences name. |
onChangedCallback* function | Function called when preferences are changed. |
onResetCallback* function | Function called when preferences are reset. |
get()
Get named preference value. Shortcut: prefs[name]
Returns
Type | Description |
---|---|
* | Preference value. |
hasTag(name,tag)
Checks whether a tag is associated to a name
Parameters
name* string | Preference name |
tag* string | The tag to check for |
load(defaultValues)
Load preference values from web storage/defaults.
Parameters
defaultValues* object | Preference names and their default values. |
remove(name,removeFromWebStorage)
Removes an existing preference.
Parameters
name* string | Preference name. |
removeFromWebStorage boolean | True to clear the web storage entry for this preference. |
Returns
Type | Description |
---|---|
boolean | True if the preference was removed. |
removeListeners(name)
Remove listeners for preference changed and reset events.
Parameters
name* string | Preferences name. |
reset(tag,include)
Reset preferences to default values. If a tag is specified, then only certain preferences are reset.
Parameters
tag string | Optional tag. |
include boolean | True to reset only preferences with matching tags. |
set(name,value,notify)
Set named preference value. Value is not persisted if tag ‘no-storage’ is set. Do not use shortcut prefs[name] = value.
Parameters
name* string | Preference name. |
value* * | Preference value. |
notify boolean | If true then av.PREF_CHANGED_EVENT is fired. |
Returns
Type | Description |
---|---|
boolean | True if the value changed, false otherwise. |
tag(tag,names)
Adds a tag to the specified preferences. These are used by reset().
Parameters
tag* string | |
names Array.<string>|string | Preference names, default all preferences. |
untag(tag,names)
Removes a tag from the specified preferences. These are used by reset().
Parameters
tag* string | |
names Array.<string>|string | Preference names, default all preferences. |