@kitware/vtk.js 24.13.0 → 24.14.1

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.
@@ -27,22 +27,22 @@ export interface IStyle {
27
27
  *
28
28
  */
29
29
  export interface IScalarBarActorInitialValues extends IActorInitialValues {
30
- automated?: boolean,
31
- autoLayout?: (publicAPI: object, model: object) => void,
32
- axisLabel?: string,
33
- barPosition?: Vector2,
34
- barSize?: Size,
35
- boxPosition?: Vector2,
36
- boxSize?: Size,
37
- scalarToColors?: null,
38
- axisTitlePixelOffset?: number,
39
- axisTextStyle?: IStyle,
40
- tickLabelPixelOffset?: number,
41
- tickTextStyle?: IStyle,
42
- generateTicks?: (helper: any) => void,
43
- drawBelowRangeSwatch?: boolean,
44
- drawAboveRangeSwatch?: boolean,
45
- drawNanAnnotation?: boolean,
30
+ automated?: boolean,
31
+ autoLayout?: (publicAPI: object, model: object) => void,
32
+ axisLabel?: string,
33
+ barPosition?: Vector2,
34
+ barSize?: Size,
35
+ boxPosition?: Vector2,
36
+ boxSize?: Size,
37
+ scalarToColors?: null,
38
+ axisTitlePixelOffset?: number,
39
+ axisTextStyle?: IStyle,
40
+ tickLabelPixelOffset?: number,
41
+ tickTextStyle?: IStyle,
42
+ generateTicks?: (helper: any) => void,
43
+ drawBelowRangeSwatch?: boolean,
44
+ drawAboveRangeSwatch?: boolean,
45
+ drawNanAnnotation?: boolean,
46
46
  }
47
47
 
48
48
  export interface vtkScalarBarActor extends vtkActor {
@@ -88,10 +88,11 @@ export interface vtkScalarBarActor extends vtkActor {
88
88
  */
89
89
  getAutoLayout(): any;
90
90
 
91
- /**
92
- *
93
- */
94
- getGenerateTicks(): any;
91
+ /**
92
+ *
93
+ */
94
+ getGenerateTicks(): any;
95
+
95
96
  /**
96
97
  *
97
98
  */
@@ -122,7 +123,6 @@ export interface vtkScalarBarActor extends vtkActor {
122
123
  */
123
124
  getBoxPositionByReference(): Vector2;
124
125
 
125
-
126
126
  /**
127
127
  *
128
128
  */
@@ -180,23 +180,24 @@ export interface vtkScalarBarActor extends vtkActor {
180
180
  */
181
181
  setAutoLayout(autoLayout: any): boolean;
182
182
 
183
- /**
184
- * Sets the function used to generate legend ticks.
185
- *
186
- * This function takes a vtkScalarBarActorHelper and returns true on success.
187
- * To have the desired effect, the function must call: `helper.setTicks(ticks: num[])` and `helper.setTickStrings(tickStrings: string[])`.
188
- *
189
- * After setting the generateTicks function you must regenerate the vtkScalarBarActor for your changes to take effect.
190
- * One way to do that is:
191
- * ```
192
- * const mapper = scalarBarActor.getMapper()
193
- * if (mapper) {
194
- * mapper.getLookupTable().resetAnnotations()
195
- * }
196
- * ```
197
- * @param {(helper: any) => void} generateTicks
198
- */
199
- setGenerateTicks(generateTicks: (helper: any) => void): boolean;
183
+ /**
184
+ * Sets the function used to generate legend ticks.
185
+ *
186
+ * This function takes a vtkScalarBarActorHelper and returns true on success.
187
+ * To have the desired effect, the function must call: `helper.setTicks(ticks: num[])` and `helper.setTickStrings(tickStrings: string[])`.
188
+ *
189
+ * After setting the generateTicks function you must regenerate the vtkScalarBarActor for your changes to take effect.
190
+ * One way to do that is:
191
+ * ```
192
+ * const mapper = scalarBarActor.getMapper()
193
+ * if (mapper) {
194
+ * mapper.getLookupTable().resetAnnotations()
195
+ * }
196
+ * ```
197
+ * @param generateTicks
198
+ */
199
+ setGenerateTicks(generateTicks: (helper: any) => void): boolean;
200
+
200
201
  /**
201
202
  *
202
203
  * @param {Boolean} automated
@@ -279,7 +280,7 @@ export interface vtkScalarBarActor extends vtkActor {
279
280
  * Set whether the NaN annotation should be rendered or not.
280
281
  * @param {Boolean} drawNanAnnotation
281
282
  */
282
- setDrawNanAnnotation(drawNanAnnotation: boolean): boolean;
283
+ setDrawNanAnnotation(drawNanAnnotation: boolean): boolean;
283
284
 
284
285
  /**
285
286
  * Set whether the Below range swatch should be rendered or not
@@ -360,7 +361,7 @@ export function newInstance(initialValues?: IScalarBarActorInitialValues): vtkSc
360
361
  * (i.e., in the renderer's viewport) on top of the 3D graphics window.
361
362
  */
362
363
  export declare const vtkScalarBarActor: {
363
- newInstance: typeof newInstance,
364
- extend: typeof extend,
364
+ newInstance: typeof newInstance;
365
+ extend: typeof extend;
365
366
  };
366
367
  export default vtkScalarBarActor;
@@ -198,7 +198,7 @@ function vtkScalarBarActorHelper(publicAPI, model) {
198
198
  model.camera = camera;
199
199
  model.renderWindow = renderWindow; // did something significant change? If so rebuild a lot of things
200
200
 
201
- if (model.forceUpdate || Math.max(scalarsToColors.getMTime(), publicAPI.getMTime()) > model.lastRebuildTime.getMTime()) {
201
+ if (model.forceUpdate || Math.max(scalarsToColors.getMTime(), publicAPI.getMTime(), model.renderable.getMTime()) > model.lastRebuildTime.getMTime()) {
202
202
  var range = scalarsToColors.getMappingRange();
203
203
  model.lastTickBounds = _toConsumableArray(range); // compute tick marks for axes (update for log scale)
204
204
 
@@ -0,0 +1,16 @@
1
+ export declare enum InterpolationType {
2
+ NEAREST = 0,
3
+ LINEAR = 1,
4
+ FAST_LINEAR = 2
5
+ }
6
+
7
+ export declare enum OpacityMode {
8
+ FRACTIONAL = 0,
9
+ PROPORTIONAL = 1,
10
+ }
11
+
12
+ declare const _default: {
13
+ InterpolationType: typeof InterpolationType;
14
+ OpacityMode: typeof OpacityMode;
15
+ };
16
+ export default _default;
@@ -33,6 +33,8 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) {
33
33
  publicAPI.setType(ObjectType.ARRAY_BUFFER);
34
34
 
35
35
  publicAPI.createVBO = function (cellArray, inRep, outRep, options) {
36
+ var selectionMaps = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
37
+
36
38
  if (!cellArray.getData() || !cellArray.getData().length) {
37
39
  model.elementCount = 0;
38
40
  return 0;
@@ -263,10 +265,34 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) {
263
265
  } else if (model.coordShiftAndScaleEnabled === true) {
264
266
  // Make sure to reset
265
267
  publicAPI.setCoordShiftAndScale(null, null);
268
+ } // Initialize the structures used to keep track of point ids and cell ids for selectors
269
+
270
+
271
+ if (selectionMaps) {
272
+ if (!selectionMaps.points && !selectionMaps.cells) {
273
+ selectionMaps.points = new Int32Array(caboCount);
274
+ selectionMaps.cells = new Int32Array(caboCount);
275
+ } else {
276
+ var newPoints = new Int32Array(caboCount + selectionMaps.points.length);
277
+ newPoints.set(selectionMaps.points);
278
+ selectionMaps.points = newPoints;
279
+ var newCells = new Int32Array(caboCount + selectionMaps.points.length);
280
+ newCells.set(selectionMaps.cells);
281
+ selectionMaps.cells = newCells;
282
+ }
266
283
  }
267
284
 
285
+ var pointCount = options.vertexOffset;
286
+
268
287
  addAPoint = function addAPointFunc(i) {
269
- // Vertices
288
+ // Keep track of original point and cell ids, for selection
289
+ if (selectionMaps) {
290
+ selectionMaps.points[pointCount] = i;
291
+ selectionMaps.cells[pointCount] = cellCount;
292
+ }
293
+
294
+ ++pointCount; // Vertices
295
+
270
296
  pointIdx = i * 3;
271
297
 
272
298
  if (!model.coordShiftAndScaleEnabled) {
@@ -3,7 +3,8 @@ var PassTypes = {
3
3
  ACTOR_PASS: 0,
4
4
  COMPOSITE_INDEX_PASS: 1,
5
5
  ID_LOW24: 2,
6
- MAX_KNOWN_PASS: 2
6
+ ID_HIGH24: 3,
7
+ MAX_KNOWN_PASS: 3
7
8
  };
8
9
  var Constants = {
9
10
  PassTypes: PassTypes
@@ -23,6 +23,15 @@ function getInfoHash(info) {
23
23
  return "".concat(info.propID, " ").concat(info.compositeID);
24
24
  }
25
25
 
26
+ function getAlpha(xx, yy, pb, area) {
27
+ if (!pb) {
28
+ return 0;
29
+ }
30
+
31
+ var offset = (yy * (area[2] - area[0] + 1) + xx) * 4;
32
+ return pb[offset + 3];
33
+ }
34
+
26
35
  function convert(xx, yy, pb, area) {
27
36
  if (!pb) {
28
37
  return 0;
@@ -41,6 +50,15 @@ function convert(xx, yy, pb, area) {
41
50
  return val;
42
51
  }
43
52
 
53
+ function getID(low24, high8) {
54
+ /* eslint-disable no-bitwise */
55
+ var val = high8;
56
+ val <<= 24;
57
+ val |= low24;
58
+ return val;
59
+ /* eslint-enable no-bitwise */
60
+ }
61
+
44
62
  function getPixelInformationWithData(buffdata, inDisplayPosition, maxDistance, outSelectedPosition) {
45
63
  // Base case
46
64
  var maxDist = maxDistance < 0 ? 0 : maxDistance;
@@ -80,6 +98,15 @@ function getPixelInformationWithData(buffdata, inDisplayPosition, maxDistance, o
80
98
  _info.displayPosition = inDisplayPosition;
81
99
  }
82
100
 
101
+ if (buffdata.pixBuffer[PassTypes.ID_LOW24]) {
102
+ if (getAlpha(displayPosition[0], displayPosition[1], buffdata.pixBuffer[PassTypes.ID_LOW24], buffdata.area) === 0.0) {
103
+ return _info;
104
+ }
105
+ }
106
+
107
+ var low24 = convert(displayPosition[0], displayPosition[1], buffdata.pixBuffer[PassTypes.ID_LOW24], buffdata.area);
108
+ var high24 = convert(displayPosition[0], displayPosition[1], buffdata.pixBuffer[PassTypes.ID_HIGH24], buffdata.area);
109
+ _info.attributeID = getID(low24, high24);
83
110
  return _info;
84
111
  } // Iterate over successively growing boxes.
85
112
  // They recursively call the base case to handle single pixels.
@@ -167,6 +194,7 @@ function convertSelection(fieldassociation, dataMap, captureZValues, renderer, o
167
194
  child.getProperties().propID = value.info.propID;
168
195
  child.getProperties().prop = value.info.prop;
169
196
  child.getProperties().compositeID = value.info.compositeID;
197
+ child.getProperties().attributeID = value.info.attributeID;
170
198
  child.getProperties().pixelCount = value.pixelCount;
171
199
 
172
200
  if (captureZValues) {
@@ -233,6 +261,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
233
261
  model.classHierarchy.push('vtkOpenGLHardwareSelector'); //----------------------------------------------------------------------------
234
262
 
235
263
  publicAPI.releasePixBuffers = function () {
264
+ model.rawPixBuffer = [];
236
265
  model.pixBuffer = [];
237
266
  model.zBuffer = null;
238
267
  }; //----------------------------------------------------------------------------
@@ -270,8 +299,24 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
270
299
  model._openGLRenderer.setSelector(publicAPI);
271
300
 
272
301
  model.hitProps = {};
302
+ model.propPixels = {};
273
303
  model.props = [];
274
304
  publicAPI.releasePixBuffers();
305
+
306
+ if (model.fieldAssociation === FieldAssociations.FIELD_ASSOCIATION_POINTS) {
307
+ var gl = model._openGLRenderWindow.getContext();
308
+
309
+ var originalBlending = gl.isEnabled(gl.BLEND);
310
+ gl.disable(gl.BLEND);
311
+
312
+ model._openGLRenderWindow.traverseAllPasses();
313
+
314
+ model._renderer.setPreserveDepthBuffer(true);
315
+
316
+ if (originalBlending) {
317
+ gl.enable(gl.BLEND);
318
+ }
319
+ }
275
320
  }; //----------------------------------------------------------------------------
276
321
 
277
322
 
@@ -281,11 +326,26 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
281
326
  model._openGLRenderer.setSelector(null);
282
327
 
283
328
  model.framebuffer.restorePreviousBindingsAndBuffers();
329
+
330
+ model._renderer.setPreserveDepthBuffer(false);
331
+ };
332
+
333
+ publicAPI.preCapturePass = function () {
334
+ var gl = model._openGLRenderWindow.getContext(); // Disable blending
335
+
336
+
337
+ model.originalBlending = gl.isEnabled(gl.BLEND);
338
+ gl.disable(gl.BLEND);
284
339
  };
285
340
 
286
- publicAPI.preCapturePass = function () {};
341
+ publicAPI.postCapturePass = function () {
342
+ var gl = model._openGLRenderWindow.getContext(); // Restore blending if it was enabled prior to the capture
343
+
287
344
 
288
- publicAPI.postCapturePass = function () {}; //----------------------------------------------------------------------------
345
+ if (model.originalBlending) {
346
+ gl.enable(gl.BLEND);
347
+ }
348
+ }; //----------------------------------------------------------------------------
289
349
 
290
350
 
291
351
  publicAPI.select = function () {
@@ -385,13 +445,13 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
385
445
 
386
446
  model.originalBackground = model._renderer.getBackgroundByReference();
387
447
 
388
- model._renderer.setBackground(0.0, 0.0, 0.0);
448
+ model._renderer.setBackground(0.0, 0.0, 0.0, 0.0);
389
449
 
390
450
  var rpasses = model._openGLRenderWindow.getRenderPasses();
391
451
 
392
452
  publicAPI.beginSelection();
393
453
 
394
- for (model.currentPass = PassTypes.MIN_KNOWN_PASS; model.currentPass <= PassTypes.COMPOSITE_INDEX_PASS; model.currentPass++) {
454
+ for (model.currentPass = PassTypes.MIN_KNOWN_PASS; model.currentPass <= PassTypes.MAX_KNOWN_PASS; model.currentPass++) {
395
455
  if (publicAPI.passRequired(model.currentPass)) {
396
456
  publicAPI.preCapturePass(model.currentPass);
397
457
 
@@ -405,6 +465,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
405
465
 
406
466
  publicAPI.postCapturePass(model.currentPass);
407
467
  publicAPI.savePixelBuffer(model.currentPass);
468
+ publicAPI.processPixelBuffers();
408
469
  }
409
470
  }
410
471
 
@@ -418,10 +479,28 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
418
479
  // model._openGLRenderWindow.traverseAllPasses();
419
480
 
420
481
  return true;
482
+ };
483
+
484
+ publicAPI.processPixelBuffers = function () {
485
+ model.props.forEach(function (prop, index) {
486
+ if (publicAPI.isPropHit(index)) {
487
+ prop.processSelectorPixelBuffers(publicAPI, model.propPixels[index]);
488
+ }
489
+ });
421
490
  }; //----------------------------------------------------------------------------
422
491
 
423
492
 
424
493
  publicAPI.passRequired = function (pass) {
494
+ if (pass === PassTypes.ID_HIGH24) {
495
+ if (model.fieldAssociation === FieldAssociations.FIELD_ASSOCIATION_POINTS) {
496
+ return model.maximumPointId > 0x00ffffff;
497
+ }
498
+
499
+ if (model.fieldAssociation === FieldAssociations.FIELD_ASSOCIATION_CELLS) {
500
+ return model.maximumCellId > 0x00ffffff;
501
+ }
502
+ }
503
+
425
504
  return true;
426
505
  }; //----------------------------------------------------------------------------
427
506
 
@@ -429,6 +508,12 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
429
508
  publicAPI.savePixelBuffer = function (passNo) {
430
509
  model.pixBuffer[passNo] = model._openGLRenderWindow.getPixelData(model.area[0], model.area[1], model.area[2], model.area[3]);
431
510
 
511
+ if (!model.rawPixBuffer[passNo]) {
512
+ var size = (model.area[2] - model.area[0] + 1) * (model.area[3] - model.area[1] + 1) * 4;
513
+ model.rawPixBuffer[passNo] = new Uint8Array(size);
514
+ model.rawPixBuffer[passNo].set(model.pixBuffer[passNo]);
515
+ }
516
+
432
517
  if (passNo === PassTypes.ACTOR_PASS) {
433
518
  if (model.captureZValues) {
434
519
  var rpasses = model._openGLRenderWindow.getRenderPasses();
@@ -442,12 +527,14 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
442
527
  }
443
528
  }
444
529
 
445
- publicAPI.buildPropHitList(model.pixBuffer[passNo]);
530
+ publicAPI.buildPropHitList(model.rawPixBuffer[passNo]);
446
531
  }
447
532
  }; //----------------------------------------------------------------------------
448
533
 
449
534
 
450
535
  publicAPI.buildPropHitList = function (pixelbuffer) {
536
+ var offset = 0;
537
+
451
538
  for (var yy = 0; yy <= model.area[3] - model.area[1]; yy++) {
452
539
  for (var xx = 0; xx <= model.area[2] - model.area[0]; xx++) {
453
540
  var val = convert(xx, yy, pixelbuffer, model.area);
@@ -457,8 +544,13 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
457
544
 
458
545
  if (!(val in model.hitProps)) {
459
546
  model.hitProps[val] = true;
547
+ model.propPixels[val] = [];
460
548
  }
549
+
550
+ model.propPixels[val].push(offset * 4);
461
551
  }
552
+
553
+ ++offset;
462
554
  }
463
555
  }
464
556
  }; //----------------------------------------------------------------------------
@@ -552,8 +644,18 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
552
644
  var offset = (displayPosition[1] * (model.area[2] - model.area[0] + 1) + displayPosition[0]) * 4;
553
645
  _info2.zValue = (256 * model.zBuffer[offset] + model.zBuffer[offset + 1]) / 65535.0;
554
646
  _info2.displayPosition = inDisplayPosition;
647
+ } // Skip attribute ids if alpha is zero (missed)
648
+
649
+
650
+ if (model.pixBuffer[PassTypes.ID_LOW24]) {
651
+ if (getAlpha(displayPosition[0], displayPosition[1], model.pixBuffer[PassTypes.ID_LOW24], model.area) === 0.0) {
652
+ return _info2;
653
+ }
555
654
  }
556
655
 
656
+ var low24 = convert(displayPosition[0], displayPosition[1], model.pixBuffer[PassTypes.ID_LOW24], model.area);
657
+ var high24 = convert(displayPosition[0], displayPosition[1], model.pixBuffer[PassTypes.ID_HIGH24], model.area);
658
+ _info2.attributeID = getID(low24, high24);
557
659
  return _info2;
558
660
  } // Iterate over successively growing boxes.
559
661
  // They recursively call the base case to handle single pixels.
@@ -659,6 +761,14 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
659
761
  }
660
762
 
661
763
  return convertSelection(model.fieldAssociation, dataMap, model.captureZValues, model._renderer, model._openGLRenderWindow);
764
+ };
765
+
766
+ publicAPI.getRawPixelBuffer = function (passNo) {
767
+ return model.rawPixBuffer[passNo];
768
+ };
769
+
770
+ publicAPI.getPixelBuffer = function (passNo) {
771
+ return model.pixBuffer[passNo];
662
772
  }; //----------------------------------------------------------------------------
663
773
 
664
774
 
@@ -694,6 +804,8 @@ var DEFAULT_VALUES = {
694
804
  currentPass: -1,
695
805
  propColorValue: null,
696
806
  props: null,
807
+ maximumPointId: 0,
808
+ maximumCellId: 0,
697
809
  idOffset: 1
698
810
  }; // ----------------------------------------------------------------------------
699
811
 
@@ -710,7 +822,7 @@ function extend(publicAPI, model) {
710
822
  }
711
823
 
712
824
  macro.setGetArray(publicAPI, model, ['area'], 4);
713
- macro.setGet(publicAPI, model, ['_renderer', 'currentPass', '_openGLRenderWindow']);
825
+ macro.setGet(publicAPI, model, ['_renderer', 'currentPass', '_openGLRenderWindow', 'maximumPointId', 'maximumCellId']);
714
826
  macro.setGetArray(publicAPI, model, ['propColorValue'], 3);
715
827
  macro.moveToProtected(publicAPI, model, ['renderer', 'openGLRenderWindow']);
716
828
  macro.event(publicAPI, model, 'event'); // Object methods
@@ -41,6 +41,12 @@ function vtkOpenGLHelper(publicAPI, model) {
41
41
  var mode = publicAPI.getOpenGLMode(rep);
42
42
  var wideLines = publicAPI.haveWideLines(ren, actor);
43
43
  var gl = model.context;
44
+ var depthMask = gl.getParameter(gl.DEPTH_WRITEMASK);
45
+
46
+ if (model.pointPicking) {
47
+ gl.depthMask(false);
48
+ }
49
+
44
50
  var drawingLines = mode === gl.LINES;
45
51
 
46
52
  if (drawingLines && wideLines) {
@@ -55,6 +61,11 @@ function vtkOpenGLHelper(publicAPI, model) {
55
61
  }
56
62
 
57
63
  var stride = (mode === gl.POINTS ? 1 : 0) || (mode === gl.LINES ? 2 : 3);
64
+
65
+ if (model.pointPicking) {
66
+ gl.depthMask(depthMask);
67
+ }
68
+
58
69
  return model.CABO.getElementCount() / stride;
59
70
  }
60
71
 
@@ -62,6 +73,10 @@ function vtkOpenGLHelper(publicAPI, model) {
62
73
  };
63
74
 
64
75
  publicAPI.getOpenGLMode = function (rep) {
76
+ if (model.pointPicking) {
77
+ return model.context.POINTS;
78
+ }
79
+
65
80
  var type = model.primitiveType;
66
81
 
67
82
  if (rep === Representation.POINTS || type === primTypes.Points) {
@@ -144,22 +159,38 @@ function vtkOpenGLHelper(publicAPI, model) {
144
159
  publicAPI.getProgram().setUniformf('lineWidthStepSize', lineWidth / Math.ceil(lineWidth));
145
160
  publicAPI.getProgram().setUniformf('halfLineWidth', halfLineWidth);
146
161
  }
162
+
163
+ if (model.primitiveType === primTypes.Points || actor.getProperty().getRepresentation() === Representation.POINTS) {
164
+ publicAPI.getProgram().setUniformf('pointSize', actor.getProperty().getPointSize());
165
+ } else if (model.pointPicking) {
166
+ publicAPI.getProgram().setUniformf('pointSize', publicAPI.getPointPickingPrimitiveSize());
167
+ }
147
168
  };
148
169
 
149
170
  publicAPI.replaceShaderPositionVC = function (shaders, ren, actor) {
150
- var VSSource = shaders.Vertex; // for lines, make sure we add the width code
171
+ var VSSource = shaders.Vertex; // Always set point size in case we need picking
172
+
173
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Dec', ['//VTK::PositionVC::Dec', 'uniform float pointSize;']).result;
174
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', ['//VTK::PositionVC::Impl', ' gl_PointSize = pointSize;'], false).result; // for lines, make sure we add the width code
151
175
 
152
176
  if (publicAPI.getOpenGLMode(actor.getProperty().getRepresentation()) === model.context.LINES && publicAPI.haveWideLines(ren, actor)) {
153
177
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Dec', ['//VTK::PositionVC::Dec', 'uniform vec2 viewportSize;', 'uniform float lineWidthStepSize;', 'uniform float halfLineWidth;']).result;
154
178
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', ['//VTK::PositionVC::Impl', ' if (halfLineWidth > 0.0)', ' {', ' float offset = float(gl_InstanceID / 2) * lineWidthStepSize - halfLineWidth;', ' vec4 tmpPos = gl_Position;', ' vec3 tmpPos2 = tmpPos.xyz / tmpPos.w;', ' tmpPos2.x = tmpPos2.x + 2.0 * mod(float(gl_InstanceID), 2.0) * offset / viewportSize[0];', ' tmpPos2.y = tmpPos2.y + 2.0 * mod(float(gl_InstanceID + 1), 2.0) * offset / viewportSize[1];', ' gl_Position = vec4(tmpPos2.xyz * tmpPos.w, tmpPos.w);', ' }']).result;
155
- } // for points make sure to add in the point size
179
+ }
156
180
 
181
+ shaders.Vertex = VSSource;
182
+ };
157
183
 
158
- if (actor.getProperty().getRepresentation() === Representation.POINTS || model.primitiveType === primTypes.Points) {
159
- VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', ['//VTK::PositionVC::Impl', " gl_PointSize = ".concat(actor.getProperty().getPointSize(), ".0;")], false).result;
184
+ publicAPI.getPointPickingPrimitiveSize = function () {
185
+ if (model.primitiveType === primTypes.Points) {
186
+ return 2;
160
187
  }
161
188
 
162
- shaders.Vertex = VSSource;
189
+ if (model.primitiveType === primTypes.Lines) {
190
+ return 4;
191
+ }
192
+
193
+ return 6;
163
194
  };
164
195
  } // ----------------------------------------------------------------------------
165
196
  // Object factory
@@ -173,7 +204,8 @@ var DEFAULT_VALUES = {
173
204
  VAO: null,
174
205
  attributeUpdateTime: null,
175
206
  CABO: null,
176
- primitiveType: 0
207
+ primitiveType: 0,
208
+ pointPicking: false
177
209
  }; // ----------------------------------------------------------------------------
178
210
 
179
211
  function extend(publicAPI, model) {
@@ -185,7 +217,7 @@ function extend(publicAPI, model) {
185
217
  macro.obj(model.shaderSourceTime);
186
218
  model.attributeUpdateTime = {};
187
219
  macro.obj(model.attributeUpdateTime);
188
- macro.setGet(publicAPI, model, ['program', 'shaderSourceTime', 'VAO', 'attributeUpdateTime', 'CABO', 'primitiveType']);
220
+ macro.setGet(publicAPI, model, ['program', 'shaderSourceTime', 'VAO', 'attributeUpdateTime', 'CABO', 'primitiveType', 'pointPicking']);
189
221
  model.program = vtkShaderProgram.newInstance();
190
222
  model.VAO = vtkVertexArrayObject.newInstance();
191
223
  model.CABO = vtkCellArrayBufferObject.newInstance(); // Object methods