Skip to content

Commit

Permalink
fix hidden edit panel when synthesispose was selected
Browse files Browse the repository at this point in the history
  • Loading branch information
AnselChang committed Apr 6, 2024
1 parent 58d911a commit 6e81fe9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/app/selected-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { MechanismService } from './services/mechanism.service';
import { SynthesisBuilderService } from './services/synthesis/synthesis-builder.service';
import { ActiveObjService } from 'src/app/services/active-obj.service';

export enum TabID {
SYNTHESIZE,
Expand All @@ -18,7 +19,11 @@ export class SelectedTabService {
private _tabNum: BehaviorSubject<TabID>;
private _tabVisible: BehaviorSubject<boolean>;

constructor(private synthesis: SynthesisBuilderService, private mechanism: MechanismService) {
constructor(
private synthesis: SynthesisBuilderService,
private mechanism: MechanismService,
private activeObjService: ActiveObjService
) {
this._tabNum = new BehaviorSubject<TabID>(TabID.EDIT);
this._tabVisible = new BehaviorSubject<boolean>(true);
}
Expand All @@ -28,6 +33,11 @@ export class SelectedTabService {
let previousTab = this.getCurrentTab();
let isDifferentTab = previousTab !== tabID;

// when switching from synthesis to edit/analyze tab, clear selected synthesis pose, if it exists
if (previousTab === TabID.SYNTHESIZE && this.activeObjService.getSelectedObjType() === "SynthesisPose") {
this.activeObjService.updateSelectedObj(null);
}

this._tabNum.next(tabID);
this._tabVisible.next(true);

Expand Down
8 changes: 7 additions & 1 deletion src/app/services/active-obj.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { RealLink } from '../model/link';
import { Coord } from '../model/coord';
import { SynthesisPose } from './synthesis/synthesis-util';

export type ActiveObjType = "Nothing" | "Joint" | "Force" | "Link" | "Grid" | "SynthesisPose";

@Injectable({
providedIn: 'root',
})
export class ActiveObjService {
objType: string = 'Nothing';
objType: ActiveObjType = 'Nothing';
selectedJoint!: RealJoint;
prevSelectedJoint!: RealJoint;
selectedForce!: Force;
Expand All @@ -35,6 +37,10 @@ export class ActiveObjService {
}
}

getSelectedObjType(): ActiveObjType {
return this.objType;
}

fakeUpdateSelectedObj() {
//Don't actually update the selected object, just emit the event so subscribers can update
this.onActiveObjChange.emit(this.objType);
Expand Down

0 comments on commit 6e81fe9

Please sign in to comment.