Process points callback message from the frontend
(self, change)
| 633 | |
| 634 | @observe("_js2py_pointsCallback") |
| 635 | def _handler_js2py_pointsCallback(self, change): |
| 636 | """ |
| 637 | Process points callback message from the frontend |
| 638 | """ |
| 639 | |
| 640 | # Receive message |
| 641 | # --------------- |
| 642 | callback_data = change["new"] |
| 643 | |
| 644 | if not callback_data: |
| 645 | self._js2py_pointsCallback = None |
| 646 | return |
| 647 | |
| 648 | # Get event type |
| 649 | # -------------- |
| 650 | event_type = callback_data["event_type"] |
| 651 | |
| 652 | # Build Selector Object |
| 653 | # --------------------- |
| 654 | if callback_data.get("selector", None): |
| 655 | selector_data = callback_data["selector"] |
| 656 | selector_type = selector_data["type"] |
| 657 | selector_state = selector_data["selector_state"] |
| 658 | if selector_type == "box": |
| 659 | selector = BoxSelector(**selector_state) |
| 660 | elif selector_type == "lasso": |
| 661 | selector = LassoSelector(**selector_state) |
| 662 | else: |
| 663 | raise ValueError("Unsupported selector type: %s" % selector_type) |
| 664 | else: |
| 665 | selector = None |
| 666 | |
| 667 | # Build Input Device State Object |
| 668 | # ------------------------------- |
| 669 | if callback_data.get("device_state", None): |
| 670 | device_state_data = callback_data["device_state"] |
| 671 | state = InputDeviceState(**device_state_data) |
| 672 | else: |
| 673 | state = None |
| 674 | |
| 675 | # Build Trace Points Dictionary |
| 676 | # ----------------------------- |
| 677 | points_data = callback_data["points"] |
| 678 | trace_points = { |
| 679 | trace_ind: { |
| 680 | "point_inds": [], |
| 681 | "xs": [], |
| 682 | "ys": [], |
| 683 | "trace_name": self._data_objs[trace_ind].name, |
| 684 | "trace_index": trace_ind, |
| 685 | } |
| 686 | for trace_ind in range(len(self._data_objs)) |
| 687 | } |
| 688 | |
| 689 | for x, y, point_ind, trace_ind in zip( |
| 690 | points_data["xs"], |
| 691 | points_data["ys"], |
| 692 | points_data["point_indexes"], |
nothing calls this directly
no test coverage detected