code dump 1
This commit is contained in:
parent
e736eb4c60
commit
f0357aa8ec
File diff suppressed because it is too large
Load Diff
|
|
@ -11,7 +11,8 @@ input = { git = "https://github.com/Smithay/input.rs" }
|
||||||
udev = "0.2"
|
udev = "0.2"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
errno = "0.2"
|
errno = "0.2"
|
||||||
csv = "1.1.3"
|
csv = "1.1"
|
||||||
|
druid = "0.6"
|
||||||
|
|
||||||
[dependencies.gtk]
|
[dependencies.gtk]
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
|
@ -24,4 +25,3 @@ features = ["v2_60"]
|
||||||
[dependencies.gdk]
|
[dependencies.gdk]
|
||||||
version = ""
|
version = ""
|
||||||
features = ["v3_24"]
|
features = ["v3_24"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ def import_csv_data(filename):
|
||||||
reader = csv.reader(csv_fp)
|
reader = csv.reader(csv_fp)
|
||||||
next(reader) # skip header
|
next(reader) # skip header
|
||||||
for row in reader:
|
for row in reader:
|
||||||
for i, v in enumerate([stylus_x, stylus_y, stylus_pressure, time]):
|
for i, v in enumerate([stylus_x, stylus_y]): #, stylus_pressure, time]):
|
||||||
v.append(float(row[i]))
|
v.append(float(row[i]))
|
||||||
stylus_pos = np.array([stylus_x, stylus_y])
|
stylus_pos = np.array([stylus_x, stylus_y])
|
||||||
time = np.array(time)
|
time = np.array(time)
|
||||||
|
|
|
||||||
|
|
@ -46,21 +46,24 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 29,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"ename": "NameError",
|
||||||
"text/plain": [
|
"evalue": "name 'pos' is not defined",
|
||||||
"215"
|
"output_type": "error",
|
||||||
]
|
"traceback": [
|
||||||
},
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
"execution_count": 29,
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||||
"metadata": {},
|
"\u001b[0;32m<ipython-input-2-85aa0823d467>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mpos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||||
"output_type": "execute_result"
|
"\u001b[0;31mNameError\u001b[0m: name 'pos' is not defined"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": []
|
"source": [
|
||||||
|
"pos[0]"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
|
@ -104,7 +107,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.7.5"
|
"version": "3.8.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
||||||
|
|
@ -64,15 +64,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
println!("{} points drawn", state.point_buffer.len());
|
|
||||||
|
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
let save_button = Button::new_from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Menu);
|
let save_button = Button::new_from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Menu);
|
||||||
//save_button.connect_clicked(|_| {
|
|
||||||
//
|
|
||||||
//});
|
|
||||||
let clear_button = Button::new_from_icon_name(Some("edit-clear-all-symbolic"), gtk::IconSize::Menu);
|
let clear_button = Button::new_from_icon_name(Some("edit-clear-all-symbolic"), gtk::IconSize::Menu);
|
||||||
let check_button = CheckButton::new_with_label("Join Points");
|
let check_button = CheckButton::new_with_label("Join Points");
|
||||||
|
|
||||||
|
|
@ -96,6 +92,18 @@ fn main() {
|
||||||
win_clone.queue_draw();
|
win_clone.queue_draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let state_clone_4 = Rc::clone(&app_state);
|
||||||
|
save_button.connect_clicked(move |_| {
|
||||||
|
let writer = csv::Writer::from_path("acquired_data.csv");
|
||||||
|
if let Ok(mut wrt) = writer {
|
||||||
|
wrt.write_record(&["x", "y"]).expect("write error");
|
||||||
|
for pt in &state_clone_4.borrow().point_buffer {
|
||||||
|
wrt.write_record(&[pt.0.to_string(), pt.1.to_string()]).expect("write error");
|
||||||
|
}
|
||||||
|
wrt.flush().unwrap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let state_clone_3 = Rc::clone(&app_state);
|
let state_clone_3 = Rc::clone(&app_state);
|
||||||
let win_clone_2 = Rc::clone(&window);
|
let win_clone_2 = Rc::clone(&window);
|
||||||
check_button.connect_clicked(move |_| {
|
check_button.connect_clicked(move |_| {
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,8 @@ impl LibinputInterface for SimpleLibinputInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let udev_ctx = udev::Context::new().unwrap();
|
|
||||||
let libinput_interface = SimpleLibinputInterface{};
|
let libinput_interface = SimpleLibinputInterface{};
|
||||||
let mut libinput_ctx = Libinput::new_from_udev(libinput_interface, &udev_ctx);
|
let mut libinput_ctx = Libinput::new_with_udev(libinput_interface);
|
||||||
|
|
||||||
libinput_ctx.udev_assign_seat("seat0").unwrap();
|
libinput_ctx.udev_assign_seat("seat0").unwrap();
|
||||||
|
|
||||||
|
|
@ -44,7 +43,7 @@ fn main() {
|
||||||
while let Some(event) = libinput_ctx.next() {
|
while let Some(event) = libinput_ctx.next() {
|
||||||
if let Event::Tablet(tablet_evt) = event {
|
if let Event::Tablet(tablet_evt) = event {
|
||||||
if let TabletToolEvent::Axis(axis_evt) = tablet_evt {
|
if let TabletToolEvent::Axis(axis_evt) = tablet_evt {
|
||||||
if axis_evt.pressure() > 1e-3 {
|
if true { //axis_evt.pressure() > 1e-3 {
|
||||||
let pressure = axis_evt.pressure();
|
let pressure = axis_evt.pressure();
|
||||||
let x_t = axis_evt.x_transformed(1080);
|
let x_t = axis_evt.x_transformed(1080);
|
||||||
let y_t = axis_evt.y_transformed(1920);
|
let y_t = axis_evt.y_transformed(1920);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue