@genome-spy/core 0.30.0 → 0.30.3
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/dist/index.es.js +16379 -0
- package/dist/index.js +43 -43
- package/package.json +10 -7
- package/src/data/collector.js +0 -183
- package/src/data/collector.test.js +0 -84
- package/src/data/dataFlow.js +0 -148
- package/src/data/dataFlow.test.js +0 -5
- package/src/data/facetNode.js +0 -17
- package/src/data/flow.test.js +0 -72
- package/src/data/flowBatch.d.ts +0 -40
- package/src/data/flowNode.js +0 -283
- package/src/data/flowNode.test.js +0 -50
- package/src/data/flowOptimizer.js +0 -123
- package/src/data/flowOptimizer.test.js +0 -193
- package/src/data/flowTestUtils.js +0 -63
- package/src/data/formats/fasta.js +0 -32
- package/src/data/formats/fasta.test.js +0 -27
- package/src/data/sources/dataSource.js +0 -22
- package/src/data/sources/dataSourceFactory.js +0 -24
- package/src/data/sources/dataUtils.js +0 -78
- package/src/data/sources/dynamicCallbackSource.js +0 -57
- package/src/data/sources/dynamicSource.js +0 -37
- package/src/data/sources/inlineSource.js +0 -67
- package/src/data/sources/inlineSource.test.js +0 -56
- package/src/data/sources/namedSource.js +0 -79
- package/src/data/sources/sequenceSource.js +0 -46
- package/src/data/sources/sequenceSource.test.js +0 -46
- package/src/data/sources/urlSource.js +0 -74
- package/src/data/transforms/aggregate.js +0 -70
- package/src/data/transforms/clone.js +0 -40
- package/src/data/transforms/clone.test.js +0 -11
- package/src/data/transforms/coverage.js +0 -187
- package/src/data/transforms/coverage.test.js +0 -123
- package/src/data/transforms/filter.js +0 -37
- package/src/data/transforms/filter.test.js +0 -18
- package/src/data/transforms/filterScoredLabels.js +0 -134
- package/src/data/transforms/flattenCompressedExons.js +0 -57
- package/src/data/transforms/flattenDelimited.js +0 -74
- package/src/data/transforms/flattenDelimited.test.js +0 -87
- package/src/data/transforms/flattenSequence.js +0 -39
- package/src/data/transforms/flattenSequence.test.js +0 -34
- package/src/data/transforms/formula.js +0 -39
- package/src/data/transforms/formula.test.js +0 -19
- package/src/data/transforms/identifier.js +0 -108
- package/src/data/transforms/identifier.test.js +0 -83
- package/src/data/transforms/linearizeGenomicCoordinate.js +0 -101
- package/src/data/transforms/measureText.js +0 -44
- package/src/data/transforms/pileup.js +0 -128
- package/src/data/transforms/pileup.test.js +0 -70
- package/src/data/transforms/project.js +0 -41
- package/src/data/transforms/project.test.js +0 -32
- package/src/data/transforms/regexExtract.js +0 -61
- package/src/data/transforms/regexExtract.test.js +0 -67
- package/src/data/transforms/regexFold.js +0 -141
- package/src/data/transforms/regexFold.test.js +0 -160
- package/src/data/transforms/sample.js +0 -101
- package/src/data/transforms/sample.test.js +0 -38
- package/src/data/transforms/stack.js +0 -137
- package/src/data/transforms/stack.test.js +0 -91
- package/src/data/transforms/transformFactory.js +0 -60
- package/src/embedApi.d.ts +0 -67
- package/src/encoder/accessor.js +0 -82
- package/src/encoder/accessor.test.js +0 -47
- package/src/encoder/encoder.js +0 -394
- package/src/encoder/encoder.test.js +0 -98
- package/src/fonts/Lato-Regular.json +0 -1267
- package/src/fonts/Lato-Regular.png +0 -0
- package/src/fonts/OFL.txt +0 -93
- package/src/fonts/README.md +0 -3
- package/src/fonts/bmFont.d.ts +0 -58
- package/src/fonts/bmFontManager.js +0 -357
- package/src/fonts/bmFontMetrics.js +0 -108
- package/src/genome/genome.js +0 -317
- package/src/genome/genome.test.js +0 -188
- package/src/genome/genomeStore.js +0 -54
- package/src/genome/locusFormat.js +0 -31
- package/src/genome/scaleIndex.d.ts +0 -38
- package/src/genome/scaleIndex.js +0 -166
- package/src/genome/scaleIndex.test.js +0 -78
- package/src/genome/scaleLocus.d.ts +0 -11
- package/src/genome/scaleLocus.js +0 -108
- package/src/genome/scaleLocus.test.js +0 -4
- package/src/genomeSpy.js +0 -785
- package/src/gl/arrayBuilder.js +0 -199
- package/src/gl/dataToVertices.js +0 -636
- package/src/gl/includes/common.glsl +0 -63
- package/src/gl/includes/picking.fragment.glsl +0 -1
- package/src/gl/includes/picking.vertex.glsl +0 -27
- package/src/gl/includes/sampleFacet.glsl +0 -107
- package/src/gl/includes/scales.glsl +0 -112
- package/src/gl/link.fragment.glsl +0 -18
- package/src/gl/link.vertex.glsl +0 -111
- package/src/gl/point.fragment.glsl +0 -123
- package/src/gl/point.vertex.glsl +0 -129
- package/src/gl/rect.fragment.glsl +0 -51
- package/src/gl/rect.vertex.glsl +0 -114
- package/src/gl/rule.fragment.glsl +0 -52
- package/src/gl/rule.vertex.glsl +0 -89
- package/src/gl/text.fragment.glsl +0 -31
- package/src/gl/text.vertex.glsl +0 -246
- package/src/gl/webGLHelper.js +0 -504
- package/src/img/bowtie.svg +0 -1
- package/src/img/genomespy-favicon.svg +0 -34
- package/src/index.html +0 -11
- package/src/index.js +0 -128
- package/src/marks/link.js +0 -175
- package/src/marks/mark.js +0 -975
- package/src/marks/markUtils.js +0 -125
- package/src/marks/pointMark.js +0 -251
- package/src/marks/rectMark.js +0 -241
- package/src/marks/rule.js +0 -250
- package/src/marks/text.js +0 -278
- package/src/node_modules/.vitest/results.json +0 -1
- package/src/scale/colorUtils.js +0 -184
- package/src/scale/glslScaleGenerator.js +0 -502
- package/src/scale/scale.js +0 -451
- package/src/scale/scale.test.js +0 -324
- package/src/scale/ticks.js +0 -203
- package/src/scale/ticks.test.js +0 -40
- package/src/singlePageApp.js +0 -13
- package/src/spec/axis.d.ts +0 -296
- package/src/spec/channel.d.ts +0 -430
- package/src/spec/data.d.ts +0 -196
- package/src/spec/font.d.ts +0 -15
- package/src/spec/genome.d.ts +0 -35
- package/src/spec/mark.d.ts +0 -429
- package/src/spec/root.d.ts +0 -17
- package/src/spec/sampleView.d.ts +0 -180
- package/src/spec/scale.d.ts +0 -273
- package/src/spec/title.d.ts +0 -102
- package/src/spec/tooltip.d.ts +0 -9
- package/src/spec/transform.d.ts +0 -479
- package/src/spec/view.d.ts +0 -201
- package/src/styles/genome-spy.scss +0 -153
- package/src/tooltip/dataTooltipHandler.js +0 -64
- package/src/tooltip/refseqGeneTooltipHandler.js +0 -78
- package/src/tooltip/tooltipHandler.ts +0 -12
- package/src/types/filetypes.d.ts +0 -14
- package/src/types/flatqueue.d.ts +0 -53
- package/src/types/glsl.d.ts +0 -4
- package/src/types/internmap.d.ts +0 -22
- package/src/types/object.d.ts +0 -21
- package/src/types/vega-loader.d.ts +0 -1
- package/src/types/vega-scale.d.ts +0 -60
- package/src/utils/addBaseUrl.js +0 -19
- package/src/utils/addBaseUrl.test.js +0 -22
- package/src/utils/animator.js +0 -83
- package/src/utils/arrayUtils.js +0 -61
- package/src/utils/binnedIndex.js +0 -167
- package/src/utils/binnedIndex.test.js +0 -155
- package/src/utils/clamp.js +0 -8
- package/src/utils/cloner.js +0 -34
- package/src/utils/cloner.test.js +0 -24
- package/src/utils/coalesce.js +0 -11
- package/src/utils/coalesce.test.js +0 -16
- package/src/utils/concatIterables.js +0 -26
- package/src/utils/concatIterables.test.js +0 -8
- package/src/utils/debounce.js +0 -37
- package/src/utils/domainArray.js +0 -216
- package/src/utils/domainArray.test.js +0 -130
- package/src/utils/eerp.js +0 -13
- package/src/utils/expression.js +0 -32
- package/src/utils/field.js +0 -28
- package/src/utils/formatObject.js +0 -31
- package/src/utils/indexer.js +0 -43
- package/src/utils/indexer.test.js +0 -47
- package/src/utils/inertia.js +0 -124
- package/src/utils/interactionEvent.js +0 -33
- package/src/utils/iterateNestedMaps.js +0 -21
- package/src/utils/iterateNestedMaps.test.js +0 -33
- package/src/utils/kWayMerge.js +0 -42
- package/src/utils/kWayMerge.test.js +0 -26
- package/src/utils/layout/flexLayout.js +0 -368
- package/src/utils/layout/flexLayout.test.js +0 -311
- package/src/utils/layout/grid.js +0 -95
- package/src/utils/layout/grid.test.js +0 -71
- package/src/utils/layout/padding.js +0 -120
- package/src/utils/layout/point.js +0 -23
- package/src/utils/layout/rectangle.js +0 -288
- package/src/utils/layout/rectangle.test.js +0 -172
- package/src/utils/mergeObjects.js +0 -99
- package/src/utils/mergeObjects.test.js +0 -42
- package/src/utils/numberExtractor.js +0 -24
- package/src/utils/numberExtractor.test.js +0 -6
- package/src/utils/point.js +0 -14
- package/src/utils/propertyCacher.js +0 -70
- package/src/utils/propertyCacher.test.js +0 -85
- package/src/utils/propertyCoalescer.js +0 -42
- package/src/utils/propertyCoalescer.test.js +0 -22
- package/src/utils/reservationMap.js +0 -103
- package/src/utils/reservationMap.test.js +0 -20
- package/src/utils/scaleNull.js +0 -19
- package/src/utils/setOperations.js +0 -75
- package/src/utils/smoothstep.js +0 -10
- package/src/utils/throttle.js +0 -34
- package/src/utils/topK.js +0 -76
- package/src/utils/topK.test.js +0 -64
- package/src/utils/transition.js +0 -74
- package/src/utils/ui/tooltip.js +0 -189
- package/src/utils/url.js +0 -22
- package/src/utils/variableTools.js +0 -24
- package/src/utils/variableTools.test.js +0 -13
- package/src/view/axisResolution.js +0 -140
- package/src/view/axisResolution.test.js +0 -201
- package/src/view/axisView.js +0 -747
- package/src/view/concatView.js +0 -45
- package/src/view/containerView.js +0 -159
- package/src/view/facetView.js +0 -491
- package/src/view/flowBuilder.js +0 -367
- package/src/view/flowBuilder.test.js +0 -125
- package/src/view/gridView.js +0 -786
- package/src/view/implicitRootView.js +0 -14
- package/src/view/importView.js +0 -19
- package/src/view/layerView.js +0 -74
- package/src/view/rendering.d.ts +0 -44
- package/src/view/renderingContext/compositeViewRenderingContext.js +0 -51
- package/src/view/renderingContext/deferredViewRenderingContext.js +0 -176
- package/src/view/renderingContext/layoutRecorderViewRenderingContext.js +0 -128
- package/src/view/renderingContext/simpleViewRenderingContext.js +0 -64
- package/src/view/renderingContext/svgViewRenderingContext.js +0 -125
- package/src/view/renderingContext/viewRenderingContext.js +0 -41
- package/src/view/scaleResolution.js +0 -797
- package/src/view/scaleResolution.test.js +0 -572
- package/src/view/scaleResolutionApi.d.ts +0 -40
- package/src/view/testUtils.js +0 -51
- package/src/view/title.js +0 -165
- package/src/view/unitView.js +0 -382
- package/src/view/view.js +0 -612
- package/src/view/view.test.js +0 -214
- package/src/view/viewContext.d.ts +0 -62
- package/src/view/viewFactory.js +0 -181
- package/src/view/viewFactory.test.js +0 -17
- package/src/view/viewUtils.js +0 -327
- package/src/view/zoom.js +0 -89
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import GridView from "./gridView";
|
|
2
|
-
|
|
3
|
-
export default class ImplicitRootView extends GridView {
|
|
4
|
-
/**
|
|
5
|
-
* @param {import("./viewUtils").ViewContext} context
|
|
6
|
-
* @param {import("./view").default} view
|
|
7
|
-
*/
|
|
8
|
-
constructor(context, view) {
|
|
9
|
-
super({ vconcat: [] }, context, undefined, "implicitRoot", 1);
|
|
10
|
-
|
|
11
|
-
view.parent = this;
|
|
12
|
-
this.appendChild(view);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/view/importView.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import View from "./view";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This is just a placeholder for custom tracks that are imported by name.
|
|
5
|
-
*/
|
|
6
|
-
export default class ImportView extends View {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {import("../spec/view").ImportSpec} spec
|
|
10
|
-
* @param {import("./viewUtils").ViewContext} context
|
|
11
|
-
* @param {import("./view").default} parent
|
|
12
|
-
* @param {string} name
|
|
13
|
-
*/
|
|
14
|
-
constructor(spec, context, parent, name) {
|
|
15
|
-
super(spec, context, parent, name);
|
|
16
|
-
|
|
17
|
-
this.spec = spec; // Set here again to keep types happy
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/view/layerView.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { isLayerSpec, isUnitSpec } from "./viewFactory";
|
|
2
|
-
import ContainerView from "./containerView";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {import("./view").default} View
|
|
6
|
-
*/
|
|
7
|
-
export default class LayerView extends ContainerView {
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {import("./viewUtils").LayerSpec} spec
|
|
11
|
-
* @param {import("./viewUtils").ViewContext} context
|
|
12
|
-
* @param {ContainerView} parent
|
|
13
|
-
* @param {string} name
|
|
14
|
-
*/
|
|
15
|
-
constructor(spec, context, parent, name) {
|
|
16
|
-
super(spec, context, parent, name);
|
|
17
|
-
|
|
18
|
-
this.spec = spec;
|
|
19
|
-
|
|
20
|
-
/** @type {(LayerView | import("./unitView").default)[]} */
|
|
21
|
-
this.children = (spec.layer || []).map((childSpec, i) => {
|
|
22
|
-
if (isLayerSpec(childSpec) || isUnitSpec(childSpec)) {
|
|
23
|
-
return context.createView(childSpec, this, "layer" + i);
|
|
24
|
-
} else {
|
|
25
|
-
throw new Error(
|
|
26
|
-
"LayerView accepts only unit or layer specs as children!"
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @returns {IterableIterator<View>}
|
|
34
|
-
*/
|
|
35
|
-
*[Symbol.iterator]() {
|
|
36
|
-
for (const child of this.children) {
|
|
37
|
-
yield child;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {import("./renderingContext/viewRenderingContext").default} context
|
|
43
|
-
* @param {import("../utils/layout/rectangle").default} coords
|
|
44
|
-
* @param {import("./view").RenderingOptions} [options]
|
|
45
|
-
*/
|
|
46
|
-
render(context, coords, options = {}) {
|
|
47
|
-
if (!this.isVisible()) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
context.pushView(this, coords);
|
|
52
|
-
|
|
53
|
-
for (const child of this.children) {
|
|
54
|
-
child.render(context, coords, options);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
context.popView(this);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @param {import("../utils/interactionEvent").default} event
|
|
62
|
-
*/
|
|
63
|
-
propagateInteractionEvent(event) {
|
|
64
|
-
this.handleInteractionEvent(undefined, event, true);
|
|
65
|
-
if (this.children.length) {
|
|
66
|
-
// Propagate to the top layer
|
|
67
|
-
this.children.at(-1).propagateInteractionEvent(event);
|
|
68
|
-
}
|
|
69
|
-
if (event.stopped) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
this.handleInteractionEvent(undefined, event, false);
|
|
73
|
-
}
|
|
74
|
-
}
|
package/src/view/rendering.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { LocSize } from "../utils/layout/flexLayout";
|
|
2
|
-
import Rectangle from "../utils/layout/rectangle";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Describes the location of a sample facet. Left is the primary pos, right is for
|
|
6
|
-
* transitioning between two sets of samples.
|
|
7
|
-
*/
|
|
8
|
-
export interface SampleFacetRenderingOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Location and height on unit scale, zero at top
|
|
11
|
-
*/
|
|
12
|
-
locSize: LocSize;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Target (during transition)
|
|
16
|
-
*/
|
|
17
|
-
targetLocSize?: LocSize;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface RenderingOptions {
|
|
21
|
-
/**
|
|
22
|
-
* Which facet to render (if faceting is being used)
|
|
23
|
-
*/
|
|
24
|
-
facetId?: any;
|
|
25
|
-
|
|
26
|
-
sampleFacetRenderingOptions?: SampleFacetRenderingOptions;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Clip rendering using the given rectangle.
|
|
30
|
-
* Mainly intended for clipping scrollable views.
|
|
31
|
-
*/
|
|
32
|
-
clipRect?: Rectangle;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Options that affect the whole rendering pass.
|
|
37
|
-
*/
|
|
38
|
-
export interface GlobalRenderingOptions {
|
|
39
|
-
/**
|
|
40
|
-
* Replace colors with unique ids for picking.
|
|
41
|
-
* Views that haven't enabled picking can be skipped.
|
|
42
|
-
*/
|
|
43
|
-
picking?: boolean;
|
|
44
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import ViewRenderingContext from "./viewRenderingContext";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {import("../view").default} View
|
|
5
|
-
*/
|
|
6
|
-
export default class CompositeViewRenderingContext extends ViewRenderingContext {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {...ViewRenderingContext} contexts
|
|
10
|
-
*/
|
|
11
|
-
constructor(...contexts) {
|
|
12
|
-
super({});
|
|
13
|
-
|
|
14
|
-
this.contexts = contexts;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Must be called when a view's render() method is entered
|
|
19
|
-
*
|
|
20
|
-
* @param {View} view
|
|
21
|
-
* @param {import("../../utils/layout/rectangle").default} coords View coordinates
|
|
22
|
-
* inside the padding.
|
|
23
|
-
*/
|
|
24
|
-
pushView(view, coords) {
|
|
25
|
-
for (const context of this.contexts) {
|
|
26
|
-
context.pushView(view, coords);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Must be called when a view's render() method is being exited
|
|
32
|
-
*
|
|
33
|
-
* @param {View} view
|
|
34
|
-
*/
|
|
35
|
-
popView(view) {
|
|
36
|
-
for (const context of this.contexts) {
|
|
37
|
-
context.popView(view);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {import("../../marks/mark").default} mark
|
|
44
|
-
* @param {import("../view").RenderingOptions} options
|
|
45
|
-
*/
|
|
46
|
-
renderMark(mark, options) {
|
|
47
|
-
for (const context of this.contexts) {
|
|
48
|
-
context.renderMark(mark, options);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { group } from "d3-array";
|
|
2
|
-
|
|
3
|
-
import ViewRenderingContext from "./viewRenderingContext";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @typedef {object} DeferredRenderingRequest Allows for collecting marks for
|
|
8
|
-
* optimized rendering order.
|
|
9
|
-
* @prop {import("../../marks/mark").default} mark
|
|
10
|
-
* @prop {function():void} callback
|
|
11
|
-
* @prop {import("../../utils/layout/rectangle").default} coords
|
|
12
|
-
* @prop {import("../../utils/layout/rectangle").default} [clipRect]
|
|
13
|
-
*/
|
|
14
|
-
export default class DeferredViewRenderingContext extends ViewRenderingContext {
|
|
15
|
-
/**
|
|
16
|
-
* @param {import("../rendering").GlobalRenderingOptions} globalOptions
|
|
17
|
-
* @param {import("../../gl/webGLHelper").default} webGLHelper
|
|
18
|
-
*/
|
|
19
|
-
constructor(globalOptions, webGLHelper) {
|
|
20
|
-
super(globalOptions);
|
|
21
|
-
|
|
22
|
-
this.webGLHelper = webGLHelper;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @type {DeferredRenderingRequest[]}
|
|
26
|
-
*/
|
|
27
|
-
this.buffer = [];
|
|
28
|
-
|
|
29
|
-
/** @type {import("../../utils/layout/rectangle").default} */
|
|
30
|
-
this.coords = undefined;
|
|
31
|
-
|
|
32
|
-
/** @type {Set<import("../view").default>} */
|
|
33
|
-
this.views = new Set();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Must be called when a view's render() method is entered
|
|
38
|
-
*
|
|
39
|
-
* @param {import("../view").default} view
|
|
40
|
-
* @param {import("../../utils/layout/rectangle").default} coords View coordinates
|
|
41
|
-
* inside the padding.
|
|
42
|
-
*/
|
|
43
|
-
pushView(view, coords) {
|
|
44
|
-
this.views.add(view);
|
|
45
|
-
this.coords = coords;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {import("../../marks/mark").default} mark
|
|
51
|
-
* @param {import("../view").RenderingOptions} options
|
|
52
|
-
*/
|
|
53
|
-
renderMark(mark, options) {
|
|
54
|
-
if (this.globalOptions.picking && !mark.isPickingParticipant()) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const callback = mark.render(options);
|
|
59
|
-
if (callback) {
|
|
60
|
-
this.buffer.push({
|
|
61
|
-
mark,
|
|
62
|
-
callback,
|
|
63
|
-
coords: this.coords,
|
|
64
|
-
clipRect: options.clipRect,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Renders marks in an optimized order, minimizing the number of WebGL state
|
|
71
|
-
* changes.
|
|
72
|
-
*/
|
|
73
|
-
renderDeferred() {
|
|
74
|
-
if (!this.batch) {
|
|
75
|
-
this._buildBatch();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (this.batch.length == 0) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const gl = this.webGLHelper.gl;
|
|
83
|
-
const picking = this.globalOptions.picking;
|
|
84
|
-
|
|
85
|
-
gl.bindFramebuffer(
|
|
86
|
-
gl.FRAMEBUFFER,
|
|
87
|
-
picking ? this.webGLHelper._pickingBufferInfo.framebuffer : null
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
this.webGLHelper.clearAll();
|
|
91
|
-
|
|
92
|
-
for (const view of this.views) {
|
|
93
|
-
view.onBeforeRender();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Execute the batch
|
|
97
|
-
for (const op of this.batch) {
|
|
98
|
-
op();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (picking) {
|
|
102
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_buildBatch() {
|
|
107
|
-
/**
|
|
108
|
-
* Store the operations as a sequence of commands for cheap subsequent rendering.
|
|
109
|
-
*
|
|
110
|
-
* @type {(function():void)[]}
|
|
111
|
-
*/
|
|
112
|
-
this.batch = [];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Is drawing enabled or not. As an optimization this is toggled off for invisible views.
|
|
116
|
-
*/
|
|
117
|
-
let enabled = true;
|
|
118
|
-
|
|
119
|
-
let viewportVisible = true;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @type {function(function():void):(function():void)}
|
|
123
|
-
*/
|
|
124
|
-
const ifEnabled = (op) => () => {
|
|
125
|
-
if (enabled) op();
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @type {function(function():void):(function():void)}
|
|
130
|
-
*/
|
|
131
|
-
const ifEnabledAndVisible = (op) => () => {
|
|
132
|
-
if (enabled && viewportVisible) op();
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// Group by marks in order to minimize program changes
|
|
136
|
-
const requestByMark = group(this.buffer, (request) => request.mark);
|
|
137
|
-
|
|
138
|
-
for (const [mark, requests] of requestByMark.entries()) {
|
|
139
|
-
if (!mark.isReady()) {
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// eslint-disable-next-line no-loop-func
|
|
144
|
-
this.batch.push(() => {
|
|
145
|
-
enabled = mark.unitView.getEffectiveOpacity() > 0;
|
|
146
|
-
});
|
|
147
|
-
// Change program, set common uniforms (mark properties, shared domains)
|
|
148
|
-
this.batch.push(
|
|
149
|
-
...mark
|
|
150
|
-
.prepareRender(this.globalOptions)
|
|
151
|
-
.map((op) => ifEnabled(op))
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
/** @type {import("../../utils/layout/rectangle").default} */
|
|
155
|
-
let previousCoords;
|
|
156
|
-
for (const request of requests) {
|
|
157
|
-
const coords = request.coords;
|
|
158
|
-
// Render each facet
|
|
159
|
-
if (!coords.equals(previousCoords)) {
|
|
160
|
-
this.batch.push(
|
|
161
|
-
// eslint-disable-next-line no-loop-func
|
|
162
|
-
ifEnabled(() => {
|
|
163
|
-
// Suppress rendering if viewport is outside the clipRect
|
|
164
|
-
viewportVisible = mark.setViewport(
|
|
165
|
-
coords,
|
|
166
|
-
request.clipRect
|
|
167
|
-
);
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
this.batch.push(ifEnabledAndVisible(request.callback));
|
|
172
|
-
previousCoords = request.coords;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { peek } from "../../utils/arrayUtils";
|
|
2
|
-
import ViewRenderingContext from "./viewRenderingContext";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A Rendering context that doesn't render anything. It creates a hierarchy
|
|
6
|
-
* of view coordinates, including faceted views that are repeated multiple times.
|
|
7
|
-
* The coordinates can be used for mouse events / interactions, for example.
|
|
8
|
-
*
|
|
9
|
-
* @typedef {import("../view").default} View
|
|
10
|
-
* @typedef {import("../../utils/layout/rectangle").default} Rectangle
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
export default class LayoutRecorderViewRenderingContext extends ViewRenderingContext {
|
|
14
|
-
/**
|
|
15
|
-
* @param {import("../rendering").GlobalRenderingOptions} globalOptions
|
|
16
|
-
*/
|
|
17
|
-
constructor(globalOptions) {
|
|
18
|
-
super(globalOptions);
|
|
19
|
-
|
|
20
|
-
/** @type {ViewCoords} */
|
|
21
|
-
this.root = undefined;
|
|
22
|
-
|
|
23
|
-
/** @type {ViewCoords[]} */
|
|
24
|
-
this.stack = [];
|
|
25
|
-
|
|
26
|
-
/** @type {ViewCoords} */
|
|
27
|
-
this.lastAddition = undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Must be called when a view's render() method is entered
|
|
32
|
-
*
|
|
33
|
-
* @param {View} view
|
|
34
|
-
* @param {Rectangle} coords View coordinates
|
|
35
|
-
* inside the padding.
|
|
36
|
-
*/
|
|
37
|
-
pushView(view, coords) {
|
|
38
|
-
// TODO: Facet id
|
|
39
|
-
|
|
40
|
-
const viewCoords = new ViewCoords(view, coords);
|
|
41
|
-
|
|
42
|
-
if (!this.root) {
|
|
43
|
-
this.root = viewCoords;
|
|
44
|
-
} else {
|
|
45
|
-
peek(this.stack).addChild(viewCoords);
|
|
46
|
-
}
|
|
47
|
-
this.stack.push(viewCoords);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Must be called when a view's render() method is being exited
|
|
52
|
-
*
|
|
53
|
-
* @param {View} view
|
|
54
|
-
*/
|
|
55
|
-
popView(view) {
|
|
56
|
-
this.stack.pop();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getLayout() {
|
|
60
|
-
return this.root;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Represents coordinates of view instances. Faceted views objects may have
|
|
66
|
-
* been rendered at multiple locations.
|
|
67
|
-
*/
|
|
68
|
-
class ViewCoords {
|
|
69
|
-
/**
|
|
70
|
-
* @param {View} view
|
|
71
|
-
* @param {Rectangle} coords
|
|
72
|
-
*/
|
|
73
|
-
constructor(view, coords) {
|
|
74
|
-
this.view = view;
|
|
75
|
-
this.coords = coords;
|
|
76
|
-
/** @type {ViewCoords[]} */
|
|
77
|
-
this.children = [];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @param {ViewCoords} viewCoords
|
|
83
|
-
*/
|
|
84
|
-
addChild(viewCoords) {
|
|
85
|
-
const last = peek(this.children);
|
|
86
|
-
if (
|
|
87
|
-
last &&
|
|
88
|
-
viewCoords.view === last.view &&
|
|
89
|
-
viewCoords.coords.equals(last.coords)
|
|
90
|
-
) {
|
|
91
|
-
// Skip extra copies of sample facets. They all have the same coords.
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
this.children.push(viewCoords);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Broadcasts a message to views that include the given (x, y) point.
|
|
100
|
-
* This is mainly intended for mouse events.
|
|
101
|
-
*
|
|
102
|
-
* @param {import("../../utils/interactionEvent").default} event
|
|
103
|
-
*/
|
|
104
|
-
dispatchInteractionEvent(event) {
|
|
105
|
-
if (this.coords.containsPoint(event.point.x, event.point.y)) {
|
|
106
|
-
this.view.handleInteractionEvent(this.coords, event, true);
|
|
107
|
-
if (event.stopped) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (this.children.length == 0) {
|
|
112
|
-
event.target = this.view;
|
|
113
|
-
} else {
|
|
114
|
-
for (const child of this.children) {
|
|
115
|
-
child.dispatchInteractionEvent(event);
|
|
116
|
-
if (event.target) {
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
if (event.stopped) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
this.view.handleInteractionEvent(this.coords, event, false);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import ViewRenderingContext from "./viewRenderingContext";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This class is mainly for illustrative purpose, i.e., how the rendering
|
|
5
|
-
* would be performed in the most straightforward, unoptimized way.
|
|
6
|
-
*
|
|
7
|
-
* @typedef {import("../view").default} View
|
|
8
|
-
*/
|
|
9
|
-
export default class SimpleViewRenderingContext extends ViewRenderingContext {
|
|
10
|
-
/**
|
|
11
|
-
* @param {import("../rendering").GlobalRenderingOptions} globalOptions
|
|
12
|
-
*/
|
|
13
|
-
constructor(globalOptions) {
|
|
14
|
-
super(globalOptions);
|
|
15
|
-
/** @type {import("../../utils/layout/rectangle").default} */
|
|
16
|
-
this.coords = undefined;
|
|
17
|
-
|
|
18
|
-
/** @type {Set<import("../view").default>} */
|
|
19
|
-
this.views = new Set();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Must be called when a view's render() method is entered
|
|
24
|
-
*
|
|
25
|
-
* @param {View} view
|
|
26
|
-
* @param {import("../../utils/layout/rectangle").default} coords View coordinates
|
|
27
|
-
* inside the padding.
|
|
28
|
-
*/
|
|
29
|
-
pushView(view, coords) {
|
|
30
|
-
if (!this.views.has(view)) {
|
|
31
|
-
// Ensure that the method is called only once, even when rendering facets.
|
|
32
|
-
view.onBeforeRender();
|
|
33
|
-
this.views.add(view);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
this.coords = coords;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Must be called when a view's render() method is being exited
|
|
41
|
-
*
|
|
42
|
-
* @param {View} view
|
|
43
|
-
*/
|
|
44
|
-
popView(view) {
|
|
45
|
-
//
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {import("../../marks/mark").default} mark
|
|
51
|
-
* @param {import("../view").RenderingOptions} options
|
|
52
|
-
*/
|
|
53
|
-
renderMark(mark, options) {
|
|
54
|
-
if (this.globalOptions.picking && !mark.isPickingParticipant()) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
for (const op of mark.prepareRender(this.globalOptions)) {
|
|
59
|
-
op();
|
|
60
|
-
}
|
|
61
|
-
mark.setViewport(this.coords, options.clipRect);
|
|
62
|
-
mark.render(options)();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { peek } from "../../utils/arrayUtils";
|
|
2
|
-
import ViewRenderingContext from "./viewRenderingContext";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A trivial proof-of-concept SVG rendering context. Doesn't render any
|
|
6
|
-
* marks at this point, only placeholders.
|
|
7
|
-
*
|
|
8
|
-
* @typedef {import("../view").default} View
|
|
9
|
-
*/
|
|
10
|
-
export default class SvgViewRenderingContext extends ViewRenderingContext {
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {import("../rendering").GlobalRenderingOptions} globalOptions
|
|
14
|
-
*/
|
|
15
|
-
constructor(globalOptions) {
|
|
16
|
-
super(globalOptions);
|
|
17
|
-
|
|
18
|
-
/** @type {import("../../utils/layout/rectangle").default} */
|
|
19
|
-
this.coords = undefined;
|
|
20
|
-
|
|
21
|
-
this.svg = document.createElementNS(
|
|
22
|
-
"http://www.w3.org/2000/svg",
|
|
23
|
-
"svg"
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
/** @type {SVGElement[]} */
|
|
27
|
-
this.nodeStack = [this.svg];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Must be called when a view's render() method is entered
|
|
32
|
-
*
|
|
33
|
-
* @param {View} view
|
|
34
|
-
* @param {import("../../utils/layout/rectangle").default} coords View coordinates
|
|
35
|
-
* inside the padding.
|
|
36
|
-
*/
|
|
37
|
-
pushView(view, coords) {
|
|
38
|
-
view.onBeforeRender();
|
|
39
|
-
this.coords = coords;
|
|
40
|
-
|
|
41
|
-
if (this._currentNode === this.svg) {
|
|
42
|
-
const viewBox = coords.expand(view.getPadding());
|
|
43
|
-
this.svg.setAttributeNS(
|
|
44
|
-
null,
|
|
45
|
-
"viewBox",
|
|
46
|
-
[viewBox.x, viewBox.y, viewBox.width, viewBox.height].join(" ")
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const group = createNode("g");
|
|
51
|
-
const title = createNode("title");
|
|
52
|
-
title.textContent = view.name;
|
|
53
|
-
group.appendChild(title);
|
|
54
|
-
|
|
55
|
-
this._currentNode.appendChild(group);
|
|
56
|
-
this.nodeStack.push(group);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Must be called when a view's render() method is being exited
|
|
61
|
-
*
|
|
62
|
-
* @param {View} view
|
|
63
|
-
*/
|
|
64
|
-
popView(view) {
|
|
65
|
-
this.nodeStack.pop();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @param {import("../../marks/mark").default} mark
|
|
71
|
-
* @param {import("../view").RenderingOptions} options
|
|
72
|
-
*/
|
|
73
|
-
renderMark(mark, options) {
|
|
74
|
-
const current = this._currentNode;
|
|
75
|
-
|
|
76
|
-
const rect = createNode("rect", {
|
|
77
|
-
x: this.coords.x,
|
|
78
|
-
y: this.coords.y,
|
|
79
|
-
width: this.coords.width,
|
|
80
|
-
height: this.coords.height,
|
|
81
|
-
fill: "transparent",
|
|
82
|
-
stroke: "black",
|
|
83
|
-
"stroke-width": 1,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const name = createNode("text", {
|
|
87
|
-
x: this.coords.x + this.coords.width / 2,
|
|
88
|
-
y: this.coords.y + this.coords.height / 2,
|
|
89
|
-
"dominant-baseline": "middle",
|
|
90
|
-
"text-anchor": "middle",
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
name.textContent = mark.getType();
|
|
94
|
-
|
|
95
|
-
current.appendChild(rect);
|
|
96
|
-
current.appendChild(name);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
getSvg() {
|
|
100
|
-
return this.svg;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
get _currentNode() {
|
|
104
|
-
return peek(this.nodeStack);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Adapted from: https://stackoverflow.com/a/37411738/1547896
|
|
110
|
-
*
|
|
111
|
-
* @param {string} name
|
|
112
|
-
* @param {Record<string, any>} [attributes]
|
|
113
|
-
*/
|
|
114
|
-
function createNode(name, attributes) {
|
|
115
|
-
const element = document.createElementNS(
|
|
116
|
-
"http://www.w3.org/2000/svg",
|
|
117
|
-
name
|
|
118
|
-
);
|
|
119
|
-
if (attributes) {
|
|
120
|
-
for (const [k, v] of Object.entries(attributes)) {
|
|
121
|
-
element.setAttributeNS(null, k, v);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return element;
|
|
125
|
-
}
|