-
-
Notifications
You must be signed in to change notification settings - Fork 382
refactor(polylinewidget): makes Angle and Distance widgets inherits from PolyLineWidget #2392
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
base: master
Are you sure you want to change the base?
refactor(polylinewidget): makes Angle and Distance widgets inherits from PolyLineWidget #2392
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.
@Julesdevops |
function canPlacePoints() { | ||
return model.getMaxPoints() | ||
? model.widgetState.getHandleList().length < model.getMaxPoints() | ||
: true; |
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.
!model.getMaxPoints() || model.widgetState.getHandleList().length < model.getMaxPoints()
@@ -144,6 +155,11 @@ export default function widgetBehavior(publicAPI, model) { | |||
model._interactor.render(); | |||
} | |||
|
|||
// Don't make any more points | |||
if (!canPlacePoints()) { |
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.
what if you were simply dragging a point, should you also "lose focus" ?
@@ -162,7 +178,7 @@ export default function widgetBehavior(publicAPI, model) { | |||
// -------------------------------------------------------------------------- | |||
|
|||
publicAPI.grabFocus = () => { | |||
if (!model.hasFocus) { | |||
if (!model.hasFocus && canPlacePoints()) { |
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.
does it mean you can't grab focus if you are dragging a point ?
|
||
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues); | ||
macro.setGet(publicAPI, model, ['manipulator']); | ||
macro.setGet(publicAPI, model, ['manipulator', 'maxPoints']); |
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.
you need to document that setting maxpoint at run time won't reduce the number of points
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.js
file was almost the same between the 3 widgets, which was a potential source of bugs or difference on behaviors.Results
behavior.js
andstate.js
) in Angle and Distance widgets.Changes
getMaxPoints
/setMaxPoints
PR and Code Checklist
npm run reformat
to have correctly formatted codeTesting