refactor(polylinewidget): makes Angle and Distance widgets inherits from PolyLineWidget#2392
Open
tomsuchel wants to merge 1 commit intoKitware:masterfrom
Open
refactor(polylinewidget): makes Angle and Distance widgets inherits from PolyLineWidget#2392tomsuchel wants to merge 1 commit intoKitware:masterfrom
tomsuchel wants to merge 1 commit intoKitware:masterfrom
Conversation
…rom PolyLineWidget Refactors PolyLineWidget so it can support having a max number of points. Makes AngleWidget and DistanceWidget inherits from PolyLineWidget by limiting their maxPoints to 2 and 3. Remove a lot of duplicate code between Angle and Distance widgets.
Contributor
Author
|
@Julesdevops |
finetjul
reviewed
May 2, 2022
| function canPlacePoints() { | ||
| return model.getMaxPoints() | ||
| ? model.widgetState.getHandleList().length < model.getMaxPoints() | ||
| : true; |
Member
There was a problem hiding this comment.
!model.getMaxPoints() || model.widgetState.getHandleList().length < model.getMaxPoints()
finetjul
reviewed
May 2, 2022
| } | ||
|
|
||
| // Don't make any more points | ||
| if (!canPlacePoints()) { |
Member
There was a problem hiding this comment.
what if you were simply dragging a point, should you also "lose focus" ?
finetjul
reviewed
May 2, 2022
|
|
||
| publicAPI.grabFocus = () => { | ||
| if (!model.hasFocus) { | ||
| if (!model.hasFocus && canPlacePoints()) { |
Member
There was a problem hiding this comment.
does it mean you can't grab focus if you are dragging a point ?
finetjul
reviewed
May 2, 2022
|
|
||
| vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues); | ||
| macro.setGet(publicAPI, model, ['manipulator']); | ||
| macro.setGet(publicAPI, model, ['manipulator', 'maxPoints']); |
Member
There was a problem hiding this comment.
you need to document that setting maxpoint at run time won't reduce the number of points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Angle and Distance widgets were basically PolyLineWidgets but with a hard-coded limit on their number of points, and a method to compute an angle/distance. The
behavior.jsfile was almost the same between the 3 widgets, which was a potential source of bugs or difference on behaviors.Results
behavior.jsandstate.js) in Angle and Distance widgets.Changes
getMaxPoints/setMaxPointsPR and Code Checklist
npm run reformatto have correctly formatted codeTesting