Singleton settings manager for the CAD application.

This class manages application-wide settings with:

  • Persistent storage using localStorage
  • Event notification when settings change
  • Type-safe setting access
  • Default value fallbacks

The settings are automatically saved to localStorage and restored on application start.

// Get the singleton instance
const settings = AcApSettingManager.instance;

// Set a setting value
settings.set('isShowToolbar', false);

// Get a setting value
const showToolbar = settings.get('isShowToolbar');

// Toggle a boolean setting
settings.toggle('isDebug');

// Listen for setting changes
settings.events.modified.addEventListener(args => {
console.log(`Setting ${args.key} changed to:`, args.value);
});

Type Parameters

Constructors

Properties

events: { modified: AcCmEventManager<AcApSettingManagerEventArgs<T>> } = ...

Events fired when settings are modified

Type declaration

Accessors

  • get isDebug(): boolean

    Gets whether debug mode is enabled.

    Returns boolean

    True if debug mode is enabled

  • set isDebug(value: boolean): void

    Sets whether debug mode is enabled.

    Parameters

    • value: boolean

      True to enable debug mode

    Returns void

  • get isShowCommandLine(): boolean

    Gets whether the command line is visible.

    Returns boolean

    True if command line should be shown

  • set isShowCommandLine(value: boolean): void

    Sets whether the command line is visible.

    Parameters

    • value: boolean

      True to show the command line

    Returns void

  • get isShowCoordinate(): boolean

    Gets whether coordinate display is visible.

    Returns boolean

    True if coordinates should be displayed

  • set isShowCoordinate(value: boolean): void

    Sets whether coordinate display is visible.

    Parameters

    • value: boolean

      True to show coordinates

    Returns void

  • get isShowStats(): boolean

    Gets whether performance statistics are displayed.

    Returns boolean

    True if stats should be shown

  • set isShowStats(value: boolean): void

    Sets whether performance statistics are displayed.

    Parameters

    • value: boolean

      True to show stats

    Returns void

  • get isShowToolbar(): boolean

    Gets whether the toolbar is visible.

    Returns boolean

    True if toolbar should be shown

  • set isShowToolbar(value: boolean): void

    Sets whether the toolbar is visible.

    Parameters

    • value: boolean

      True to show the toolbar

    Returns void

Methods

  • Gets a setting value.

    Returns the stored value or the default value if not set.

    Type Parameters

    • K extends string | number | symbol

      The setting key type

    Parameters

    • key: K

      The setting key to retrieve

    Returns NonNullable<AcApSettings & T>[K]

    The setting value

    const isDebug = settings.get('isDebug');
    const fontMapping = settings.get('fontMapping');
  • Sets a setting value and persists it to localStorage.

    Fires a modified event after the setting is saved.

    Type Parameters

    • K extends string | number | symbol

      The setting key type

    Parameters

    • key: K

      The setting key to modify

    • value: T[K]

      The new value for the setting

    Returns void

    settings.set('isShowToolbar', false);
    settings.set('fontMapping', { 'Arial': 'Helvetica' });
  • Sets a single font mapping entry.

    Parameters

    • originalFont: string

      The original font name

    • mappedFont: string

      The replacement font name

    Returns void

  • Toggles a boolean setting value.

    Only works with boolean settings. The caller should ensure the setting is boolean.

    Type Parameters

    • K extends string | number | symbol

      The setting key type

    Parameters

    • key: K

      The boolean setting key to toggle

    Returns void

    settings.toggle('isDebug');        // false -> true
    settings.toggle('isShowToolbar'); // true -> false