@@ -105,7 +105,6 @@ function vtkLineWidget(publicAPI, model) {
105105 model . widgetRep . setPoint1Visibility ( 1 ) ;
106106 model . widgetRep . setPoint2Visibility ( 1 ) ;
107107
108-
109108 // // Widgets can't be enabled together because of interaction event which doesn't
110109 // // manage priority
111110 // model.point1Widget.setEnable(1);
@@ -170,9 +169,7 @@ function vtkLineWidget(publicAPI, model) {
170169 if ( model . widgetRep . getInteractionState === InteractionState . OUTSIDE ) {
171170 return ;
172171 }
173- const pos = model . interactor . getEventPosition ( model . interactor . getPointerIndex ( ) ) ;
174- const boundingContainer = model . interactor . getCanvas ( ) . getBoundingClientRect ( ) ;
175- const position = [ pos . x - boundingContainer . left , pos . y + boundingContainer . top ] ;
172+ const position = publicAPI . get2DPointerPosition ( ) ;
176173
177174 if ( model . widgetState === WidgetState . START ) {
178175 const pos3D = model . point1Widget . getWidgetRep ( ) . displayToWorld ( position , 0 ) ;
@@ -224,10 +221,7 @@ function vtkLineWidget(publicAPI, model) {
224221 model . widgetRep . setInteractionState ( State . ONLINE ) ;
225222 }
226223
227- const pos = model . interactor . getEventPosition ( model . interactor . getPointerIndex ( ) ) ;
228- const boundingContainer = model . interactor . getCanvas ( ) . getBoundingClientRect ( ) ;
229- const position = [ pos . x - boundingContainer . left , pos . y + boundingContainer . top ] ;
230-
224+ const position = publicAPI . get2DPointerPosition ( ) ;
231225 model . widgetState = WidgetState . ACTIVE ;
232226 model . widgetRep . startComplexWidgetInteraction ( position ) ;
233227 publicAPI . invokeStartInteractionEvent ( ) ;
@@ -238,26 +232,22 @@ function vtkLineWidget(publicAPI, model) {
238232 return ;
239233 }
240234 model . widgetRep . setInteractionState ( State . SCALING ) ;
241- const pos = model . interactor . getEventPosition ( model . interactor . getPointerIndex ( ) ) ;
242- const boundingContainer = model . interactor . getCanvas ( ) . getBoundingClientRect ( ) ;
243- const position = [ pos . x - boundingContainer . left , pos . y + boundingContainer . top ] ;
244-
235+ const position = publicAPI . get2DPointerPosition ( ) ;
245236 model . widgetState = WidgetState . ACTIVE ;
246237 model . widgetRep . startComplexWidgetInteraction ( position ) ;
247238 publicAPI . invokeStartInteractionEvent ( ) ;
248239 } ;
249240
250241 publicAPI . moveAction = ( ) => {
251- const pos = model . interactor . getEventPosition ( model . interactor . getPointerIndex ( ) ) ;
252- const boundingContainer = model . interactor . getCanvas ( ) . getBoundingClientRect ( ) ;
253- const position = [ pos . x - boundingContainer . left , pos . y + boundingContainer . top ] ;
242+ const position = publicAPI . get2DPointerPosition ( ) ;
254243
255244 // Need to check where the mouse is
256245 if ( model . widgetState === WidgetState . MANIPULATE ) {
257246 model . interactor . disable ( ) ; // to avoid extra renders()
258247
259248 model . point1Widget . setEnable ( 0 ) ;
260249 model . point2Widget . setEnable ( 0 ) ;
250+
261251 if ( model . currentHandle === 1 ) {
262252 model . point1Widget . setEnable ( 1 ) ;
263253 }
@@ -296,9 +286,7 @@ function vtkLineWidget(publicAPI, model) {
296286 if ( model . widgetState === WidgetState . START ) {
297287 return ;
298288 }
299- const pos = model . interactor . getEventPosition ( model . interactor . getPointerIndex ( ) ) ;
300- const boundingContainer = model . interactor . getCanvas ( ) . getBoundingClientRect ( ) ;
301- const position = [ pos . x - boundingContainer . left , pos . y + boundingContainer . top ] ;
289+ const position = publicAPI . get2DPointerPosition ( ) ;
302290 model . widgetRep . complexWidgetInteraction ( position ) ;
303291 model . widgetRep . setPoint1WorldPosition ( model . point1Widget . getWidgetRep ( ) . getWorldPosition ( ) ) ;
304292 model . widgetRep . setPoint2WorldPosition ( model . point2Widget . getWidgetRep ( ) . getWorldPosition ( ) ) ;
0 commit comments