[lab3] Vertex IDs in graph render
This commit is contained in:
parent
1cbbfade75
commit
642bb6619d
@ -8,7 +8,7 @@ use crate::algo::{
|
||||
};
|
||||
use bgtu_ai_utility::UpdatePending;
|
||||
use bgtu_ai_utility::gui::lengths_table::draw_lengths_table;
|
||||
use bgtu_ai_utility::gui::render::render_graph;
|
||||
use bgtu_ai_utility::gui::render_graph;
|
||||
use bgtu_ai_utility::gui::{boot_eframe, labeled_slider};
|
||||
use eframe::egui;
|
||||
use eframe::egui::{Frame, Ui};
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
mod boot;
|
||||
pub mod lengths_table;
|
||||
pub mod render;
|
||||
mod render_graph;
|
||||
mod slider;
|
||||
mod subwindow;
|
||||
|
||||
pub use boot::boot_eframe;
|
||||
pub use slider::{labeled_slider, slider};
|
||||
pub use subwindow::subwindow;
|
||||
pub use render_graph::render_graph;
|
||||
@ -1,5 +1,6 @@
|
||||
use crate::graph::{Edge, EdgesVec, VerticesVec};
|
||||
use eframe::egui::{Color32, Pos2, Rect, Ui};
|
||||
use eframe::egui;
|
||||
use eframe::egui::{Align2, Color32, FontDefinitions, Pos2, Rect, StrokeKind, Ui, Vec2};
|
||||
use eframe::epaint::{CornerRadius, Stroke};
|
||||
|
||||
pub fn render_graph<D>(
|
||||
@ -34,6 +35,34 @@ pub fn render_graph<D>(
|
||||
Stroke::new(1.0, intensity2color(normalized_intensity(e))),
|
||||
);
|
||||
}
|
||||
let font_id = &ui.style().text_styles[&egui::TextStyle::Body];
|
||||
|
||||
for (vi, _) in vertices.iter_indexed() {
|
||||
let center = vertex_locations[vi];
|
||||
let center = Pos2::new(
|
||||
center.0 * rect.width() + rect.min.x,
|
||||
center.1 * rect.height() + rect.min.y,
|
||||
);
|
||||
|
||||
let galley =
|
||||
canvas.layout_no_wrap(vi.to_string(), font_id.clone(), Color32::from_rgb(0, 0, 0));
|
||||
|
||||
canvas.rect(
|
||||
Rect::from_center_size(center, galley.size() + Vec2::new(6.0, 6.0)),
|
||||
CornerRadius::from(0),
|
||||
Color32::from_rgb(0, 0, 0),
|
||||
Stroke::new(1.0, Color32::from_rgb(255, 255, 255)),
|
||||
StrokeKind::Middle,
|
||||
);
|
||||
|
||||
canvas.text(
|
||||
center,
|
||||
Align2::CENTER_CENTER,
|
||||
vi,
|
||||
font_id.clone(),
|
||||
Color32::from_rgb(255, 255, 255),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn intensity2color(intensity: f64) -> Color32 {
|
||||
Loading…
Reference in New Issue
Block a user