Skip to content
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

Bug/3194/camera perspective of custom view #3698

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions visualization/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Fixed 🐞

- Revert [#3655](https://github.com/MaibornWolff/codecharta/pull/3665) as we implement new navigation methods
- Camera perspective is correctly adopted from the custom configuration[#3194](https://github.com/MaibornWolff/codecharta/pull/3194)

## [1.127.0] - 2024-08-12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CustomConfigHelper } from "../../../../../util/customConfigHelper"
import { ThreeCameraService } from "../../../../codeMap/threeViewer/threeCamera.service"
import { ThreeMapControlsService } from "../../../../codeMap/threeViewer/threeMapControls.service"
import { Store } from "@ngrx/store"
import { ThreeRendererService } from "../../../../codeMap/threeViewer/threeRenderer.service"

@Component({
selector: "cc-apply-custom-config-button",
Expand All @@ -17,10 +18,17 @@ export class ApplyCustomConfigButtonComponent {
constructor(
private store: Store,
private threeCameraService: ThreeCameraService,
private threeOrbitControlsService: ThreeMapControlsService
private threeOrbitControlsService: ThreeMapControlsService,
private threeRendererService: ThreeRendererService
) {}

applyCustomConfig() {
CustomConfigHelper.applyCustomConfig(this.customConfigItem.id, this.store, this.threeCameraService, this.threeOrbitControlsService)
CustomConfigHelper.applyCustomConfig(
this.customConfigItem.id,
this.store,
this.threeCameraService,
this.threeOrbitControlsService,
this.threeRendererService
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ThreeCameraService } from "../../../codeMap/threeViewer/threeCamera.ser
import { ThreeMapControlsService } from "../../../codeMap/threeViewer/threeMapControls.service"
import { Store } from "@ngrx/store"
import { MatExpansionPanel } from "@angular/material/expansion"
import { ThreeRendererService } from "../../../codeMap/threeViewer/threeRenderer.service"

@Component({
selector: "cc-custom-config-item-group",
Expand All @@ -22,7 +23,8 @@ export class CustomConfigItemGroupComponent implements OnChanges {
constructor(
private store: Store,
private threeCameraService: ThreeCameraService,
private threeOrbitControlsService: ThreeMapControlsService
private threeOrbitControlsService: ThreeMapControlsService,
private threeRendererService: ThreeRendererService
) {}

ngOnChanges(changes: SimpleChanges): void {
Expand Down Expand Up @@ -57,6 +59,12 @@ export class CustomConfigItemGroupComponent implements OnChanges {
}

applyCustomConfig(configId: string) {
CustomConfigHelper.applyCustomConfig(configId, this.store, this.threeCameraService, this.threeOrbitControlsService)
CustomConfigHelper.applyCustomConfig(
configId,
this.store,
this.threeCameraService,
this.threeOrbitControlsService,
this.threeRendererService
)
}
}
16 changes: 6 additions & 10 deletions visualization/app/codeCharta/util/customConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ThreeMapControlsService } from "../ui/codeMap/threeViewer/threeMapContr
import { BehaviorSubject } from "rxjs"
import { VisibleFilesBySelectionMode } from "../ui/customConfigs/visibleFilesBySelectionMode.selector"
import { Store } from "@ngrx/store"
import { setState } from "../state/store/state.actions"
import { ThreeRendererService } from "../ui/codeMap/threeViewer/threeRenderer.service"

export const CUSTOM_CONFIG_FILE_EXTENSION = ".cc.config.json"
const CUSTOM_CONFIGS_LOCAL_STORAGE_VERSION = "1.0.1"
Expand Down Expand Up @@ -193,18 +193,14 @@ export class CustomConfigHelper {
configId: string,
store: Store,
threeCameraService: ThreeCameraService,
threeOrbitControlsService: ThreeMapControlsService
threeOrbitControlsService: ThreeMapControlsService,
threeRendererService: ThreeRendererService
) {
const customConfig = this.getCustomConfigSettings(configId)
store.dispatch(setState({ value: customConfig.stateSettings }))

// TODO: remove this dirty timeout and set camera settings properly
// This timeout is a chance that CustomConfigs for a small map can be restored and applied completely (even the camera positions)
if (customConfig.camera) {
setTimeout(() => {
threeOrbitControlsService.setControlTarget(customConfig.camera.cameraTarget)
threeCameraService.setPosition(customConfig.camera.camera)
}, 100)
threeCameraService.setPosition(customConfig.camera.camera)
threeOrbitControlsService.setControlTarget(customConfig.camera.cameraTarget)
}
threeRendererService.render()
}
}
Loading