Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve filter based on feedback #27

Merged
merged 25 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c4950e
remove unnecessary import
brauliorivas May 31, 2024
f381347
make filters more compact
brauliorivas May 31, 2024
7085a38
populate simulation status options based on file
brauliorivas May 31, 2024
4f6fd31
apply sort of dependecy inversion, so elements are taken passed dynam…
brauliorivas Jun 1, 2024
9c643f2
apply same technique for filters
brauliorivas Jun 1, 2024
e67e6eb
[FIX] when filtering particles, these are maintained even if boxes ar…
brauliorivas Jun 2, 2024
489bf69
[FIX] update test based on new filtering logic (new id's for links)
brauliorivas Jun 2, 2024
67bfb6d
create filter for generator status
brauliorivas Jun 3, 2024
5c6833a
add units to range parameters
brauliorivas Jun 3, 2024
1eed533
update filters for ranges to require an object
brauliorivas Jun 3, 2024
83580b7
trigger filter when enter key is pressed
brauliorivas Jun 4, 2024
d3be20b
remove exclamation mark
brauliorivas Jun 4, 2024
1ee4ca8
display gen status and sim status in a smaller space
brauliorivas Jun 4, 2024
0b27623
display each range input in one line
brauliorivas Jun 4, 2024
49f2bf8
fix small bug (change from innerHTML to appendChild
brauliorivas Jun 5, 2024
6ee00c6
set final filter box width on startup
brauliorivas Jun 5, 2024
e6bc547
use full name for checkboxes
brauliorivas Jun 5, 2024
c2c767a
sort checkboxes by value
brauliorivas Jun 5, 2024
a3af9ba
display gen and sim status in column
brauliorivas Jun 5, 2024
2769764
check simStatus as in EDM4hep + display names instead of number
brauliorivas Jun 5, 2024
66222e3
pass dynamically data for bitfield elements and exchange class betwee…
brauliorivas Jun 5, 2024
73624a3
removed unused imports
brauliorivas Jun 5, 2024
82904c8
change names + display dictionary
brauliorivas Jun 6, 2024
ec594c5
bolder title + rearrange checkboxes
brauliorivas Jun 7, 2024
75428b1
rearrange only sim status
brauliorivas Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion css/filter.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#filter {
width: 16%;
min-width: 100px;
position: fixed;
flex-direction: column;
background-color: #f5f5f5;
Expand Down Expand Up @@ -33,4 +33,5 @@
#filters {
display: flex;
flex-direction: column;
padding: 10px 0;
}
9 changes: 9 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ body {
.manipulation-tool {
display: none;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type="number"] {
-moz-appearance: textfield;
}
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<div id="input-modal" class="modal-background">
<div class="modal-content">

<p>¡Welcome to <span id="logo">
<p>Welcome to <span id="logo">
<span id="logo-d">d</span><span id="logo-m">m</span><span id="logo-x">X</span>
</span>!</p>
</span></p>

<div id="input-message">
</div>
Expand Down
35 changes: 34 additions & 1 deletion js/draw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export function drawAll(ctx, parentLinks, childrenLinks, infoBoxes) {
import { canvas, ctx } from "./main.js";

export function drawAll(ctx, currentParticles) {
const { parentLinks, childrenLinks, infoBoxes } = currentParticles;

ctx.clearRect(0, 0, canvas.width, canvas.height);
// console.time("drawParentLinks");
for (const link of parentLinks) {
Expand All @@ -16,3 +20,32 @@ export function drawAll(ctx, parentLinks, childrenLinks, infoBoxes) {
}
// console.timeEnd("drawBoxes");
}

export function drawVisible(currentParticles, visibleParticles) {
const {
infoBoxes: visibleBoxes,
parentLinks: visibleParentLinks,
childrenLinks: visibleChildrenLinks,
} = visibleParticles;

const { parentLinks, childrenLinks, infoBoxes } = currentParticles;

const boundigClientRect = canvas.getBoundingClientRect();
ctx.clearRect(
0 - boundigClientRect.x,
0 - boundigClientRect.y,
window.innerWidth,
window.innerHeight
);
for (const linkId of visibleParentLinks) {
if (parentLinks[linkId] !== undefined)
parentLinks[linkId].draw(ctx, infoBoxes);
}
for (const linkId of visibleChildrenLinks) {
if (childrenLinks[linkId] !== undefined)
childrenLinks[linkId].draw(ctx, infoBoxes);
}
for (const boxId of visibleBoxes) {
infoBoxes[boxId].draw(ctx);
}
}
147 changes: 147 additions & 0 deletions js/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { canvas, ctx } from "./main.js";
import { drawAll, drawVisible } from "./draw.js";

const mouseDown = function (
event,
currentParticles,
visibleParticles,
dragTools
) {
event.preventDefault();
const boundigClientRect = canvas.getBoundingClientRect();
const mouseX = parseInt(event.clientX - boundigClientRect.x);
const mouseY = parseInt(event.clientY - boundigClientRect.y);

dragTools.prevMouseX = mouseX;
dragTools.prevMouseY = mouseY;

const infoBoxes = currentParticles.infoBoxes;
const visibleBoxes = visibleParticles.infoBoxes;
for (let i = visibleBoxes.length - 1; i >= 0; i--) {
if (infoBoxes[visibleBoxes[i]].isHere(mouseX, mouseY)) {
dragTools.draggedInfoBox = visibleBoxes[i];
dragTools.isDragging = true;
return;
}
}
};

const mouseUp = function (event, particlesHandler, dragTools) {
if (!dragTools.isDragging) {
return;
}

event.preventDefault();
dragTools.isDragging = false;

// console.time("drawAll");
drawAll(ctx, particlesHandler);
// console.timeEnd("drawAll");
};

const mouseOut = function (event, dragTools) {
if (!dragTools.isDragging) {
return;
}

event.preventDefault();
dragTools.isDragging = false;
};

const mouseMove = function (
event,
currentParticles,
visibleParticles,
dragTools
) {
if (!dragTools.isDragging) {
return;
}
event.preventDefault();

const boundigClientRect = canvas.getBoundingClientRect();
const mouseX = parseInt(event.clientX - boundigClientRect.x);
const mouseY = parseInt(event.clientY - boundigClientRect.y);

const dx = mouseX - dragTools.prevMouseX;
const dy = mouseY - dragTools.prevMouseY;

const infoBox = currentParticles.infoBoxes[dragTools.draggedInfoBox];
infoBox.x += dx;
infoBox.y += dy;

// console.time("drawVisible");
drawVisible(currentParticles, visibleParticles);
// console.timeEnd("drawVisible");

dragTools.prevMouseX = mouseX;
dragTools.prevMouseY = mouseY;
};

const getVisible = function (currentParticles, visibleParticles) {
const boundigClientRect = canvas.getBoundingClientRect();

const { infoBoxes, parentLinks, childrenLinks } = currentParticles;

const visibleBoxes = [];
const visibleParentLinks = [];
const visibleChildrenLinks = [];

for (const box of infoBoxes) {
if (box === null) continue;
if (
box.isVisible(
0 - boundigClientRect.x,
0 - boundigClientRect.y,
window.innerWidth,
window.innerHeight
)
) {
visibleBoxes.push(box.id);
}
}

for (const link of parentLinks) {
if (
link.isVisible(
0 - boundigClientRect.x,
0 - boundigClientRect.y,
window.innerWidth,
window.innerHeight,
infoBoxes
)
) {
visibleParentLinks.push(link.id);
}
}

for (const link of childrenLinks) {
if (
link.isVisible(
0 - boundigClientRect.x,
0 - boundigClientRect.y,
window.innerWidth,
window.innerHeight,
infoBoxes
)
) {
visibleChildrenLinks.push(link.id);
}
}

/*
console.log("Visible boxes: ", visibleBoxes);
console.log("Visible parentLinks: ", visibleParentLinks);
console.log("Visible childrenLinks: ", visibleChildrenLinks);
*/

visibleParticles.infoBoxes = visibleBoxes;
visibleParticles.parentLinks = visibleParentLinks;
visibleParticles.childrenLinks = visibleChildrenLinks;
};

const onScroll = function (currentParticles, visibleParticles) {
getVisible(currentParticles, visibleParticles);
};

export { mouseDown, mouseUp, mouseOut, mouseMove, getVisible, onScroll };
Loading
Loading