-
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/set agent color #325
Conversation
jest coverage report 🧪Total coverage
Show files with reduced coverage 🔻Reduced coverage
|
Feature/set agent color edits
const colorNumber = convertColorStringToNumber(color); | ||
const newColor = [ | ||
((colorNumber & 0x00ff0000) >> 16) / 255.0, | ||
((colorNumber & 0x0000ff00) >> 8) / 255.0, | ||
((colorNumber & 0x000000ff) >> 0) / 255.0, | ||
1.0, | ||
]; | ||
const currentIndex = this.indexOfColor(newColor); |
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.
when does addNewColor get called? Do you always know the agent type when you are calling it? ... trying to understand why indexOfColor is needed.
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.
it's just in the case that the user changed the color of an agent to a color already in the data array
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.
These get called in changeAgentsColor in viewport, which takes agent, tags, and color in the form of colorChanges. The function call that needs the IDs returned from addNewColor is setColorForIds in visGeo.
src/simularium/SelectionInterface.ts
Outdated
import { EncodedTypeMapping } from "./types"; | ||
import { convertColorNumberToString } from "../visGeometry/color-utils"; | ||
import _ from "lodash"; |
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.
can remove (see npm run lint
output)
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.
oops, fixed this and the two other things the linter caught
@@ -15,9 +18,15 @@ export interface SelectionEntry { | |||
tags: string[]; | |||
} | |||
|
|||
export interface ColorChanges { | |||
agents: SelectionEntry[]; |
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.
this would be better named as agentTypes.
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.
on second thought, I realize we use "agents" in other SelectionEntry names as well. so at least it's consistent. Slightly confusing because we don't set colors on individual agents.
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.
LGTM!
): void { | ||
const newColor = convertColorNumberToString(color); | ||
const entry = this.entries[agentName]; | ||
// if no display state update parent color |
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.
- This comment isn't necessary
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.
looks good, there's just one comment I left to myself that is no longer relevant
|
uiDisplayData, | ||
particleTypeNames, | ||
agentColors, | ||
setColorSelectionInfo, | ||
updateAgentColorArray, |
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.
Just peeking in, should these props have type annotations or does it not need them?
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.
I am guessing that the type checking rules are not set up to enforce this in our typecheck/linter. It would be good to turn those rules on in a separate PR!
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.
The example Viewer code can be a bit fast and loose compared the to the core Viewer code. I like the idea of typing it better, or even refactoring it into component files someday when there is bandwidth.
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.
I didn't realize this was the viewer test-app code. Totally agree that the bar is lower for those source files, although it doesn't need to be.
Problem
Closes Set Agent Color #148
Solution
In brief: colorChanges are now part of SelectionStateInfo. Viewer watches for changes to selectionStateInfo.colorChanges and calls changeAgentsColor in response to changes. changeAgentsColor updates visGeometry and UiDisplayData to ensure color changes are represented both in the viewport and in embedding applications that reference the UiDisplayData.
Added a few helper functions, cleaned unused ColorMapping in visGeo and made small updates to existing functions to accommodate new behavior.
Selection Interface:
Viewport:
VisGeometry:
Example Viewer/ColorPicker.tsx
Steps to Verify: