Skip to content

Commit

Permalink
Revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hnn0003 committed Jun 12, 2024
1 parent 9326375 commit 488fa3d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

/** JSON representation of settings associated with a DisplayStyle3dProps. */
export interface DisplayStyle3dSettingsProps extends DisplayStyleSettingsProps {
Expand Down Expand Up @@ -152,6 +152,7 @@ export interface HemisphereLightsProps {
intensity?: number;
}


/**
* Wire format for the solar directional light associated with a {@linkcode LightSettingsProps}. The light is colored
* white and oriented in any direction in world coordinates. It will cast shadows if it is above the world XY plane and
Expand Down Expand Up @@ -372,6 +373,7 @@ export interface SpatialClassifierProps {
isActive?: boolean;
}


/** JSON representation of SpatialClassifierFlags. */
export interface SpatialClassifierFlagsProps {
inside: SpatialClassifierInsideDisplay;
Expand Down
117 changes: 48 additions & 69 deletions packages/saved-views-react/src/translation/displayStyleExtractor.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import type {
DisplayStyle3dProps,
DisplayStyleProps,
} from "@itwin/core-common";
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import type { DisplayStyle3dProps, DisplayStyleProps } from "@itwin/core-common";
import type { ViewState } from "@itwin/core-frontend";
import type {
DisplayStyle3dSettingsProps,
DisplayStyleSettingsProps,
ViewITwin2d,
ViewITwin3d,
DisplayStyle3dSettingsProps, DisplayStyleSettingsProps, ViewITwin2d, ViewITwin3d,
} from "@itwin/saved-views-client";

import type { LegacySavedView3d, LegacySavedView2d } from "./SavedViewTypes.js";
import {
applyExtraction,
extractArray,
extractArrayConditionally,
extractBoolean,
extractColor,
extractColorLegacy,
extractConditionally,
extractNumber,
extractNumberOrBool,
extractObject,
extractPlainTypedMap,
extractRGB,
extractSimpleArray,
extractString,
extractStringOrArray,
extractStringOrNumber,
extractStringOrNumberArray,
isAnyColorFormat,
simpleTypeOf,
type ExtractionFunc,
applyExtraction, extractArray, extractArrayConditionally, extractBoolean, extractColor, extractColorLegacy,
extractConditionally, extractNumber, extractNumberOrBool, extractObject, extractPlainTypedMap, extractRGB,
extractSimpleArray, extractString, extractStringOrArray, extractStringOrNumber, extractStringOrNumberArray,
isAnyColorFormat, simpleTypeOf, type ExtractionFunc,
} from "./extractionUtilities.js";

const viewFlagMappings: ExtractionFunc<void, void>[] = [
Expand Down Expand Up @@ -179,8 +157,10 @@ const displayStyleModelAppearanceMappings: ExtractionFunc<void, void>[] = [
extractString("modelId"),
];

const displayStyleModelAppearanceLegacyMappings: ExtractionFunc<void, void>[] =
[...featureAppearanceLegacyMappings, extractString("modelId")];
const displayStyleModelAppearanceLegacyMappings: ExtractionFunc<void, void>[] = [
...featureAppearanceLegacyMappings,
extractString("modelId"),
];

const contextRealityModelsMappings: ExtractionFunc<void, void>[] = [
extractObject(
Expand Down Expand Up @@ -404,20 +384,35 @@ const hiddenLineSettingsLegacyMappings: ExtractionFunc<void, void>[] = [
];

const keyColorPropsMappings: ExtractionFunc<void, void>[] = [
extractNumber("value"),
extractColor("color"),
];

const keyColorPropsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("value"),
extractColorLegacy("color"),
];

const thematicGradientSettingsPropsMappings: ExtractionFunc<void, void>[] = [
extractNumber("mode"),
extractNumber("stepCount"),
extractColorLegacy("marginColor"),
extractColor("marginColor"),
extractNumber("colorScheme"),
extractArray(keyColorPropsMappings, "customKeys"),
extractNumber("colorMix"),
extractNumber("transparencyMode"),
];

const thematicGradientSettingsPropsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("mode"),
extractNumber("stepCount"),
extractColorLegacy("marginColor"),
extractNumber("colorScheme"),
extractArray(keyColorPropsLegacyMappings, "customKeys"),
extractNumber("colorMix"),
extractNumber("transparencyMode"),
];

const thematicDisplaySensorPropsMappings: ExtractionFunc<void, void>[] = [
extractSimpleArray(simpleTypeOf("number"), "position"),
extractNumber("value"),
Expand All @@ -438,6 +433,15 @@ const thematicDisplaySettingsMappings: ExtractionFunc<void, void>[] = [
extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"),
];

const thematicDisplaySettingsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("displayMode"),
extractObject(thematicGradientSettingsPropsLegacyMappings, "gradientSettings"),
extractSimpleArray(simpleTypeOf("number"), "range"),
extractSimpleArray(simpleTypeOf("number"), "axis"),
extractSimpleArray(simpleTypeOf("number"), "sunDirection"),
extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"),
];

const cutStyleMappings: ExtractionFunc<void, void>[] = [
extractObject(viewFlagOverridesMapping, "viewflags"),
extractObject(hiddenLineSettingsMappings, "hiddenLine"),
Expand Down Expand Up @@ -514,26 +518,14 @@ const displayStylesLegacyMapping: ExtractionFunc<void, void>[] = [
extractNumber("monochromeMode"),
extractString("renderTimeline"),
extractNumber("timePoint"),
extractArray(
displayStyleSubCategoryLegacyMappings,
"subCategoryOvr",
"subCategoryOverrides",
),
extractArray(displayStyleSubCategoryLegacyMappings, "subCategoryOvr", "subCategoryOverrides"),
extractObject(backgroundMapMappings, "backgroundMap"),
extractArray(contextRealityModelsLegacyMappings, "contextRealityModels"),
extractStringOrArray("excludedElements"),
extractObject(mapImageryLegacyMapping, "mapImagery"),
extractArray(
displayStyleModelAppearanceLegacyMappings,
"modelOvr",
"modelOverrides",
),
extractArray(displayStyleModelAppearanceLegacyMappings, "modelOvr", "modelOverrides"),
extractObject(clipStyleLegacyMappings, "clipStyle"),
extractArray(
displayStylePlanarClipMaskMappings,
"planarClipOvr",
"planarClipOverrides",
),
extractArray(displayStylePlanarClipMaskMappings, "planarClipOvr", "planarClipOverrides"),
];

const environmentMappings: ExtractionFunc<void, void>[] = [
Expand Down Expand Up @@ -688,10 +680,7 @@ const lightsLegacyMappings: ExtractionFunc<void, void>[] = [
],
"hemisphere",
),
extractObject(
[extractColorLegacy("color"), extractNumber("intensity")],
"ambient",
),
extractObject([extractColorLegacy("color"), extractNumber("intensity")], "ambient"),
extractNumber("specularIntensity"),
extractNumber("numCels"),
extractObject(
Expand Down Expand Up @@ -728,12 +717,8 @@ const displayStyle3dLegacyMapping: ExtractionFunc<void, void>[] = [
extractObject(ambientOcclusionMappings, "ao", "ambientOcclusion"),
extractObject(solarShadowLegacyMappings, "solarShadows"),
extractObject(lightsLegacyMappings, "lights"),
extractPlainTypedMap(
planProjectionSettingsMappings,
simpleTypeOf("string"),
"planProjections",
),
extractObject(thematicDisplaySettingsMappings, "thematic"),
extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
extractObject(thematicDisplaySettingsLegacyMappings, "thematic"),
extractObject(hiddenLineSettingsLegacyMappings, "hline", "hiddenLine"),
];

Expand All @@ -752,8 +737,7 @@ export const extractDisplayStyle = (data: object, viewState?: ViewState) => {
applyExtraction(styles, output, displayStylesMapping);
}
if ("displayStyleProps" in data) {
styles = (data as LegacySavedView2d).displayStyleProps.jsonProperties
?.styles;
styles = (data as LegacySavedView2d).displayStyleProps.jsonProperties?.styles;
applyExtraction(styles, output, displayStylesLegacyMapping);
}
if (styles === undefined) {
Expand All @@ -765,9 +749,7 @@ export const extractDisplayStyle = (data: object, viewState?: ViewState) => {
return output;
};

export function extractDisplayStyle2dFromLegacy(
data: DisplayStyleProps,
): DisplayStyleSettingsProps {
export function extractDisplayStyle2dFromLegacy(data: DisplayStyleProps): DisplayStyleSettingsProps {
const styles = data.jsonProperties?.styles;
const output = {};
applyExtraction(styles, output, displayStyle3dLegacyMapping);
Expand All @@ -783,8 +765,7 @@ export const extractDisplayStyle3d = (data: object) => {
applyExtraction(styles, output, displayStyle3dMapping);
}
if ("displayStyleProps" in data) {
styles = (data as LegacySavedView3d).displayStyleProps.jsonProperties
?.styles;
styles = (data as LegacySavedView3d).displayStyleProps.jsonProperties?.styles;
applyExtraction(styles, output, displayStyle3dLegacyMapping);
}
if (styles === undefined) {
Expand All @@ -794,9 +775,7 @@ export const extractDisplayStyle3d = (data: object) => {
return output;
};

export function extractDisplayStyle3dFromLegacy(
data: DisplayStyle3dProps,
): DisplayStyle3dSettingsProps {
export function extractDisplayStyle3dFromLegacy(data: DisplayStyle3dProps): DisplayStyle3dSettingsProps {
const output = {} as DisplayStyle3dSettingsProps;
const styles = data.jsonProperties?.styles;
applyExtraction(styles, output, displayStyle3dLegacyMapping);
Expand Down

0 comments on commit 488fa3d

Please sign in to comment.