|
257 | 257 |
|
258 | 258 | <border-conditions ref="borderConditionsComponent" :dialog="dialogBorderConditions" :properties="properties" |
259 | 259 | @closeDialog="dialogBorderConditions = false"/> |
260 | | - <import-packing ref="refImportPacking"/> |
| 260 | + <import-packing ref="refImportPacking" @loadtxtpacking="loadTxtPacking"/> |
261 | 261 | <download-packing ref="refExportPacking"/> |
262 | 262 |
|
263 | 263 | </v-toolbar> |
|
434 | 434 | p.mouseReleased = () => { |
435 | 435 | locked = false; |
436 | 436 | if (dragged) { |
437 | | - // let box = { |
438 | | - // points: [ |
439 | | - // { |
440 | | - // x: Math.min(bx, xInit), |
441 | | - // y: Math.min(by, yInit) |
442 | | - // }, |
443 | | - // { |
444 | | - // x: Math.max(bx, xInit), |
445 | | - // y: Math.min(by, yInit) |
446 | | - // }, |
447 | | - // { |
448 | | - // x: Math.max(bx, xInit), |
449 | | - // y: Math.max(by, yInit) |
450 | | - // }, |
451 | | - // { |
452 | | - // x: Math.min(bx, xInit), |
453 | | - // y: Math.max(by, yInit) |
454 | | - // }, |
455 | | - // ] |
456 | | - // }; |
457 | | - // let height = this.packing.height; |
458 | | - // let width = this.packing.width; |
459 | | - // if(this.packing.graph) { |
460 | | - // this.packing.polygons.forEach(pol => { |
461 | | - // for (let i = 0; i < pol.points.length; i++) { |
462 | | - // let pntA = pol.points[i]; |
463 | | - // let pntB = pol.points[(i + 1) % pol.points.length]; |
464 | | - // |
465 | | - // if ([pntA.x, pntA.y] in this.packing.graph && [pntB.x, pntB.y] in this.packing.graph[[pntA.x, pntA.y]]) { |
466 | | - // this.packing.graph[[pntA.x, pntA.y]][[pntB.x, pntB.y]] = { |
467 | | - // selected: false |
468 | | - // } |
469 | | - // } else if ([pntB.x, pntB.y] in this.packing.graph && [pntA.x, pntA.y] in this.packing.graph[[pntB.x, pntB.y]]) { |
470 | | - // this.packing.graph[[pntB.x, pntB.y]][[pntA.x, pntA.y]] = { |
471 | | - // selected: false |
472 | | - // } |
473 | | - // } |
474 | | - // } |
475 | | - // }); |
476 | | - // this.packing.polygons.forEach(pol => { |
477 | | - // pol.selected = this.polygonIntersection(pol, box, width, height, p); |
478 | | - // for (let i = 0; i < pol.points.length; i++) { |
479 | | - // let pntA = pol.points[i]; |
480 | | - // let pntB = pol.points[(i + 1) % pol.points.length]; |
481 | | - // |
482 | | - // if ([pntA.x, pntA.y] in this.packing.graph && [pntB.x, pntB.y] in this.packing.graph[[pntA.x, pntA.y]]) { |
483 | | - // this.packing.graph[[pntA.x, pntA.y]][[pntB.x, pntB.y]] = { |
484 | | - // selected: pol.selected || this.packing.graph[[pntA.x, pntA.y]][[pntB.x, pntB.y]].selected |
485 | | - // } |
486 | | - // } else if ([pntB.x, pntB.y] in this.packing.graph && [pntA.x, pntA.y] in this.packing.graph[[pntB.x, pntB.y]]) { |
487 | | - // this.packing.graph[[pntB.x, pntB.y]][[pntA.x, pntA.y]] = { |
488 | | - // selected: pol.selected || this.packing.graph[[pntB.x, pntB.y]][[pntA.x, pntA.y]].selected |
489 | | - // } |
490 | | - // } |
491 | | - // } |
492 | | - // }); |
493 | | - // } |
| 437 | + let box = { |
| 438 | + points: [ |
| 439 | + { |
| 440 | + x: Math.min(bx, xInit), |
| 441 | + y: Math.min(by, yInit) |
| 442 | + }, |
| 443 | + { |
| 444 | + x: Math.max(bx, xInit), |
| 445 | + y: Math.min(by, yInit) |
| 446 | + }, |
| 447 | + { |
| 448 | + x: Math.max(bx, xInit), |
| 449 | + y: Math.max(by, yInit) |
| 450 | + }, |
| 451 | + { |
| 452 | + x: Math.min(bx, xInit), |
| 453 | + y: Math.max(by, yInit) |
| 454 | + }, |
| 455 | + ] |
| 456 | + }; |
| 457 | + let height = this.packing.height; |
| 458 | + let width = this.packing.width; |
| 459 | + if(this.packing.graph) { |
| 460 | + this.packing.polygons.forEach(pol => { |
| 461 | + pol.selected = false; |
| 462 | + }); |
| 463 | + this.packing.polygons.forEach(pol => { |
| 464 | + pol.selected = this.polygonIntersection(pol, box, width, height, p); |
| 465 | + }); |
| 466 | + } |
494 | 467 | dragged = false; |
495 | 468 | p.draw(); |
496 | 469 | } |
|
526 | 499 | const pntA = JSON.parse("[" + pointA + "]"); |
527 | 500 | const pntB = JSON.parse("[" + pointB + "]"); |
528 | 501 |
|
529 | | - if (graph[pointA][pointB].selected) { |
530 | | - p.stroke(189, 189, 189); |
531 | | - } else { |
532 | | - p.stroke(33, 33, 33); |
533 | | - } |
534 | | -
|
535 | | - if (graph[pointA][pointB].selected) { |
536 | | - p.strokeWeight(4); |
537 | | - } else { |
538 | | - p.strokeWeight(3); |
539 | | - } |
| 502 | + p.stroke(33, 33, 33); |
| 503 | + p.strokeWeight(3); |
540 | 504 |
|
541 | 505 | p.line( |
542 | 506 | ((pntA[0] / width) * widthContainer) + xAxisOffset, |
|
755 | 719 | } |
756 | 720 | } |
757 | 721 | } |
| 722 | + if(polygon.selected) { |
| 723 | + p.fill('rgba(0,0,0, 0.25)'); |
| 724 | + p.beginShape(); |
| 725 | + polygon.points.forEach(pnt => { |
| 726 | + p.vertex( |
| 727 | + ((pnt.x / width) * this.getWidth(p)) + this.getOffsetXAxis(), |
| 728 | + (((height - pnt.y) / height) * this.getHeight(p)) + + this.getOffsetYAxis() |
| 729 | + ); |
| 730 | + }); |
| 731 | + p.endShape(p.CLOSE); |
| 732 | + } |
758 | 733 | }, |
759 | 734 | execute() { |
760 | 735 | this.$validator.validateAll().then(result => { |
|
838 | 813 | } |
839 | 814 | }); |
840 | 815 | }, |
| 816 | + loadTxtPacking(data) { |
| 817 | + this.$store.commit("newPacking", data); |
| 818 | + this.parseMesh(data); |
| 819 | + this.$refs.borderConditionsComponent.updatePacking(); |
| 820 | + }, |
841 | 821 | parseMesh(mesh) { |
842 | 822 | //console.log(resp); |
843 | 823 |
|
|
0 commit comments