Skip to content

Commit cb5a420

Browse files
authored
Merge pull request #10 from martinRenou/remove_figure
Remove FigureGL
2 parents f63e2aa + 51eec57 commit cb5a420

13 files changed

Lines changed: 200 additions & 285 deletions

File tree

bqplot_gl/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Copyright (c) The bqplot Development Team.
55
# Distributed under the terms of the Modified BSD License.
66

7-
from .figure import FigureGL # noqa
87
from .marks import * # noqa
98
from ._version import __version__, version_info # noqa
109

bqplot_gl/figure.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/lines.ipynb

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,14 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "faf6701a",
77
"metadata": {},
8-
"outputs": [
9-
{
10-
"data": {
11-
"application/vnd.jupyter.widget-view+json": {
12-
"model_id": "c4ee4d8bc9a04a279a55494a782a76cd",
13-
"version_major": 2,
14-
"version_minor": 0
15-
},
16-
"text/plain": [
17-
"FigureGL(axes=[Axis(label='Index', scale=LinearScale()), Axis(label='lines', orientation='vertical', scale=Lin…"
18-
]
19-
},
20-
"metadata": {},
21-
"output_type": "display_data"
22-
}
23-
],
8+
"outputs": [],
249
"source": [
2510
"from bqplot import *\n",
2611
"\n",
27-
"from bqplot_gl import FigureGL, ScatterGL, LinesGL\n",
12+
"from bqplot_gl import ScatterGL, LinesGL\n",
2813
"\n",
2914
"import numpy as np\n",
3015
"import pandas as pd\n",
@@ -47,12 +32,12 @@
4732
"ax_x = Axis(scale=sc_x, label='Index')\n",
4833
"ax_y = Axis(scale=sc_y, orientation='vertical', label='lines')\n",
4934
"\n",
50-
"FigureGL(marks=[lines], axes=[ax_x, ax_y], title='Lines', interaction=panzoom)"
35+
"Figure(marks=[lines], axes=[ax_x, ax_y], title='Lines', interaction=panzoom)"
5136
]
5237
},
5338
{
5439
"cell_type": "code",
55-
"execution_count": 2,
40+
"execution_count": null,
5641
"id": "bd78813d",
5742
"metadata": {},
5843
"outputs": [],
@@ -62,7 +47,7 @@
6247
},
6348
{
6449
"cell_type": "code",
65-
"execution_count": 3,
50+
"execution_count": null,
6651
"id": "52a1f6dc",
6752
"metadata": {},
6853
"outputs": [],
@@ -91,7 +76,7 @@
9176
],
9277
"metadata": {
9378
"kernelspec": {
94-
"display_name": "Python 3 (ipykernel)",
79+
"display_name": "Python 3",
9580
"language": "python",
9681
"name": "python3"
9782
},
@@ -105,7 +90,7 @@
10590
"name": "python",
10691
"nbconvert_exporter": "python",
10792
"pygments_lexer": "ipython3",
108-
"version": "3.9.6"
93+
"version": "3.9.5"
10994
}
11095
},
11196
"nbformat": 4,

examples/scatter.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"source": [
1010
"from bqplot import *\n",
1111
"\n",
12-
"from bqplot_gl import FigureGL, ScatterGL\n",
12+
"from bqplot_gl import ScatterGL\n",
1313
"\n",
1414
"import numpy as np\n",
1515
"import pandas as pd\n",
@@ -44,7 +44,7 @@
4444
"ax_x = Axis(scale=sc_x, label='Date')\n",
4545
"ax_y = Axis(scale=sc_y, orientation='vertical', tick_format='0.0f', label='Security 2')\n",
4646
"\n",
47-
"fig = FigureGL(marks=[scatt], axes=[ax_x, ax_y])\n",
47+
"fig = Figure(marks=[scatt], axes=[ax_x, ax_y])\n",
4848
"fig"
4949
]
5050
},

src/LinesGLView.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ import 'three/examples/js/lines/LineMaterial';
1313
import 'three/examples/js/lines/LineSegmentsGeometry';
1414
import 'three/examples/js/lines/LineGeometry';
1515

16-
import { ScaleType, FigureGLView } from './figure';
17-
1816
import { LinesGLModel } from './LinesGLModel';
1917

2018
import { Values } from './values';
2119

20+
import { ScaleType, initializeBqplotFigure } from './utils';
21+
2222
export class LinesGLView extends Lines {
2323
async render() {
2424
await super.render();
2525

26+
initializeBqplotFigure(this.parent);
27+
2628
// Create material for markers
2729
this.material = new THREE.LineMaterial();
2830
this.material.uniforms.domain_x = { type: '2f', value: [0, 1] };
@@ -56,10 +58,8 @@ export class LinesGLView extends Lines {
5658
this.listenTo(this.model, 'change:x change:y', this.updateGeometry);
5759
this.listenTo(this.model, 'change:stroke_width', this.update_stroke_width);
5860

59-
this.updateScene();
60-
this.listenTo(this.parent, 'margin_updated', () => {
61-
this.updateScene();
62-
});
61+
this.parent.extras.webGLMarks.push(this);
62+
this.parent.extras.webGLRequestRender();
6363
}
6464

6565
beforeCompile(shader) {
@@ -124,11 +124,11 @@ export class LinesGLView extends Lines {
124124
);
125125
this.geometry.setPositions(current.array_vec3['position']);
126126

127-
this.updateScene();
127+
this.parent.extras.webGLRequestRender();
128128
}
129129

130130
update_line_xy(animate: boolean) {
131-
this.updateScene();
131+
this.parent.extras.webGLRequestRender();
132132
}
133133

134134
update_style() {
@@ -140,12 +140,12 @@ export class LinesGLView extends Lines {
140140
} else {
141141
this.material.uniforms.opacity.value = 1;
142142
}
143-
this.updateScene();
143+
this.parent.extras.webGLRequestRender();
144144
}
145145

146146
update_stroke_width() {
147147
this.material.linewidth = this.model.get('stroke_width');
148-
this.updateScene();
148+
this.parent.extras.webGLRequestRender();
149149
}
150150

151151
updateMaterialScales() {
@@ -182,15 +182,8 @@ export class LinesGLView extends Lines {
182182
];
183183
this.updateMaterialScales();
184184

185-
fig.renderer.render(this.scene, fig.camera);
186-
}
187-
188-
updateScene() {
189-
this.parent.update_gl();
190-
}
191-
192-
relayout() {
193-
this.updateScene();
185+
const { renderer, camera } = fig.extras.webGLRenderer;
186+
renderer.render(this.scene, camera);
194187
}
195188

196189
draw(animate) {}
@@ -202,6 +195,4 @@ export class LinesGLView extends Lines {
202195
scene: THREE.Scene;
203196

204197
model: LinesGLModel;
205-
206-
parent: FigureGLView;
207198
}

0 commit comments

Comments
 (0)