Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | 331x 331x 18x 18x 87x 14x 975x 125x 1x 1x 1x 1x 1x 1x 1x 13x 2x 2x 1x 1x 1x 4x 1x 1x 6x 12x 11x 8x 4x 4x 1x 4x 2x 6x 8x 1x 2x 8x 4x 1x 1x 2x 1x 1x 1x 4x 3x 4x 23x 15x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 1x 102x 79x 18x 17x 3x 3x 1x 5x 5x 5x 3x 17x 17x 79x 79x 122x 419x 419x 419x | import {
createInstance,
executePayload,
registerOnPayloadHandler,
} from '@3cr/sdk-browser';
import { unref } from 'vue';
import {
DataOverlaysActions,
FileManagementActions,
FrontEndInterfaces,
InteractivityActions,
LayoutActions,
NavigationCubeActions,
PresetsActions,
ScanMovementActions,
ScanOrientationActions,
SlidersActions,
ViewSelectionActions,
FrontEndPayload,
InteractivityState,
MarkupsActions,
McadActions,
ObjectBoolean,
ObjectColour,
ObjectInvert,
ObjectVisibility,
NavigationCubeTransform,
ColourData,
MovementData,
RotationValue,
FlipValue,
InvertTransformData,
DataOverlayData,
ViewToggleData,
GraphicType,
ColourPresetData,
GreyscalePresetData,
LoadFileData,
LocalLoadDataset,
LoadSessionState,
ObjectInfo,
ObjectId,
ObjectPosition,
ObjectSize,
ObjectIcon,
ObjectSize2D,
ParentPayload,
UnparentPayload,
} from '@3cr/types-ts';
import {
ActionCallback,
InterfaceCallback,
Viewer3crPayload,
Viewer3crService,
ViewerPayload,
} from '@3cr/viewer-types-ts';
import { currentColourPreset, transactionStarted } from '@/models/scanState';
import { EventHandlers } from '@/models/eventHandlers';
import { CustomLayout } from '@3cr/viewer-types-ts/types/viewer-3cr-service';
type ObjectDimensionalVisibility = {
Version: string;
Id: string;
Visibility2d: boolean;
Visibility3d: boolean;
};
export class Viewer3crServiceImpl implements Viewer3crService {
private interfaceCallbacks = new EventHandlers<string, InterfaceCallback>();
private actionCallbacks = new EventHandlers<string, ActionCallback>();
async register(canvas: HTMLCanvasElement): Promise<void> {
await registerOnPayloadHandler(this.onPayload.bind(this));
await createInstance(canvas);
}
addInterfaceHandler(iface: string, callback: InterfaceCallback): void {
this.interfaceCallbacks.add(iface, callback);
}
removeInterfaceHandler(iface: string, callback: InterfaceCallback): void {
this.interfaceCallbacks.remove(iface, callback);
}
addActionHandler(action: string, callback: ActionCallback): void {
this.actionCallbacks.add(action, callback);
}
removeActionHandler(action: string, callback: ActionCallback): void {
this.actionCallbacks.remove(action, callback);
}
/**
* DO-03: Set 2D annotation visibility.
* @param payload The object visibility payload.
*/
async setAnnotation2dVisibility(
payload: Viewer3crPayload<ObjectVisibility>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do03,
payload,
);
}
/**
* DO-04: Set 2D annotation icon size.
* @param payload The annotation 2D size payload.
*/
async setAnnotation2dSize(
payload: Viewer3crPayload<ObjectSize2D>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do04,
payload,
);
}
/**
* DO-05: Set 2D annotation colour.
* @param payload The annotation 2D colour payload.
*/
async setAnnotation2dColour(
payload: Viewer3crPayload<ObjectColour>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do05,
payload,
);
}
/**
* DO-06: Set annotation icon.
* @param payload The annotation icon payload.
*/
async setAnnotationIcon(
payload: Viewer3crPayload<ObjectIcon>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do06,
payload,
);
}
/**
* DO-08: Set 3D annotation size.
* @param payload The annotation 3D size payload.
*/
async setAnnotation3dSize(
payload: Viewer3crPayload<ObjectSize>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do08,
payload,
);
}
/**
* DO-09: Set 3D annotation colour.
* @param payload The annotation 3D colour payload.
*/
async setAnnotation3dColour(
payload: Viewer3crPayload<ObjectColour>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do09,
payload,
);
}
/**
* DO-11: Set 3D annotation visibility.
* @param payload The object visibility payload.
*/
async setAnnotation3dVisibility(
payload: Viewer3crPayload<ObjectVisibility>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.data_overlay,
DataOverlaysActions.do11,
payload,
);
}
/**
* FM-01: Load scan.
* @param payload The load scan payload.
*/
async loadScan(payload: Viewer3crPayload<ViewerPayload>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm01,
payload,
);
}
/**
* FM-03: Load previous CurrentScanState values.
* @param payload The load session payload.
*/
async loadScanSession(
payload: Viewer3crPayload<LoadSessionState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm03,
payload,
);
}
/**
* FM-05: Sets the data overlay session with the given session file.
* This will clear all previously loaded data overlay sessions.
* @param payload The load session payload.
*/
async setDataOverlaySession(
payload: Viewer3crPayload<LoadSessionState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm05,
payload,
);
}
/**
* FM-06: Adds a data overlay session to existing sessions.
* @param payload The load session payload.
*/
async addDataOverlaySession(
payload: Viewer3crPayload<LoadSessionState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm06,
payload,
);
}
/**
* FM-07: Receives URL from external UI for MCAD Object and reads meta-data of each object.
* @param payload The load MCAD payload.
*/
async loadExternalMcadObject(
payload: Viewer3crPayload<LoadFileData>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm07,
payload,
);
}
/**
* FM-08: Local File Path for Loading of a MCAD Object.
* @param payload The load MCAD payload.
*/
async loadLocalMcadObject(
payload: Viewer3crPayload<LocalLoadDataset>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm08,
payload,
);
}
/**
* FM-09: Load separate MCAD file from external UI.
* @param payload The load session payload.
*/
async loadMcadObjects(
payload: Viewer3crPayload<LoadSessionState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.file_management,
FileManagementActions.fm09,
payload,
);
}
/**
* IN-01: Enable or disable the mouse input.
* @param payload The interactivity state payload.
*/
async setMouseInput(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.interactivity,
InteractivityActions.in01,
payload,
);
}
/**
* IN-02: Enable or disable the keyboard input.
* @param payload The interactivity state payload.
*/
async setKeyboardInput(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.interactivity,
InteractivityActions.in02,
payload,
);
}
/**
* MC-03: Set visibility of MCAD objects.
* @param payload The object visibility payload.
*/
async setMcadObjectVisibility(
payload: Viewer3crPayload<ObjectVisibility>,
): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc03, payload);
}
/**
* MC-04: Set colour & opacity of MCAD objects.
* @param payload The object colour payload.
*/
async setMcadObjectColour(
payload: Viewer3crPayload<ObjectColour>,
): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc04, payload);
}
/**
* MC-05: Enables movement of MCAD objects.
* @param payload The object state payload.
*/
async moveMcadObject(
payload: Viewer3crPayload<ObjectBoolean>,
): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc05, payload);
}
/**
* MC-06: Enables rotation of MCAD objects.
* @param payload The object state payload.
*/
async rotateMcadObject(
payload: Viewer3crPayload<ObjectBoolean>,
): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc06, payload);
}
/**
* MC-09: Lock or unlock MCAD objects.
* @param payload The lock payload.
*/
async lockMcad(payload: Viewer3crPayload<ObjectBoolean>): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc09, payload);
}
/**
* MC-10: Group MCAD objects.
* @param payload The group MCAD payload.
*/
async groupMcad(payload: Viewer3crPayload<ParentPayload>): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc10, payload);
}
/**
* MC-11: Ungroup MCAD objects.
* @param payload The ungroup MCAD payload.
*/
async ungroupMcad(payload: Viewer3crPayload<UnparentPayload>): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc11, payload);
}
/**
* MC-16: Invert MCAD objects.
* @param payload The object invert payload.
*/
async invertMcadObject(
payload: Viewer3crPayload<ObjectInvert>,
): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc16, payload);
}
/**
* MC-17: Remove MCAD objects.
* @param payload The remove MCAD object payload.
*/
async removeMcadObject(payload: Viewer3crPayload<ObjectId>): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc17, payload);
}
/**
* MC-18: Set MCAD object title.
* @param payload The MCAD object title payload.
*/
async setMcadObjectTitle(
payload: Viewer3crPayload<ObjectInfo>,
): Promise<void> {
await this.sendPayload(FrontEndInterfaces.mcad, McadActions.mc18, payload);
}
/**
* MU-01: Create a 2d annotation.
* @param payload The 2d annotation interaction payload.
*/
async createAnnotation2dTool(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu01,
payload,
);
}
/**
* MU-02: Create a 3d annotation.
* @param payload The 3d annotation interaction payload.
*/
async createAnnotation3dTool(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu02,
payload,
);
}
/**
* MU-03: Create Annotation(s) in 2D/3D.
* @param payload The create annotation payload.
*/
async createAnnotation(
payload: Viewer3crPayload<DataOverlayData[]>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu03,
payload,
);
}
/**
* MU-04: Move annotation in 2D view.
* @param payload The move annotation payload.
*/
async moveAnnotation2dTool(
payload: Viewer3crPayload<ObjectBoolean>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu04,
payload,
);
}
/**
* MU-05: Move annotation in 3D view.
* @param payload The move annotation payload.
*/
async moveAnnotation3dTool(
payload: Viewer3crPayload<ObjectBoolean>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu05,
payload,
);
}
/**
* MU-06: Move multiple annotations.
* @param payload The move annotations payload.
*/
async moveAnnotation(
payload: Viewer3crPayload<ObjectPosition[]>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu06,
payload,
);
}
/**
* MU-07: Remove annotation.
* @param payload The remove annotation payload.
*/
async removeAnnotation(payload: Viewer3crPayload<ObjectId>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu07,
payload,
);
}
/**
* MU-08: Update annotation title.
* @param payload The update annotation title payload.
*/
async updateAnnotationTitle(
payload: Viewer3crPayload<ObjectInfo>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu08,
payload,
);
}
/**
* MU-09: Update annotation description.
* @param payload The update annotation description payload.
*/
async updateAnnotationDescription(
payload: Viewer3crPayload<ObjectInfo>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu09,
payload,
);
}
/**
* MU-10: Update annotation actions.
* @param payload The update annotation actions payload.
*/
async updateAnnotationActions(
payload: Viewer3crPayload<ObjectInfo>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu10,
payload,
);
}
/**
* MU-16: Set 2D/3D visibility of measurements.
* @param payload The measurement visibility payload.
*/
async setMeasurementVisibility(
payload: Viewer3crPayload<ObjectDimensionalVisibility[]>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu16,
payload,
);
}
/**
* MU-20: 2D length tool.
* @param payload The tool interactivity payload.
*/
async lengthTool(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu20,
payload,
);
}
/**
* MU-21: 2D polygon tool.
* @param payload The tool interactivity payload.
*/
async polygonTool(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu21,
payload,
);
}
/**
* MU-22: 2D angle tool.
* @param payload The tool interactivity payload.
*/
async angleTool(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.markups,
MarkupsActions.mu22,
payload,
);
}
/**
* NC-01: Set Navigation Cube Co-ordinates and Size.
* @param payload The navigation cube payload.
*/
async setNavCubePositionSize(
payload: Viewer3crPayload<NavigationCubeTransform>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.navigation_cube,
NavigationCubeActions.nc01,
payload,
);
}
/**
* NC-02: Set Navigation Cube Visibility.
* @param payload The navigation cube visibility payload.
*/
async setNavCubeVisibility(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.navigation_cube,
NavigationCubeActions.nc02,
payload,
);
}
/**
* NC-03: Set Navigation Cube Interactivity.
* @param payload The navigation cube interactivity payload.
*/
async setNavCubeInteractivity(
payload: Viewer3crPayload<InteractivityState>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.navigation_cube,
NavigationCubeActions.nc03,
payload,
);
}
/**
* NC-05: Set Navigation Cube Colour and Opacity.
* All values must be floats between 0 and 1.
* @param payload The navigation cube colour payload.
*/
async setNavCubeColourOpacity(
payload: Viewer3crPayload<ColourData>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.navigation_cube,
NavigationCubeActions.nc05,
payload,
);
}
/**
* NC-07: Set Navigation Cube Highlight Colour and Opacity.
* All values must be floats between 0 and 255.
* @param payload The navigation cube highlight colour payload.
*/
async setNavCubeHighlightColourOpacity(
payload: Viewer3crPayload<ColourData>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.navigation_cube,
NavigationCubeActions.nc07,
payload,
);
}
/**
* NC-08: Set Navigation Cube Face Graphics.
* @param type Face type of cube.
*/
async setNavCubeGraphics(type: GraphicType): Promise<void> {
const message = { Version: '0.0.1', Value: type };
await this.sendPayload(
FrontEndInterfaces.navigation_cube,
NavigationCubeActions.nc08,
{ message },
);
}
/**
* SM-13: Pan the selected view to the left.
* @param payload The scan movement payload.
*/
async panLeft(payload: Viewer3crPayload<MovementData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm13,
payload,
);
}
/**
* SM-14: Pan the selected view to the right.
* @param payload The scan movement payload.
*/
async panRight(payload: Viewer3crPayload<MovementData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm14,
payload,
);
}
/**
* SM-15: Pan the selected view upwards.
* @param payload The scan movement payload.
*/
async panUp(payload: Viewer3crPayload<MovementData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm15,
payload,
);
}
/**
* SM-16: Pan the selected view downwards.
* @param payload The scan movement payload.
*/
async panDown(payload: Viewer3crPayload<MovementData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm16,
payload,
);
}
/**
* SM-17: Zoom In.
* @param payload The scan zoom payload.
*/
async zoomIn(payload: Viewer3crPayload<MovementData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm17,
payload,
);
}
/**
* SM-18: Zoom out.
* @param payload The scan zoom payload.
*/
async zoomOut(payload: Viewer3crPayload<MovementData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm18,
payload,
);
}
/**
* SM-26: Pan view.
* @param payload The pan payload.
*/
async pan(payload: Viewer3crPayload<ViewToggleData>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_movement,
ScanMovementActions.sm26,
payload,
);
}
/**
* SO-01: Rotate 2D view by up to +-XXX degrees.
* @param payload The scan movement payload.
*/
async rotateByDeg(payload: Viewer3crPayload<RotationValue>) {
await this.sendPayload(
FrontEndInterfaces.scan_orientation,
ScanOrientationActions.so01,
payload,
);
}
/**
* SO-02: Flip 2D View Horizontally.
* @param payload The scan flip payload.
*/
async flipHorizontally(payload: Viewer3crPayload<FlipValue>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_orientation,
ScanOrientationActions.so02,
payload,
);
}
/**
* SO-03: Flip 2D View Vertically.
* @param payload The scan flip payload.
*/
async flipVertically(payload: Viewer3crPayload<FlipValue>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_orientation,
ScanOrientationActions.so03,
payload,
);
}
/**
* SO-04: Invert Volume Rendering
* @param payload The invert volume payload.
*/
async invertTransform(
payload: Viewer3crPayload<InvertTransformData>,
): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.scan_orientation,
ScanOrientationActions.so04,
payload,
);
}
async viewSelection(action: ViewSelectionActions) {
const payload = { message: { Version: '1.0.0' } };
await this.sendPayload(FrontEndInterfaces.view_selection, action, payload);
}
async viewSelectionToggleView(payload: Viewer3crPayload<ViewToggleData>) {
await this.sendPayload(
FrontEndInterfaces.view_selection,
ViewSelectionActions.vs07,
payload,
);
}
async sliderHandler(action: SlidersActions, value: number) {
if (unref(transactionStarted)) return;
await this.slider(action, value);
}
async scanMovementHandler(action: ScanMovementActions, value: number) {
if (unref(transactionStarted)) return;
await this.scanMovement(action, value);
}
async layouts(action: LayoutActions) {
const payload = { message: { Version: '1.0.0' } };
await this.sendPayload(FrontEndInterfaces.layout, action, payload);
}
async customLayout(payload: Viewer3crPayload<CustomLayout>): Promise<void> {
await this.sendPayload(
FrontEndInterfaces.layout,
LayoutActions.lo04,
payload,
);
}
async setPreset(
action: PresetsActions,
preset: ColourPresetData | GreyscalePresetData,
) {
const payload = { message: preset };
await this.sendPayload(FrontEndInterfaces.presets, action, payload);
if (action === PresetsActions.pr02) {
currentColourPreset.value = preset as ColourPresetData;
}
}
private async scanMovement(action: ScanMovementActions, value: number) {
const payload = { message: { Version: '0.0.1', Value: value } };
await this.sendPayload(FrontEndInterfaces.scan_movement, action, payload);
}
private async slider(action: SlidersActions, value: number) {
const payload = { message: { Version: '0.0.1', Value: value } };
await this.sendPayload(FrontEndInterfaces.sliders, action, payload);
}
async sendPayload(
iface: string,
action: string,
payload: Viewer3crPayload<unknown>,
): Promise<void> {
await executePayload({
Version: '0.0.1',
Interface: iface as any,
Action: action as any,
Message: payload.message ? JSON.stringify(payload.message) : null,
ReturnChannel: payload.returnChannel
? JSON.stringify(payload.returnChannel)
: null,
ReturnTo: payload.returnTo ?? null,
});
}
async onPayload(payload: FrontEndPayload): Promise<void> {
const { Interface, Message, Action, ReturnChannel, ReturnTo } = payload;
await this.interfaceCallbacks.call(
Interface,
Message,
Action,
ReturnChannel,
ReturnTo,
);
await this.actionCallbacks.call(Action, Message, ReturnChannel, ReturnTo);
}
}
|