Skip to content

Commit 787fb4e

Browse files
Add ui elements to handle updating color range (time, data, custom).
This commit also cleans up the ui of the proxy editor, as well as adding a new collapsable section called Color Management. Also, it adds to the opacity editor a button for toggling surface opacity mapping on the active representations lookup table. Change-Id: Ib6b6fd258644e9580c3b98029233b15a686e103e
1 parent 04df19f commit 787fb4e

File tree

8 files changed

+485
-93
lines changed

8 files changed

+485
-93
lines changed

VTK

Submodule VTK updated from 77d60b4 to 9ea8020

Web/Applications/Visualizer/www/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</div>
6262

6363
<div class="row hide-on-start">
64-
<div class='col-xs-12 col-sm-5 col-md-4 col-lg-3 scroll-overflow fix-height pv-gray-lighter-transparent lower-right-round-corner inspector-container' style='z-index: 1000;'>
64+
<div class='col-xs-12 col-sm-5 col-md-4 col-lg-3 scroll-overflow fix-height pv-gray-lighter-transparent lower-right-round-corner inspector-container' style='z-index: 1000; overflow-y: auto; overflow-x: hidden;'>
6565
<div class="row inspector" data-type="pipeline">
6666
<div class='clickable col-xS-12 col-sm-12 col-md-12 col-lg-12 nopadding pv-pipeline'>
6767
</div>

Web/Applications/Visualizer/www/main.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
.head-toolbar span { position: relative; top: 2px; font-size: 16px; }
44
.fix-height { position: relative; top: 0; left: 0; }
5-
.property { margin: 5px -15px; }
65
.pv-time-input { position: relative; top: 2px; width: 80px; border: solid 1px white; background: none; padding: 2px 10px; }
76

87
/* ---- Font - colors - Cursor ----- */
@@ -59,18 +58,6 @@ select.pv-form-height { font-size: 12px; }
5958
.dl-horizontal dd { margin-left: 80px; }
6059
.dl-horizontal dt { width: 60px; }
6160

62-
/* ---- Proxy editor ---- */
63-
64-
.pv-absolute-left { position: absolute; left: -15px; top: -25px; }
65-
66-
.pv-collapsable-content { padding-top: 25px; }
67-
.pv-collapsable-content.pv-collapse { padding: 0; }
68-
div.pv-collapse-title { display: none; position: relative; }
69-
div.pv-no-collapse-title { display: block; position: relative; }
70-
.pv-collapse > div { display: none !important; }
71-
.pv-collapse div.pv-collapse-title { display: block !important; }
72-
73-
7461
/* ---- Information Tab ---- */
7562

7663
.pv-data-info dl { margin-bottom: 0; }

Web/Applications/Visualizer/www/main.js

Lines changed: 105 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@
475475
proxyEditor.bind('update-scalar-opacity-function', onUpdateOpacityPoints);
476476
proxyEditor.bind('store-scalar-opacity-parameters', onStoreOpacityParameters);
477477
proxyEditor.bind('initialize-scalar-opacity-widget', onInitializeScalarOpacityWidget);
478+
proxyEditor.bind('request-scalar-range', onRequestScalarRange);
479+
proxyEditor.bind('push-new-surface-opacity', onSurfaceOpacityChanged);
478480
}
479481

480482
// ------------------------------------------------------------------------
@@ -515,7 +517,7 @@
515517
function onUpdateOpacityPoints(event) {
516518
var colorBy = event.colorBy;
517519
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];
519521
startWorking();
520522
session.call('pv.color.manager.opacity.points.set', args).then(function(successResult) {
521523
viewport.invalidateScene();
@@ -524,6 +526,22 @@
524526
}
525527
}
526528

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+
527545
function onStoreOpacityParameters(event) {
528546
var colorArray = event.colorBy.array;
529547
if (colorArray.length >= 2 && colorArray[1] !== '') {
@@ -536,36 +554,86 @@
536554

537555
// ------------------------------------------------------------------------
538556

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+
539572
function onRescaleTransferFunction(event) {
540573
startWorking();
541574
var options = { proxyId: event.id, type: event.mode };
542575
if(event.mode === 'custom') {
543576
options.min = event.min;
544577
options.max = event.max;
545578
}
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 [];
547602
}
548603

549604
// ------------------------------------------------------------------------
550605

551606
function onNewProxyLoaded() {
552607
if(pipelineDataModel.metadata && pipelineDataModel.source && pipelineDataModel.representation && pipelineDataModel.view) {
553608
var props = [].concat(
609+
"+Color Management",
610+
extractRepresentation(pipelineDataModel.representation.properties),
554611
"ColorByPanel",
612+
"_Color Management",
555613
"+Source", pipelineDataModel.source.properties, '_Source',
556614
"-Representation", pipelineDataModel.representation.properties, '_Representation',
557615
"-View", pipelineDataModel.view.properties, "_View"
558616
),
559617
ui = [].concat(
618+
"+Color Management",
619+
extractRepresentation(pipelineDataModel.representation.ui),
560620
"ColorByPanel",
621+
"_Color Management",
561622
"+Source", pipelineDataModel.source.ui, '_Source',
562623
"-Representation", pipelineDataModel.representation.ui, '_Representation',
563624
"-View", pipelineDataModel.view.ui, "_View"
564625
);
565626

566627

567628
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);
569637
$('.inspector-container').scrollTop(0);
570638
} catch(err) {
571639
console.log(err);
@@ -592,31 +660,51 @@
592660
// Opacity editor widget creation
593661
// ========================================================================
594662
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+
}
605680

606681
if (colorArray.length >= 2 && colorArray[1] !== '') {
607-
var retrieveKey = colorArray[1] + ":opacityParameters";
608682

683+
var retrieveKey = colorArray[1] + ":opacityParameters";
609684
session.call('pv.keyvaluepair.retrieve', [retrieveKey]).then(function(result) {
610685
if (result !== null) {
611686
initOptions.gaussiansList = result.gaussianPoints;
612687
initOptions.linearPoints = result.linearPoints;
688+
initOptions.gaussianMode = result.gaussianMode;
689+
initOptions.interactiveMode = result.interactiveMode;
613690
}
614-
container.opacityEditor(initOptions);
691+
gotInitParam('currentPointSet');
615692
workDone();
616693
}, workDone);
617-
}
618694

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+
}
620708
}
621709

622710
// ========================================================================

Web/Python/paraview/web/protocols.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,24 @@ def rescaleTransferFunction(self, options):
461461
rangemax,
462462
extend)
463463

464+
if status['success']:
465+
currentRange = self.getCurrentScalarRange(proxyId)
466+
status['range'] = currentRange
467+
464468
return status
465469

470+
# RpcName: getCurrentScalarRange => pv.color.manager.scalar.range.get
471+
@exportRpc("pv.color.manager.scalar.range.get")
472+
def getCurrentScalarRange(self, proxyId):
473+
proxy = self.mapIdToProxy(proxyId)
474+
rep = simple.GetRepresentation(proxy)
475+
476+
lookupTable = rep.LookupTable
477+
cMin = lookupTable.RGBPoints[0]
478+
cMax = lookupTable.RGBPoints[-4]
479+
480+
return { 'min': cMin, 'max': cMax }
481+
466482
# RpcName: colorBy => pv.color.manager.color.by
467483
@exportRpc("pv.color.manager.color.by")
468484
def colorBy(self, representation, colorMode, arrayLocation='POINTS', arrayName='', vectorMode='Magnitude', vectorComponent=0, rescale=False):
@@ -494,9 +510,9 @@ def colorBy(self, representation, colorMode, arrayLocation='POINTS', arrayName='
494510

495511
# RpcName: setOpacityFunctionPoints => pv.color.manager.opacity.points.set
496512
@exportRpc("pv.color.manager.opacity.points.set")
497-
def setOpacityFunctionPoints(self, representation, arrayName, pointArray):
498-
repProxy = self.mapIdToProxy(representation)
499-
lutProxy = repProxy.LookupTable
513+
def setOpacityFunctionPoints(self, arrayName, pointArray):
514+
lutProxy = simple.GetColorTransferFunction(arrayName)
515+
pwfProxy = simple.GetOpacityTransferFunction(arrayName)
500516

501517
# Use whatever the current scalar range is for this array
502518
cMin = lutProxy.RGBPoints[0]
@@ -510,10 +526,28 @@ def setOpacityFunctionPoints(self, representation, arrayName, pointArray):
510526
pointArray[idx] = (x * (cMax - cMin)) + cMin
511527

512528
# Set the Points property to scaled and biased points array
513-
repProxy.ScalarOpacityFunction.Points = pointArray
529+
pwfProxy.Points = pointArray
530+
531+
simple.Render()
532+
533+
# RpcName: setSurfaceOpacity => pv.color.manager.surface.opacity.set
534+
@exportRpc("pv.color.manager.surface.opacity.set")
535+
def setSurfaceOpacity(self, representation, enabled):
536+
repProxy = self.mapIdToProxy(representation)
537+
lutProxy = repProxy.LookupTable
538+
539+
lutProxy.EnableOpacityMapping = enabled
514540

515541
simple.Render()
516542

543+
# RpcName: getSurfaceOpacity => pv.color.manager.surface.opacity.get
544+
@exportRpc("pv.color.manager.surface.opacity.get")
545+
def getSurfaceOpacity(self, representation):
546+
repProxy = self.mapIdToProxy(representation)
547+
lutProxy = repProxy.LookupTable
548+
549+
return lutProxy.EnableOpacityMapping
550+
517551
# RpcName: selectColorMap => pv.color.manager.select.preset
518552
@exportRpc("pv.color.manager.select.preset")
519553
def selectColorMap(self, representation, paletteName):

0 commit comments

Comments
 (0)