( x, y )
| 505 | } |
| 506 | |
| 507 | selectCtrl( x, y ){ |
| 508 | let activeCtrl = null; |
| 509 | const xOrg = this.canvas.width * this.config.yAxis; |
| 510 | const scale = (this.canvas.width * 0.95 - xOrg)/ this.config.xMax; |
| 511 | const tolerance = (7.0/scale) * (7.0/scale); |
| 512 | const ctrls = [ 'ctrlA', 'ctrlB', 'radius', 'start', 'end', 'clockwise' ]; |
| 513 | this.nodes.forEach( node => { |
| 514 | if (node.options){ |
| 515 | if ( activeCtrl == null){ |
| 516 | ctrls.forEach( ctrlName => { |
| 517 | if (activeCtrl == null ){ |
| 518 | let ctrl; |
| 519 | switch(ctrlName){ |
| 520 | case 'ctrlA': |
| 521 | case 'ctrlB': |
| 522 | ctrl = node.options[ctrlName]; |
| 523 | break; |
| 524 | case 'radius': |
| 525 | ctrl = Geometry.calcPointOnCircle( node.x, node.y, node.options.radius, Math.PI ); |
| 526 | ctrl.type = 'radius'; |
| 527 | ctrl.node = node; |
| 528 | break; |
| 529 | case 'start': |
| 530 | ctrl = Geometry.calcPointOnCircle( node.x, node.y, node.options.radius, node.options.start ); |
| 531 | ctrl.type = 'start'; |
| 532 | ctrl.node = node; |
| 533 | break; |
| 534 | case 'end': |
| 535 | ctrl = Geometry.calcPointOnCircle( node.x, node.y, node.options.radius, node.options.end ); |
| 536 | ctrl.type = 'end'; |
| 537 | ctrl.node = node; |
| 538 | break; |
| 539 | case 'clockwise': |
| 540 | ctrl = { x: node.x, y: node.y + 20/scale, node, type: ctrlName }; |
| 541 | break; |
| 542 | } |
| 543 | if ( ctrl){ |
| 544 | const x1 = ctrl.x - x; |
| 545 | const y1 = ctrl.y - y; |
| 546 | const sqDist = x1*x1 + y1*y1; |
| 547 | if (sqDist<tolerance) activeCtrl = ctrl; |
| 548 | } |
| 549 | } |
| 550 | }); |
| 551 | } |
| 552 | } |
| 553 | }) |
| 554 | return activeCtrl; |
| 555 | } |
| 556 | |
| 557 | addNode( tool, x, y, insertIndex = -1 ){ |
| 558 | let pt = this.graph.convertScreenToPath( x, y ); |
no test coverage detected