Skip to content

Commit

Permalink
Deploy preview for PR 70 🛫
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Aug 3, 2024
1 parent 77fda02 commit 758f97f
Show file tree
Hide file tree
Showing 16 changed files with 313 additions and 126 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion pr-preview/pr-70/css/filter.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#filters {
display: none;
position: fixed;
top: 10px;
right: 10px;
z-index: 1;
width: 25%;
width: 300px;
max-height: 50%;
overflow-y: auto;
padding: 10px;
Expand Down
214 changes: 154 additions & 60 deletions pr-preview/pr-70/js/draw/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,18 @@ function bezierCurve({
return curve;
}

export function drawBezierLink(link) {
export function drawBezierLink(link, reverse = false) {
const app = getApp();
const container = getContainer();

const [fromX, fromY] = fromPoints(link.from);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.from,
link.to
);

let curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
cpFromY: cpFromY,
cpToX: cpToX + link.xShift,
cpToY: cpToY,
toX: toX + link.xShift,
toY: toY,
color: link.color,
});

link.renderedLink = curve;

const boxFrom = link.from.renderedBox;
const boxTo = link.to.renderedBox;

const boxFromOnMove = () => {
container.removeChild(curve);
if (!reverse) {
const [fromX, fromY] = fromPoints(link.from);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.from,
link.to
);
curve = bezierCurve({

let curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
Expand All @@ -94,29 +71,87 @@ export function drawBezierLink(link) {
toY: toY,
color: link.color,
});

link.renderedLink = curve;
link.renderedLink.renderable = link.isVisible();

const boxFrom = link.from.renderedBox;
const boxTo = link.to.renderedBox;

const boxFromOnMove = () => {
container.removeChild(curve);
const [fromX, fromY] = fromPoints(link.from);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.from,
link.to
);
curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
cpFromY: cpFromY,
cpToX: cpToX + link.xShift,
cpToY: cpToY,
toX: toX + link.xShift,
toY: toY,
color: link.color,
});
link.renderedLink = curve;
link.renderedLink.renderable = link.isVisible();
container.addChild(curve);
};

boxFrom.on("pointerdown", () => {
app.stage.on("pointermove", boxFromOnMove);
});
app.stage.on("pointerup", () => {
app.stage.off("pointermove", boxFromOnMove);
});
app.stage.on("pointerupoutside", () => {
app.stage.off("pointermove", boxFromOnMove);
});

const boxToOnMove = () => {
container.removeChild(curve);
const [fromX, fromY] = fromPoints(link.from);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.from,
link.to
);
curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
cpFromY: cpFromY,
cpToX: cpToX + link.xShift,
cpToY: cpToY,
toX: toX + link.xShift,
toY: toY,
color: link.color,
});
link.renderedLink = curve;
link.renderedLink.renderable = link.isVisible();
container.addChild(curve);
};

boxTo.on("pointerdown", () => {
app.stage.on("pointermove", boxToOnMove);
});
app.stage.on("pointerup", () => {
app.stage.off("pointermove", boxToOnMove);
});
app.stage.on("pointerupoutside", () => {
app.stage.off("pointermove", boxToOnMove);
});

container.addChild(curve);
};

boxFrom.on("pointerdown", () => {
app.stage.on("pointermove", boxFromOnMove);
});
app.stage.on("pointerup", () => {
app.stage.off("pointermove", boxFromOnMove);
});
app.stage.on("pointerupoutside", () => {
app.stage.off("pointermove", boxFromOnMove);
});

const boxToOnMove = () => {
container.removeChild(curve);
const [fromX, fromY] = fromPoints(link.from);
} else {
const [fromX, fromY] = fromPoints(link.to);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.from,
link.to
link.to,
link.from
);
curve = bezierCurve({

let curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
Expand All @@ -127,20 +162,79 @@ export function drawBezierLink(link) {
toY: toY,
color: link.color,
});

link.renderedLink = curve;
link.renderedLink.renderable = link.isVisible();

const boxFrom = link.to.renderedBox;
const boxTo = link.from.renderedBox;

const boxFromOnMove = () => {
container.removeChild(curve);
const [fromX, fromY] = fromPoints(link.to);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.to,
link.from
);
curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
cpFromY: cpFromY,
cpToX: cpToX + link.xShift,
cpToY: cpToY,
toX: toX + link.xShift,
toY: toY,
color: link.color,
});
link.renderedLink = curve;
link.renderedLink.renderable = link.isVisible();
container.addChild(curve);
};

boxFrom.on("pointerdown", () => {
app.stage.on("pointermove", boxFromOnMove);
});
app.stage.on("pointerup", () => {
app.stage.off("pointermove", boxFromOnMove);
});
app.stage.on("pointerupoutside", () => {
app.stage.off("pointermove", boxFromOnMove);
});

const boxToOnMove = () => {
container.removeChild(curve);
const [fromX, fromY] = fromPoints(link.to);
const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints(
link.to,
link.from
);
curve = bezierCurve({
fromX: fromX + link.xShift,
fromY: fromY,
cpFromX: cpFromX + link.xShift,
cpFromY: cpFromY,
cpToX: cpToX + link.xShift,
cpToY: cpToY,
toX: toX + link.xShift,
toY: toY,
color: link.color,
});
link.renderedLink = curve;
link.renderedLink.renderable = link.isVisible();
container.addChild(curve);
};

boxTo.on("pointerdown", () => {
app.stage.on("pointermove", boxToOnMove);
});

app.stage.on("pointerup", () => {
app.stage.off("pointermove", boxToOnMove);
});
app.stage.on("pointerupoutside", () => {
app.stage.off("pointermove", boxToOnMove);
});

container.addChild(curve);
};

boxTo.on("pointerdown", () => {
app.stage.on("pointermove", boxToOnMove);
});
app.stage.on("pointerup", () => {
app.stage.off("pointermove", boxToOnMove);
});
app.stage.on("pointerupoutside", () => {
app.stage.off("pointermove", boxToOnMove);
});

container.addChild(curve);
}
}
4 changes: 2 additions & 2 deletions pr-preview/pr-70/js/event-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { loadObjects } from "./types/load.js";
import { copyObject } from "./lib/copy.js";
import { jsonData, selectedObjectTypes } from "./main.js";
import { objectTypes } from "./types/objects.js";
import { drawCurrentView, saveScrollLocation } from "./views/views.js";
import { drawView, getView, saveScrollLocation } from "./views/views.js";

const eventNumber = document.getElementById("selected-event");
const previousEvent = document.getElementById("previous-event");
Expand Down Expand Up @@ -49,7 +49,7 @@ export function renderEvent(eventNumber) {
currentEvent.event = eventNumber;
loadSelectedEvent();
updateEventNumber();
drawCurrentView();
drawView(getView());
}

previousEvent.addEventListener("click", () => {
Expand Down
18 changes: 6 additions & 12 deletions pr-preview/pr-70/js/filters/collections/mcparticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function renderMCParticleFilters() {
Object.keys(SimStatusBitFieldDisplayValues).forEach((status) => {
const checkbox = new CheckboxComponent(
"simulatorStatus",
status,
SimStatusBitFieldDisplayValues[status]
);
checkboxes.simStatus.push(checkbox);
Expand All @@ -50,7 +51,7 @@ function renderMCParticleFilters() {
container.appendChild(generatorStatusTitle);

[1, 2, 3, 4].map((status) => {
const checkbox = new CheckboxComponent("generatorStatus", status);
const checkbox = new CheckboxComponent("generatorStatus", status, status);
checkboxes.generatorStatus.push(checkbox);
container.appendChild(checkbox.render());
});
Expand Down Expand Up @@ -81,22 +82,15 @@ export function initMCParticleFilters(parentContainer) {
const { simStatus, generatorStatus } = checkboxes;

for (const checkbox of simStatus) {
const checked = checkbox.checked();
if (
!bitfieldCheckboxLogic(
checked,
SimStatusBitFieldDisplayValues[checkbox.displayedName],
object,
"simulatorStatus"
)
) {
const { checked, value } = checkbox.getValues();
if (!bitfieldCheckboxLogic(checked, value, object, "simulatorStatus")) {
return false;
}
}

for (const checkbox of generatorStatus) {
const checked = checkbox.checked();
if (!checkboxLogic(checked, object, "generatorStatus")) {
const { checked, value } = checkbox.getValues();
if (!checkboxLogic(checked, value, object, "generatorStatus")) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pr-preview/pr-70/js/filters/collections/vertex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RangeComponent, rangeLogic } from "../components/range.js";
import { magnitudeRangeLogic, RangeComponent } from "../components/range.js";

function renderVertexFilters() {
const container = document.createElement("div");
Expand Down
14 changes: 9 additions & 5 deletions pr-preview/pr-70/js/filters/components/checkbox.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export class CheckboxComponent {
constructor(propertyName, displayedName) {
constructor(propertyName, displayedName, value) {
this.propertyName = propertyName;
this.displayedName = displayedName;
this.value = value;
}

render() {
Expand All @@ -19,14 +20,17 @@ export class CheckboxComponent {
return div;
}

checked() {
return this.checkbox.checked;
getValues() {
return {
checked: this.checkbox.checked,
value: this.value,
};
}
}

export function checkboxLogic(checked, object, property) {
export function checkboxLogic(checked, value, object, property) {
if (checked) {
return object[property] === checked;
return object[property] === value;
}
return true;
}
Expand Down
11 changes: 6 additions & 5 deletions pr-preview/pr-70/js/filters/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { initMCParticleFilters } from "./collections/mcparticle.js";
import { initRecoParticleFilters } from "./collections/recoparticle.js";
import { initTrackFilters } from "./collections/track.js";
import { initVertexFilters } from "./collections/vertex.js";
import { reconnect } from "./reconnect.js";
import { reconnect, restoreObjectsLinks } from "./reconnect.js";

const map = {
"edm4hep::MCParticle": initMCParticleFilters,
Expand Down Expand Up @@ -42,7 +42,7 @@ export function initFilters(
) {
const criteriaFunctions = {};

const setupContent = () => {
const resetFiltersContent = () => {
const content = document.getElementById("filters-content");
content.replaceChildren();

Expand All @@ -63,16 +63,17 @@ export function initFilters(
}
};

setupContent();
resetFiltersContent();

filters.apply = async () => {
reconnect({ viewObjects, viewCurrentObjects }, criteriaFunctions);
reconnect(viewObjects, viewCurrentObjects, criteriaFunctions);
await render(viewCurrentObjects);
filterScroll();
setRenderable(viewCurrentObjects);
};
filters.reset = async () => {
setupContent();
resetFiltersContent();
restoreObjectsLinks(viewCurrentObjects);
copyObject(viewObjects, viewCurrentObjects);
await render(viewCurrentObjects);
originalScroll();
Expand Down
Loading

0 comments on commit 758f97f

Please sign in to comment.