Feature: Named views (#5532)
* feature: building skeleton for adding a viewpoint in frontend as well as rust with the settings toml * chore: named views loaded into memory * fix: testing code * chore: saving off progress, skeleton for listing and deleting named views * fix: fixed state stale dereferencing issue * feat: initial skeleton for loading view points * fix: pushing bug * fix: saving off progress * fix: trying to update to main? * fix: main fixes, API fixes * fix: what is happening * fix: ope * fix: implemented default values on serde * fix: pushing working dev code... need to clean it up * feature: adding no results found on filteroptions within an options input, not just command input bar level * fix: initial PR cleanup pass of junky code * fix: addressing comments in initial pass * fix: addressing PR comments * fix: moved modeling.namedViews to app.namedViews as per request * fix: _id and _version are now id and version. * fix: python codespell, perspective * fix: cargo fmt * fix: updating description of the named view commands * fix: removing testing code * fix: feature flag this to DEV only * fix: ts ignore for production engine api * fix: deep parital fights arrays and objects within settings, doing a namedview type predicate checking * fix: auto fixes * Remove unnecessary alias * Reword toast messages (more consistency) * fmt * cargo clippy * Fix Set appearance flakes * cargo test * fix: removing pub since the toml_stringify was refactored * fix: adding ignore this on user level * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * chore: Vec<NamedView> to HashMap<uuid::Uuid,NamedView> * fix: removing debugging code * chore: HashMap to IndexMap * fix: remove testing code --------- Co-authored-by: 49lf <ircsurfer33@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -20,6 +20,7 @@ import { isArray, toSync } from 'lib/utils'
|
||||
import { reportRejection } from 'lib/trap'
|
||||
import { CameraProjectionType } from 'wasm-lib/kcl/bindings/CameraProjectionType'
|
||||
import { OnboardingStatus } from 'wasm-lib/kcl/bindings/OnboardingStatus'
|
||||
import { NamedView } from 'wasm-lib/kcl/bindings/NamedView'
|
||||
import { CameraOrbitType } from 'wasm-lib/kcl/bindings/CameraOrbitType'
|
||||
|
||||
/**
|
||||
@ -263,6 +264,11 @@ export function createSettings() {
|
||||
)
|
||||
},
|
||||
}),
|
||||
namedViews: new Setting<{ [key in string]: NamedView }>({
|
||||
defaultValue: {},
|
||||
validate: (v) => true,
|
||||
hideOnLevel: 'user',
|
||||
}),
|
||||
},
|
||||
/**
|
||||
* Settings that affect the behavior while modeling.
|
||||
|
@ -23,6 +23,7 @@ import { err } from 'lib/trap'
|
||||
import { DeepPartial } from 'lib/types'
|
||||
import { Configuration } from 'wasm-lib/kcl/bindings/Configuration'
|
||||
import { ProjectConfiguration } from 'wasm-lib/kcl/bindings/ProjectConfiguration'
|
||||
import { NamedView } from 'wasm-lib/kcl/bindings/NamedView'
|
||||
import { SaveSettingsPayload, SettingsLevel } from './settingsTypes'
|
||||
|
||||
/**
|
||||
@ -72,6 +73,43 @@ export function configurationToSettingsPayload(
|
||||
}
|
||||
}
|
||||
|
||||
export function isNamedView(
|
||||
namedView: DeepPartial<NamedView> | undefined
|
||||
): namedView is NamedView {
|
||||
const namedViewKeys = [
|
||||
'name',
|
||||
'eye_offset',
|
||||
'fov_y',
|
||||
'ortho_scale_enabled',
|
||||
'ortho_scale_factor',
|
||||
'pivot_position',
|
||||
'pivot_rotation',
|
||||
'world_coord_system',
|
||||
'version',
|
||||
] as const
|
||||
|
||||
return namedViewKeys.every((key) => {
|
||||
return namedView && namedView[key]
|
||||
})
|
||||
}
|
||||
|
||||
function deepPartialNamedViewsToNamedViews(
|
||||
maybeViews: { [key: string]: NamedView | undefined } | undefined
|
||||
): { [key: string]: NamedView } {
|
||||
const namedViews: { [key: string]: NamedView } = {}
|
||||
|
||||
if (!maybeViews) {
|
||||
return namedViews
|
||||
}
|
||||
|
||||
Object.entries(maybeViews)?.forEach(([key, maybeView]) => {
|
||||
if (isNamedView(maybeView)) {
|
||||
namedViews[key] = maybeView
|
||||
}
|
||||
})
|
||||
return namedViews
|
||||
}
|
||||
|
||||
export function projectConfigurationToSettingsPayload(
|
||||
configuration: DeepPartial<ProjectConfiguration>
|
||||
): DeepPartial<SaveSettingsPayload> {
|
||||
@ -87,6 +125,9 @@ export function projectConfigurationToSettingsPayload(
|
||||
allowOrbitInSketchMode:
|
||||
configuration?.settings?.app?.allow_orbit_in_sketch_mode,
|
||||
enableSSAO: configuration?.settings?.modeling?.enable_ssao,
|
||||
namedViews: deepPartialNamedViewsToNamedViews(
|
||||
configuration?.settings?.app?.named_views
|
||||
),
|
||||
},
|
||||
modeling: {
|
||||
defaultUnit: configuration?.settings?.modeling?.base_unit,
|
||||
|
Reference in New Issue
Block a user