-
Notifications
You must be signed in to change notification settings - Fork 16
DM-7462: create dispatch function, rendering style and stored status for region selection #177
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
Conversation
…l select modes including rendering style, color, and line width.
|
* @param {string} fileOnServer region file name on server | ||
* @param {string[]|string} regionAry array or string of region description | ||
* @param {string[]|string} plotId array or string of plot id. If plotId is empty, all plots of the active group are applied. | ||
* @param {function} dispatcher |
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.
should be last param
In general, there quite a few eslint warnings/errors (with our .eslintrc) in the changed files, like unused imports, vars, etc. It would be beneficial to fix them.
firefly.util.addActionListener(firefly.action.type.REGION_SELECT, onRegionSelect); Can we have a string, which represents user region in REGION_SELECT payload? |
'selectedRegion' in dispatchSelectRegion does take either string, array of strings (for programmatic purpose) or region object (for the usage of UI clicking) . |
Yes, dispatchSelectRegion does work as expected - any of the regions added can be programmatically selected from an external script. I am talking about different thing: an external script should also be able to react to region selection made by mouse click in the UI. An external script can trigger UI changes by calling action dispatchers. But it can also react to any UI action by adding a listener to this action. A listener is a user-defined function, a callback, which is called whenever the action goes through the flux. For example, some external script is using Firefly API to plot amplifiers, represented on the image by box regions. Each amplifier is described by unique name and region string, and this 1 to 1 map between name and region string is maintained by the script. When region is clicked, the script displays name. To do it, the script defines a callback, which takes REGION_SELECT action object and uses the action payload to find which region is selected. The only representation of region the script is aware of is region string. But the payload of REGION_SELECT action (triggered by mouse click) has only selectedRegion object, which is Firefly-internal representation of the region. |
as we discussed in previous meeting, a utility function 'getSelectedRegion' is provided to report the status of the selected region, i.e. the region string. Moreover, region string is actually stored in region object. If needed, one more utility besides 'getSelectedRegon' could be implemented to return the region string based on the region object. Would that be ok for the callback provided by the external script to use either utility to get the region string? dispatchSelectRegion mainly uses region object to form the highlight result. The string(s) passed to the dispatchSelectRegion is used for discovering the region object. Adding both region object and region string to the action payload seems redundant for dispatchSelectRegion itself. |
Sorry, I completely forgot about getSelectedRegion. Yes, the callback can 2016-09-13 23:59 GMT-07:00 Cindy Wang [email protected]:
|
I have tested getSelectedRegion, it works great. All that needs to be done
is to export getSelectedRegion from ApiUtilImage and add it to JSDoc by
adding @public annotation and including RegionPlot.js into the list of
sources in jsdoc_config.json We might also want to mention it in
dispatchRegionSelect JSDoc.
|
/** | ||
* @summary get the region description of the selected region from the specified region layer | ||
* @param {string} drawLayerId id of the drawing layer | ||
* @return {string} |
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 noticed this method returns null, when no region in drawLayerId is selected.
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.
if the click occurs nowhere (no region under), then the previous selected region will become de-selected. Passing a 'null' is the way to de-select the region.
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.
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 will document it, but this is not public function. Is that needed in public?
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.
If you pass a 'null' or empty array into 'dispatchSelectRegion', it will work as de-select. I will be documented on the dispatch function. Thanks.
getSelectedRegion needs to be public. Every method exposed via API should 2016-09-14 11:20 GMT-07:00 Cindy Wang [email protected]:
|
…AddRegionEntry. export getSelectedRegion from ApiUtilImage.jsx update jsdoc for region dispatch functions.
…n PointDataObj.js.
some addition to the implementation:
|
Implementation:
Testing:
You may delete the region layer and create a new region layer to see the different rendering effect on the selected region. (set the style before clicking 'Create Region Layer')
(the default rendering style for selected region is applied in here).