/** @packageDocumentation * @module Rendering */ import { Id64, Id64String } from "@bentley/bentleyjs-core"; import { BatchType, Feature } from "./FeatureTable"; import { ColorDef } from "./ColorDef"; import { GeometryClass } from "./GeometryParams"; import { LinePixels } from "./LinePixels"; import { RgbColor, RgbColorProps } from "./RgbColor"; import { SubCategoryOverride } from "./SubCategoryOverride"; /** Properties used to initialize a [[FeatureAppearance]]. * @public */ export interface FeatureAppearanceProps { /** The color of the Feature */ rgb?: RgbColorProps; /** The line weight in pixels as an integer in [1, 31] */ weight?: number; /** The transparency in the range [0.0, 1.0] where 0 indicates fully opaque and 1 indicates fully transparent. */ transparency?: number; /** The pixel pattern used to draw lines. */ linePixels?: LinePixels; /** If true, ignore the [[RenderMaterial]] associated with surfaces. */ ignoresMaterial?: true | undefined; /** If true, the associated [[Feature]] will not be drawn when using [Viewport.readPixels]($frontend). */ nonLocatable?: true | undefined; /** If true, the associated [[Feature]] will be emphasized. Emphasized features are rendered using the [[Hilite.Settings]] defined by [Viewport.emphasisSettings]($frontend). */ emphasized?: true | undefined; } /** Defines overrides for selected aspects of a [[Feature]]'s symbology. * Any member defined in the appearance overrides that aspect of symbology for all [[Feature]]s to which the appearance is applied. * @see [[FeatureOverrides]] to customize the appearance of multiple features. * @public */ export declare class FeatureAppearance implements FeatureAppearanceProps { readonly rgb?: RgbColor; readonly weight?: number; readonly transparency?: number; readonly linePixels?: LinePixels; readonly ignoresMaterial?: true | undefined; readonly nonLocatable?: true | undefined; readonly emphasized?: true | undefined; /** An appearance that overrides nothing. */ static readonly defaults: FeatureAppearance; static fromJSON(props?: FeatureAppearanceProps): FeatureAppearance; /** Create a FeatureAppearance that overrides only the RGB color. * @note The transparency component of the ColorDef is ignored. */ static fromRgb(color: ColorDef): FeatureAppearance; /** Create a FeatureAppearance that overrides the RGB and transparency. * The appearance's transparency is derived from the transparency component of the ColorDef. */ static fromRgba(color: ColorDef): FeatureAppearance; /** Create a FeatureAppearance that overrides only the transparency */ static fromTransparency(transparencyValue: number): FeatureAppearance; /** Create a FeatureAppearance with overrides corresponding to those defined by the supplied SubCategoryOverride. */ static fromSubCategoryOverride(ovr: SubCategoryOverride): FeatureAppearance; /** Returns true if this appearance does not override any aspects of symbology. */ get matchesDefaults(): boolean; get overridesRgb(): boolean; get overridesTransparency(): boolean; get overridesLinePixels(): boolean; get overridesWeight(): boolean; get overridesSymbology(): boolean; get overridesNonLocatable(): boolean; get isFullyTransparent(): boolean; /** Returns true if any aspect of the appearance is overridden (i.e., if any member is not undefined). */ get anyOverridden(): boolean; equals(other: FeatureAppearance): boolean; toJSON(): FeatureAppearanceProps; /** Convert this appearance to JSON, and override any properties explicitly specified by `changedProps` in the result. * Example: * ```ts * const base = FeatureAppearance.fromRgba(ColorDef.white); // transparency=0, rgb=white * const clone = base.cloneProps({ transparency: undefined, weight: 5 }); // transparency=undefined, rgb=white, weight=5 * ``` * @see [[FeatureAppearance.clone]]. */ cloneProps(changedProps: FeatureAppearanceProps): FeatureAppearanceProps; /** Create a copy of this appearance, overriding any properties explicitly specified by `changedProps`. * Example: * ```ts * const base = FeatureAppearance.fromRgba(ColorDef.white); // transparency=0, rgb=white * const clone = base.clone({ transparency: undefined, weight: 5 }); // transparency=undefined, rgb=white, weight=5 * ``` * @see [[FeatureAppearance.cloneProps]]. */ clone(changedProps: FeatureAppearanceProps): FeatureAppearance; /** Produce a FeatureAppearance from the supplied appearance in which any aspect not defined by the base appearance is overridden by this appearance. */ extendAppearance(base: FeatureAppearance): FeatureAppearance; protected constructor(props: FeatureAppearanceProps); private rgbIsEqual; } /** Interface adopted by an object that can supply a [[FeatureAppearance]] given a low-level description of a [[Feature]]. * @see [[FeatureOverrides]] for the commonly-used implementation. * @see [[FeatureAppearanceProvider]] to supplement the appearance supplied by this interface. * @public */ export interface FeatureAppearanceSource { /** Supplies the desired appearance overrides for the specified [[Feature]], or `undefined` if the feature should not be drawn. * The feature is described by its components for efficiency reasons. * @param elemLo The lower 32 bits of the feature's element Id. * @param elemHi The upper 32 bits of the feature's element Id. * @param subcatLo The lower 32 bits of the feature's subcategory Id. * @param subcatHi The upper 32 bits of the feature's subcategory Id. * @param geomClass The geometry class of the feature. * @param modelLo The lower 32 bits of the feature's model Id. * @param modelHi The upper 32 bits of the feature's model Id. * @param type The type of batch to which the feature belongs. * @param animationNodeId The Id of the corresponding node in the [[RenderSchedule]], or `0` if none. * @returns The desired appearance overrides, or `undefined` to indicate the feature should not be displayed. * @see [Id64.isValidUint32Pair]($bentleyjs-core) to determine if the components of an [Id64String]($bentleyjs-core) represent a valid Id. */ getAppearance(elemLo: number, elemHi: number, subcatLo: number, subcatHi: number, geomClass: GeometryClass, modelLo: number, modelHi: number, type: BatchType, animationNodeId: number): FeatureAppearance | undefined; } /** Specifies how to customize the appearance of individual [[Feature]]s, typically within the context of a [Viewport]($frontend). * Individual aspects of a feature's appearance - like visibility, color, and transparency - are overridden by supplying a [[FeatureAppearance]]. * Those overrides can be specified on the basis of the feature's model, element, and/or subcategory. A default set of overrides can also be specified to * apply to the appearance of any feature not otherwise overridden. * * It is possible to override multiple aspects of a feature on different bases. For example, you might specify that all features belonging to subcategory "A" should be drawn in red, * and that all features belonging to model "B" should be drawn 50% transparent. In this case, a feature belonging to both subcategory "A" and model "B" will be drawn as 50% transparent red - * the separate overrides are combined to produce the feature's overall appearance. * * In the case of conflicts, there is an order of precedence: * - Model overrides take highest precedence. * - Element overrides are of higher precedence than subcategory overrides. * - Subcategory overrides have lowest precedence. * * For example, you might specify that all features belonging to subcategory "A" should be drawn in red, and all those belonging to model "B" should be drawn in green. * Then a feature belonging to subcategory "A" and model "B" will be drawn in green, because the model overrides take precedence. * * Instances of this class are not typically instantiated by an application directly; instead, an application can implement a [FeatureOverrideProvider]($frontend) * that augments the overrides supplied by a viewport. * * @see [FeatureSymbology.Overrides]($frontend) to create overrides specific to a [Viewport]($frontend) or [ViewState]($frontend). * @see [FeatureOverrideProvider]($frontend) to customize the appearance of features within a [Viewport]($frontend). * @public */ export declare class FeatureOverrides implements FeatureAppearanceSource { /** Ids of elements that should never be drawn. This takes precedence over [[alwaysDrawn]]. @internal */ protected readonly _neverDrawn: Id64.Uint32Set; /** Ids of elements that should always be drawn. [[neverDrawn]] takes precedence over this set. @internal */ protected readonly _alwaysDrawn: Id64.Uint32Set; /** If true, no elements *except* those defined in the "always drawn" set will be drawn. * @see [[setAlwaysDrawn]] */ isAlwaysDrawnExclusive: boolean; /** If true, the always-drawn elements are drawn even if their subcategories are not visible. * @see [[setAlwaysDrawn]] */ alwaysDrawnIgnoresSubCategory: boolean; /** If true, all subcategories are considered visible. This is used for drawing sheets via section callouts in the absence of an actual sheet view. * @internal */ ignoreSubCategory: boolean; /** Overrides applied to any feature not explicitly overridden. @internal */ protected _defaultOverrides: FeatureAppearance; /** Whether construction geometry should be drawn. @internal */ protected _constructions: boolean; /** Whether dimensions should be drawn. @internal */ protected _dimensions: boolean; /** Whether area patterns should be drawn. @internal */ protected _patterns: boolean; /** Whether line weights should be applied. If false, all lines are rendered 1-pixel wide. @internal */ protected _lineWeights: boolean; /** Overrides applied to all elements belonging to each model. @internal */ protected readonly _modelOverrides: Id64.Uint32Map; /** Overrides applied to specific elements. @internal */ protected readonly _elementOverrides: Id64.Uint32Map; /** Overrides applied to geometry belonging to each subcategory. @internal */ protected readonly _subCategoryOverrides: Id64.Uint32Map; /** The set of displayed subcategories. Geometry belonging to subcategories not included in this set will not be drawn. @internal */ protected readonly _visibleSubCategories: Id64.Uint32Set; /** Display priorities assigned to subcategories, possibly overridden by display style. Only applicable for plan projection models. @internal */ protected readonly _subCategoryPriorities: Id64.Uint32Map; /** Per-model, a set of subcategories whose visibility should be inverted for elements within that model. * Populated by Viewport. * @internal */ protected readonly _modelSubCategoryOverrides: Id64.Uint32Map; /** Ids of animation nodes that should never be drawn. * @internal */ readonly neverDrawnAnimationNodes: Set; /** Mapping of animation node Ids to overrides applied to the corresponding animation nodes. * @internal */ readonly animationNodeOverrides: Map; /** Overrides applied to features for which no other overrides are defined */ get defaultOverrides(): FeatureAppearance; /** Whether or not line weights are applied. If false, all lines are drawn with a weight of 1. */ get lineWeights(): boolean; /** @internal */ get neverDrawn(): Id64.Uint32Set; /** @internal */ get alwaysDrawn(): Id64.Uint32Set; /** @internal */ protected isNeverDrawn(elemIdLo: number, elemIdHi: number, animationNodeId: number): boolean; /** @internal */ protected isAlwaysDrawn(idLo: number, idHi: number): boolean; /** Returns true if the [SubCategory]($backend) specified by Id is in the set of visible subcategories. @internal */ isSubCategoryVisible(idLo: number, idHi: number): boolean; /** @internal */ isSubCategoryVisibleInModel(subcatLo: number, subcatHi: number, modelLo: number, modelHi: number): boolean; /** @internal */ protected getModelOverrides(idLo: number, idHi: number): FeatureAppearance | undefined; /** @internal */ protected getElementOverrides(idLo: number, idHi: number, animationNodeId: number): FeatureAppearance | undefined; /** @internal */ protected getSubCategoryOverrides(idLo: number, idHi: number): FeatureAppearance | undefined; /** Add a [SubCategory]($backend) to the set of visible subcategories. */ setVisibleSubCategory(id: Id64String): void; /** Specify the Id of an element that should never be drawn. */ setNeverDrawn(id: Id64String): void; /** Specify the Id of an element that should always be drawn. */ setAlwaysDrawn(id: Id64String): void; /** Specify the Id of a animation node that should never be drawn. */ setAnimationNodeNeverDrawn(id: number): void; /** Specify the Ids of elements that should never be drawn. */ setNeverDrawnSet(ids: Iterable): void; /** Specify the Ids of elements that should always be drawn. */ setAlwaysDrawnSet(ids: Iterable, exclusive: boolean, ignoreSubCategory?: boolean): void; /** Returns the feature's appearance overrides, or undefined if the feature is not visible. */ getFeatureAppearance(feature: Feature, modelId: Id64String, type?: BatchType, animationNodeId?: number): FeatureAppearance | undefined; private static readonly _weight1Appearance; /** Returns a feature's appearance overrides, or undefined if the feature is not visible. * Takes Id64s as pairs of unsigned 32-bit integers for efficiency, because that is how they are stored by the PackedFeatureTable associated with each batch of graphics. * @see [[getFeatureAppearance]] for an equivalent function that accepts [Id64String]($bentleyjs-core)s instead of integer pairs. */ getAppearance(elemLo: number, elemHi: number, subcatLo: number, subcatHi: number, geomClass: GeometryClass, modelLo: number, modelHi: number, type: BatchType, animationNodeId: number): FeatureAppearance | undefined; /** Classifiers behave totally differently...in particular they are never invisible unless fully-transparent. * @internal */ protected getClassifierAppearance(elemLo: number, elemHi: number, subcatLo: number, subcatHi: number, modelLo: number, modelHi: number, animationNodeId: number): FeatureAppearance | undefined; /** Return whether geometry of the specified class should be drawn. * @see [[ViewFlags.constructions]], [[ViewFlags.dimensions]], and [[ViewFlags.patterns]]. */ isClassVisible(geomClass: GeometryClass): boolean; /** Specify overrides for all elements within the specified model. * @param id The Id of the model. * @param app The symbology overrides. * @param replaceExisting Specifies whether to replace a pre-existing override for the same model. * @note These overrides take priority over all other overrides. * @note If [[defaultOverrides]] are defined, they will not apply to any element within this model, even if the supplied appearance overrides nothing. */ overrideModel(id: Id64String, app: FeatureAppearance, replaceExisting?: boolean): void; /** Specify overrides for all geometry belonging to the specified [SubCategory]($backend). * @param id The Id of the subcategory. * @param app The symbology overrides. * @param replaceExisting Specifies whether to replace a pre-existing override for the same subcategory. * @note These overrides have lower priority than element and model overrides. * @note If [[defaultOverrides]] are defined, they will not apply to any geometry within this subcategory, even if the supplied appearance overrides nothing. */ overrideSubCategory(id: Id64String, app: FeatureAppearance, replaceExisting?: boolean): void; /** Specify overrides for all geometry originating from the specified element. * @param id The Id of the element. * @param app The symbology overrides. * @param replaceExisting Specifies whether to replace a pre-existing override for the same element. * @note These overrides take precedence over subcategory overrides, but not over model overrides. * @note If [[defaultOverrides]] are defined, they will not apply to this element, even if the supplied appearance overrides nothing. */ overrideElement(id: Id64String, app: FeatureAppearance, replaceExisting?: boolean): void; /** Specify overrides for all geometry originating from the specified animation node. * @param id The Id of the animation node. * @param app The symbology overrides. * @note These overrides do not take precedence over element overrides. */ overrideAnimationNode(id: number, app: FeatureAppearance): void; /** Defines a default appearance to be applied to any [[Feature]] *not* explicitly overridden. * @param appearance The symbology overrides. * @param replaceExisting Specifies whether to replace the current default overrides if they are already defined. */ setDefaultOverrides(appearance: FeatureAppearance, replaceExisting?: boolean): void; /** Get the display priority of a subcategory. This is only relevant when using [[PlanProjectionSettings]]. * @internal */ getSubCategoryPriority(idLo: number, idHi: number): number; /** Construct a new Overrides that overrides nothing. * @see [FeatureSymbology.Overrides]($frontend) to construct overrides based on a [ViewState]($frontend) or [Viewport]($frontend). */ constructor(); /** Returns true if geometry belonging to the specified subcategory will be drawn. */ isSubCategoryIdVisible(id: Id64String): boolean; /** Returns the overrides applied to geometry belonging to the specified model, if any such are defined. */ getModelOverridesById(id: Id64String): FeatureAppearance | undefined; /** Returns the overrides applied to geometry belonging to the specified element, if any such are defined. */ getElementOverridesById(id: Id64String): FeatureAppearance | undefined; /** Returns the overrides applied to geometry belonging to the specified subcategory, if any such are defined. */ getSubCategoryOverridesById(id: Id64String): FeatureAppearance | undefined; /** Returns true if the specified Feature will be drawn. */ isFeatureVisible(feature: Feature): boolean; } /** Interface adopted by an object that can supply the [[FeatureAppearance]] supplied by a [[FeatureAppearanceSource]]. * This is useful for selectively overriding or agumenting a [Viewport]($frontend)'s symbology overrides. * A typical implementation will invoke [[FeatureAppearanceSource.getAppeaprance]] and customize the returned appearance. * @see [[FeatureAppearanceProvider.chain]] to chain two providers together. * @public */ export interface FeatureAppearanceProvider { /** Supply the desired appearance overrides for the specified [[Feature]], or `undefined` if the feature should not be drawn. * The feature is described by its components for efficiency reasons. * @param source The base symbology overrides, e.g., typically defined by a [Viewport]($frontend). * @param elemLo The lower 32 bits of the feature's element Id. * @param elemHi The upper 32 bits of the feature's element Id. * @param subcatLo The lower 32 bits of the feature's subcategory Id. * @param subcatHi The upper 32 bits of the feature's subcategory Id. * @param geomClass The geometry class of the feature. * @param modelLo The lower 32 bits of the feature's model Id. * @param modelHi The upper 32 bits of the feature's model Id. * @param type The type of batch to which the feature belongs. * @param animationNodeId The Id of the corresponding node in the [[RenderSchedule]], or `0` if none. * @returns The desired appearance overrides, or `undefined` to indicate the feature should not be displayed. * @see [[FeatureAppearanceSource.getAppearance]] to forward the request to the source. * @see [Id64.isValidUint32Pair]($bentleyjs-core) to determine if the components of an [Id64String]($bentleyjs-core) represent a valid Id. */ getFeatureAppearance(source: FeatureAppearanceSource, elemLo: number, elemHi: number, subcatLo: number, subcatHi: number, geomClass: GeometryClass, modelLo: number, modelHi: number, type: BatchType, animationNodeId: number): FeatureAppearance | undefined; } /** @public */ export declare namespace FeatureAppearanceProvider { /** Create a provider that obtains each feature's appearance from the source, and if the feature is visible, modifies the appearance. * @param supplementAppearance A function accepting the feature's base appearance and returning a supplemental appearance. * @public */ function supplement(supplementAppearance: (appearance: FeatureAppearance) => FeatureAppearance): FeatureAppearanceProvider; /** Chain two FeatureAppearanceProviders together such that `first`'s `getFeatureAppearance` function is applied before `second`'s. * If `second` invokes `source.getAppearance()`, the returned appearance will include any modifications applied by `first`. * @public */ function chain(first: FeatureAppearanceProvider, second: FeatureAppearanceProvider): FeatureAppearanceProvider; } //# sourceMappingURL=FeatureSymbology.d.ts.map