Skip to content

Commit

Permalink
CELE-107 Fix issue with active synchronizers
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Nov 5, 2024
1 parent 1afe2eb commit 4f7d94c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ const TwoDViewer = () => {
const handleNodeClick = (event) => {
const node = event.target;
const neuronId = node.id();
const selectedNeurons = workspace.getSelection(ViewerType.Graph);
const isSelected = selectedNeurons.includes(neuronId) || selectedNeurons.some((e) => workspace.getNeuronCellsByClass(neuronId).includes(e));

if (isSelected) {
Expand All @@ -266,16 +267,16 @@ const TwoDViewer = () => {
if (workspace.getNeuronClass(neuronId) === neuronId) {
const relatedNeurons = workspace.getNeuronCellsByClass(neuronId);
for (const neuron of relatedNeurons) {
workspace.forceRemoveSelection(neuron, ViewerType.EM);
workspace.forceRemoveSelection(neuron, ViewerType.ThreeD);
workspace.locallyRemoveSelection(neuron, ViewerType.EM);
workspace.locallyRemoveSelection(neuron, ViewerType.ThreeD);
}
}
} else {
workspace.addSelection(neuronId, ViewerType.Graph);
const relatedNeurons = workspace.getNeuronCellsByClass(neuronId);
for (const neuron of relatedNeurons) {
workspace.forceInjectSelection(neuron, ViewerType.EM);
workspace.forceInjectSelection(neuron, ViewerType.ThreeD);
workspace.locallyInjectSelection(neuron, ViewerType.EM);
workspace.locallyInjectSelection(neuron, ViewerType.ThreeD);
}
}
};
Expand Down
22 changes: 14 additions & 8 deletions applications/visualizer/frontend/src/models/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class SynchronizerOrchestrator {
if (connectedSynchronizer === synchronizer) {
continue;
}
if (connectedSynchronizer.canHandle(otherViewer)) {
if (connectedSynchronizer.canHandle(otherViewer) && connectedSynchronizer.active) {
synchros.add(connectedSynchronizer);
}
}
Expand All @@ -155,15 +155,21 @@ export class SynchronizerOrchestrator {
}
}

public forceInjectSelection(selection: string, target: ViewerType) {
this.contexts[target].push(selection);
public locallyInjectSelection(selection: string, target: ViewerType) {
const synchronizers = this.getConnectedViewers(target);
if ([...synchronizers].some((sync) => sync.canHandle(target) && sync.active)) {
this.contexts[target].push(selection);
}
}

public forceRemoveSelection(selection: string, target: ViewerType) {
const selected = this.contexts[target];
const index = selected.indexOf(selection);
if (index > -1) {
selected.splice(index, 1);
public locallyRemoveSelection(selection: string, target: ViewerType) {
const synchronizers = this.getConnectedViewers(target);
if ([...synchronizers].some((sync) => sync.canHandle(target) && sync.active)) {
const selected = this.contexts[target];
const index = selected.indexOf(selection);
if (index > -1) {
selected.splice(index, 1);
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions applications/visualizer/frontend/src/models/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ export class Workspace {
}

@triggerUpdate
forceInjectSelection(selection: string, target: ViewerType) {
this.syncOrchestrator.forceInjectSelection(selection, target);
locallyInjectSelection(selection: string, target: ViewerType) {
this.syncOrchestrator.locallyInjectSelection(selection, target);
}

@triggerUpdate
forceRemoveSelection(selection: string, target: ViewerType) {
this.syncOrchestrator.forceRemoveSelection(selection, target);
locallyRemoveSelection(selection: string, target: ViewerType) {
this.syncOrchestrator.locallyRemoveSelection(selection, target);
}

@triggerUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const CAMERA_POSITION = new Vector3(0, 0, 50);
export const CAMERA_NEAR = 0.1;
export const CAMERA_FAR = 2000;

export const LIGHT_1_COLOR = "0x404040";
export const LIGHT_2_COLOR = "0xccccff";
export const LIGHT_1_COLOR = 0xffffff;
export const LIGHT_2_COLOR = 0xccccff;
export const LIGHT_2_POSITION = new Vector3(-1, 0.75, -0.5);

export const LIGHT_SCENE_BACKGROUND = "#f6f5f4";
Expand Down

0 comments on commit 4f7d94c

Please sign in to comment.