@@ -105,7 +105,6 @@ function vtkLineWidget(publicAPI, model) {
105
105
model . widgetRep . setPoint1Visibility ( 1 ) ;
106
106
model . widgetRep . setPoint2Visibility ( 1 ) ;
107
107
108
-
109
108
// // Widgets can't be enabled together because of interaction event which doesn't
110
109
// // manage priority
111
110
// model.point1Widget.setEnable(1);
@@ -170,9 +169,7 @@ function vtkLineWidget(publicAPI, model) {
170
169
if ( model . widgetRep . getInteractionState === InteractionState . OUTSIDE ) {
171
170
return ;
172
171
}
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 ( ) ;
176
173
177
174
if ( model . widgetState === WidgetState . START ) {
178
175
const pos3D = model . point1Widget . getWidgetRep ( ) . displayToWorld ( position , 0 ) ;
@@ -224,10 +221,7 @@ function vtkLineWidget(publicAPI, model) {
224
221
model . widgetRep . setInteractionState ( State . ONLINE ) ;
225
222
}
226
223
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 ( ) ;
231
225
model . widgetState = WidgetState . ACTIVE ;
232
226
model . widgetRep . startComplexWidgetInteraction ( position ) ;
233
227
publicAPI . invokeStartInteractionEvent ( ) ;
@@ -238,26 +232,22 @@ function vtkLineWidget(publicAPI, model) {
238
232
return ;
239
233
}
240
234
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 ( ) ;
245
236
model . widgetState = WidgetState . ACTIVE ;
246
237
model . widgetRep . startComplexWidgetInteraction ( position ) ;
247
238
publicAPI . invokeStartInteractionEvent ( ) ;
248
239
} ;
249
240
250
241
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 ( ) ;
254
243
255
244
// Need to check where the mouse is
256
245
if ( model . widgetState === WidgetState . MANIPULATE ) {
257
246
model . interactor . disable ( ) ; // to avoid extra renders()
258
247
259
248
model . point1Widget . setEnable ( 0 ) ;
260
249
model . point2Widget . setEnable ( 0 ) ;
250
+
261
251
if ( model . currentHandle === 1 ) {
262
252
model . point1Widget . setEnable ( 1 ) ;
263
253
}
@@ -296,9 +286,7 @@ function vtkLineWidget(publicAPI, model) {
296
286
if ( model . widgetState === WidgetState . START ) {
297
287
return ;
298
288
}
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 ( ) ;
302
290
model . widgetRep . complexWidgetInteraction ( position ) ;
303
291
model . widgetRep . setPoint1WorldPosition ( model . point1Widget . getWidgetRep ( ) . getWorldPosition ( ) ) ;
304
292
model . widgetRep . setPoint2WorldPosition ( model . point2Widget . getWidgetRep ( ) . getWorldPosition ( ) ) ;
0 commit comments