@kitware/vtk.js 25.0.0 → 25.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Rendering/Core/Prop/Constants.d.ts +9 -0
- package/Rendering/Core/Prop/Constants.js +9 -0
- package/Rendering/Core/Prop.d.ts +69 -35
- package/Rendering/Core/Prop.js +27 -10
- package/Rendering/Core/Property2D.js +6 -2
- package/Rendering/Core/ScalarBarActor.js +113 -141
- package/Rendering/OpenGL/PolyDataMapper.js +16 -2
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/Profiles/All.js +2 -0
- package/Rendering/Profiles/Geometry.js +2 -0
- package/Rendering/WebGPU/Actor.js +20 -6
- package/Rendering/WebGPU/Actor2D.js +149 -0
- package/Rendering/WebGPU/CellArrayMapper.js +69 -22
- package/Rendering/WebGPU/Glyph3DMapper.js +10 -1
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
- package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
- package/Rendering/WebGPU/Profiles/All.js +2 -0
- package/Rendering/WebGPU/Profiles/Geometry.js +2 -0
- package/Rendering/WebGPU.js +2 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import { vec3, mat4 } from 'gl-matrix';
|
|
4
3
|
import * as d3 from 'd3-scale';
|
|
5
4
|
import { N as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
6
5
|
import macro from '../../macros.js';
|
|
@@ -29,15 +28,6 @@ var VectorMode = vtkScalarsToColors.VectorMode; // -----------------------------
|
|
|
29
28
|
// multiple rendering backends.
|
|
30
29
|
//
|
|
31
30
|
// ----------------------------------------------------------------------------
|
|
32
|
-
// some shared temp variables to reduce heap allocs
|
|
33
|
-
|
|
34
|
-
var ptv3 = new Float64Array(3);
|
|
35
|
-
var pt2v3 = new Float64Array(3);
|
|
36
|
-
var tmpv3 = new Float64Array(3);
|
|
37
|
-
var tmp2v3 = new Float64Array(3);
|
|
38
|
-
var xDir = new Float64Array(3);
|
|
39
|
-
var yDir = new Float64Array(3);
|
|
40
|
-
var invmat = new Float64Array(16);
|
|
41
31
|
|
|
42
32
|
function applyTextStyle(ctx, style) {
|
|
43
33
|
ctx.strokeStyle = style.strokeColor;
|
|
@@ -94,35 +84,31 @@ function defaultAutoLayout(publicAPI, model) {
|
|
|
94
84
|
var boxSize = helper.getBoxSizeByReference(); // if vertical
|
|
95
85
|
|
|
96
86
|
if (helper.getLastAspectRatio() > 1.0) {
|
|
97
|
-
helper.setTickLabelPixelOffset(0.
|
|
98
|
-
var tickWidth = 2.0 * (textSizes.tickWidth + helper.getTickLabelPixelOffset()) / lastSize[0];
|
|
99
|
-
helper.setAxisTitlePixelOffset(0.8 * axisTextStyle.fontSize); // width required if the title is vertical
|
|
100
|
-
|
|
101
|
-
var titleWidth = 2.0 * (textSizes.titleHeight + helper.getAxisTitlePixelOffset()) / lastSize[0]; // if the title will fit within the width of the bar then that looks
|
|
87
|
+
helper.setTickLabelPixelOffset(0.3 * tickTextStyle.fontSize); // if the title will fit within the width of the bar then that looks
|
|
102
88
|
// nicer to put it at the top (helper.topTitle), otherwise rotate it
|
|
103
89
|
// and place it sideways
|
|
104
90
|
|
|
105
|
-
if (tickWidth +
|
|
91
|
+
if (textSizes.titleWidth <= textSizes.tickWidth + helper.getTickLabelPixelOffset() + 0.8 * tickTextStyle.fontSize) {
|
|
106
92
|
helper.setTopTitle(true);
|
|
107
|
-
|
|
93
|
+
helper.setAxisTitlePixelOffset(0.2 * tickTextStyle.fontSize);
|
|
94
|
+
boxSize[0] = 2.0 * (textSizes.tickWidth + helper.getTickLabelPixelOffset() + 0.8 * tickTextStyle.fontSize) / lastSize[0];
|
|
108
95
|
helper.setBoxPosition([0.98 - boxSize[0], -0.92]);
|
|
109
96
|
} else {
|
|
110
|
-
|
|
97
|
+
helper.setAxisTitlePixelOffset(0.2 * tickTextStyle.fontSize);
|
|
98
|
+
boxSize[0] = 2.0 * (textSizes.titleHeight + helper.getAxisTitlePixelOffset() + textSizes.tickWidth + helper.getTickLabelPixelOffset() + 0.8 * tickTextStyle.fontSize) / lastSize[0];
|
|
111
99
|
helper.setBoxPosition([0.99 - boxSize[0], -0.92]);
|
|
112
100
|
}
|
|
113
101
|
|
|
114
102
|
boxSize[1] = Math.max(1.2, Math.min(1.84 / yAxisAdjust, 1.84));
|
|
115
103
|
} else {
|
|
116
104
|
// horizontal
|
|
117
|
-
helper.setAxisTitlePixelOffset(2
|
|
118
|
-
helper.setTickLabelPixelOffset(0.
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
boxSize[0] = Math.min(1.9, Math.max(1.4, 1.4 * _tickWidth * (helper.getTicks().length + 3)));
|
|
125
|
-
boxSize[1] = tickHeight + titleHeight;
|
|
105
|
+
helper.setAxisTitlePixelOffset(1.2 * tickTextStyle.fontSize);
|
|
106
|
+
helper.setTickLabelPixelOffset(0.1 * tickTextStyle.fontSize);
|
|
107
|
+
var titleHeight = // total offset from top of bar (includes ticks)
|
|
108
|
+
2.0 * (0.8 * tickTextStyle.fontSize + textSizes.titleHeight + helper.getAxisTitlePixelOffset()) / lastSize[1];
|
|
109
|
+
var tickWidth = 2.0 * textSizes.tickWidth / lastSize[0];
|
|
110
|
+
boxSize[0] = Math.min(1.9, Math.max(1.4, 1.4 * tickWidth * (helper.getTicks().length + 3)));
|
|
111
|
+
boxSize[1] = titleHeight;
|
|
126
112
|
helper.setBoxPosition([-0.5 * boxSize[0], -0.97]);
|
|
127
113
|
} // recomute bar segments based on positioning
|
|
128
114
|
|
|
@@ -169,8 +155,10 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
169
155
|
model.renderable = renderable;
|
|
170
156
|
model.barActor.setProperty(renderable.getProperty());
|
|
171
157
|
model.barActor.setParentProp(renderable);
|
|
158
|
+
model.barActor.setCoordinateSystemToDisplay();
|
|
172
159
|
model.tmActor.setProperty(renderable.getProperty());
|
|
173
160
|
model.tmActor.setParentProp(renderable);
|
|
161
|
+
model.tmActor.setCoordinateSystemToDisplay();
|
|
174
162
|
model.generateTicks = renderable.generateTicks;
|
|
175
163
|
model.axisTextStyle = _objectSpread({}, renderable.getAxisTextStyle());
|
|
176
164
|
model.tickTextStyle = _objectSpread({}, renderable.getTickTextStyle());
|
|
@@ -223,19 +211,10 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
223
211
|
publicAPI.recomputeBarSegments(textSizes);
|
|
224
212
|
}
|
|
225
213
|
|
|
226
|
-
model.forceViewUpdate = true;
|
|
227
|
-
model.lastRebuildTime.modified();
|
|
228
|
-
model.forceUpdate = false;
|
|
229
|
-
} // compute bounds for label quads whenever the camera changes or forced
|
|
230
|
-
// the polydata mapper could be modified to accept NDC coords then this
|
|
231
|
-
// would be called far less often
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (model.forceViewUpdate || model.camera.getMTime() > model.lastRedrawTime.getMTime()) {
|
|
235
214
|
publicAPI.updatePolyDataForLabels();
|
|
236
215
|
publicAPI.updatePolyDataForBarSegments();
|
|
237
|
-
model.
|
|
238
|
-
model.
|
|
216
|
+
model.lastRebuildTime.modified();
|
|
217
|
+
model.forceUpdate = false;
|
|
239
218
|
}
|
|
240
219
|
}; // create the texture map atlas that contains the rendering of
|
|
241
220
|
// all the text strings. Only needs to be called when the text strings
|
|
@@ -349,15 +328,15 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
349
328
|
model.barPosition[1] = model.boxPosition[1];
|
|
350
329
|
segSize[1] = tickHeight;
|
|
351
330
|
} else {
|
|
352
|
-
var
|
|
331
|
+
var _tickWidth = (2.0 * textSizes.tickWidth - 8) / model.lastSize[0];
|
|
353
332
|
|
|
354
333
|
var _titleHeight = 2.0 * (textSizes.titleHeight + model.axisTitlePixelOffset) / model.lastSize[1];
|
|
355
334
|
|
|
356
335
|
model.barSize[0] = model.boxSize[0];
|
|
357
336
|
model.barPosition[0] = model.boxPosition[0];
|
|
358
|
-
model.barSize[1] = model.boxSize[1] - _titleHeight
|
|
337
|
+
model.barSize[1] = model.boxSize[1] - _titleHeight;
|
|
359
338
|
model.barPosition[1] = model.boxPosition[1];
|
|
360
|
-
segSize[0] =
|
|
339
|
+
segSize[0] = _tickWidth;
|
|
361
340
|
}
|
|
362
341
|
|
|
363
342
|
return segSize;
|
|
@@ -414,62 +393,91 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
414
393
|
pushSeg('Above', [1.1, 1.1, 1.1, 1.1]);
|
|
415
394
|
}
|
|
416
395
|
}; // called by updatePolyDataForLabels
|
|
417
|
-
// modifies class constants
|
|
396
|
+
// modifies class constants tmp2v3
|
|
418
397
|
|
|
419
398
|
|
|
420
|
-
|
|
399
|
+
var tmp2v3 = new Float64Array(3); // anchor point = pos
|
|
400
|
+
// H alignment = left, middle, right
|
|
401
|
+
// V alignment = bottom, middle, top
|
|
402
|
+
// Text Orientation = horizontal, vertical
|
|
403
|
+
// orientation
|
|
404
|
+
|
|
405
|
+
publicAPI.createPolyDataForOneLabel = function (text, pos, alignment, orientation, offset, results) {
|
|
421
406
|
var value = model._tmAtlas.get(text);
|
|
422
407
|
|
|
423
408
|
if (!value) {
|
|
424
409
|
return;
|
|
425
410
|
} // have to find the four corners of the texture polygon for this label
|
|
426
|
-
// convert anchor point to View Coords
|
|
427
411
|
|
|
428
412
|
|
|
429
413
|
var ptIdx = results.ptIdx;
|
|
430
|
-
var cellIdx = results.cellIdx;
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
414
|
+
var cellIdx = results.cellIdx; // get achor point in pixels
|
|
415
|
+
|
|
416
|
+
tmp2v3[0] = (0.5 * pos[0] + 0.5) * model.lastSize[0];
|
|
417
|
+
tmp2v3[1] = (0.5 * pos[1] + 0.5) * model.lastSize[1];
|
|
418
|
+
tmp2v3[2] = pos[2];
|
|
419
|
+
tmp2v3[0] += offset[0];
|
|
420
|
+
tmp2v3[1] += offset[1]; // get text size in display pixels
|
|
421
|
+
|
|
422
|
+
var textSize = [];
|
|
423
|
+
var textAxes = orientation === 'vertical' ? [1, 0] : [0, 1];
|
|
424
|
+
|
|
425
|
+
if (orientation === 'vertical') {
|
|
426
|
+
textSize[0] = value.width;
|
|
427
|
+
textSize[1] = -value.height; // update anchor point based on alignment
|
|
428
|
+
|
|
429
|
+
if (alignment[0] === 'middle') {
|
|
430
|
+
tmp2v3[1] -= value.width / 2.0;
|
|
431
|
+
} else if (alignment[0] === 'right') {
|
|
432
|
+
tmp2v3[1] -= value.width;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (alignment[1] === 'middle') {
|
|
436
|
+
tmp2v3[0] += value.height / 2.0;
|
|
437
|
+
} else if (alignment[1] === 'top') {
|
|
438
|
+
tmp2v3[0] += value.height;
|
|
439
|
+
}
|
|
439
440
|
} else {
|
|
440
|
-
|
|
441
|
+
textSize[0] = value.width;
|
|
442
|
+
textSize[1] = value.height; // update anchor point based on alignment
|
|
443
|
+
|
|
444
|
+
if (alignment[0] === 'middle') {
|
|
445
|
+
tmp2v3[0] -= value.width / 2.0;
|
|
446
|
+
} else if (alignment[0] === 'right') {
|
|
447
|
+
tmp2v3[0] -= value.width;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (alignment[1] === 'middle') {
|
|
451
|
+
tmp2v3[1] -= value.height / 2.0;
|
|
452
|
+
} else if (alignment[1] === 'top') {
|
|
453
|
+
tmp2v3[1] -= value.height;
|
|
454
|
+
}
|
|
441
455
|
}
|
|
442
456
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
results.points[ptIdx * 3] = ptv3[0];
|
|
447
|
-
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
448
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
457
|
+
results.points[ptIdx * 3] = tmp2v3[0];
|
|
458
|
+
results.points[ptIdx * 3 + 1] = tmp2v3[1];
|
|
459
|
+
results.points[ptIdx * 3 + 2] = tmp2v3[2];
|
|
449
460
|
results.tcoords[ptIdx * 2] = value.tcoords[0];
|
|
450
461
|
results.tcoords[ptIdx * 2 + 1] = value.tcoords[1];
|
|
451
462
|
ptIdx++;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
results.points[ptIdx * 3] =
|
|
455
|
-
results.points[ptIdx * 3 +
|
|
456
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
463
|
+
tmp2v3[textAxes[0]] += textSize[0];
|
|
464
|
+
results.points[ptIdx * 3] = tmp2v3[0];
|
|
465
|
+
results.points[ptIdx * 3 + 1] = tmp2v3[1];
|
|
466
|
+
results.points[ptIdx * 3 + 2] = tmp2v3[2];
|
|
457
467
|
results.tcoords[ptIdx * 2] = value.tcoords[2];
|
|
458
468
|
results.tcoords[ptIdx * 2 + 1] = value.tcoords[3];
|
|
459
469
|
ptIdx++;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
results.points[ptIdx * 3] =
|
|
463
|
-
results.points[ptIdx * 3 +
|
|
464
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
470
|
+
tmp2v3[textAxes[1]] += textSize[1];
|
|
471
|
+
results.points[ptIdx * 3] = tmp2v3[0];
|
|
472
|
+
results.points[ptIdx * 3 + 1] = tmp2v3[1];
|
|
473
|
+
results.points[ptIdx * 3 + 2] = tmp2v3[2];
|
|
465
474
|
results.tcoords[ptIdx * 2] = value.tcoords[4];
|
|
466
475
|
results.tcoords[ptIdx * 2 + 1] = value.tcoords[5];
|
|
467
476
|
ptIdx++;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
results.points[ptIdx * 3] =
|
|
471
|
-
results.points[ptIdx * 3 +
|
|
472
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
477
|
+
tmp2v3[textAxes[0]] -= textSize[0];
|
|
478
|
+
results.points[ptIdx * 3] = tmp2v3[0];
|
|
479
|
+
results.points[ptIdx * 3 + 1] = tmp2v3[1];
|
|
480
|
+
results.points[ptIdx * 3 + 2] = tmp2v3[2];
|
|
473
481
|
results.tcoords[ptIdx * 2] = value.tcoords[6];
|
|
474
482
|
results.tcoords[ptIdx * 2 + 1] = value.tcoords[7];
|
|
475
483
|
ptIdx++; // add the two triangles to represent the quad
|
|
@@ -490,34 +498,10 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
490
498
|
// etc. This changes every time the camera viewpoint changes
|
|
491
499
|
|
|
492
500
|
|
|
493
|
-
|
|
494
|
-
var cmat = model.camera.getCompositeProjectionMatrix(model.lastAspectRatio, -1, 1);
|
|
495
|
-
mat4.transpose(cmat, cmat);
|
|
496
|
-
mat4.invert(invmat, cmat);
|
|
497
|
-
var size = model.lastSize; // compute pixel to distance factors
|
|
498
|
-
|
|
499
|
-
tmpv3[0] = 0.0;
|
|
500
|
-
tmpv3[1] = 0.0;
|
|
501
|
-
tmpv3[2] = -0.99; // near plane
|
|
502
|
-
|
|
503
|
-
vec3.transformMat4(ptv3, tmpv3, invmat); // moving 0.1 in NDC
|
|
504
|
-
|
|
505
|
-
tmpv3[0] += 0.1;
|
|
506
|
-
vec3.transformMat4(pt2v3, tmpv3, invmat); // results in WC move of
|
|
507
|
-
|
|
508
|
-
vec3.subtract(xDir, pt2v3, ptv3);
|
|
509
|
-
tmpv3[0] -= 0.1;
|
|
510
|
-
tmpv3[1] += 0.1;
|
|
511
|
-
vec3.transformMat4(pt2v3, tmpv3, invmat); // results in WC move of
|
|
512
|
-
|
|
513
|
-
vec3.subtract(yDir, pt2v3, ptv3);
|
|
514
|
-
|
|
515
|
-
for (var i = 0; i < 3; i++) {
|
|
516
|
-
xDir[i] /= 0.5 * 0.1 * size[0];
|
|
517
|
-
yDir[i] /= 0.5 * 0.1 * size[1];
|
|
518
|
-
} // update the polydata
|
|
519
|
-
|
|
501
|
+
var tmpv3 = new Float64Array(3);
|
|
520
502
|
|
|
503
|
+
publicAPI.updatePolyDataForLabels = function () {
|
|
504
|
+
// update the polydata
|
|
521
505
|
var numLabels = publicAPI.getTickStrings().length + model.barSegments.length;
|
|
522
506
|
var numPts = numLabels * 4;
|
|
523
507
|
var numTris = numLabels * 2;
|
|
@@ -530,55 +514,54 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
530
514
|
polys: polys,
|
|
531
515
|
points: points,
|
|
532
516
|
tcoords: tcoords
|
|
533
|
-
}; // compute the direction vector
|
|
517
|
+
}; // compute the direction vector
|
|
534
518
|
|
|
535
519
|
var offsetAxis = model.vertical ? 0 : 1;
|
|
536
|
-
var spacedAxis = model.vertical ? 1 : 0;
|
|
520
|
+
var spacedAxis = model.vertical ? 1 : 0;
|
|
521
|
+
tmpv3[2] = -0.99; // near plane
|
|
522
|
+
// draw the title
|
|
537
523
|
|
|
524
|
+
var alignment = model.vertical ? ['right', 'middle'] : ['middle', 'bottom'];
|
|
538
525
|
var dir = [0, 1];
|
|
526
|
+
var tickOffsets = [0, 0];
|
|
539
527
|
|
|
540
528
|
if (model.vertical) {
|
|
529
|
+
tickOffsets[0] = -model.tickLabelPixelOffset;
|
|
530
|
+
|
|
541
531
|
if (model.topTitle) {
|
|
542
532
|
tmpv3[0] = model.boxPosition[0] + 0.5 * model.boxSize[0];
|
|
543
|
-
tmpv3[1] = model.barPosition[1] + model.barSize[1];
|
|
544
|
-
vec3.transformMat4(ptv3, tmpv3, invmat); // write the axis label
|
|
533
|
+
tmpv3[1] = model.barPosition[1] + model.barSize[1]; // write the axis label
|
|
545
534
|
|
|
546
|
-
publicAPI.createPolyDataForOneLabel(model.renderable.getAxisLabel(),
|
|
535
|
+
publicAPI.createPolyDataForOneLabel(model.renderable.getAxisLabel(), tmpv3, ['middle', 'bottom'], 'horizontal', [0, model.axisTitlePixelOffset], results);
|
|
547
536
|
} else {
|
|
548
537
|
tmpv3[0] = model.barPosition[0] + model.barSize[0];
|
|
549
|
-
tmpv3[1] = model.barPosition[1] + 0.5 * model.barSize[1];
|
|
550
|
-
vec3.transformMat4(ptv3, tmpv3, invmat); // write the axis label
|
|
538
|
+
tmpv3[1] = model.barPosition[1] + 0.5 * model.barSize[1]; // write the axis label
|
|
551
539
|
|
|
552
|
-
|
|
553
|
-
publicAPI.createPolyDataForOneLabel(model.renderable.getAxisLabel(), ptv3, yDir, xDir, [0, -1], model.axisTitlePixelOffset, results);
|
|
554
|
-
vec3.scale(xDir, xDir, -1);
|
|
540
|
+
publicAPI.createPolyDataForOneLabel(model.renderable.getAxisLabel(), tmpv3, ['middle', 'top'], 'vertical', [model.axisTitlePixelOffset, 0], results);
|
|
555
541
|
}
|
|
556
542
|
|
|
557
543
|
dir = [-1, 0];
|
|
558
544
|
} else {
|
|
545
|
+
tickOffsets[1] = model.tickLabelPixelOffset;
|
|
559
546
|
tmpv3[0] = model.barPosition[0] + 0.5 * model.barSize[0];
|
|
560
547
|
tmpv3[1] = model.barPosition[1] + model.barSize[1];
|
|
561
|
-
|
|
562
|
-
publicAPI.createPolyDataForOneLabel(model.renderable.getAxisLabel(), ptv3, xDir, yDir, dir, model.axisTitlePixelOffset, results);
|
|
548
|
+
publicAPI.createPolyDataForOneLabel(model.renderable.getAxisLabel(), tmpv3, ['middle', 'bottom'], 'horizontal', [0, model.axisTitlePixelOffset], results);
|
|
563
549
|
}
|
|
564
550
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
tmp2v3[offsetAxis] = model.barPosition[offsetAxis] + (0.5 * dir[offsetAxis] + 0.5) * model.barSize[offsetAxis];
|
|
568
|
-
tmp2v3[spacedAxis] = model.barPosition[spacedAxis] + model.barSize[spacedAxis] * 0.5; // draw bar segment labels
|
|
551
|
+
tmpv3[offsetAxis] = model.barPosition[offsetAxis] + (0.5 * dir[offsetAxis] + 0.5) * model.barSize[offsetAxis];
|
|
552
|
+
tmpv3[spacedAxis] = model.barPosition[spacedAxis] + model.barSize[spacedAxis] * 0.5; // draw bar segment labels
|
|
569
553
|
|
|
570
554
|
var tickSeg = null;
|
|
571
555
|
|
|
572
|
-
for (var
|
|
573
|
-
var seg = model.barSegments[
|
|
556
|
+
for (var i = 0; i < model.barSegments.length; i++) {
|
|
557
|
+
var seg = model.barSegments[i];
|
|
574
558
|
|
|
575
559
|
if (seg.title === 'ticks') {
|
|
576
560
|
// handle ticks below
|
|
577
561
|
tickSeg = seg;
|
|
578
562
|
} else {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
publicAPI.createPolyDataForOneLabel(seg.title, ptv3, xDir, yDir, dir, model.tickLabelPixelOffset, results);
|
|
563
|
+
tmpv3[spacedAxis] = model.barPosition[spacedAxis] + 0.5 * model.barSize[spacedAxis] * (seg.corners[2][spacedAxis] + seg.corners[0][spacedAxis]);
|
|
564
|
+
publicAPI.createPolyDataForOneLabel(seg.title, tmpv3, alignment, 'horizontal', tickOffsets, results);
|
|
582
565
|
}
|
|
583
566
|
} // write the tick labels
|
|
584
567
|
|
|
@@ -590,9 +573,8 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
590
573
|
|
|
591
574
|
for (var t = 0; t < ticks.length; t++) {
|
|
592
575
|
var tickPos = (ticks[t] - model.lastTickBounds[0]) / (model.lastTickBounds[1] - model.lastTickBounds[0]);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
publicAPI.createPolyDataForOneLabel(tickStrings[t], ptv3, xDir, yDir, dir, model.tickLabelPixelOffset, results);
|
|
576
|
+
tmpv3[spacedAxis] = tickSegmentStart + tickSegmentSize * tickPos;
|
|
577
|
+
publicAPI.createPolyDataForOneLabel(tickStrings[t], tmpv3, alignment, 'horizontal', tickOffsets, results);
|
|
596
578
|
}
|
|
597
579
|
|
|
598
580
|
var tcoordDA = vtkDataArray.newInstance({
|
|
@@ -611,9 +593,6 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
611
593
|
publicAPI.updatePolyDataForBarSegments = function () {
|
|
612
594
|
var _scalarsToColors$getU, _scalarsToColors$getU2;
|
|
613
595
|
|
|
614
|
-
var cmat = model.camera.getCompositeProjectionMatrix(model.lastAspectRatio, -1, 1);
|
|
615
|
-
mat4.transpose(cmat, cmat);
|
|
616
|
-
mat4.invert(invmat, cmat);
|
|
617
596
|
var scalarsToColors = model.renderable.getScalarsToColors();
|
|
618
597
|
var numberOfExtraColors = 0;
|
|
619
598
|
|
|
@@ -647,16 +626,13 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
647
626
|
|
|
648
627
|
for (var i = 0; i < model.barSegments.length; i++) {
|
|
649
628
|
var seg = model.barSegments[i];
|
|
650
|
-
tmp2v3[1] = model.barPosition[1] + model.barSize[1] * 0.5;
|
|
651
|
-
tmp2v3[2] = -0.99; // near plane
|
|
652
629
|
|
|
653
630
|
for (var e = 0; e < 4; e++) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
points[ptIdx * 3] =
|
|
658
|
-
points[ptIdx * 3 +
|
|
659
|
-
points[ptIdx * 3 + 2] = ptv3[2];
|
|
631
|
+
tmpv3[0] = model.barPosition[0] + seg.corners[e][0] * model.barSize[0];
|
|
632
|
+
tmpv3[1] = model.barPosition[1] + seg.corners[e][1] * model.barSize[1];
|
|
633
|
+
points[ptIdx * 3] = (0.5 * tmpv3[0] + 0.5) * model.lastSize[0];
|
|
634
|
+
points[ptIdx * 3 + 1] = (0.5 * tmpv3[1] + 0.5) * model.lastSize[1];
|
|
635
|
+
points[ptIdx * 3 + 2] = tmpv3[2];
|
|
660
636
|
|
|
661
637
|
for (var nc = 0; nc < numComps; nc++) {
|
|
662
638
|
scalars[ptIdx * numComps + nc] = model.lastTickBounds[0] + seg.scalars[e] * (model.lastTickBounds[1] - model.lastTickBounds[0]);
|
|
@@ -699,10 +675,6 @@ var newScalarBarActorHelper = macro.newInstance(function (publicAPI, model) {
|
|
|
699
675
|
macro.getArray(publicAPI, model, ['boxPosition', 'boxSize']);
|
|
700
676
|
macro.setArray(publicAPI, model, ['boxPosition', 'boxSize'], 2);
|
|
701
677
|
model.forceUpdate = false;
|
|
702
|
-
model.lastRedrawTime = {};
|
|
703
|
-
macro.obj(model.lastRedrawTime, {
|
|
704
|
-
mtime: 0
|
|
705
|
-
});
|
|
706
678
|
model.lastRebuildTime = {};
|
|
707
679
|
macro.obj(model.lastRebuildTime, {
|
|
708
680
|
mtime: 0
|
|
@@ -5,6 +5,7 @@ import vtkHelper from './Helper.js';
|
|
|
5
5
|
import vtkMapper from '../Core/Mapper.js';
|
|
6
6
|
import { l as normalize, u as uninitializeBounds } from '../../Common/Core/Math/index.js';
|
|
7
7
|
import vtkOpenGLTexture from './Texture.js';
|
|
8
|
+
import vtkProp from '../Core/Prop.js';
|
|
8
9
|
import vtkProperty from '../Core/Property.js';
|
|
9
10
|
import vtkShaderProgram from './ShaderProgram.js';
|
|
10
11
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
@@ -30,7 +31,8 @@ var StartEvent = {
|
|
|
30
31
|
};
|
|
31
32
|
var EndEvent = {
|
|
32
33
|
type: 'EndEvent'
|
|
33
|
-
};
|
|
34
|
+
};
|
|
35
|
+
var CoordinateSystem = vtkProp.CoordinateSystem; // ----------------------------------------------------------------------------
|
|
34
36
|
// vtkOpenGLPolyDataMapper methods
|
|
35
37
|
// ----------------------------------------------------------------------------
|
|
36
38
|
|
|
@@ -904,7 +906,19 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
904
906
|
mcwc: null,
|
|
905
907
|
normalMatrix: null
|
|
906
908
|
} : model.openGLActor.getKeyMatrices();
|
|
907
|
-
|
|
909
|
+
|
|
910
|
+
if (actor.getCoordinateSystem() === CoordinateSystem.DISPLAY) {
|
|
911
|
+
var size = model.openGLRenderer.getTiledSizeAndOrigin();
|
|
912
|
+
mat4.identity(model.tmpMat4);
|
|
913
|
+
model.tmpMat4[0] = 2.0 / size.usize;
|
|
914
|
+
model.tmpMat4[12] = -1.0;
|
|
915
|
+
model.tmpMat4[5] = 2.0 / size.vsize;
|
|
916
|
+
model.tmpMat4[13] = -1.0;
|
|
917
|
+
mat4.multiply(model.tmpMat4, model.tmpMat4, inverseShiftScaleMatrix);
|
|
918
|
+
program.setUniformMatrix('MCPCMatrix', model.tmpMat4);
|
|
919
|
+
} else {
|
|
920
|
+
program.setUniformMatrix('MCPCMatrix', safeMatrixMultiply([keyMats.wcpc, actMats.mcwc, inverseShiftScaleMatrix], mat4, model.tmpMat4));
|
|
921
|
+
}
|
|
908
922
|
|
|
909
923
|
if (program.isUniformUsed('MCVCMatrix')) {
|
|
910
924
|
program.setUniformMatrix('MCVCMatrix', safeMatrixMultiply([keyMats.wcvc, actMats.mcwc, inverseShiftScaleMatrix], mat4, model.tmpMat4));
|