-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/session colors #400
Changes from 26 commits
e5bc443
65985e3
1b04d38
f5935c6
130044b
687e4f3
40d9425
4ca2123
5f27d77
fc3f96f
f3e0816
d015892
627c414
dfb53d9
6f9bfa8
9678d19
1bab4fe
d6a6a76
a355255
e3f8f82
cc52ba7
6cae2d5
a158e4e
8e54623
98662fb
2337d40
a9b8fed
311175c
f2de0a1
80bb750
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,7 @@ const initialState: ViewerState = { | |
selectionStateInfo: { | ||
highlightedAgents: [], | ||
hiddenAgents: [], | ||
colorChange: null, | ||
appliedColors: [], | ||
}, | ||
filePending: null, | ||
simulariumFile: null, | ||
|
@@ -676,14 +676,15 @@ class Viewer extends React.Component<InputParams, ViewerState> { | |
this.setState({ agentColors }); | ||
}; | ||
|
||
public setColorSelectionInfo = (colorChange) => { | ||
public setColorSelectionInfo = (appliedColors) => { | ||
this.setState({ | ||
...this.state, | ||
uiDisplayData: appliedColors, | ||
selectionStateInfo: { | ||
hiddenAgents: this.state.selectionStateInfo.hiddenAgents, | ||
highlightedAgents: | ||
this.state.selectionStateInfo.highlightedAgents, | ||
colorChange: colorChange, | ||
appliedColors: appliedColors, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting that state is now duplicated here. I don't have quite enough context on why this would be necessary, or whether this change would imply a similar duplication in the actual simularium-website code. But, particularly if it does, I'd ask a couple questions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently no error will throw, but display will be incorrect if these two are out of sync after more than one color selection. In the website we will be storing two possibilities for color state (so that we can toggle between default and user selections). The Here we could apply the suggestion from your second bullet, removing the In regards to merging the paths related to |
||
}); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,6 @@ export { | |
} from "./simularium"; | ||
export { compareTimes, loadSimulariumFile } from "./util"; | ||
export { DEFAULT_CAMERA_SPEC } from "./constants"; | ||
export { AgentData } from "./simularium/types"; | ||
export type { AgentData } from "./simularium/types"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small bug fix folded in here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be included in the types imports up above and should be exported directly from "./simularium" like the rest of them are. probably should be it's own PR because currently it breaks running the viewer on main There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you, PR here. |
||
|
||
export default Viewport; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ const idMapping = { | |
}; | ||
|
||
const color = ""; | ||
const initialColorChanges = null; | ||
const initialAppliedColors = []; | ||
|
||
describe("SelectionInterface module", () => { | ||
describe("decode", () => { | ||
|
@@ -232,7 +232,7 @@ describe("SelectionInterface module", () => { | |
{ name: "D", tags: [] }, | ||
], | ||
hiddenAgents: [], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't appear to matter to these tests currently, but be careful: these tests are now taking the same copy of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated to use spread operator |
||
}; | ||
const ids = si.getHighlightedIds(selectionStateHighlight); | ||
const allAs = [0, 1, 2, 3]; | ||
|
@@ -252,7 +252,7 @@ describe("SelectionInterface module", () => { | |
{ name: "D", tags: [""] }, | ||
], | ||
hiddenAgents: [], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
}; | ||
const ids = si.getHighlightedIds(selectionStateHighlight); | ||
|
||
|
@@ -269,7 +269,7 @@ describe("SelectionInterface module", () => { | |
{ name: "E", tags: ["t1000"] }, | ||
], | ||
hiddenAgents: [], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
}; | ||
const ids = si.getHighlightedIds(selectionStateHighlight); | ||
|
||
|
@@ -282,7 +282,7 @@ describe("SelectionInterface module", () => { | |
const selectionStateHighlight = { | ||
highlightedAgents: [{ name: "E", tags: [""] }], | ||
hiddenAgents: [], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
}; | ||
const ids = si.getHighlightedIds(selectionStateHighlight); | ||
|
||
|
@@ -300,7 +300,7 @@ describe("SelectionInterface module", () => { | |
{ name: "A", tags: [] }, | ||
{ name: "C", tags: [] }, | ||
], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
}; | ||
const ids = si.getHiddenIds(selectionStateHide); | ||
|
||
|
@@ -316,7 +316,7 @@ describe("SelectionInterface module", () => { | |
{ name: "A", tags: ["t1", "t2"] }, | ||
{ name: "B", tags: ["t1"] }, | ||
], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
}; | ||
const ids = si.getHiddenIds(selectionStateHide); | ||
expect(ids).toEqual([1, 2, 3, 5, 7]); | ||
|
@@ -332,7 +332,7 @@ describe("SelectionInterface module", () => { | |
{ name: "A", tags: [""] }, | ||
{ name: "C", tags: ["", "t1", "t2"] }, | ||
], | ||
colorChange: initialColorChanges, | ||
appliedColors: initialAppliedColors, | ||
}; | ||
const ids = si.getHiddenIds(selectionStateHide); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ import { AgentData, TrajectoryFileInfoAny } from "../simularium/types"; | |
import { updateTrajectoryFileInfoFormat } from "../simularium/versionHandlers"; | ||
import { FrontEndError, ErrorLevel } from "../simularium/FrontEndError"; | ||
import { RenderStyle, VisGeometry, NO_AGENT } from "../visGeometry"; | ||
import { ColorChange } from "../simularium/SelectionInterface"; | ||
import FrameRecorder from "../simularium/FrameRecorder"; | ||
import { DEFAULT_FRAME_RATE } from "../constants"; | ||
|
||
|
@@ -342,12 +341,12 @@ class Viewport extends React.Component< | |
} | ||
if ( | ||
!isEqual( | ||
selectionStateInfo.colorChange, | ||
prevProps.selectionStateInfo.colorChange | ||
selectionStateInfo.appliedColors, | ||
prevProps.selectionStateInfo.appliedColors | ||
) && | ||
selectionStateInfo.colorChange !== null | ||
selectionStateInfo.appliedColors.length > 0 | ||
) { | ||
this.changeAgentsColor(selectionStateInfo.colorChange); | ||
this.changeAgentsColor(selectionStateInfo.appliedColors); | ||
} | ||
} | ||
|
||
|
@@ -596,12 +595,24 @@ class Viewport extends React.Component< | |
} | ||
} | ||
|
||
public changeAgentsColor(colorChange: ColorChange): void { | ||
const { agent, color } = colorChange; | ||
const agentIds = this.selectionInterface.getAgentIdsByNamesAndTags([ | ||
agent, | ||
]); | ||
this.visGeometry.applyColorToAgents(agentIds, color); | ||
public changeAgentsColor(appliedColors: UIDisplayData): void { | ||
appliedColors.forEach((agent) => { | ||
const agentIds = this.selectionInterface.getAgentIdsByNamesAndTags([ | ||
{ name: agent.name, tags: [] }, | ||
]); | ||
this.visGeometry.applyColorToAgents( | ||
agentIds, | ||
agent.color | ||
); | ||
|
||
agent.displayStates.forEach((state) => { | ||
const stateIds = | ||
this.selectionInterface.getAgentIdsByNamesAndTags([ | ||
{ name: agent.name, tags: [state.name] }, | ||
]); | ||
this.visGeometry.applyColorToAgents(stateIds, state.color); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Under the hood, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and why not, its cleaner! Also even if |
||
}); | ||
} | ||
|
||
public stopAnimate(): void { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview of front end work here in the test bed. Instead of passing in a
colorChange
we send in auiDisplayData
In pairing w @meganrm we decided to make the front end responsible for generating and storing this state, viewer just renders