Integration updates

This commit is contained in:
AlexandruPopovici
2022-08-23 16:49:57 +03:00
parent 0e00cb67bf
commit 7a09ee7dfa
3 changed files with 51 additions and 49 deletions
@@ -9,8 +9,6 @@ import {
Viewer,
SelectionEvent,
PropertyInfo,
NumericPropertyInfo,
StringPropertyInfo,
FilteringState
} from '@speckle/viewer'
import emojis from '@/main/store/emojis'
@@ -223,10 +221,10 @@ export function setPreventCommentCollapse(shouldPrevent: boolean) {
// VIEWER
export function handleViewerSelection(selectionInfo: SelectionEvent) {
export async function handleViewerSelection(selectionInfo: SelectionEvent) {
if (!selectionInfo) {
updateState({ selectedObjects: [] })
getInitializedViewer().FilteringManager.resetSelection()
await getInitializedViewer().resetSelection()
return
}
@@ -239,38 +237,38 @@ export function handleViewerSelection(selectionInfo: SelectionEvent) {
state.selectedObjects = [selectionInfo.userData]
}
getInitializedViewer().FilteringManager.selectObjects(
getInitializedViewer().selectObjects(
state.selectedObjects.map((o) => o.id) as string[]
)
updateState(state)
}
export function clearSelectionDisplay() {
getInitializedViewer().FilteringManager.resetSelection()
export async function clearSelectionDisplay() {
await getInitializedViewer().resetSelection()
}
export function resetSelection() {
export async function resetSelection() {
updateState({ selectedObjects: [] })
getInitializedViewer().FilteringManager.resetSelection()
await getInitializedViewer().resetSelection()
}
export function highlightObjects(objectIds: string[]) {
getInitializedViewer().FilteringManager.highlightObjects(objectIds)
export async function highlightObjects(objectIds: string[]) {
await getInitializedViewer().highlightObjects(objectIds)
}
export function removeHighlights() {
export async function removeHighlights() {
// TODO
getInitializedViewer().FilteringManager.resetHighlight()
await getInitializedViewer().resetHighlight()
}
// FILTERING NEW
export function isolateObjects2(
export async function isolateObjects2(
objectIds: string[],
stateKey: string,
includeDescendants = false
) {
const result = getInitializedViewer().FilteringManager.isolateObjects(
const result = await getInitializedViewer().isolateObjects(
objectIds,
stateKey,
includeDescendants
@@ -279,12 +277,12 @@ export function isolateObjects2(
updateState({ currentFilterState: result })
}
export function unIsolateObjects2(
export async function unIsolateObjects2(
objectIds: string[],
stateKey: string,
includeDescendants = false
) {
const result = getInitializedViewer().FilteringManager.unIsolateObjects(
const result = await getInitializedViewer().unIsolateObjects(
objectIds,
stateKey,
includeDescendants
@@ -293,12 +291,12 @@ export function unIsolateObjects2(
console.log(result)
}
export function hideObjects2(
export async function hideObjects2(
objectIds: string[],
stateKey: string,
includeDescendants = false
) {
const result = getInitializedViewer().FilteringManager.hideObjects(
const result = await getInitializedViewer().hideObjects(
objectIds,
stateKey,
includeDescendants
@@ -307,12 +305,12 @@ export function hideObjects2(
console.log(result)
}
export function showObjects2(
export async function showObjects2(
objectIds: string[],
stateKey: string,
includeDescendants = false
) {
const result = getInitializedViewer().FilteringManager.showObjects(
const result = await getInitializedViewer().showObjects(
objectIds,
stateKey,
includeDescendants
@@ -323,8 +321,8 @@ export function showObjects2(
console.log(result)
}
export function setColorFilter(property: PropertyInfo) {
const result = getInitializedViewer().FilteringManager.setColorFilter(property)
export async function setColorFilter(property: PropertyInfo) {
const result = await getInitializedViewer().setColorFilter(property)
updateState({ currentFilterState: result })
console.log(result)
}
@@ -718,7 +716,7 @@ export async function setFilterDirectly(params: { filter: Filter }) {
}
}
export function resetFilter() {
export async function resetFilter() {
const viewer = getInitializedViewer()
resetInternalHideIsolateObjectState()
@@ -729,6 +727,6 @@ export function resetFilter() {
currentFilterState: null
})
viewer.FilteringManager.reset()
await viewer.reset()
viewer.applyFilter(null)
}
+4 -4
View File
@@ -106,22 +106,22 @@ export interface IViewer {
objectIds: string[],
stateKey?: string,
includeDescendants?
): Promise<void>
): Promise<FilteringState>
hideObjects(
objectIds: string[],
stateKey?: string,
includeDescendants?
): Promise<void>
): Promise<FilteringState>
isolateObjects(
objectIds: string[],
stateKey?: string,
includeDescendants?
): Promise<void>
): Promise<FilteringState>
unIsolateObjects(
objectIds: string[],
stateKey?: string,
includeDescendants?
): Promise<void>
): Promise<FilteringState>
selectObjects(objectIds: string[]): Promise<void>
resetSelection(): Promise<void>
+24 -20
View File
@@ -119,11 +119,11 @@ export class Viewer extends EventEmitter implements IViewer {
this.filteringManager = new FilteringManager(this.speckleRenderer)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(window as any).WT = WorldTree
// ;(window as any).WT = WorldTree
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(window as any).FM = this.filteringManager
// ;(window as any).FM = this.filteringManager
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(window as any).V = this
// ;(window as any).V = this
}
public getObjectProperties(resourceURL: string = null): PropertyInfo[] {
@@ -148,10 +148,11 @@ export class Viewer extends EventEmitter implements IViewer {
objectIds: string[],
stateKey: string = null,
includeDescendants = false
): Promise<void> {
return new Promise<void>((resolve) => {
this.filteringManager.hideObjects(objectIds, stateKey, includeDescendants)
resolve()
): Promise<FilteringState> {
return new Promise<FilteringState>((resolve) => {
resolve(
this.filteringManager.hideObjects(objectIds, stateKey, includeDescendants)
)
})
}
@@ -159,10 +160,11 @@ export class Viewer extends EventEmitter implements IViewer {
objectIds: string[],
stateKey: string = null,
includeDescendants = false
): Promise<void> {
return new Promise<void>((resolve) => {
this.filteringManager.showObjects(objectIds, stateKey, includeDescendants)
resolve()
): Promise<FilteringState> {
return new Promise<FilteringState>((resolve) => {
resolve(
this.filteringManager.showObjects(objectIds, stateKey, includeDescendants)
)
})
}
@@ -170,10 +172,11 @@ export class Viewer extends EventEmitter implements IViewer {
objectIds: string[],
stateKey: string = null,
includeDescendants = false
): Promise<void> {
return new Promise<void>((resolve) => {
this.filteringManager.isolateObjects(objectIds, stateKey, includeDescendants)
resolve()
): Promise<FilteringState> {
return new Promise<FilteringState>((resolve) => {
resolve(
this.filteringManager.isolateObjects(objectIds, stateKey, includeDescendants)
)
})
}
@@ -181,10 +184,11 @@ export class Viewer extends EventEmitter implements IViewer {
objectIds: string[],
stateKey: string = null,
includeDescendants = false
): Promise<void> {
return new Promise<void>((resolve) => {
this.filteringManager.unIsolateObjects(objectIds, stateKey, includeDescendants)
resolve()
): Promise<FilteringState> {
return new Promise<FilteringState>((resolve) => {
resolve(
this.filteringManager.unIsolateObjects(objectIds, stateKey, includeDescendants)
)
})
}
@@ -395,7 +399,7 @@ export class Viewer extends EventEmitter implements IViewer {
* LEGACY: Handles (or tries to handle) old viewer filtering.
* @param args legacy filter object
*/
public async applyFilter(filter: Record<string, unknown>) {
public async applyFilter(filter: unknown) {
filter
// return this.FilteringManager.handleLegacyFilter(filter)
}