main
Antonio De Lucreziis 2 months ago
parent 69b35e6a38
commit 6209477a3f

@ -1,6 +1,6 @@
use std::time::Instant; use std::time::Instant;
use macroquad::{prelude::*, rand, ui::root_ui}; use macroquad::{prelude::*, ui::root_ui};
#[macroquad::main("by-hand")] #[macroquad::main("by-hand")]
async fn main() { async fn main() {

@ -533,8 +533,8 @@ fn generate() -> (
) { ) {
let mut g: StableGraph<(String, Orientation), ()> = StableGraph::new(); let mut g: StableGraph<(String, Orientation), ()> = StableGraph::new();
let file = std::fs::File::open(env::args().nth(1).expect("missing gfa file argument")).unwrap(); let entries =
let entries = parser::parse_source(file).unwrap(); parser::parse_file(env::args().nth(1).expect("missing gfa file argument")).unwrap();
let mut index_map = HashMap::new(); let mut index_map = HashMap::new();

@ -26,14 +26,14 @@ pub struct SettingsInteraction {
pub struct SettingsNavigation { pub struct SettingsNavigation {
pub fit_to_screen_enabled: bool, pub fit_to_screen_enabled: bool,
pub zoom_and_pan_enabled: bool, pub zoom_and_pan_enabled: bool,
pub screen_padding: f32, // pub screen_padding: f32,
pub zoom_speed: f32, pub zoom_speed: f32,
} }
impl Default for SettingsNavigation { impl Default for SettingsNavigation {
fn default() -> Self { fn default() -> Self {
Self { Self {
screen_padding: 0.3, // screen_padding: 0.3,
zoom_speed: 0.1, zoom_speed: 0.1,
fit_to_screen_enabled: true, fit_to_screen_enabled: true,
zoom_and_pan_enabled: false, zoom_and_pan_enabled: false,

@ -46,8 +46,7 @@ impl App for InteractiveApp {
fn generate_graph() -> Graph<(String, Orientation), ()> { fn generate_graph() -> Graph<(String, Orientation), ()> {
let mut g: StableGraph<(String, Orientation), ()> = StableGraph::new(); let mut g: StableGraph<(String, Orientation), ()> = StableGraph::new();
let file = std::fs::File::open("../../dataset/example.gfa").unwrap(); let entries = parser::parse_file("../../dataset/example.gfa").unwrap();
let entries = parser::parse_source(file).unwrap();
let mut index_map = HashMap::new(); let mut index_map = HashMap::new();

@ -21,8 +21,9 @@ use macroquad::prelude::*;
async fn main() { async fn main() {
let mut graph = Graph::<(String, Orientation), ()>::new(); let mut graph = Graph::<(String, Orientation), ()>::new();
let file = std::fs::File::open(env::args().nth(1).expect("missing gfa file argument")).unwrap(); let filename = env::args().nth(1).expect("missing gfa file argument");
let entries = parser::parse_source(file).unwrap();
let entries = parser::parse_file(filename).expect("failed to parse file");
let mut index_map = HashMap::new(); let mut index_map = HashMap::new();

@ -137,15 +137,7 @@ fn load_graph() -> StableGraph<(String, Point2<f32>), ()> {
let mut graph = StableGraph::new(); let mut graph = StableGraph::new();
let filename = env::args().nth(1).expect("missing gfa file argument"); let filename = env::args().nth(1).expect("missing gfa file argument");
let entries = parser::parse_file(filename).expect("failed to parse file");
let file_lines_count = BufReader::new(std::fs::File::open(&filename).expect("file not found"))
.lines()
.progress_with(indicatif::ProgressBar::new_spinner())
.count() as u64;
let file = std::fs::File::open(filename).unwrap();
let entries = parser::parse_source(file, file_lines_count).unwrap();
let mut index_map = HashMap::new(); let mut index_map = HashMap::new();

@ -1,4 +1,5 @@
use std::{ use std::{
borrow::Cow,
io::{self, BufRead, BufReader, Read}, io::{self, BufRead, BufReader, Read},
str::FromStr, str::FromStr,
thread, thread,
@ -126,6 +127,17 @@ fn parse_walk(line: &str) -> Entry {
} }
} }
pub fn parse_file<R: AsRef<str>>(file: R) -> io::Result<Vec<Entry>> {
let file_lines_count = BufReader::new(std::fs::File::open(file.as_ref())?)
.lines()
.progress_count(0)
.count() as u64;
let file = std::fs::File::open(file.as_ref())?;
parse_source(file, file_lines_count)
}
pub fn parse_source<R: Read>(reader: R, line_count: u64) -> io::Result<Vec<Entry>> { pub fn parse_source<R: Read>(reader: R, line_count: u64) -> io::Result<Vec<Entry>> {
let mut entries = Vec::new(); let mut entries = Vec::new();
let mut skipped = Vec::new(); let mut skipped = Vec::new();

Loading…
Cancel
Save