|
513 | 513 | proxyEditor.bind('initialize-scalar-opacity-widget', onInitializeScalarOpacityWidget); |
514 | 514 | proxyEditor.bind('request-scalar-range', onRequestScalarRange); |
515 | 515 | proxyEditor.bind('push-new-surface-opacity', onSurfaceOpacityChanged); |
| 516 | + proxyEditor.bind('initialize-color-editor-widget', onInitializeColorEditorWidget); |
| 517 | + proxyEditor.bind('update-rgb-points', onUpdateRgbPoints); |
516 | 518 | } |
517 | 519 |
|
518 | 520 | // ------------------------------------------------------------------------ |
|
562 | 564 | session.call('pv.color.manager.opacity.points.set', args).then(function(successResult) { |
563 | 565 | viewport.invalidateScene(); |
564 | 566 | workDone(); |
565 | | - }, workDone); |
| 567 | + }, error); |
566 | 568 | } |
567 | 569 | } |
568 | 570 |
|
|
576 | 578 | session.call('pv.color.manager.surface.opacity.set', args).then(function(successResult) { |
577 | 579 | viewport.invalidateScene(); |
578 | 580 | workDone(); |
579 | | - }, workDone); |
| 581 | + }, error); |
580 | 582 | } |
581 | 583 | } |
582 | 584 |
|
|
588 | 590 | var storeKey = colorArray[1] + ":opacityParameters"; |
589 | 591 | var args = [storeKey, event.parameters]; |
590 | 592 | startWorking(); |
591 | | - session.call('pv.keyvaluepair.store', args).then(workDone, workDone); |
| 593 | + session.call('pv.keyvaluepair.store', args).then(workDone, error); |
592 | 594 | } |
593 | 595 | } |
594 | 596 |
|
|
604 | 606 | 'max': curScalarRange.max |
605 | 607 | }); |
606 | 608 | workDone(); |
607 | | - }, workDone); |
| 609 | + }, error); |
608 | 610 | } |
609 | 611 |
|
610 | 612 | // ------------------------------------------------------------------------ |
|
619 | 621 | session.call('pv.color.manager.rescale.transfer.function', [options]).then(function(successResult) { |
620 | 622 | if (successResult['success'] === true) { |
621 | 623 | viewport.invalidateScene(); |
| 624 | + |
622 | 625 | proxyEditor.trigger({ |
623 | 626 | 'type': 'update-scalar-range-values', |
624 | 627 | 'min': successResult.range.min, |
625 | 628 | 'max': successResult.range.max |
626 | 629 | }); |
| 630 | + |
| 631 | + session.call('pv.color.manager.rgb.points.get', [event.colorBy.array[1]]).then(function(result) { |
| 632 | + proxyEditor.trigger({ |
| 633 | + 'type': 'notify-new-rgb-points-received', |
| 634 | + 'rgbpoints': result |
| 635 | + }); |
| 636 | + workDone(); |
| 637 | + }, error); |
| 638 | + } else { |
| 639 | + workDone(); |
627 | 640 | } |
628 | | - workDone(); |
629 | | - }, workDone); |
| 641 | + }, error); |
630 | 642 | } |
631 | 643 |
|
632 | 644 | // ------------------------------------------------------------------------ |
|
646 | 658 | function onNewProxyLoaded() { |
647 | 659 | if(pipelineDataModel.metadata && pipelineDataModel.source && pipelineDataModel.representation && pipelineDataModel.view) { |
648 | 660 | var colorBy = pipelineDataModel.representation.colorBy, |
| 661 | + widgetKey = 'pv.proxy.editor.settings', |
| 662 | + widgetSettings = retrieveWidgetSettings(widgetKey), |
| 663 | + options = { 'widgetKey': widgetKey, 'widgetData': widgetSettings }, |
| 664 | + srcVal = widgetSettings['Source'] || "+Source", |
| 665 | + repVal = widgetSettings['Representation'] || "-Representation", |
| 666 | + viewVal = widgetSettings['View'] || "-View", |
| 667 | + colMgmtVal = widgetSettings['Color Management'] || "+Color Management", |
649 | 668 | props = [].concat( |
650 | | - "+Source", pipelineDataModel.source.properties, '_Source', |
651 | | - "-Representation", pipelineDataModel.representation.properties, '_Representation', |
652 | | - "-View", pipelineDataModel.view.properties, "_View" |
| 669 | + srcVal, pipelineDataModel.source.properties, '_Source', |
| 670 | + repVal, pipelineDataModel.representation.properties, '_Representation', |
| 671 | + viewVal, pipelineDataModel.view.properties, "_View" |
653 | 672 | ), |
654 | 673 | ui = [].concat( |
655 | | - "+Source", pipelineDataModel.source.ui, '_Source', |
656 | | - "-Representation", pipelineDataModel.representation.ui, '_Representation', |
657 | | - "-View", pipelineDataModel.view.ui, "_View" |
| 674 | + srcVal, pipelineDataModel.source.ui, '_Source', |
| 675 | + repVal, pipelineDataModel.representation.ui, '_Representation', |
| 676 | + viewVal, pipelineDataModel.view.ui, "_View" |
658 | 677 | ); |
659 | 678 |
|
660 | 679 | if (!$.isEmptyObject(colorBy) && colorBy.hasOwnProperty('array')) { |
661 | | - props = [].concat("+Color Management", |
| 680 | + props = [].concat(colMgmtVal, |
662 | 681 | extractRepresentation(pipelineDataModel.representation.properties), |
663 | 682 | "ColorByPanel", |
664 | 683 | "_Color Management", |
665 | 684 | props); |
666 | | - ui = [].concat("+Color Management", |
| 685 | + ui = [].concat(colMgmtVal, |
667 | 686 | extractRepresentation(pipelineDataModel.representation.ui), |
668 | 687 | "ColorByPanel", |
669 | 688 | "_Color Management", |
|
678 | 697 | ui, |
679 | 698 | pipelineDataModel.source.data.arrays, |
680 | 699 | paletteNameList, |
681 | | - colorBy); |
| 700 | + colorBy, |
| 701 | + options); |
| 702 | + proxyEditor.bind('store-widget-settings', onStoreWidgetSettings); |
682 | 703 | $('.inspector-container').scrollTop(0); |
683 | 704 | } catch(err) { |
684 | 705 | console.log(err); |
|
701 | 722 | } |
702 | 723 | } |
703 | 724 |
|
| 725 | + // ------------------------------------------------------------------------ |
| 726 | + |
| 727 | + function onStoreWidgetSettings(event) { |
| 728 | + vtkWeb.storeApplicationDataObject(event.widgetKey, event.widgetData); |
| 729 | + } |
| 730 | + |
| 731 | + function retrieveWidgetSettings(widgetKey) { |
| 732 | + return vtkWeb.retrieveApplicationDataObject(widgetKey); |
| 733 | + } |
| 734 | + |
| 735 | + // ======================================================================== |
| 736 | + // Color editor widget creation |
| 737 | + // ======================================================================== |
| 738 | + |
| 739 | + function onInitializeColorEditorWidget(event) { |
| 740 | + var container = event.container, |
| 741 | + colorArray = event.colorBy.array, |
| 742 | + initOptions = { |
| 743 | + 'topMargin': 10, |
| 744 | + 'rightMargin': 15, |
| 745 | + 'bottomMargin': 10, |
| 746 | + 'leftMargin': 15, |
| 747 | + 'widgetKey': 'pv.color.editor.settings' |
| 748 | + }; |
| 749 | + |
| 750 | + if (colorArray.length >= 2 && colorArray[1] !== '') { |
| 751 | + startWorking(); |
| 752 | + session.call('pv.color.manager.rgb.points.get', [colorArray[1]]).then(function(result) { |
| 753 | + initOptions['rgbInfo'] = result; |
| 754 | + initOptions['widgetData'] = retrieveWidgetSettings(initOptions['widgetKey']); |
| 755 | + container.colorEditor(initOptions); |
| 756 | + container.bind('store-widget-settings', onStoreWidgetSettings); |
| 757 | + workDone(); |
| 758 | + }, error); |
| 759 | + } else { |
| 760 | + console.log("WARNING: Initializing the color editor while not coloring by an array."); |
| 761 | + container.colorEditor(initOptions); |
| 762 | + } |
| 763 | + } |
| 764 | + |
| 765 | + function onUpdateRgbPoints(event) { |
| 766 | + var arrayName = event.colorBy.array[1]; |
| 767 | + var rgbInfo = event.rgbInfo; |
| 768 | + |
| 769 | + startWorking(); |
| 770 | + session.call('pv.color.manager.rgb.points.set', [arrayName, rgbInfo]).then(function(result) { |
| 771 | + workDone(); |
| 772 | + viewport.invalidateScene(); |
| 773 | + }, error); |
| 774 | + } |
| 775 | + |
704 | 776 | // ======================================================================== |
705 | 777 | // Opacity editor widget creation |
706 | 778 | // ======================================================================== |
|
713 | 785 | 'topMargin': 10, |
714 | 786 | 'rightMargin': 15, |
715 | 787 | 'bottomMargin': 10, |
716 | | - 'leftMargin': 15 |
| 788 | + 'leftMargin': 15, |
| 789 | + 'widgetKey': 'pv.opacity.editor.settings' |
717 | 790 | }; |
718 | 791 |
|
719 | 792 | function gotInitParam(paramName) { |
720 | 793 | needParams.splice(needParams.indexOf(paramName), 1); |
721 | 794 | if (needParams.length === 0) { |
| 795 | + initOptions['widgetData'] = retrieveWidgetSettings(initOptions['widgetKey']); |
722 | 796 | container.opacityEditor(initOptions); |
| 797 | + container.bind('store-widget-settings', onStoreWidgetSettings); |
723 | 798 | } |
724 | 799 | } |
725 | 800 |
|
|
731 | 806 | initOptions.gaussiansList = result.gaussianPoints; |
732 | 807 | initOptions.linearPoints = result.linearPoints; |
733 | 808 | initOptions.gaussianMode = result.gaussianMode; |
734 | | - initOptions.interactiveMode = result.interactiveMode; |
735 | 809 | } |
736 | 810 | gotInitParam('currentPointSet'); |
737 | 811 | workDone(); |
738 | | - }, workDone); |
| 812 | + }, error); |
739 | 813 |
|
740 | 814 | var representation = event.colorBy.representation; |
741 | 815 | session.call('pv.color.manager.surface.opacity.get', [representation]).then(function(result) { |
|
744 | 818 | } |
745 | 819 | gotInitParam('surfaceOpacityEnabled'); |
746 | 820 | workDone(); |
747 | | - }, workDone); |
| 821 | + }, error); |
748 | 822 |
|
749 | 823 | } else { |
750 | 824 | console.log("WARNING: Initializing the opacity editor while not coloring by an array."); |
|
806 | 880 | alert(saveResult.message); |
807 | 881 | } |
808 | 882 | workDone(); |
809 | | - }, workDone); |
| 883 | + }, error); |
810 | 884 | } |
811 | 885 |
|
812 | 886 | function updateSaveDataFilename(activeType) { |
|
0 commit comments