-
Notifications
You must be signed in to change notification settings - Fork 2
feat(component_color): add component color for model_components #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
46fcfaf
feat(component_color): add component color for model_components
MaxNumerique 3066c15
Apply prepare changes
MaxNumerique fd13558
color options feature via context menu
MaxNumerique d0859af
new icon
MaxNumerique 75a97c7
implementation with MESH_TYPES
MaxNumerique 9fd8cc8
save color state & rename component
MaxNumerique 26f6ded
feat(componentColor): add component color for model_components
MaxNumerique 848b8bb
getModelComponentColor
MaxNumerique 3f1dc88
refacto
MaxNumerique 61351e4
revert
MaxNumerique 76ace59
no more viewerStore.request
MaxNumerique 77e968a
no fallback
MaxNumerique 5239c9d
refacto and fix performance
MaxNumerique c2cf431
...dataStyleState
MaxNumerique 83b6bdf
useDataStyleStateStore to useDataStyleState
MaxNumerique 9083065
Merge branch 'feat/model_components_color' of https://github.com/Geod…
MaxNumerique e925a08
dataStyleStateStore to dataStyleState
MaxNumerique File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/components/Viewer/Generic/Model/ModelComponentsOptions.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <script setup> | ||
| import ModelColor from "@ogw_front/assets/viewer_svgs/model_component_color.svg"; | ||
| import ViewerContextMenuItem from "@ogw_front/components/Viewer/ContextMenuItem"; | ||
| import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/ColorPicker.vue"; | ||
|
|
||
| import { useDataStyleStore } from "@ogw_front/stores/data_style"; | ||
| import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer"; | ||
|
|
||
| const dataStyleStore = useDataStyleStore(); | ||
| const hybridViewerStore = useHybridViewerStore(); | ||
|
|
||
| const { itemProps } = defineProps({ | ||
| itemProps: { type: Object, required: true }, | ||
| }); | ||
|
|
||
| const modelId = computed(() => itemProps.meta_data.modelId); | ||
| const componentId = computed(() => itemProps.id); | ||
|
|
||
| const color = computed({ | ||
| get: () => dataStyleStore.getModelComponentColor(modelId.value, componentId.value), | ||
| set: async (newValue) => { | ||
| await dataStyleStore.setModelComponentsColor(modelId.value, [componentId.value], newValue); | ||
| hybridViewerStore.remoteRender(); | ||
| }, | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <ViewerContextMenuItem :itemProps="itemProps" tooltip="Components color" :btn_image="ModelColor"> | ||
| <template #options> | ||
| <v-row class="pa-0" align="center"> | ||
| <v-col> | ||
| <ViewerOptionsColorPicker v-model="color" /> | ||
| </v-col> | ||
| </v-row> | ||
| </template> | ||
| </ViewerContextMenuItem> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,96 +1,92 @@ | ||
| import { database } from "@ogw_internal/database/database.js"; | ||
| import { getDefaultStyle } from "@ogw_front/utils/default_styles"; | ||
| import { useDataStore } from "@ogw_front/stores/data"; | ||
| import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state"; | ||
| import { useDataStyleState } from "@ogw_internal/stores/data_style/state"; | ||
| import { useMeshStyle } from "@ogw_internal/stores/data_style/mesh/index"; | ||
| import { useModelStyle } from "@ogw_internal/stores/data_style/model/index"; | ||
|
|
||
| export const useDataStyleStore = defineStore("dataStyle", () => { | ||
| const dataStyleState = useDataStyleStateStore(); | ||
| const dataStyleState = useDataStyleState(); | ||
| const meshStyleStore = useMeshStyle(); | ||
| const modelStyleStore = useModelStyle(); | ||
| const dataStore = useDataStore(); | ||
|
|
||
| async function addDataStyle(id, geode_object) { | ||
| await database.data_style.put(structuredClone({ id, ...getDefaultStyle(geode_object) })); | ||
| } | ||
|
|
||
| async function setVisibility(id, visibility) { | ||
| const item = await dataStore.item(id); | ||
| const { viewer_type } = item; | ||
|
|
||
| if (viewer_type === "mesh") { | ||
| return meshStyleStore.setMeshVisibility(id, visibility); | ||
| } | ||
| if (viewer_type === "model") { | ||
| return modelStyleStore.setModelVisibility(id, visibility); | ||
| } | ||
| throw new Error("Unknown viewer_type"); | ||
| } | ||
|
|
||
| async function applyDefaultStyle(id) { | ||
| const item = await dataStore.item(id); | ||
| const { viewer_type } = item; | ||
|
|
||
| if (viewer_type === "mesh") { | ||
| return meshStyleStore.applyMeshStyle(id); | ||
| } | ||
| if (viewer_type === "model") { | ||
| return modelStyleStore.applyModelStyle(id); | ||
| } | ||
| throw new Error(`Unknown viewer_type: ${viewer_type}`); | ||
| } | ||
|
|
||
| function exportStores() { | ||
| return { | ||
| styles: dataStyleState.styles, | ||
| componentStyles: dataStyleState.componentStyles, | ||
| }; | ||
| } | ||
|
|
||
| async function importStores(snapshot) { | ||
| const stylesSnapshot = snapshot.styles; | ||
| const componentStylesSnapshot = snapshot.componentStyles; | ||
|
|
||
| await dataStyleState.clear(); | ||
|
|
||
| const style_promises = Object.entries(stylesSnapshot).map(([id, style]) => | ||
| database.data_style.put(structuredClone({ id, ...style })), | ||
| ); | ||
| const component_style_promises = Object.values(componentStylesSnapshot).map((style) => | ||
| database.model_component_datastyle.put(structuredClone(style)), | ||
| ); | ||
|
|
||
| await Promise.all([...style_promises, ...component_style_promises]); | ||
| } | ||
|
|
||
| function applyAllStylesFromState() { | ||
| const ids = Object.keys(dataStyleState.styles); | ||
| const promises = ids.map(async (id) => { | ||
| const meta = await dataStore.item(id); | ||
| const viewerType = meta.viewer_type; | ||
| if (viewerType === "mesh") { | ||
| return meshStyleStore.applyMeshStyle(id); | ||
| } else if (viewerType === "model") { | ||
| return modelStyleStore.applyModelStyle(id); | ||
| } | ||
| }); | ||
| return Promise.all(promises); | ||
| } | ||
|
|
||
| return { | ||
| styles: dataStyleState.styles, | ||
| getStyle: dataStyleState.getStyle, | ||
| objectVisibility: dataStyleState.objectVisibility, | ||
| selectedObjects: dataStyleState.selectedObjects, | ||
| ...meshStyleStore, | ||
| ...modelStyleStore, | ||
| setComponentsVisibility: modelStyleStore.setModelComponentsVisibility, | ||
| addDataStyle, | ||
| applyDefaultStyle, | ||
| setVisibility, | ||
| exportStores, | ||
| importStores, | ||
| applyAllStylesFromState, | ||
| ...dataStyleState, | ||
| ...meshStyleStore, | ||
| ...modelStyleStore, | ||
| }; | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.