Verified Commit 2694484a authored by Pascal Engélibert's avatar Pascal Engélibert 🚴
Browse files

Layout settings UI

parent ca37f9ad
......@@ -919,18 +919,18 @@ checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
[[package]]
name = "bytemuck"
version = "1.8.0"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead"
checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc"
dependencies = [
"bytemuck_derive",
]
[[package]]
name = "bytemuck_derive"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54"
checksum = "562e382481975bc61d11275ac5e62a19abd00b0547d99516a415336f183dcd0e"
dependencies = [
"proc-macro2",
"quote",
......@@ -1376,9 +1376,9 @@ dependencies = [
[[package]]
name = "darling"
version = "0.13.1"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
dependencies = [
"darling_core",
"darling_macro",
......@@ -1386,9 +1386,9 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.13.1"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324"
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
dependencies = [
"fnv",
"ident_case",
......@@ -1400,9 +1400,9 @@ dependencies = [
[[package]]
name = "darling_macro"
version = "0.13.1"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
dependencies = [
"darling_core",
"quote",
......@@ -1555,9 +1555,9 @@ dependencies = [
[[package]]
name = "euclid"
version = "0.22.6"
version = "0.22.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da96828553a086d7b18dcebfc579bd9628b016f86590d7453c115e490fa74b80"
checksum = "b52c2ef4a78da0ba68fbe1fd920627411096d2ac478f7f4c9f3a54ba6705bade"
dependencies = [
"num-traits",
]
......@@ -1622,6 +1622,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "forceatlas2"
version = "0.4.0"
source = "git+https://framagit.org/ZettaScript/forceatlas2-rs.git#269c3e2d88eaf5443093363eee807ab3b00f00d0"
dependencies = [
"itertools",
"maths-traits",
......@@ -1988,9 +1989,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.8.0"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
dependencies = [
"autocfg",
"hashbrown 0.11.2",
......@@ -2188,9 +2189,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.121"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259"
[[package]]
name = "libloading"
......@@ -2220,10 +2221,11 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.4.6"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
dependencies = [
"autocfg",
"scopeguard",
]
......@@ -2774,7 +2776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58"
dependencies = [
"lock_api",
"parking_lot_core 0.9.1",
"parking_lot_core 0.9.2",
]
[[package]]
......@@ -2793,9 +2795,9 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.1"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954"
checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37"
dependencies = [
"cfg-if 1.0.0",
"libc",
......@@ -2878,9 +2880,9 @@ checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
[[package]]
name = "pkg-config"
version = "0.3.24"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "png"
......@@ -2927,9 +2929,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro2"
version = "1.0.36"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
dependencies = [
"unicode-xid",
]
......@@ -2987,9 +2989,9 @@ checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6"
[[package]]
name = "raw-window-handle"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fba75eee94a9d5273a68c9e1e105d9cffe1ef700532325788389e5a83e2522b7"
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
dependencies = [
"cty",
]
......@@ -3027,9 +3029,9 @@ checksum = "a0d463f2884048e7153449a55166f91028d5b0ea53c79377099ce4e8cf0cf9bb"
[[package]]
name = "redox_syscall"
version = "0.2.12"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0"
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
dependencies = [
"bitflags",
]
......@@ -3246,9 +3248,9 @@ dependencies = [
[[package]]
name = "simdutf8"
version = "0.1.3"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c970da16e7c682fa90a261cf0724dee241c9f7831635ecc4e988ae8f3b505559"
checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
[[package]]
name = "siphasher"
......@@ -3258,9 +3260,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]]
name = "slab"
version = "0.4.5"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "slotmap"
......@@ -3400,9 +3402,9 @@ checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2"
[[package]]
name = "syn"
version = "1.0.90"
version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
dependencies = [
"proc-macro2",
"quote",
......@@ -3541,9 +3543,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.23"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c"
checksum = "90442985ee2f57c9e1b548ee72ae842f4a9a20e3f417cc38dbc5dc684d9bb4ee"
dependencies = [
"lazy_static",
"valuable",
......@@ -3562,9 +3564,9 @@ dependencies = [
[[package]]
name = "tracing-subscriber"
version = "0.3.9"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e0ab7bdc962035a87fba73f3acca9b8a8d0034c2e6f60b84aeaaddddc155dce"
checksum = "b9df98b037d039d03400d9dd06b0f8ce05486b5f25e9a2d7d36196e142ebbc52"
dependencies = [
"ansi_term",
"lazy_static",
......@@ -3920,9 +3922,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.32.0"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6"
checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
......@@ -3933,33 +3935,33 @@ dependencies = [
[[package]]
name = "windows_aarch64_msvc"
version = "0.32.0"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5"
checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d"
[[package]]
name = "windows_i686_gnu"
version = "0.32.0"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615"
checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed"
[[package]]
name = "windows_i686_msvc"
version = "0.32.0"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172"
checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956"
[[package]]
name = "windows_x86_64_gnu"
version = "0.32.0"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc"
checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4"
[[package]]
name = "windows_x86_64_msvc"
version = "0.32.0"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316"
checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9"
[[package]]
name = "winit"
......
......@@ -15,8 +15,8 @@ bevy_polyline = "0.1.4"
chrono = "0.4.19"
dashmap = { version = "5.2.0", features = ["rayon"] }
dup-crypto = "0.58.0"
#forceatlas2 = { git = "https://framagit.org/ZettaScript/forceatlas2-rs.git", default_features = false, features = ["parallel"] }
forceatlas2 = { path = "../forceatlas2", default_features = false, features = ["parallel"] }
forceatlas2 = { git = "https://framagit.org/ZettaScript/forceatlas2-rs.git", default_features = false, features = ["parallel"] }
#forceatlas2 = { path = "../forceatlas2", default_features = false, features = ["parallel"] }
indicatif = "0.16.2"
num-traits = "0.2.14"
palette = "0.6.0"
......
......@@ -4,20 +4,6 @@
(temporary name)
## Development status
* [x] Apply/revert blocks
* [x] Update scene when state changes
* [x] Real time force layout
* [x] Node selection & centering
* [x] Read the actual blockchain
* [ ] Block info
* [ ] Identity info
* [ ] Filtering
* [x] Blockchain timeline
* [ ] Transactions
* [x] Coloring
## Run
```bash
......
......@@ -83,6 +83,11 @@ struct UiState {
cert_polyline_color: egui::color::Hsva,
idty_coloring_criterion: IdtyColoringCriterion,
idty_colors: [egui::color::Hsva; 2],
layout_enabled: bool,
layout_ka: f32,
layout_kg: f32,
layout_kr: f32,
layout_speed: f32,
selected_idty: Option<state::IdtyId>,
target_block_number: u32,
}
......@@ -104,6 +109,11 @@ impl Default for UiState {
v: 1.0,
a: 1.0,
}; 2],
layout_enabled: true,
layout_ka: 1.0,
layout_kg: 1.0,
layout_kr: 1.0,
layout_speed: 0.01,
selected_idty: None,
target_block_number: 0,
}
......@@ -572,38 +582,49 @@ impl<C: 'static + Debug + blockchain::Config, R: 'static + BcReader<C>> Gexplore
mut polylines: ResMut<Assets<Polyline>>,
mut query_idty: Query<(&state::IdtyId, &mut Transform)>,
query_cert: Query<&Handle<Polyline>>,
ui_state: Res<UiState>,
) {
layout_module.layout.iteration();
for (idty_id, mut idty_pos) in query_idty.iter_mut() {
let point = layout_module
.layout
.points
.get(*layout_module.idty_map.get(idty_id).unwrap());
idty_pos.translation[0] = point[0];
idty_pos.translation[1] = point[1];
idty_pos.translation[2] = point[2];
}
// TODO do this only on event
let mut layout_settings = layout_module.layout.get_settings().clone();
layout_settings.speed = ui_state.layout_speed;
layout_settings.ka = ui_state.layout_ka;
layout_settings.kg = ui_state.layout_kg;
layout_settings.kr = ui_state.layout_kr;
layout_module.layout.set_settings(layout_settings);
bc_reader.state().certs.iter().for_each(|o| {
let (cert_id, cert) = o.pair();
let cert_transform = polylines
.get_mut(
query_cert
.get(*entities.certs.get(cert_id).unwrap())
.unwrap(),
)
.unwrap();
cert_transform.vertices[0] = query_idty
.get(*entities.idties.get(&cert.issuer).unwrap())
.unwrap()
.1
.translation;
cert_transform.vertices[1] = query_idty
.get(*entities.idties.get(&cert.receiver).unwrap())
.unwrap()
.1
.translation;
});
if ui_state.layout_enabled {
layout_module.layout.iteration();
for (idty_id, mut idty_pos) in query_idty.iter_mut() {
let point = layout_module
.layout
.points
.get(*layout_module.idty_map.get(idty_id).unwrap());
idty_pos.translation[0] = point[0];
idty_pos.translation[1] = point[1];
idty_pos.translation[2] = point[2];
}
bc_reader.state().certs.iter().for_each(|o| {
let (cert_id, cert) = o.pair();
let cert_transform = polylines
.get_mut(
query_cert
.get(*entities.certs.get(cert_id).unwrap())
.unwrap(),
)
.unwrap();
cert_transform.vertices[0] = query_idty
.get(*entities.idties.get(&cert.issuer).unwrap())
.unwrap()
.1
.translation;
cert_transform.vertices[1] = query_idty
.get(*entities.idties.get(&cert.receiver).unwrap())
.unwrap()
.1
.translation;
});
}
}
fn ui(mut egui_context: ResMut<EguiContext>, mut ui_state: ResMut<UiState>, bc_reader: Res<R>) {
......@@ -631,6 +652,29 @@ impl<C: 'static + Debug + blockchain::Config, R: 'static + BcReader<C>> Gexplore
ui.label(format!("Identities: {}", bc_reader.state().idties.len()));
ui.label(format!("Certifications: {}", bc_reader.state().certs.len()));
});
egui::Window::new("Layout").show(egui_context.ctx_mut(), |ui| {
ui.checkbox(&mut ui_state.layout_enabled, "Enabled");
ui.add(
egui::Slider::new(&mut ui_state.layout_speed, 0.00001..=10.)
.logarithmic(true)
.text("speed"),
);
ui.add(
egui::Slider::new(&mut ui_state.layout_ka, 0.001..=100.)
.logarithmic(true)
.text("attraction"),
);
ui.add(
egui::Slider::new(&mut ui_state.layout_kr, 0.001..=100.)
.logarithmic(true)
.text("repulsion"),
);
ui.add(
egui::Slider::new(&mut ui_state.layout_kg, 0.001..=100.)
.logarithmic(true)
.text("gravity"),
);
});
egui::Window::new("Appearance").show(egui_context.ctx_mut(), |ui| {
egui::containers::ComboBox::from_label("Identity")
.selected_text(ui_state.idty_coloring_criterion.to_str())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment