Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public overrideSubCategory(id: Id64String, app: Appearance, replaceExisting: boolean = true): void {
// NB: We used to do nothing if this.isSubCategoryVisible() => false but now models can turn invisible subcategories visible in their own context.
const idLo = Id64.getLowerUint32(id);
const idHi = Id64.getUpperUint32(id);
// NB: Appearance may specify no overridden symbology - this means "don't apply the default overrides to this subcategory"
if (replaceExisting || undefined === this.getSubCategoryOverrides(idLo, idHi))
this._subCategoryOverrides.set(idLo, idHi, app);
}
public async saveThumbnail(viewId: Id64String, thumbnail: ThumbnailProps): Promise {
const val = new Uint8Array(thumbnail.image.length + 24); // include the viewId and metadata in the binary transfer by allocating a new buffer 24 bytes larger than the image size
new Uint32Array(val.buffer, 0, 4).set([thumbnail.image.length, thumbnail.format === "jpeg" ? ImageSourceFormat.Jpeg : ImageSourceFormat.Png, thumbnail.width, thumbnail.height]); // metadata at offset 0
const low32 = Id64.getLowerUint32(viewId);
const high32 = Id64.getUpperUint32(viewId);
new Uint32Array(val.buffer, 16, 2).set([low32, high32]); // viewId is 8 bytes starting at offset 16
val.set(thumbnail.image, 24); // image data at offset 24
return IModelWriteRpcInterface.getClient().saveThumbnail(this._iModel.iModelToken.toJSON(), val);
}
}
case VariableValueTypes.Id64Array: return (actualValue as string[]).map((id) => Id64.getUpperUint32(id));
default: return undefined;
private changeValueType(actualValue: VariableValue, fromType: VariableValueTypes, toType: VariableValueTypes): VariableValue | undefined {
switch (toType) {
case VariableValueTypes.Bool:
switch (fromType) {
case VariableValueTypes.Int: return (0 !== actualValue);
case VariableValueTypes.Id64: return Id64.isValidId64(actualValue as string);
default: return undefined;
}
case VariableValueTypes.Int:
switch (fromType) {
case VariableValueTypes.Bool: return actualValue ? 1 : 0;
case VariableValueTypes.Id64: return Id64.getUpperUint32(actualValue as string);
default: return undefined;
}
case VariableValueTypes.IntArray:
switch (fromType) {
case VariableValueTypes.Id64Array: return (actualValue as string[]).map((id) => Id64.getUpperUint32(id));
default: return undefined;
}
case VariableValueTypes.Id64:
switch (fromType) {
case VariableValueTypes.Bool: return Id64.fromLocalAndBriefcaseIds(actualValue ? 1 : 0, 0);
case VariableValueTypes.Int: return Id64.fromLocalAndBriefcaseIds(actualValue as number, 0);
default: return undefined;
}
case VariableValueTypes.Id64Array:
switch (fromType) {
case VariableValueTypes.IntArray: return (actualValue as number[]).map((int) => Id64.fromLocalAndBriefcaseIds(int, 0));
});
this._constructions = constructions;
this._dimensions = dimensions;
this._patterns = patterns;
this._lineWeights = viewFlags.weights;
for (const categoryId of view.categorySelector.categories) {
const subCategoryIds = view.iModel.subcategories.getSubCategories(categoryId);
if (undefined === subCategoryIds)
continue;
for (const subCategoryId of subCategoryIds) {
if (view.isSubCategoryVisible(subCategoryId)) {
const idLo = Id64.getLowerUint32(subCategoryId);
const idHi = Id64.getUpperUint32(subCategoryId);
this._visibleSubCategories.add(idLo, idHi);
}
}
}
}
public getElementOverridesById(id: Id64String): Appearance | undefined { return this.getElementOverrides(Id64.getLowerUint32(id), Id64.getUpperUint32(id), 0); }
/** Returns the overrides applied to geometry belonging to the specified subcategory, if any such are defined. */