Skip to content

Commit

Permalink
Merge pull request #393 from Dessia-tech/dev
Browse files Browse the repository at this point in the history
Dev to master
  • Loading branch information
GhislainJ authored Jul 15, 2024
2 parents ce39aa4 + 6354738 commit 2625efb
Show file tree
Hide file tree
Showing 30 changed files with 15,072 additions and 5,985 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.26.0]
### Add
- RemoteFigure.setFeatureFilter to directly edit rubberbands' value from external requests
- Multiplot.setFeatureFilter to directly edit rubberbands' value from external requests
- Emit rubberband changes

### Fix
- Labels:
- fix wide text
- remove shape hovering
- RubberBand: fix rubberband deletion when putting it outside view point
- Fixing tests on dev

## [0.25.1]
### Doc
- Changing doc link in readme
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/multiplot.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PointSet } from "../../instrumented/collections";
import { Scatter, Graph2D, Draw, ParallelPlot } from "../../instrumented/figures";
import { Multiplot } from "../../instrumented/multiplot";
import multiplotData from '../data_src/multiplot.data.json';
import { filterUpdate } from "../../instrumented/interactions";

const MOUSE_OFFSET = new Vertex(8, 8); // TODO: I f****** don't understand why this add (8, 8) is required for mouse to be as specified
const canvasID = "canvas";
Expand Down Expand Up @@ -150,6 +151,7 @@ describe("Multiplot.mouseListener", function() {
});

it("should draw a SelectionBox on .figures[1] and rubberBand on other rubberBanded axes", function () {
cy.spy(filterUpdate, 'next');
window.dispatchEvent(shiftKeyDown);
canvas.dispatchEvent(mouseMove2);
canvas.dispatchEvent(mouseDown2);
Expand All @@ -165,6 +167,8 @@ describe("Multiplot.mouseListener", function() {
expect(multiplot.rubberBands.get(scatter2.axes[0].name).length, "multiplot rubberBand[0] updated").to.be.closeTo(25.4, 0.1);
expect(multiplot.rubberBands.get(scatter2.axes[1].name).length, "multiplot rubberBand[1] updated").to.be.closeTo(1.02, 0.01);

expect(filterUpdate.next).to.have.been.calledWith({id: multiplot.canvasID, rubberbands: multiplot.rubberBands});

const rubberBandName0 = scatter2.axes[0].name;
const rubberBandName1 = scatter2.axes[1].name;
multiplot.figures.forEach(figure => {
Expand Down Expand Up @@ -322,4 +326,9 @@ describe("Multiplot.diverse", function() {
expect(figure.isZooming, `figure[${i}].isZooming`).to.be.false;
});
});

it('should write values in axes[0].rubberBand', function() {
multiplot.setFeatureFilter("x", -1, 25);
expect(multiplot.selectedIndices.length, "multiplot.selectedIndices.length").to.be.equal(61);
});
});
53 changes: 34 additions & 19 deletions cypress/e2e/remoteFigure.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ describe("RemoteFigure.changeAxisFeature", function() {
});
});

describe("RemoteFigure.setFeatureFilters", function() {
it('should write values in axes[0].rubberBand', function() {
const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id);
figure.setCanvas(canvas.id);
figure.axes[0] = new Axis(figure.features.get("x"), new Rect(new Vertex(), new Vertex(100, 100)), new Vertex(), new Vertex(100, 0), "x", new Vertex());
figure.setFeatureFilter("x", -1, 1.1);
expect(figure.selectedIndices.length, "figure.selectedIndices.length").to.be.equal(2);
});
});


describe("RemoteFigure.resizeUpdate", function() {
it("should resize figure", function() {
const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id);
Expand All @@ -147,16 +158,6 @@ describe("RemoteFigure.resizeUpdate", function() {
});
});

describe("RemoteFigure.resizeWindow", function() {
it("should resize figure with new window size", function() {
const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id);
figure.setCanvas(canvas.id);
figure.resizeWindow(700, 500);
expect(figure.size.x, "size.x").to.be.equal(700);
expect(figure.size.y, "size.y").to.be.equal(500);
});
});

describe("RemoteFigure.reset", function() {
it("should reset scales and selectors", function() {
const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id);
Expand Down Expand Up @@ -214,6 +215,7 @@ describe("RemoteFigure.mouseListener", function() {
const mouseDown = new MouseEvent('mousedown', { clientX: 150, clientY: 150 });
const mouseMove1 = new MouseEvent('mousemove', { clientX: 150, clientY: 150 });
const mouseMove2 = new MouseEvent('mousemove', { clientX: 370, clientY: 520 });
const mouseMove3 = new MouseEvent('mousemove', { clientX: 20000, clientY: 0 });
const mouseWheel = new WheelEvent('wheel', { clientX: 150, clientY: 150, deltaY: ZOOM_FACTOR });
const mouseLeave = new MouseEvent('mouseleave', {});

Expand Down Expand Up @@ -262,6 +264,19 @@ describe("RemoteFigure.mouseListener", function() {
expect(canvas.style.cursor, "default cursor").to.be.equal("default");
});

it("should preserve rubberBand min and max values", function () {
figure.axes[0].rubberBand.minValue = 0;
figure.axes[0].rubberBand.maxValue = 200;
figure.draw();
expect(figure.axes[0].rubberBand.canvasLength, "rubberBand.canvasLength").to.be.closeTo(764, 1.);
canvas.dispatchEvent(mouseMove1);
canvas.dispatchEvent(mouseDown);
canvas.dispatchEvent(mouseMove3);
canvas.dispatchEvent(mouseUp);
expect(figure.axes[0].rubberBand.canvasLength, "rubberBand.canvasLength").to.be.equal(0);
figure.reset();
});

it("should translate figure", function() {
canvas.dispatchEvent(mouseMove1);
canvas.dispatchEvent(mouseDown);
Expand All @@ -273,7 +288,7 @@ describe("RemoteFigure.mouseListener", function() {

expect(figure.translation, "translation").to.deep.equal(new Vertex());
});

it("should handle wheel events", function() {
const minValue0 = figure.axes[0].minValue;
const maxValue0 = figure.axes[0].maxValue;
Expand All @@ -295,16 +310,16 @@ describe("RemoteFigure.mouseListener", function() {
const maxValue1 = figure.axes[1].maxValue;

figure.zoomIn();
expect(figure.axes[0].minValue, "minValue0").to.not.be.equal(minValue0);
expect(figure.axes[0].maxValue, "maxValue0").to.not.be.equal(maxValue0);
expect(figure.axes[1].minValue, "minValue0").to.not.be.equal(minValue1);
expect(figure.axes[1].maxValue, "maxValue1").to.not.be.equal(maxValue1);
expect(figure.axes[0].minValue, "minValue0").to.not.be.closeTo(minValue0, 0.001);
expect(figure.axes[0].maxValue, "maxValue0").to.not.be.closeTo(maxValue0, 0.001);
expect(figure.axes[1].minValue, "minValue0").to.not.be.closeTo(minValue1, 0.001);
expect(figure.axes[1].maxValue, "maxValue1").to.not.be.closeTo(maxValue1, 0.001);

figure.zoomOut();
expect(figure.axes[0].minValue, "minValue0").to.be.equal(minValue0);
expect(figure.axes[0].maxValue, "maxValue0").to.be.equal(maxValue0);
expect(figure.axes[1].minValue, "minValue0").to.be.equal(minValue1);
expect(figure.axes[1].maxValue, "maxValue1").to.be.equal(maxValue1);
expect(figure.axes[0].minValue, "minValue0").to.be.closeTo(minValue0, 0.001);
expect(figure.axes[0].maxValue, "maxValue0").to.be.closeTo(maxValue0, 0.001);
expect(figure.axes[1].minValue, "minValue0").to.be.closeTo(minValue1, 0.001);
expect(figure.axes[1].maxValue, "maxValue1").to.be.closeTo(maxValue1, 0.001);
});

it("should reset state correctly on mouseleave", function() {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/visualRegressions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ FIGURES_DATA.forEach(figureData => {
it("should hover line even if mouse is not exactly on line", function () {
cy.window().then((win) => {
const draw = win.eval('plot_data');
let [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 809, "offsetY": 196} as MouseEvent);
let [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 807, "offsetY": 196} as MouseEvent);
draw.castMouseMove(canvasMouse, frameMouse, mouseCoords);
expect(draw.relativeObjects.shapes[23].isHovered).to.be.true;

[canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 816, "offsetY": 196} as MouseEvent);
[canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 810, "offsetY": 196} as MouseEvent);
draw.castMouseMove(canvasMouse, frameMouse, mouseCoords);
expect(draw.relativeObjects.shapes[23].isHovered).to.be.true;
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2625efb

Please sign in to comment.