|
475 | 475 | proxyEditor.bind('update-scalar-opacity-function', onUpdateOpacityPoints); |
476 | 476 | proxyEditor.bind('store-scalar-opacity-parameters', onStoreOpacityParameters); |
477 | 477 | proxyEditor.bind('initialize-scalar-opacity-widget', onInitializeScalarOpacityWidget); |
| 478 | + proxyEditor.bind('request-scalar-range', onRequestScalarRange); |
| 479 | + proxyEditor.bind('push-new-surface-opacity', onSurfaceOpacityChanged); |
478 | 480 | } |
479 | 481 |
|
480 | 482 | // ------------------------------------------------------------------------ |
|
515 | 517 | function onUpdateOpacityPoints(event) { |
516 | 518 | var colorBy = event.colorBy; |
517 | 519 | if (colorBy.array.length >= 2 && colorBy.array[1] !== '') { |
518 | | - var args = [colorBy.representation, colorBy.array, event.points]; |
| 520 | + var args = [colorBy.array[1], event.points]; |
519 | 521 | startWorking(); |
520 | 522 | session.call('pv.color.manager.opacity.points.set', args).then(function(successResult) { |
521 | 523 | viewport.invalidateScene(); |
|
524 | 526 | } |
525 | 527 | } |
526 | 528 |
|
| 529 | + // ------------------------------------------------------------------------ |
| 530 | + |
| 531 | + function onSurfaceOpacityChanged(event) { |
| 532 | + var colorBy = event.colorBy; |
| 533 | + if (colorBy.array.length >= 2 && colorBy.array[1] !== '') { |
| 534 | + var args = [colorBy.representation, (event.opacity === true ? 1 : 0)]; |
| 535 | + startWorking(); |
| 536 | + session.call('pv.color.manager.surface.opacity.set', args).then(function(successResult) { |
| 537 | + viewport.invalidateScene(); |
| 538 | + workDone(); |
| 539 | + }, workDone); |
| 540 | + } |
| 541 | + } |
| 542 | + |
| 543 | + // ------------------------------------------------------------------------ |
| 544 | + |
527 | 545 | function onStoreOpacityParameters(event) { |
528 | 546 | var colorArray = event.colorBy.array; |
529 | 547 | if (colorArray.length >= 2 && colorArray[1] !== '') { |
|
536 | 554 |
|
537 | 555 | // ------------------------------------------------------------------------ |
538 | 556 |
|
| 557 | + function onRequestScalarRange(event) { |
| 558 | + var proxyId = event.proxyId; |
| 559 | + startWorking(); |
| 560 | + session.call('pv.color.manager.scalar.range.get', [proxyId]).then(function(curScalarRange) { |
| 561 | + proxyEditor.trigger({ |
| 562 | + 'type': 'update-scalar-range-values', |
| 563 | + 'min': curScalarRange.min, |
| 564 | + 'max': curScalarRange.max |
| 565 | + }); |
| 566 | + workDone(); |
| 567 | + }, workDone); |
| 568 | + } |
| 569 | + |
| 570 | + // ------------------------------------------------------------------------ |
| 571 | + |
539 | 572 | function onRescaleTransferFunction(event) { |
540 | 573 | startWorking(); |
541 | 574 | var options = { proxyId: event.id, type: event.mode }; |
542 | 575 | if(event.mode === 'custom') { |
543 | 576 | options.min = event.min; |
544 | 577 | options.max = event.max; |
545 | 578 | } |
546 | | - session.call('pv.color.manager.rescale.transfer.function', [options]).then(invalidatePipeline, invalidatePipeline); |
| 579 | + session.call('pv.color.manager.rescale.transfer.function', [options]).then(function(successResult) { |
| 580 | + if (successResult['success'] === true) { |
| 581 | + viewport.invalidateScene(); |
| 582 | + proxyEditor.trigger({ |
| 583 | + 'type': 'update-scalar-range-values', |
| 584 | + 'min': successResult.range.min, |
| 585 | + 'max': successResult.range.max |
| 586 | + }); |
| 587 | + } |
| 588 | + workDone(); |
| 589 | + }, workDone); |
| 590 | + } |
| 591 | + |
| 592 | + // ------------------------------------------------------------------------ |
| 593 | + |
| 594 | + function extractRepresentation(list) { |
| 595 | + var count = list.length; |
| 596 | + while(count--) { |
| 597 | + if(list[count].name === 'Representation') { |
| 598 | + return [list[count]]; |
| 599 | + } |
| 600 | + } |
| 601 | + return []; |
547 | 602 | } |
548 | 603 |
|
549 | 604 | // ------------------------------------------------------------------------ |
550 | 605 |
|
551 | 606 | function onNewProxyLoaded() { |
552 | 607 | if(pipelineDataModel.metadata && pipelineDataModel.source && pipelineDataModel.representation && pipelineDataModel.view) { |
553 | 608 | var props = [].concat( |
| 609 | + "+Color Management", |
| 610 | + extractRepresentation(pipelineDataModel.representation.properties), |
554 | 611 | "ColorByPanel", |
| 612 | + "_Color Management", |
555 | 613 | "+Source", pipelineDataModel.source.properties, '_Source', |
556 | 614 | "-Representation", pipelineDataModel.representation.properties, '_Representation', |
557 | 615 | "-View", pipelineDataModel.view.properties, "_View" |
558 | 616 | ), |
559 | 617 | ui = [].concat( |
| 618 | + "+Color Management", |
| 619 | + extractRepresentation(pipelineDataModel.representation.ui), |
560 | 620 | "ColorByPanel", |
| 621 | + "_Color Management", |
561 | 622 | "+Source", pipelineDataModel.source.ui, '_Source', |
562 | 623 | "-Representation", pipelineDataModel.representation.ui, '_Representation', |
563 | 624 | "-View", pipelineDataModel.view.ui, "_View" |
564 | 625 | ); |
565 | 626 |
|
566 | 627 |
|
567 | 628 | try { |
568 | | - proxyEditor.proxyEditor(pipelineDataModel.metadata.name, pipelineDataModel.metadata.leaf, pipelineDataModel.metadata.id, props, ui, pipelineDataModel.source.data.arrays, paletteNameList, pipelineDataModel.representation.colorBy); |
| 629 | + proxyEditor.proxyEditor(pipelineDataModel.metadata.name, |
| 630 | + pipelineDataModel.metadata.leaf, |
| 631 | + pipelineDataModel.metadata.id, |
| 632 | + props, |
| 633 | + ui, |
| 634 | + pipelineDataModel.source.data.arrays, |
| 635 | + paletteNameList, |
| 636 | + pipelineDataModel.representation.colorBy); |
569 | 637 | $('.inspector-container').scrollTop(0); |
570 | 638 | } catch(err) { |
571 | 639 | console.log(err); |
|
592 | 660 | // Opacity editor widget creation |
593 | 661 | // ======================================================================== |
594 | 662 | function onInitializeScalarOpacityWidget(event) { |
595 | | - var container = event.container; |
596 | | - var colorArray = event.colorArray; |
597 | | - |
598 | | - var initOptions = { |
599 | | - 'buttonsPosition': 'top', |
600 | | - 'topMargin': 10, |
601 | | - 'rightMargin': 15, |
602 | | - 'bottomMargin': 10, |
603 | | - 'leftMargin': 15 |
604 | | - }; |
| 663 | + var container = event.container, |
| 664 | + colorArray = event.colorBy.array, |
| 665 | + needParams = [ 'currentPointSet', 'surfaceOpacityEnabled' ], |
| 666 | + initOptions = { |
| 667 | + 'buttonsPosition': 'top', |
| 668 | + 'topMargin': 10, |
| 669 | + 'rightMargin': 15, |
| 670 | + 'bottomMargin': 10, |
| 671 | + 'leftMargin': 15 |
| 672 | + }; |
| 673 | + |
| 674 | + function gotInitParam(paramName) { |
| 675 | + needParams.splice(needParams.indexOf(paramName), 1); |
| 676 | + if (needParams.length === 0) { |
| 677 | + container.opacityEditor(initOptions); |
| 678 | + } |
| 679 | + } |
605 | 680 |
|
606 | 681 | if (colorArray.length >= 2 && colorArray[1] !== '') { |
607 | | - var retrieveKey = colorArray[1] + ":opacityParameters"; |
608 | 682 |
|
| 683 | + var retrieveKey = colorArray[1] + ":opacityParameters"; |
609 | 684 | session.call('pv.keyvaluepair.retrieve', [retrieveKey]).then(function(result) { |
610 | 685 | if (result !== null) { |
611 | 686 | initOptions.gaussiansList = result.gaussianPoints; |
612 | 687 | initOptions.linearPoints = result.linearPoints; |
| 688 | + initOptions.gaussianMode = result.gaussianMode; |
| 689 | + initOptions.interactiveMode = result.interactiveMode; |
613 | 690 | } |
614 | | - container.opacityEditor(initOptions); |
| 691 | + gotInitParam('currentPointSet'); |
615 | 692 | workDone(); |
616 | 693 | }, workDone); |
617 | | - } |
618 | 694 |
|
619 | | - container.opacityEditor(initOptions); |
| 695 | + var representation = event.colorBy.representation; |
| 696 | + session.call('pv.color.manager.surface.opacity.get', [representation]).then(function(result) { |
| 697 | + if (result !== null) { |
| 698 | + initOptions.surfaceOpacityEnabled = (result === 1 ? true : false); |
| 699 | + } |
| 700 | + gotInitParam('surfaceOpacityEnabled'); |
| 701 | + workDone(); |
| 702 | + }, workDone); |
| 703 | + |
| 704 | + } else { |
| 705 | + console.log("WARNING: Initializing the opacity editor while not coloring by an array."); |
| 706 | + container.opacityEditor(initOptions); |
| 707 | + } |
620 | 708 | } |
621 | 709 |
|
622 | 710 | // ======================================================================== |
|
0 commit comments