Skip to content

Commit 978f0b5

Browse files
authored
Merge branch 'master' into fix/hardware-selector-edges
2 parents c060005 + c6f2e12 commit 978f0b5

File tree

12 files changed

+117
-26
lines changed

12 files changed

+117
-26
lines changed

Examples/Volume/VolumeOutline/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function createLabelPipeline(backgroundImageData) {
8888
labelMap.actor.getProperty().setInterpolationTypeToNearest();
8989
labelMap.actor.getProperty().setUseLabelOutline(true);
9090
labelMap.actor.getProperty().setLabelOutlineThickness(3);
91+
labelMap.actor.getProperty().setLabelOutlineOpacity(1.0);
9192

9293
return labelMap;
9394
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
/* eslint-disable prefer-rest-params */
12
export default class ClassHierarchy extends Array {
2-
push(...args) {
3-
// no perf issue since args.length should be small
4-
const newArgs = args.filter((arg) => !this.includes(arg));
5-
return super.push(...newArgs);
3+
push() {
4+
for (let i = 0; i < arguments.length; i++) {
5+
if (!this.includes(arguments[i])) {
6+
super.push(arguments[i]);
7+
}
8+
}
9+
10+
return this.length;
611
}
712
}

Sources/Rendering/Core/Prop3D/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ function vtkProp3D(publicAPI, model) {
9999
};
100100

101101
publicAPI.setUserMatrix = (matrix) => {
102+
if (vtkMath.areMatricesEqual(model.userMatrix, matrix)) {
103+
return false;
104+
}
102105
mat4.copy(model.userMatrix, matrix);
103106
publicAPI.modified();
107+
return true;
104108
};
105109

106110
publicAPI.getMatrix = () => {

Sources/Rendering/Core/VolumeProperty/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ const DEFAULT_VALUES = {
253253
specularPower: 10.0,
254254
useLabelOutline: false,
255255
labelOutlineThickness: 1,
256+
labelOutlineOpacity: 1.0,
256257
};
257258

258259
// ----------------------------------------------------------------------------
@@ -295,6 +296,7 @@ export function extend(publicAPI, model, initialValues = {}) {
295296
'specularPower',
296297
'useLabelOutline',
297298
'labelOutlineThickness',
299+
'labelOutlineOpacity',
298300
]);
299301

300302
// Object methods

Sources/Rendering/Misc/RemoteView/example/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ const config = {
4646
clientToConnect
4747
.connect(config)
4848
.then((validClient) => {
49-
const viewStream = this.clientToConnect
50-
.getImageStream()
51-
.createViewStream('-1');
49+
const viewStream = clientToConnect.getImageStream().createViewStream('-1');
5250

5351
const view = vtkRemoteView.newInstance({
5452
rpcWheelEvent: 'viewport.mouse.zoom.wheel',

Sources/Rendering/OpenGL/VolumeMapper/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
10291029
.getProperty()
10301030
.getLabelOutlineThickness();
10311031

1032+
const labelOutlineOpacity = actor.getProperty().getLabelOutlineOpacity();
1033+
10321034
program.setUniformi('outlineThickness', labelOutlineThickness);
1035+
program.setUniformf('outlineOpacity', labelOutlineOpacity);
10331036
}
10341037

10351038
if (model.lastLightComplexity > 0) {

Sources/Rendering/OpenGL/glsl/vtkVolumeFS.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ varying vec3 vertexVCVSOutput;
4444

4545
#ifdef vtkImageLabelOutlineOn
4646
uniform int outlineThickness;
47+
uniform float outlineOpacity;
4748
uniform float vpWidth;
4849
uniform float vpHeight;
4950
uniform float vpOffsetX;
@@ -995,7 +996,7 @@ vec4 getColorForValue(vec4 tValue, vec3 posIS, vec3 tstep)
995996

996997
// If I am on the border, I am displayed at full opacity
997998
if (pixelOnBorder == true) {
998-
tColor.a = 1.0;
999+
tColor.a = outlineOpacity;
9991000
}
10001001
}
10011002

Sources/Testing/testMacro.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const DEFAULT_VALUES = {
3535
myProp11: 11,
3636
_myProp12: [12],
3737
_myProp13: 13,
38+
myObjectProp: { foo: 1 },
3839
};
3940

4041
// ----------------------------------------------------------------------------
@@ -74,6 +75,9 @@ function extend(publicAPI, model, initialValues = {}) {
7475
macro.setGetArray(publicAPI, model, ['_myProp12'], 1);
7576
macro.moveToProtected(publicAPI, model, ['myProp11', 'myProp12', 'myProp13']);
7677

78+
// Object member variables
79+
macro.setGet(publicAPI, model, [{ name: 'myObjectProp', type: 'object' }]);
80+
7781
// Object specific methods
7882
myClass(publicAPI, model);
7983

@@ -405,6 +409,39 @@ test('Macro methods enum tests', (t) => {
405409
t.end();
406410
});
407411

412+
test('Macro methods object tests', (t) => {
413+
const myTestClass = newInstance();
414+
415+
const mtime = myTestClass.getMTime();
416+
t.equal(
417+
myTestClass.setMyObjectProp({ foo: 1 }),
418+
false,
419+
'No change on same object'
420+
);
421+
t.equal(myTestClass.getMTime(), mtime, 'No change when setting same object');
422+
423+
t.equal(
424+
myTestClass.setMyObjectProp({ foo: 2 }),
425+
true,
426+
'Change on different object'
427+
);
428+
t.notEqual(myTestClass.getMTime(), mtime, 'Change when setting same object');
429+
t.deepEqual(
430+
myTestClass.getMyObjectProp(),
431+
{ foo: 2 },
432+
'Change on different object'
433+
);
434+
435+
myTestClass.getMyObjectProp().foo = 3;
436+
t.deepEqual(
437+
myTestClass.getMyObjectProp(),
438+
{ foo: 2 },
439+
'Getter shall return a copy'
440+
);
441+
442+
t.end();
443+
});
444+
408445
test('Macro methods object tests', (t) => {
409446
const myTestClass = newInstance();
410447

Sources/Widgets/Representations/WidgetRepresentation/index.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function connectPipeline(pipeline) {
7878
function vtkWidgetRepresentation(publicAPI, model) {
7979
// Set our className
8080
model.classHierarchy.push('vtkWidgetRepresentation');
81+
const superclass = { ...publicAPI };
8182
// Internal cache
8283
const cache = { mtimes: {}, states: [] };
8384

@@ -194,13 +195,15 @@ function vtkWidgetRepresentation(publicAPI, model) {
194195
};
195196

196197
publicAPI.setCoincidentTopologyParameters = (parameters) => {
197-
model.coincidentTopologyParameters = parameters;
198-
publicAPI.getActors().forEach((actor) => {
199-
applyCoincidentTopologyParametersToMapper(
200-
actor.getMapper(),
201-
model.coincidentTopologyParameters
202-
);
203-
});
198+
const modified = superclass.setCoincidentTopologyParameters(parameters);
199+
if (modified) {
200+
publicAPI.getActors().forEach((actor) => {
201+
applyCoincidentTopologyParametersToMapper(
202+
actor.getMapper(),
203+
model.coincidentTopologyParameters
204+
);
205+
});
206+
}
204207
};
205208

206209
publicAPI.getPixelWorldHeightAtCoord = (worldCoord) => {
@@ -268,8 +271,11 @@ export function extend(publicAPI, model, initialValues = {}) {
268271
// Object methods
269272
vtkProp.extend(publicAPI, model, initialValues);
270273
macro.algo(publicAPI, model, 1, 1);
271-
macro.get(publicAPI, model, ['labels', 'coincidentTopologyParameters']);
272-
macro.set(publicAPI, model, ['displayScaleParams']);
274+
macro.get(publicAPI, model, ['labels']);
275+
macro.set(publicAPI, model, [
276+
{ type: 'object', name: 'displayScaleParams' },
277+
{ type: 'object', name: 'coincidentTopologyParameters' },
278+
]);
273279
macro.setGet(publicAPI, model, ['scaleInPixels']);
274280

275281
// Object specific methods

Sources/Widgets/SVG/SVGLandmarkRepresentation/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ export function extend(publicAPI, model, initialValues = {}) {
168168
vtkSVGRepresentation.extend(publicAPI, model, defaultValues(initialValues));
169169

170170
macro.setGet(publicAPI, model, [
171-
'circleProps',
172-
'fontProperties',
173-
'strokeFontProperties',
174-
'textProps',
171+
{ type: 'object', name: 'circleProps' },
172+
{ type: 'object', name: 'fontProperties' },
173+
{ type: 'object', name: 'strokeFontProperties' },
174+
{ type: 'object', name: 'textProps' },
175175
]);
176176

177177
// Object specific methods

0 commit comments

Comments
 (0)