major change, little still left, optimisation left
This commit is contained in:
parent
1d174d87f1
commit
28a8c7782c
|
|
@ -118,13 +118,19 @@ version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -311,11 +317,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
|
checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
@ -556,7 +562,7 @@ checksum = "dd0eaf8df8bab402257e0a5c17a254e4cc1f72a93588a1ddfb5d356c801aa7cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cc",
|
"cc",
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"void",
|
"void",
|
||||||
]
|
]
|
||||||
|
|
@ -732,13 +738,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a76330fb486679b4ace3670f117bbc9e16204005c4bde9c4bd372f45bed34f12"
|
checksum = "c24fcd450d3fa2b592732565aa4f17a27a61c65ece4726353e000939b0edee34"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rand_core 0.6.0",
|
"rand_core 0.6.1",
|
||||||
"rand_hc",
|
"rand_hc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -749,7 +755,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ppv-lite86",
|
"ppv-lite86",
|
||||||
"rand_core 0.6.0",
|
"rand_core 0.6.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -769,9 +775,9 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_core"
|
name = "rand_core"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8b34ba8cfb21243bd8df91854c830ff0d785fff2e82ebd4434c2644cb9ada18"
|
checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
@ -782,7 +788,7 @@ version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand_core 0.6.0",
|
"rand_core 0.6.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -827,7 +833,7 @@ dependencies = [
|
||||||
"CoreFoundation-sys",
|
"CoreFoundation-sys",
|
||||||
"IOKit-sys",
|
"IOKit-sys",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"libudev",
|
"libudev",
|
||||||
"mach 0.2.3",
|
"mach 0.2.3",
|
||||||
"nix",
|
"nix",
|
||||||
|
|
@ -933,8 +939,7 @@ dependencies = [
|
||||||
"gtk",
|
"gtk",
|
||||||
"libmath",
|
"libmath",
|
||||||
"png",
|
"png",
|
||||||
"rand 0.8.0",
|
"rand 0.8.1",
|
||||||
"regex",
|
|
||||||
"serialport",
|
"serialport",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -970,9 +975,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.9.0+wasi-snapshot-preview1"
|
version = "0.10.1+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,4 @@ gio = "0.9.1"
|
||||||
glib = "0.10.3"
|
glib = "0.10.3"
|
||||||
png = "0.16.8"
|
png = "0.16.8"
|
||||||
cairo-rs = { version = "0.9.1", features = ["png"] }
|
cairo-rs = { version = "0.9.1", features = ["png"] }
|
||||||
rand = "0.8.0"
|
rand = "0.8.1"
|
||||||
regex = "1.4.2"
|
|
||||||
|
|
|
||||||
67
src/graph.rs
67
src/graph.rs
|
|
@ -3,6 +3,7 @@ use gtk::DrawingArea;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct Graph {
|
pub struct Graph {
|
||||||
pub area: DrawingArea,
|
pub area: DrawingArea,
|
||||||
|
|
@ -12,7 +13,8 @@ pub struct Graph {
|
||||||
pub scale_y_size: f64,
|
pub scale_y_size: f64,
|
||||||
pub draw_patch: bool,
|
pub draw_patch: bool,
|
||||||
pub auto_adjust_y: bool,
|
pub auto_adjust_y: bool,
|
||||||
pub lines: Vec<Line>
|
pub lines: HashMap<String, Line>,
|
||||||
|
pub pankti_sankya: f64
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Line {
|
pub struct Line {
|
||||||
|
|
@ -37,7 +39,8 @@ impl Graph {
|
||||||
scale_y_size: f64,
|
scale_y_size: f64,
|
||||||
draw_patch: bool,
|
draw_patch: bool,
|
||||||
auto_adjust_y: bool,
|
auto_adjust_y: bool,
|
||||||
lines: Vec<Line>) -> Rc<RefCell<Self>> {
|
lines: HashMap<String, Line>,
|
||||||
|
pankti_sankya: f64) -> Rc<RefCell<Self>> {
|
||||||
|
|
||||||
let graph = Rc::new(RefCell::new(Graph {
|
let graph = Rc::new(RefCell::new(Graph {
|
||||||
area,
|
area,
|
||||||
|
|
@ -47,7 +50,8 @@ impl Graph {
|
||||||
scale_y_size,
|
scale_y_size,
|
||||||
draw_patch,
|
draw_patch,
|
||||||
auto_adjust_y,
|
auto_adjust_y,
|
||||||
lines
|
lines,
|
||||||
|
pankti_sankya
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let graph_tmp = Rc::clone(&graph);
|
let graph_tmp = Rc::clone(&graph);
|
||||||
|
|
@ -69,11 +73,11 @@ impl Graph {
|
||||||
let width = area.get_allocated_width() as f64;
|
let width = area.get_allocated_width() as f64;
|
||||||
let height = area.get_allocated_height() as f64;
|
let height = area.get_allocated_height() as f64;
|
||||||
|
|
||||||
graph.borrow_mut().trim_lines();
|
|
||||||
if graph.borrow().auto_adjust_y {
|
if graph.borrow().auto_adjust_y {
|
||||||
graph.borrow_mut().adjust_scale_automatic_y();
|
graph.borrow_mut().adjust_scale_automatic_y();
|
||||||
}
|
}
|
||||||
// graph.borrow_mut().adjust_scale_automatic_x();
|
graph.borrow_mut().adjust_scale_automatic_x();
|
||||||
|
graph.borrow_mut().trim_lines();
|
||||||
|
|
||||||
Graph::draw_boxes(ctx, width, height, 40.0, 20.0, 5.0, 0.3);
|
Graph::draw_boxes(ctx, width, height, 40.0, 20.0, 5.0, 0.3);
|
||||||
Graph::draw_boxes(ctx, width, height, 40.0, 20.0, 50.0, 0.1);
|
Graph::draw_boxes(ctx, width, height, 40.0, 20.0, 50.0, 0.1);
|
||||||
|
|
@ -89,7 +93,7 @@ impl Graph {
|
||||||
ctx.set_line_width(2.0);
|
ctx.set_line_width(2.0);
|
||||||
ctx.set_line_cap(cairo::LineCap::Round);
|
ctx.set_line_cap(cairo::LineCap::Round);
|
||||||
let draw_patch = graph.borrow().draw_patch;
|
let draw_patch = graph.borrow().draw_patch;
|
||||||
for line in graph.borrow().lines.iter() {
|
for (_,line) in graph.borrow().lines.iter() {
|
||||||
for p in line.points.iter().enumerate() {
|
for p in line.points.iter().enumerate() {
|
||||||
let xp = if p.0 < line.points.len() - 1 {
|
let xp = if p.0 < line.points.len() - 1 {
|
||||||
line.points[p.0 + 1]
|
line.points[p.0 + 1]
|
||||||
|
|
@ -147,11 +151,20 @@ impl Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adjust_scale_automatic_y(&mut self) {
|
pub fn adjust_scale_automatic_y(&mut self) {
|
||||||
|
if self.lines.len() == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mut mx:Option<f64> = None;
|
let mut mx:Option<f64> = None;
|
||||||
let mut mi:Option<f64> = None;
|
let mut mi:Option<f64> = None;
|
||||||
|
|
||||||
for line in self.lines.iter() {
|
for (_, line) in self.lines.iter() {
|
||||||
|
if line.points.len() == 0 {
|
||||||
|
mx = Some(0.0);
|
||||||
|
mi = Some(0.0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if let None = mx {
|
if let None = mx {
|
||||||
mx = Some(line.points[0].1);
|
mx = Some(line.points[0].1);
|
||||||
}
|
}
|
||||||
|
|
@ -166,15 +179,8 @@ impl Graph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mx = match mx {
|
let mx = mx.unwrap();
|
||||||
Some(val) => val,
|
let mi = mi.unwrap();
|
||||||
None => 0.0
|
|
||||||
};
|
|
||||||
|
|
||||||
let mi = match mi {
|
|
||||||
Some(val) => val,
|
|
||||||
None => 0.0
|
|
||||||
};
|
|
||||||
|
|
||||||
let spread = (mx - mi).abs();
|
let spread = (mx - mi).abs();
|
||||||
|
|
||||||
|
|
@ -183,10 +189,20 @@ impl Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adjust_scale_automatic_x(&mut self) {
|
pub fn adjust_scale_automatic_x(&mut self) {
|
||||||
|
if self.lines.len() == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mut mx:Option<f64> = None;
|
let mut mx:Option<f64> = None;
|
||||||
let mut mi:Option<f64> = None;
|
let mut mi:Option<f64> = None;
|
||||||
|
|
||||||
for line in self.lines.iter() {
|
for (_, line) in self.lines.iter() {
|
||||||
|
if line.points.len() == 0 {
|
||||||
|
mx = Some(0.0);
|
||||||
|
mi = Some(0.0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if let None = mx {
|
if let None = mx {
|
||||||
mx = Some(line.points[0].0);
|
mx = Some(line.points[0].0);
|
||||||
}
|
}
|
||||||
|
|
@ -211,27 +227,24 @@ impl Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trim_lines(&mut self) {
|
pub fn trim_lines(&mut self) {
|
||||||
let mut j = 0;
|
for (_, line) in self.lines.iter_mut() {
|
||||||
while j < self.lines.len() {
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < self.lines[j].points.len() {
|
while i < line.points.len() {
|
||||||
println!("{:?}", self.lines[j].points);
|
match line.points.get(i + 2) {
|
||||||
match self.lines[j].points.get(i + 2) {
|
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
if self.lines[j].points[i+1].0 < self.scale_x_start {
|
if line.points[i+1].0 < self.scale_x_start {
|
||||||
self.lines[j].points.remove(i);
|
line.points.remove(i);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
if self.lines[j].points[self.lines[j].points.len() - 1].0 < self.scale_x_start {
|
if line.points[line.points.len() - 1].0 < self.scale_x_start {
|
||||||
self.lines.remove(j);
|
line.points.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
j += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
101
src/lib.rs
101
src/lib.rs
|
|
@ -1,14 +1,16 @@
|
||||||
mod graph;
|
mod graph;
|
||||||
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use graph::{Graph, Line};
|
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use rand::Rng;
|
||||||
|
|
||||||
|
use std::{collections::HashMap, sync::{Arc, Mutex}};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
|
||||||
|
use graph::Graph;
|
||||||
|
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
JAGRIT, SAYAN, AVRODTIH, PARIVARTIT, NIKAS
|
JAGRIT, SAYAN, AVRODTIH, PARIVARTIT, NIKAS
|
||||||
}
|
}
|
||||||
|
|
@ -48,15 +50,32 @@ pub fn build_ui(app: >k::Application, config: Arc::<Mutex::<Config>>) {
|
||||||
0.0, 100.0,
|
0.0, 100.0,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
vec![
|
HashMap::new(),
|
||||||
Line::new(1.0,1.0,0.0,vec![(10.0,10.0),(20.0,20.0),(30.0,25.0), (40.0, 50.0),(50.0,25.0)]),
|
0.0
|
||||||
// Line::new(1.0,0.0,0.0,vec![(50.0,10.0),(70.0,60.0)]),
|
|
||||||
// Line::new(0.0,1.0,0.0,vec![(50.0,50.0)])
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
win.show_all();
|
win.show_all();
|
||||||
|
|
||||||
|
// exit_menu
|
||||||
|
let exit_menu = builder.get_object::<gtk::MenuItem>("exit_menu").expect("Resource file missing!");
|
||||||
|
let tmp_win = win.clone();
|
||||||
|
exit_menu.connect_activate(move |_|{
|
||||||
|
unsafe {
|
||||||
|
tmp_win.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// about_menu
|
||||||
|
let about_menu = builder.get_object::<gtk::MenuItem>("about_menu").expect("Resource file missing!");
|
||||||
|
let about = builder.get_object::<gtk::AboutDialog>("about").expect("Resource file missing!");
|
||||||
|
|
||||||
|
about_menu.connect_activate(move |_|{
|
||||||
|
about.show_all();
|
||||||
|
});
|
||||||
|
|
||||||
|
// save_log
|
||||||
|
|
||||||
|
|
||||||
// pankti
|
// pankti
|
||||||
let pankti = builder.get_object::<gtk::SpinButton>("pankti").expect("Resource file missing!");
|
let pankti = builder.get_object::<gtk::SpinButton>("pankti").expect("Resource file missing!");
|
||||||
|
|
||||||
|
|
@ -167,6 +186,7 @@ pub fn build_ui(app: >k::Application, config: Arc::<Mutex::<Config>>) {
|
||||||
|
|
||||||
let tmp_graph = Rc::clone(&graph);
|
let tmp_graph = Rc::clone(&graph);
|
||||||
clear_graph.connect_clicked(move |_ | {
|
clear_graph.connect_clicked(move |_ | {
|
||||||
|
tmp_graph.borrow_mut().pankti_sankya = 0.0;
|
||||||
tmp_graph.borrow_mut().lines.clear();
|
tmp_graph.borrow_mut().lines.clear();
|
||||||
tmp_graph.borrow().area.queue_draw();
|
tmp_graph.borrow().area.queue_draw();
|
||||||
});
|
});
|
||||||
|
|
@ -176,9 +196,13 @@ pub fn build_ui(app: >k::Application, config: Arc::<Mutex::<Config>>) {
|
||||||
|
|
||||||
let tmp_bar = bar.clone();
|
let tmp_bar = bar.clone();
|
||||||
let tmp_config = Arc::clone(&config);
|
let tmp_config = Arc::clone(&config);
|
||||||
|
let tmp_graph = Rc::clone(&graph);
|
||||||
jagrit_btn.connect_clicked(move |_ | {
|
jagrit_btn.connect_clicked(move |_ | {
|
||||||
match tmp_config.lock() {
|
match tmp_config.lock() {
|
||||||
Ok(mut config) => {
|
Ok(mut config) => {
|
||||||
|
tmp_graph.borrow_mut().pankti_sankya = 0.0;
|
||||||
|
tmp_graph.borrow_mut().lines.clear();
|
||||||
|
tmp_graph.borrow().area.queue_draw();
|
||||||
tmp_bar.push(1, "Jagrit");
|
tmp_bar.push(1, "Jagrit");
|
||||||
config.status = Status::PARIVARTIT;
|
config.status = Status::PARIVARTIT;
|
||||||
}, Err(_) => {
|
}, Err(_) => {
|
||||||
|
|
@ -187,7 +211,7 @@ pub fn build_ui(app: >k::Application, config: Arc::<Mutex::<Config>>) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//jagrit_btn
|
//avrodith_btn
|
||||||
let avrodith_btn = builder.get_object::<gtk::ToolButton>("avrodith_btn").expect("Resource file missing!");
|
let avrodith_btn = builder.get_object::<gtk::ToolButton>("avrodith_btn").expect("Resource file missing!");
|
||||||
|
|
||||||
let tmp_bar = bar.clone();
|
let tmp_bar = bar.clone();
|
||||||
|
|
@ -276,11 +300,66 @@ pub fn build_ui(app: >k::Application, config: Arc::<Mutex::<Config>>) {
|
||||||
});
|
});
|
||||||
|
|
||||||
let full_log = builder.get_object::<gtk::CheckButton>("full_log").expect("Resource file missing!");
|
let full_log = builder.get_object::<gtk::CheckButton>("full_log").expect("Resource file missing!");
|
||||||
|
let tmp_graph = Rc::clone(&graph);
|
||||||
receiver.attach(None, move |msg| {
|
receiver.attach(None, move |msg| {
|
||||||
match msg {
|
match msg {
|
||||||
Message::Msg(text) => {
|
Message::Msg(text) => {
|
||||||
if !full_log.get_active() && text.starts_with("#") {
|
if text.starts_with("#") {
|
||||||
|
tmp_graph.borrow_mut().pankti_sankya += 1.0;
|
||||||
|
for (index, line) in text[1..].split(" ").enumerate() {
|
||||||
|
let part = line.split("=");
|
||||||
|
let part = part.into_iter().collect::<Vec<&str>>();
|
||||||
|
if part.len() == 1 {
|
||||||
|
let num = match part[0].trim().parse::<f64>() {
|
||||||
|
Ok(val) => val,
|
||||||
|
Err(_) => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let mut gp = tmp_graph.borrow_mut();
|
||||||
|
|
||||||
|
let sankhya = gp.pankti_sankya;
|
||||||
|
match gp.lines.get_mut(&index.to_string()) {
|
||||||
|
Some(val) => {
|
||||||
|
val.points.push((sankhya, num));
|
||||||
|
} None => {
|
||||||
|
let v = vec![(sankhya, num)];
|
||||||
|
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
gp.lines.insert(index.to_string(), graph::Line::new(rng.gen_range(0.0..1.0), 0.0, rng.gen_range(0.0..1.0), v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gp.area.queue_draw();
|
||||||
|
} else if part.len() == 2 {
|
||||||
|
let num = match part[1].trim().parse::<f64>() {
|
||||||
|
Ok(val) => val,
|
||||||
|
Err(_) => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let mut gp = tmp_graph.borrow_mut();
|
||||||
|
|
||||||
|
let sankhya = gp.pankti_sankya;
|
||||||
|
match gp.lines.get_mut(part[0]) {
|
||||||
|
Some(val) => {
|
||||||
|
val.points.push((sankhya, num));
|
||||||
|
} None => {
|
||||||
|
let v = vec![(sankhya, num)];
|
||||||
|
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
gp.lines.insert(part[0].to_owned(), graph::Line::new(rng.gen_range(0.0..1.0), 0.0, rng.gen_range(0.0..1.0), v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gp.area.queue_draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if full_log.get_active(){
|
||||||
|
let buf = log_area.get_buffer()
|
||||||
|
.expect("Couldn't get log_area");
|
||||||
|
buf.insert(&mut buf.get_end_iter(), &text);
|
||||||
|
log_area.scroll_to_iter(&mut buf.get_end_iter(), 0.4, true, 0.0, 0.0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let buf = log_area.get_buffer()
|
let buf = log_area.get_buffer()
|
||||||
.expect("Couldn't get log_area");
|
.expect("Couldn't get log_area");
|
||||||
|
|
@ -295,7 +374,7 @@ pub fn build_ui(app: >k::Application, config: Arc::<Mutex::<Config>>) {
|
||||||
glib::Continue(true)
|
glib::Continue(true)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Time ke hisab se pankti ko aage bhadhay
|
||||||
// let (sender, receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
// let (sender, receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
||||||
// glib::timeout_add(300, move || {
|
// glib::timeout_add(300, move || {
|
||||||
// sender.send(()).unwrap();
|
// sender.send(()).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,5 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn start() {
|
fn start() {
|
||||||
let a = vec![0,1,2,3,4,5,6,7,8,9];
|
|
||||||
|
|
||||||
let mut skiped = false;
|
|
||||||
let b: Vec<i32> = a.into_iter().filter(|x| {
|
|
||||||
if *x <= 4 {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !skiped {
|
|
||||||
skiped = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}).collect();
|
|
||||||
|
|
||||||
println!("{:?}", b);
|
|
||||||
|
|
||||||
// for (i, x) in a.iter().enumerate() {
|
|
||||||
// if *x <= 4 {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if !skiped {
|
|
||||||
// skiped = true;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// a.remove(i);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,42 @@
|
||||||
<!-- Generated with glade 3.38.2 -->
|
<!-- Generated with glade 3.38.2 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.22"/>
|
<requires lib="gtk+" version="3.22"/>
|
||||||
|
<object class="GtkAboutDialog" id="about">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="type-hint">dialog</property>
|
||||||
|
<property name="program-name">Tarangam (तरंगम्)</property>
|
||||||
|
<property name="comments" translatable="yes">A simple serial plotter.
|
||||||
|
एक सरल सीरीय्ल पलौटर।</property>
|
||||||
|
<property name="authors">Piyush Mishra</property>
|
||||||
|
<property name="logo-icon-name">image-missing</property>
|
||||||
|
<child internal-child="vbox">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">2</property>
|
||||||
|
<child internal-child="action_area">
|
||||||
|
<object class="GtkButtonBox">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="layout-style">end</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<object class="GtkImage" id="document_save">
|
<object class="GtkImage" id="document_save">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -44,7 +80,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem">
|
<object class="GtkImageMenuItem" id="save_menu">
|
||||||
<property name="label">Save Log</property>
|
<property name="label">Save Log</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -59,7 +95,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem">
|
<object class="GtkImageMenuItem" id="exit_menu">
|
||||||
<property name="label">gtk-quit</property>
|
<property name="label">gtk-quit</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -82,7 +118,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem">
|
<object class="GtkImageMenuItem" id="about_menu">
|
||||||
<property name="label">gtk-about</property>
|
<property name="label">gtk-about</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -213,25 +249,6 @@
|
||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkToolItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton">
|
|
||||||
<property name="label" translatable="yes">Timeframe</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">False</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="homogeneous">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolItem">
|
<object class="GtkToolItem">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,42 @@
|
||||||
<!-- Generated with glade 3.38.2 -->
|
<!-- Generated with glade 3.38.2 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.22"/>
|
<requires lib="gtk+" version="3.22"/>
|
||||||
|
<object class="GtkAboutDialog" id="about">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="type-hint">dialog</property>
|
||||||
|
<property name="program-name">Tarangam (तरंगम्)</property>
|
||||||
|
<property name="comments" translatable="yes">A simple serial plotter.
|
||||||
|
एक सरल सीरीय्ल पलौटर।</property>
|
||||||
|
<property name="authors">Piyush Mishra</property>
|
||||||
|
<property name="logo-icon-name">image-missing</property>
|
||||||
|
<child internal-child="vbox">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">2</property>
|
||||||
|
<child internal-child="action_area">
|
||||||
|
<object class="GtkButtonBox">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="layout-style">end</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<object class="GtkImage" id="document_save">
|
<object class="GtkImage" id="document_save">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -59,7 +95,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem">
|
<object class="GtkImageMenuItem" id="exit_menu">
|
||||||
<property name="label">gtk-quit</property>
|
<property name="label">gtk-quit</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -82,7 +118,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem">
|
<object class="GtkImageMenuItem" id="about_menu">
|
||||||
<property name="label">gtk-about</property>
|
<property name="label">gtk-about</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -213,25 +249,6 @@
|
||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkToolItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton">
|
|
||||||
<property name="label" translatable="yes">Timeframe</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">False</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="homogeneous">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolItem">
|
<object class="GtkToolItem">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue