@kitware/vtk.js 24.0.1 → 24.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/OpenGL/Glyph3DMapper.js +11 -2
- package/Rendering/OpenGL/HardwareSelector.js +11 -9
- package/Rendering/OpenGL/Helper.js +145 -3
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +10 -14
- package/Rendering/OpenGL/PolyDataMapper.js +16 -77
- package/Rendering/OpenGL/PolyDataMapper2D.js +14 -98
- package/Rendering/OpenGL/RenderWindow.js +6 -0
- package/Rendering/OpenGL/Renderer.js +4 -3
- package/Widgets/SVG/SVGLandmarkRepresentation.js +9 -2
- package/Widgets/Widgets3D/AngleWidget/behavior.js +11 -7
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +9 -5
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +5 -5
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +11 -7
- package/Widgets/Widgets3D/LabelWidget/behavior.js +25 -12
- package/Widgets/Widgets3D/LineWidget/behavior.js +14 -10
- package/Widgets/Widgets3D/PaintWidget/behavior.js +6 -4
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -7
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +11 -7
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +23 -15
- package/Widgets/Widgets3D/SphereWidget/behavior.js +15 -7
- package/Widgets/Widgets3D/SplineWidget/behavior.js +11 -8
- package/package.json +2 -2
|
@@ -2,7 +2,6 @@ import { mat4 } from 'gl-matrix';
|
|
|
2
2
|
import { newInstance as newInstance$1, setGet, obj, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
|
|
3
3
|
import vtkHelper from './Helper.js';
|
|
4
4
|
import vtkMapper2D from '../Core/Mapper2D.js';
|
|
5
|
-
import vtkOpenGLPolyDataMapper from './PolyDataMapper.js';
|
|
6
5
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
7
6
|
import { v as vtkPolyData2DFS } from './glsl/vtkPolyData2DFS.glsl.js';
|
|
8
7
|
import { v as vtkPolyData2DVS } from './glsl/vtkPolyData2DVS.glsl.js';
|
|
@@ -10,12 +9,11 @@ import vtkReplacementShaderMapper from './ReplacementShaderMapper.js';
|
|
|
10
9
|
import vtkShaderProgram from './ShaderProgram.js';
|
|
11
10
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
12
11
|
import { K as round } from '../../Common/Core/Math/index.js';
|
|
13
|
-
import { Representation } from '../Core/Property/Constants.js';
|
|
14
12
|
import { DisplayLocation } from '../Core/Property2D/Constants.js';
|
|
15
13
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
16
14
|
|
|
17
15
|
// import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
18
|
-
var primTypes =
|
|
16
|
+
var primTypes = vtkHelper.primTypes;
|
|
19
17
|
var ScalarMode = vtkMapper2D.ScalarMode;
|
|
20
18
|
var vtkErrorMacro = vtkErrorMacro$1;
|
|
21
19
|
var StartEvent = {
|
|
@@ -146,7 +144,7 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
146
144
|
// property modified (representation interpolation and lighting)
|
|
147
145
|
// input modified
|
|
148
146
|
// light complexity changed
|
|
149
|
-
if (cellBO.
|
|
147
|
+
if (cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime() || cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime()) {
|
|
150
148
|
return true;
|
|
151
149
|
}
|
|
152
150
|
|
|
@@ -172,18 +170,6 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
172
170
|
return false;
|
|
173
171
|
};
|
|
174
172
|
|
|
175
|
-
publicAPI.getOpenGLMode = function (rep, type) {
|
|
176
|
-
if (rep === Representation.POINTS || type === primTypes.Points) {
|
|
177
|
-
return model.context.POINTS;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (rep === Representation.WIREFRAME || type === primTypes.Lines || type === primTypes.TrisEdges || type === primTypes.TriStripsEdges) {
|
|
181
|
-
return model.context.LINES;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return model.context.TRIANGLES;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
173
|
publicAPI.buildBufferObjects = function (ren, actor) {
|
|
188
174
|
var poly = model.currentInput;
|
|
189
175
|
|
|
@@ -252,9 +238,7 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
252
238
|
|
|
253
239
|
publicAPI.renderPieceDraw = function (ren, actor) {
|
|
254
240
|
var representation = actor.getProperty().getRepresentation();
|
|
255
|
-
var drawSurfaceWithEdges = false;
|
|
256
241
|
var gl = model.context;
|
|
257
|
-
gl.lineWidth(actor.getProperty().getLineWidth());
|
|
258
242
|
gl.depthMask(true); // for every primitive type
|
|
259
243
|
|
|
260
244
|
for (var i = primTypes.Start; i < primTypes.End; i++) {
|
|
@@ -262,27 +246,15 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
262
246
|
var cabo = model.primitives[i].getCABO();
|
|
263
247
|
|
|
264
248
|
if (cabo.getElementCount()) {
|
|
265
|
-
|
|
266
|
-
model.
|
|
267
|
-
var mode = publicAPI.getOpenGLMode(representation, i);
|
|
268
|
-
|
|
269
|
-
if (!model.drawingEdges || !model.renderDepth) {
|
|
270
|
-
publicAPI.updateShaders(model.primitives[i], ren, actor);
|
|
271
|
-
gl.drawArrays(mode, 0, cabo.getElementCount());
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
var stride = (mode === gl.POINTS ? 1 : 0) || (mode === gl.LINES ? 2 : 3);
|
|
275
|
-
model.primitiveIDOffset += cabo.getElementCount() / stride;
|
|
249
|
+
model.lastBoundBO = model.primitives[i];
|
|
250
|
+
model.primitiveIDOffset += model.primitives[i].drawArrays(ren, actor, representation, publicAPI);
|
|
276
251
|
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
gl.lineWidth(1);
|
|
252
|
+
}
|
|
281
253
|
};
|
|
282
254
|
|
|
283
255
|
publicAPI.renderPieceFinish = function (ren, actor) {
|
|
284
|
-
if (model.
|
|
285
|
-
model.
|
|
256
|
+
if (model.lastBoundBO) {
|
|
257
|
+
model.lastBoundBO.getVAO().release();
|
|
286
258
|
}
|
|
287
259
|
};
|
|
288
260
|
|
|
@@ -402,48 +374,11 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
402
374
|
};
|
|
403
375
|
|
|
404
376
|
publicAPI.replaceShaderPositionVC = function (shaders, ren, actor) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
var FSSource = shaders.Fragment; // for points make sure to add in the point size
|
|
408
|
-
|
|
409
|
-
if (actor.getProperty().getRepresentation() === Representation.POINTS || model.lastBoundBO.getPrimitiveType() === primTypes.Points) {
|
|
410
|
-
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', ['//VTK::PositionVC::Impl', " gl_PointSize = ".concat(actor.getProperty().getPointSize(), ".0;")], false).result;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
shaders.Vertex = VSSource;
|
|
414
|
-
shaders.Geometry = GSSource;
|
|
415
|
-
shaders.Fragment = FSSource;
|
|
377
|
+
// replace common shader code
|
|
378
|
+
model.lastBoundBO.replaceShaderPositionVC(shaders, ren, actor);
|
|
416
379
|
};
|
|
417
380
|
|
|
418
|
-
publicAPI.
|
|
419
|
-
model.lastBoundBO = cellBO; // has something changed that would require us to recreate the shader?
|
|
420
|
-
|
|
421
|
-
if (publicAPI.getNeedToRebuildShaders(cellBO, ren, actor)) {
|
|
422
|
-
var shaders = {
|
|
423
|
-
Vertex: null,
|
|
424
|
-
Fragment: null,
|
|
425
|
-
Geometry: null
|
|
426
|
-
};
|
|
427
|
-
publicAPI.buildShaders(shaders, ren, actor); // compile and bind the program if needed
|
|
428
|
-
|
|
429
|
-
var newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); // if the shader changed reinitialize the VAO
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (newShader !== cellBO.getProgram()) {
|
|
433
|
-
cellBO.setProgram(newShader); // reset the VAO as the shader has changed
|
|
434
|
-
|
|
435
|
-
cellBO.getVAO().releaseGraphicsResources();
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
cellBO.getShaderSourceTime().modified();
|
|
439
|
-
} else {
|
|
440
|
-
model._openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram());
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
cellBO.getVAO().bind();
|
|
444
|
-
publicAPI.setMapperShaderParameters(cellBO, ren, actor);
|
|
445
|
-
publicAPI.setPropertyShaderParameters(cellBO, ren, actor);
|
|
446
|
-
publicAPI.setCameraShaderParameters(cellBO, ren, actor);
|
|
381
|
+
publicAPI.invokeShaderCallbacks = function (cellBO, ren, actor) {
|
|
447
382
|
var listCallbacks = model.renderable.getViewSpecificProperties().ShadersCallbacks;
|
|
448
383
|
|
|
449
384
|
if (listCallbacks) {
|
|
@@ -501,15 +436,7 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
501
436
|
} // handle wide lines
|
|
502
437
|
|
|
503
438
|
|
|
504
|
-
|
|
505
|
-
var gl = model.context;
|
|
506
|
-
var vp = gl.getParameter(gl.VIEWPORT);
|
|
507
|
-
var lineWidth = [1, 1];
|
|
508
|
-
lineWidth[0] = 2.0 * actor.getProperty().getLineWidth() / vp[2];
|
|
509
|
-
lineWidth[1] = 2.0 * actor.getProperty().getLineWidth() / vp[3];
|
|
510
|
-
cellBO.getProgram().setUniform2f('lineWidthNVC', lineWidth);
|
|
511
|
-
}
|
|
512
|
-
|
|
439
|
+
cellBO.setMapperShaderParameters(ren, actor, model.openGLRenderer.getTiledSizeAndOrigin());
|
|
513
440
|
var selector = model.openGLRenderer.getSelector();
|
|
514
441
|
cellBO.getProgram().setUniform3fArray('mapperIndex', selector ? selector.getPropColorValue() : [0.0, 0.0, 0.0]);
|
|
515
442
|
cellBO.getProgram().setUniformi('picking', selector ? selector.getCurrentPass() + 1 : 0);
|
|
@@ -529,6 +456,9 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
529
456
|
}
|
|
530
457
|
};
|
|
531
458
|
|
|
459
|
+
publicAPI.setLightingShaderParameters = function (cellBO, ren, actor) {// no-op
|
|
460
|
+
};
|
|
461
|
+
|
|
532
462
|
function safeMatrixMultiply(matrixArray, matrixType, tmpMat) {
|
|
533
463
|
matrixType.identity(tmpMat);
|
|
534
464
|
return matrixArray.reduce(function (res, matrix, index) {
|
|
@@ -598,20 +528,6 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
598
528
|
mat4.transpose(tmpMat4, tmpMat4);
|
|
599
529
|
program.setUniformMatrix('WCVCMatrix', safeMatrixMultiply([tmpMat4, inverseShiftScaleMatrix], mat4, model.tmpMat4));
|
|
600
530
|
};
|
|
601
|
-
|
|
602
|
-
publicAPI.haveWideLines = function (ren, actor) {
|
|
603
|
-
if (model.lastBoundBO === model.lines && actor.getProperty().getLineWidth() > 1.0) {
|
|
604
|
-
// we have wide lines, but the OpenGL implementation may
|
|
605
|
-
// actually support them, check the range to see if we
|
|
606
|
-
// really need have to implement our own wide lines
|
|
607
|
-
// vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(ren->GetVTKWindow());
|
|
608
|
-
// return !(
|
|
609
|
-
// renWin && renWin->GetMaximumHardwareLineWidth() >= actor->GetProperty()->GetLineWidth());
|
|
610
|
-
return true;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return false;
|
|
614
|
-
};
|
|
615
531
|
} // ----------------------------------------------------------------------------
|
|
616
532
|
// Object factory
|
|
617
533
|
// ----------------------------------------------------------------------------
|
|
@@ -737,6 +737,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
737
737
|
});
|
|
738
738
|
};
|
|
739
739
|
|
|
740
|
+
publicAPI.getHardwareMaximumLineWidth = function () {
|
|
741
|
+
var gl = publicAPI.get3DContext();
|
|
742
|
+
var lineWidthRange = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);
|
|
743
|
+
return lineWidthRange[1];
|
|
744
|
+
};
|
|
745
|
+
|
|
740
746
|
publicAPI.getGLInformations = function () {
|
|
741
747
|
var gl = publicAPI.get3DContext();
|
|
742
748
|
var glTextureFloat = gl.getExtension('OES_texture_float');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { newInstance as newInstance$1, get, setGet, vtkDebugMacro as vtkDebugMacro$1 } from '../../macros.js';
|
|
1
|
+
import { newInstance as newInstance$1, get, setGet, moveToProtected, vtkDebugMacro as vtkDebugMacro$1 } from '../../macros.js';
|
|
2
2
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
3
3
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
4
4
|
|
|
@@ -178,7 +178,7 @@ function vtkOpenGLRenderer(publicAPI, model) {
|
|
|
178
178
|
|
|
179
179
|
var DEFAULT_VALUES = {
|
|
180
180
|
context: null,
|
|
181
|
-
_openGLRenderWindow: null,
|
|
181
|
+
// _openGLRenderWindow: null,
|
|
182
182
|
selector: null
|
|
183
183
|
}; // ----------------------------------------------------------------------------
|
|
184
184
|
|
|
@@ -189,7 +189,8 @@ function extend(publicAPI, model) {
|
|
|
189
189
|
vtkViewNode.extend(publicAPI, model, initialValues); // Build VTK API
|
|
190
190
|
|
|
191
191
|
get(publicAPI, model, ['shaderCache']);
|
|
192
|
-
setGet(publicAPI, model, ['selector']);
|
|
192
|
+
setGet(publicAPI, model, ['selector']);
|
|
193
|
+
moveToProtected(publicAPI, model, ['openGLRenderWindow']); // Object methods
|
|
193
194
|
|
|
194
195
|
vtkOpenGLRenderer(publicAPI, model);
|
|
195
196
|
} // ----------------------------------------------------------------------------
|
|
@@ -16,6 +16,11 @@ function vtkSVGLandmarkRepresentation(publicAPI, model) {
|
|
|
16
16
|
|
|
17
17
|
publicAPI.render = function () {
|
|
18
18
|
var list = publicAPI.getRepresentationStates();
|
|
19
|
+
|
|
20
|
+
if (!list.length) {
|
|
21
|
+
return createSvgElement('g');
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
var coords = [];
|
|
20
25
|
var texts = [];
|
|
21
26
|
list.forEach(function (state, index) {
|
|
@@ -58,6 +63,8 @@ function vtkSVGLandmarkRepresentation(publicAPI, model) {
|
|
|
58
63
|
var splitText = texts[i].split('\n');
|
|
59
64
|
var fontSize = fontSizeToPixels(model.fontProperties);
|
|
60
65
|
splitText.forEach(function (subText, j) {
|
|
66
|
+
var _model$textProps, _model$textProps2;
|
|
67
|
+
|
|
61
68
|
var text = publicAPI.createListenableSvgElement('text', i);
|
|
62
69
|
Object.keys(model.textProps || {}).forEach(function (prop) {
|
|
63
70
|
text.setAttribute(prop, model.textProps[prop]);
|
|
@@ -65,9 +72,9 @@ function vtkSVGLandmarkRepresentation(publicAPI, model) {
|
|
|
65
72
|
text.setAttribute('x', x);
|
|
66
73
|
text.setAttribute('y', y); // Vertical offset (dy) calculation based on VerticalTextAlignment
|
|
67
74
|
|
|
68
|
-
var dy = model.textProps
|
|
75
|
+
var dy = ((_model$textProps = model.textProps) === null || _model$textProps === void 0 ? void 0 : _model$textProps.dy) || 0;
|
|
69
76
|
|
|
70
|
-
switch (model.textProps.verticalAlign) {
|
|
77
|
+
switch ((_model$textProps2 = model.textProps) === null || _model$textProps2 === void 0 ? void 0 : _model$textProps2.verticalAlign) {
|
|
71
78
|
case VerticalTextAlignment.MIDDLE:
|
|
72
79
|
dy -= fontSize * (0.5 * splitText.length - j - 1);
|
|
73
80
|
break;
|
|
@@ -42,7 +42,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
42
42
|
newHandle.setScale1(moveHandle.getScale1());
|
|
43
43
|
} else {
|
|
44
44
|
isDragging = true;
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
46
47
|
|
|
47
48
|
model._interactor.requestAnimation(publicAPI);
|
|
48
49
|
}
|
|
@@ -57,8 +58,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
57
58
|
publicAPI.handleMouseMove = function (callData) {
|
|
58
59
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
59
60
|
model.manipulator.setOrigin(model.activeState.getOrigin());
|
|
60
|
-
model.manipulator.setNormal(model.
|
|
61
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
61
|
+
model.manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
62
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
62
63
|
|
|
63
64
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
64
65
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -68,7 +69,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
if (model.hasFocus) {
|
|
71
|
-
model.
|
|
72
|
+
model._widgetManager.disablePicking();
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
return macro.VOID;
|
|
@@ -79,7 +80,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
79
80
|
|
|
80
81
|
publicAPI.handleLeftButtonRelease = function () {
|
|
81
82
|
if (isDragging && model.pickable) {
|
|
82
|
-
model.
|
|
83
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
84
|
+
|
|
83
85
|
model.widgetState.deactivate();
|
|
84
86
|
|
|
85
87
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -91,7 +93,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
91
93
|
|
|
92
94
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
93
95
|
publicAPI.invokeEndInteractionEvent();
|
|
94
|
-
|
|
96
|
+
|
|
97
|
+
model._widgetManager.enablePicking();
|
|
95
98
|
|
|
96
99
|
model._interactor.render();
|
|
97
100
|
} // Don't make any more points
|
|
@@ -134,7 +137,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
134
137
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
135
138
|
model.activeState = null;
|
|
136
139
|
model.hasFocus = false;
|
|
137
|
-
|
|
140
|
+
|
|
141
|
+
model._widgetManager.enablePicking();
|
|
138
142
|
|
|
139
143
|
model._interactor.render();
|
|
140
144
|
};
|
|
@@ -36,7 +36,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
36
36
|
newHandle.setScale1(moveHandle.getScale1());
|
|
37
37
|
} else {
|
|
38
38
|
isDragging = true;
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
40
41
|
|
|
41
42
|
model._interactor.requestAnimation(publicAPI);
|
|
42
43
|
}
|
|
@@ -55,7 +56,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
58
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
59
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
59
60
|
|
|
60
61
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
61
62
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -72,7 +73,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
72
73
|
|
|
73
74
|
publicAPI.handleLeftButtonRelease = function () {
|
|
74
75
|
if (isDragging && model.pickable) {
|
|
75
|
-
model.
|
|
76
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
77
|
+
|
|
76
78
|
model.widgetState.deactivate();
|
|
77
79
|
|
|
78
80
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -84,7 +86,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
84
86
|
|
|
85
87
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
86
88
|
publicAPI.invokeEndInteractionEvent();
|
|
87
|
-
|
|
89
|
+
|
|
90
|
+
model._widgetManager.enablePicking();
|
|
88
91
|
|
|
89
92
|
model._interactor.render();
|
|
90
93
|
}
|
|
@@ -122,7 +125,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
122
125
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
123
126
|
model.activeState = null;
|
|
124
127
|
model.hasFocus = false;
|
|
125
|
-
|
|
128
|
+
|
|
129
|
+
model._widgetManager.enablePicking();
|
|
126
130
|
|
|
127
131
|
model._interactor.render();
|
|
128
132
|
};
|
|
@@ -55,8 +55,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
55
55
|
|
|
56
56
|
if (type === 'corners') {
|
|
57
57
|
// manipulator should be a plane manipulator
|
|
58
|
-
manipulator.setNormal(model.
|
|
59
|
-
worldCoords = manipulator.handleEvent(callData, model.
|
|
58
|
+
manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
59
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (type === 'faces') {
|
|
@@ -69,7 +69,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
69
69
|
|
|
70
70
|
manipulator.setOrigin(transformVec3(center, indexToWorldT));
|
|
71
71
|
manipulator.setNormal(rotateVec3(constraintAxis, indexToWorldT));
|
|
72
|
-
worldCoords = manipulator.handleEvent(callData, model.
|
|
72
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (type === 'edges') {
|
|
@@ -78,7 +78,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
78
78
|
return a === 1 ? a : 0;
|
|
79
79
|
});
|
|
80
80
|
manipulator.setNormal(rotateVec3(edgeAxis, indexToWorldT));
|
|
81
|
-
worldCoords = manipulator.handleEvent(callData, model.
|
|
81
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (worldCoords.length) {
|
|
@@ -111,7 +111,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
111
111
|
// --------------------------------------------------------------------------
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
model.
|
|
114
|
+
model._camera = model._renderer.getActiveCamera();
|
|
115
115
|
model.classHierarchy.push('vtkImageCroppingWidgetProp');
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -21,19 +21,23 @@ function widgetBehavior(publicAPI, model) {
|
|
|
21
21
|
publicAPI.updateCursor = function () {
|
|
22
22
|
switch (model.activeState.getUpdateMethodName()) {
|
|
23
23
|
case 'updateFromOrigin':
|
|
24
|
-
model.
|
|
24
|
+
model._apiSpecificRenderWindow.setCursor('crosshair');
|
|
25
|
+
|
|
25
26
|
break;
|
|
26
27
|
|
|
27
28
|
case 'updateFromPlane':
|
|
28
|
-
model.
|
|
29
|
+
model._apiSpecificRenderWindow.setCursor('move');
|
|
30
|
+
|
|
29
31
|
break;
|
|
30
32
|
|
|
31
33
|
case 'updateFromNormal':
|
|
32
|
-
model.
|
|
34
|
+
model._apiSpecificRenderWindow.setCursor('alias');
|
|
35
|
+
|
|
33
36
|
break;
|
|
34
37
|
|
|
35
38
|
default:
|
|
36
|
-
model.
|
|
39
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
40
|
+
|
|
37
41
|
break;
|
|
38
42
|
}
|
|
39
43
|
};
|
|
@@ -88,7 +92,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
88
92
|
|
|
89
93
|
publicAPI.updateFromOrigin = function (callData) {
|
|
90
94
|
model.planeManipulator.setNormal(model.widgetState.getNormal());
|
|
91
|
-
var worldCoords = model.planeManipulator.handleEvent(callData, model.
|
|
95
|
+
var worldCoords = model.planeManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
92
96
|
|
|
93
97
|
if (model.widgetState.containsPoint(worldCoords)) {
|
|
94
98
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -101,7 +105,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
101
105
|
|
|
102
106
|
// Move origin along normal axis
|
|
103
107
|
model.lineManipulator.setNormal(model.activeState.getNormal());
|
|
104
|
-
var worldCoords = model.lineManipulator.handleEvent(callData, model.
|
|
108
|
+
var worldCoords = model.lineManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
105
109
|
|
|
106
110
|
if ((_model$widgetState = model.widgetState).containsPoint.apply(_model$widgetState, _toConsumableArray(worldCoords))) {
|
|
107
111
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -111,7 +115,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
111
115
|
|
|
112
116
|
publicAPI.updateFromNormal = function (callData) {
|
|
113
117
|
model.trackballManipulator.setNormal(model.activeState.getNormal());
|
|
114
|
-
var newNormal = model.trackballManipulator.handleEvent(callData, model.
|
|
118
|
+
var newNormal = model.trackballManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
115
119
|
model.activeState.setNormal(newNormal);
|
|
116
120
|
}; // --------------------------------------------------------------------------
|
|
117
121
|
// initialization
|
|
@@ -15,7 +15,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
15
15
|
model.representations[1].setCircleProps(_objectSpread(_objectSpread({}, model.representations[1].getCircleProps()), {}, {
|
|
16
16
|
visible: !text
|
|
17
17
|
}));
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
model._interactor.render();
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
publicAPI.getText = function () {
|
|
@@ -51,8 +52,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
51
52
|
publicAPI.loseFocus();
|
|
52
53
|
} else {
|
|
53
54
|
model.isDragging = true;
|
|
54
|
-
|
|
55
|
-
model.
|
|
55
|
+
|
|
56
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
57
|
+
|
|
58
|
+
model._interactor.requestAnimation(publicAPI);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
publicAPI.invokeStartInteractionEvent();
|
|
@@ -64,9 +67,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
64
67
|
|
|
65
68
|
publicAPI.handleLeftButtonRelease = function () {
|
|
66
69
|
if (model.isDragging && model.pickable) {
|
|
67
|
-
model.
|
|
70
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
71
|
+
|
|
68
72
|
model.widgetState.deactivate();
|
|
69
|
-
|
|
73
|
+
|
|
74
|
+
model._interactor.cancelAnimation(publicAPI);
|
|
75
|
+
|
|
70
76
|
publicAPI.invokeEndInteractionEvent();
|
|
71
77
|
} else if (model.activeState !== model.widgetState.getMoveHandle()) {
|
|
72
78
|
model.widgetState.deactivate();
|
|
@@ -74,8 +80,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
74
80
|
|
|
75
81
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
76
82
|
publicAPI.invokeEndInteractionEvent();
|
|
77
|
-
|
|
78
|
-
model.
|
|
83
|
+
|
|
84
|
+
model._widgetManager.enablePicking();
|
|
85
|
+
|
|
86
|
+
model._interactor.render();
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
model.isDragging = false;
|
|
@@ -86,7 +94,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
86
94
|
|
|
87
95
|
publicAPI.handleMouseMove = function (callData) {
|
|
88
96
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
89
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
97
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
90
98
|
|
|
91
99
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model.isDragging)) {
|
|
92
100
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -113,7 +121,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
113
121
|
publicAPI.reset();
|
|
114
122
|
model.activeState = model.widgetState.getMoveHandle();
|
|
115
123
|
model.widgetState.getMoveHandle().activate();
|
|
116
|
-
|
|
124
|
+
|
|
125
|
+
model._interactor.requestAnimation(publicAPI);
|
|
126
|
+
|
|
117
127
|
publicAPI.invokeStartInteractionEvent();
|
|
118
128
|
}
|
|
119
129
|
|
|
@@ -122,7 +132,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
122
132
|
|
|
123
133
|
publicAPI.loseFocus = function () {
|
|
124
134
|
if (model.hasFocus) {
|
|
125
|
-
model.
|
|
135
|
+
model._interactor.cancelAnimation(publicAPI);
|
|
136
|
+
|
|
126
137
|
publicAPI.invokeEndInteractionEvent();
|
|
127
138
|
}
|
|
128
139
|
|
|
@@ -130,8 +141,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
130
141
|
model.widgetState.getMoveHandle().deactivate();
|
|
131
142
|
model.activeState = null;
|
|
132
143
|
model.hasFocus = false;
|
|
133
|
-
|
|
134
|
-
model.
|
|
144
|
+
|
|
145
|
+
model._widgetManager.enablePicking();
|
|
146
|
+
|
|
147
|
+
model._interactor.render();
|
|
135
148
|
};
|
|
136
149
|
}
|
|
137
150
|
|
|
@@ -36,8 +36,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
36
36
|
|
|
37
37
|
function updateCursor(callData) {
|
|
38
38
|
model.isDragging = true;
|
|
39
|
-
model.previousPosition = _toConsumableArray(model.manipulator.handleEvent(callData, model.
|
|
40
|
-
|
|
39
|
+
model.previousPosition = _toConsumableArray(model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow));
|
|
40
|
+
|
|
41
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
41
42
|
|
|
42
43
|
model._interactor.requestAnimation(publicAPI);
|
|
43
44
|
} // --------------------------------------------------------------------------
|
|
@@ -101,8 +102,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
function computeMousePosition(p1, callData) {
|
|
104
|
-
var displayMousePos = publicAPI.computeWorldToDisplay.apply(publicAPI, [model.
|
|
105
|
-
var worldMousePos = publicAPI.computeDisplayToWorld(model.
|
|
105
|
+
var displayMousePos = publicAPI.computeWorldToDisplay.apply(publicAPI, [model._renderer].concat(_toConsumableArray(p1)));
|
|
106
|
+
var worldMousePos = publicAPI.computeDisplayToWorld(model._renderer, callData.position.x, callData.position.y, displayMousePos[2]);
|
|
106
107
|
return worldMousePos;
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
@@ -137,8 +138,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
publicAPI.rotateHandlesToFaceCamera = function () {
|
|
140
|
-
model.representations[0].setViewMatrix(Array.from(model.
|
|
141
|
-
model.representations[1].setViewMatrix(Array.from(model.
|
|
141
|
+
model.representations[0].setViewMatrix(Array.from(model._camera.getViewMatrix()));
|
|
142
|
+
model.representations[1].setViewMatrix(Array.from(model._camera.getViewMatrix()));
|
|
142
143
|
}; // Handles visibility ---------------------------------------------------------
|
|
143
144
|
|
|
144
145
|
|
|
@@ -227,7 +228,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
230
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
231
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
231
232
|
var translation = model.previousPosition ? subtract(worldCoords, model.previousPosition, []) : [0, 0, 0];
|
|
232
233
|
model.previousPosition = worldCoords;
|
|
233
234
|
|
|
@@ -269,10 +270,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
269
270
|
model._interactor.cancelAnimation(publicAPI);
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
model.
|
|
273
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
274
|
+
|
|
273
275
|
model.hasFocus = false;
|
|
274
276
|
publicAPI.invokeEndInteractionEvent();
|
|
275
|
-
|
|
277
|
+
|
|
278
|
+
model._widgetManager.enablePicking();
|
|
276
279
|
|
|
277
280
|
model._interactor.render();
|
|
278
281
|
}
|
|
@@ -314,7 +317,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
314
317
|
model.widgetState.getMoveHandle().deactivate();
|
|
315
318
|
model.activeState = null;
|
|
316
319
|
model.hasFocus = false;
|
|
317
|
-
|
|
320
|
+
|
|
321
|
+
model._widgetManager.enablePicking();
|
|
318
322
|
|
|
319
323
|
model._interactor.render();
|
|
320
324
|
};
|
|
@@ -35,8 +35,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
35
35
|
if (model.manipulator && model.activeState && model.activeState.getActive()) {
|
|
36
36
|
var _model$activeState, _model$activeState2, _model$activeState3;
|
|
37
37
|
|
|
38
|
-
var normal = model.
|
|
39
|
-
|
|
38
|
+
var normal = model._camera.getDirectionOfProjection();
|
|
39
|
+
|
|
40
|
+
var up = model._camera.getViewUp();
|
|
41
|
+
|
|
40
42
|
var right = [];
|
|
41
43
|
vec3.cross(right, up, normal);
|
|
42
44
|
|
|
@@ -47,7 +49,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
47
49
|
(_model$activeState3 = model.activeState).setDirection.apply(_model$activeState3, _toConsumableArray(normal));
|
|
48
50
|
|
|
49
51
|
model.manipulator.setNormal(normal);
|
|
50
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
52
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
51
53
|
|
|
52
54
|
if (worldCoords.length) {
|
|
53
55
|
var _model$widgetState, _model$activeState4;
|
|
@@ -76,7 +78,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
76
78
|
|
|
77
79
|
model._interactor.requestAnimation(publicAPI);
|
|
78
80
|
|
|
79
|
-
var canvas = model.
|
|
81
|
+
var canvas = model._apiSpecificRenderWindow.getCanvas();
|
|
80
82
|
|
|
81
83
|
canvas.onmouseenter = function () {
|
|
82
84
|
if (model.hasFocus && model.activeState === model.widgetState.getHandle()) {
|