"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Views
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.MutableChangeFlags = exports.ChangeFlags = exports.ChangeFlag = void 0;
/** Bit masks describing which aspects of a [[Viewport]] have changed as part of a [[ChangeFlags]].
 * @see [[Viewport.onViewportChanged]].
 * @public
 */
var ChangeFlag;
(function (ChangeFlag) {
    /** No changes. */
    ChangeFlag[ChangeFlag["None"] = 0] = "None";
    /** See [[ChangeFlags.alwaysDrawn]]. */
    ChangeFlag[ChangeFlag["AlwaysDrawn"] = 1] = "AlwaysDrawn";
    /** See [[ChangeFlags.neverDrawn]]. */
    ChangeFlag[ChangeFlag["NeverDrawn"] = 2] = "NeverDrawn";
    /** See [[ChangeFlags.viewedCategories]]. */
    ChangeFlag[ChangeFlag["ViewedCategories"] = 4] = "ViewedCategories";
    /** See [[ChangeFlags.viewedModels]]. */
    ChangeFlag[ChangeFlag["ViewedModels"] = 8] = "ViewedModels";
    /** See [[ChangeFlags.displayStyle]]. */
    ChangeFlag[ChangeFlag["DisplayStyle"] = 16] = "DisplayStyle";
    /** See [[ChangeFlags.featureOverrideProvider]]. */
    ChangeFlag[ChangeFlag["FeatureOverrideProvider"] = 32] = "FeatureOverrideProvider";
    /** See [[ChangeFlags.viewedCategoriesPerModel]]. */
    ChangeFlag[ChangeFlag["ViewedCategoriesPerModel"] = 64] = "ViewedCategoriesPerModel";
    /** See [[ChangeFlags.viewState]]. */
    ChangeFlag[ChangeFlag["ViewState"] = 128] = "ViewState";
    /** A bitmask indicating all aspects of the viewport's state have changed. */
    ChangeFlag[ChangeFlag["All"] = 268435455] = "All";
    /** A bitmask indicating all aspects of the viewport's state related to symbology overrides have changed. */
    ChangeFlag[ChangeFlag["Overrides"] = 268435319] = "Overrides";
    /** A bitmask indicating the initial state of a newly-created [[Viewport]]. */
    ChangeFlag[ChangeFlag["Initial"] = 28] = "Initial";
})(ChangeFlag || (exports.ChangeFlag = ChangeFlag = {}));
/** Describes which aspects of a [[Viewport]] have changed. Each time [[Viewport.renderFrame]] is invoked, the aspects of the viewport that have changed since
 * the previous call to `renderFrame` are computed and dispatched via the [[Viewport.onViewportChanged]] event.
 * @public
 * @extensions
 */
class ChangeFlags {
    /** The bitmask that records the state of each individual flag. */
    _flags;
    /** Create a new ChangeFlags.
     * @param flags The initial flags that should be set.
     */
    constructor(flags = ChangeFlag.Initial) {
        this._flags = flags;
    }
    /** The set of always-drawn elements has changed.
     * @see [[Viewport.setAlwaysDrawn]] and [[Viewport.clearAlwaysDrawn]].
     */
    get alwaysDrawn() { return this.isSet(ChangeFlag.AlwaysDrawn); }
    /** The set of never-drawn elements has changed.
     * @see [[Viewport.setNeverDrawn]] and [[Viewport.clearNeverDrawn]].
     */
    get neverDrawn() { return this.isSet(ChangeFlag.NeverDrawn); }
    /** The set of displayed categories defined by the viewport's [[CategorySelectorState]] has changed. */
    get viewedCategories() { return this.isSet(ChangeFlag.ViewedCategories); }
    /** The set of models to be displayed in the viewport has changed. */
    get viewedModels() { return this.isSet(ChangeFlag.ViewedModels); }
    /** The [[DisplayStyleState]] or its settings such as [ViewFlags]($common) have changed. */
    get displayStyle() { return this.isSet(ChangeFlag.DisplayStyle); }
    /** The [[FeatureOverrideProvider]] has changed, or its internal state has changed such that its overrides must be recomputed.
     * @see [[Viewport.addFeatureOverrideProvider]] and [[Viewport.setFeatureOverrideProviderChanged]].
     */
    get featureOverrideProvider() { return this.isSet(ChangeFlag.FeatureOverrideProvider); }
    /** [[Vewport.changeView]] was used to replace the previous [[ViewState]] with a new one. */
    get viewState() { return this.isSet(ChangeFlag.ViewState); }
    /** The [[PerModelCategoryVisibility.Overrides]] associated with the viewport have changed.
     * @beta
     */
    get viewedCategoriesPerModel() { return this.isSet(ChangeFlag.ViewedCategoriesPerModel); }
    /** Returns true if any of the specified flags are set. */
    isSet(flags) { return 0 !== (this._flags & flags); }
    /** Returns true if all of the specified flags are set. */
    areAllSet(flags) { return flags === (this._flags & flags); }
    /** Returns true if any aspects affecting [[FeatureSymbology.Overrides]] have changed. */
    get areFeatureOverridesDirty() { return this.isSet(ChangeFlag.Overrides); }
    /** Returns true if any aspect at all has changed. */
    get hasChanges() { return this.isSet(ChangeFlag.All); }
    /** The underlying bitmask indicating the state of each individual flag. */
    get value() { return this._flags; }
}
exports.ChangeFlags = ChangeFlags;
/** A [[ChangeFlags]] that permits modifying the states of individual [[ChangeFlag]]s.
 * @public
 */
class MutableChangeFlags extends ChangeFlags {
    /** Create a new MutableChangeFlags.
     * @param flags The initial flags that should be set.
     */
    constructor(flags = ChangeFlag.Initial) {
        super(flags);
    }
    /** Set all of the specified flags. */
    set(flags) { this._flags |= flags; }
    setAlwaysDrawn() { this.set(ChangeFlag.AlwaysDrawn); }
    setNeverDrawn() { this.set(ChangeFlag.NeverDrawn); }
    setViewedCategories() { this.set(ChangeFlag.ViewedCategories); }
    setViewedModels() { this.set(ChangeFlag.ViewedModels); }
    setDisplayStyle() { this.set(ChangeFlag.DisplayStyle); }
    setFeatureOverrideProvider() { this.set(ChangeFlag.FeatureOverrideProvider); }
    setViewState() { this.set(ChangeFlag.ViewState); }
    setViewedCategoriesPerModel() { this.set(ChangeFlag.ViewedCategoriesPerModel); }
    /** Clear all of the specified flags. By default, clears all flags. */
    clear(flags = ChangeFlag.All) { this._flags &= ~flags; }
}
exports.MutableChangeFlags = MutableChangeFlags;
//# sourceMappingURL=ChangeFlags.js.map