handle to drag, and fix rect/grid sources
This commit is contained in:
parent
d2fa6e007c
commit
59788d5363
2 changed files with 34 additions and 18 deletions
|
@ -890,7 +890,7 @@ fn view_line_canvas(app: &App, model: &GuiModel, frame: Frame) {
|
||||||
|
|
||||||
// show each configured laser in the canvas. Highlight the selected.
|
// show each configured laser in the canvas. Highlight the selected.
|
||||||
for (dac_id, config) in model.per_laser_config.iter() {
|
for (dac_id, config) in model.per_laser_config.iter() {
|
||||||
let rect = shape_rect(LaserSpace::READY);
|
let rect = shape_rect(LaserSpace::READY, 11);
|
||||||
let points = config.filters.reverse(&rect);
|
let points = config.filters.reverse(&rect);
|
||||||
|
|
||||||
|
|
||||||
|
@ -913,6 +913,21 @@ fn view_line_canvas(app: &App, model: &GuiModel, frame: Frame) {
|
||||||
.weight(thickness)
|
.weight(thickness)
|
||||||
.join_round()
|
.join_round()
|
||||||
.points_colored(vertices);
|
.points_colored(vertices);
|
||||||
|
|
||||||
|
// draggable corners for the selected area
|
||||||
|
if model.selected_stream == Some(dac_id.clone()){
|
||||||
|
let rect = shape_rect(LaserSpace::READY, 1); // find corners
|
||||||
|
let points = config.filters.reverse(&rect);
|
||||||
|
for p in points.points {
|
||||||
|
let pos = [p.position[0] * scale + translate_x, p.position[1] * -scale + translate_y];
|
||||||
|
|
||||||
|
draw.ellipse()
|
||||||
|
.x_y(pos[0], pos[1])
|
||||||
|
.radius(3.)
|
||||||
|
.color(srgba(229./255.,45./255.,159./255.,0.8));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -169,36 +169,36 @@ pub enum LaserSpace {
|
||||||
READY,
|
READY,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shape_rect(space: LaserSpace) -> LaserPoints {
|
pub fn shape_rect(space: LaserSpace, steps: usize) -> LaserPoints {
|
||||||
let offset: f32 = match space { LaserSpace::OLD => 0., _ => 1. };
|
let offset: f32 = match space { LaserSpace::OLD => 0., _ => 1. };
|
||||||
let factor: f32 = match space { LaserSpace::OLD => 1., _ => 2./0xFFF as f32 };
|
let factor: f32 = match space { LaserSpace::OLD => 1., _ => 2./0xFFF as f32 };
|
||||||
let mut points = Vec::new();
|
let mut points = Vec::new();
|
||||||
let steps: usize = 10;
|
// let steps: usize = 10;
|
||||||
for i in (0..=steps).rev() {
|
for i in (0..=steps).rev() {
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[0xFFF as f32 * factor - offset, (0xFFF * i / steps) as f32 * factor - offset],
|
position:[0xFFF as f32 * factor - offset, (0xFFF * i / steps) as f32 * factor - offset],
|
||||||
color: [1.,1.,1.],
|
color: [0.2,0.2,0.2],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for i in (0..=steps).rev() {
|
for i in (0..steps).rev() {
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[(0xFFF * i / steps) as f32 * factor - offset, 0.0 * factor - offset],
|
position:[(0xFFF * i / steps) as f32 * factor - offset, 0.0 * factor - offset],
|
||||||
color: [1.,1.,1.],
|
color: [0.2,0.2,0.2],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for i in 0..=steps {
|
for i in 0..steps {
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[0.0 * factor - offset, (0xFFF * i / steps) as f32 * factor - offset],
|
position:[0.0 * factor - offset, (0xFFF * i / steps) as f32 * factor - offset],
|
||||||
color: [1.,1.,1.],
|
color: [0.2,0.2,0.2],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for i in 0..=steps {
|
for i in 0..=steps {
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[(0xFFF * i / steps) as f32 * factor - offset , 0xFFF as f32 * factor - offset],
|
position:[(0xFFF * i / steps) as f32 * factor - offset , 0xFFF as f32 * factor - offset],
|
||||||
color: [1.,1.,1.],
|
color: [0.2,0.2,0.2],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -212,17 +212,18 @@ impl StreamSource{
|
||||||
match self {
|
match self {
|
||||||
Self::CurrentLines => current_lines,
|
Self::CurrentLines => current_lines,
|
||||||
Self::Rectangle => {
|
Self::Rectangle => {
|
||||||
shape_rect(LaserSpace::OLD)
|
shape_rect(LaserSpace::READY, 11)
|
||||||
},
|
},
|
||||||
Self::Grid => {
|
Self::Grid => {
|
||||||
let lines: usize = 5;
|
let lines: usize = 5;
|
||||||
|
let half = (0xFFF / 2) as f32;
|
||||||
let mut points = Vec::new();
|
let mut points = Vec::new();
|
||||||
// vertical lines
|
// vertical lines
|
||||||
for i in 0..=lines {
|
for i in 0..=lines {
|
||||||
let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32;
|
let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32;
|
||||||
let x = i * 0xFFF / lines;
|
let x = i * 0xFFF / lines;
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[x as f32, offset],
|
position:[(x as f32 - half) / half, (offset as f32 - half)/half],
|
||||||
color: [0., 0., 0.],
|
color: [0., 0., 0.],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
|
@ -230,7 +231,7 @@ impl StreamSource{
|
||||||
// go back and forth, so galvo has it easier
|
// go back and forth, so galvo has it easier
|
||||||
let y = if i % 2 == 0 { j } else {0xFFF - j};
|
let y = if i % 2 == 0 { j } else {0xFFF - j};
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[x as f32, y as f32],
|
position:[(x as f32 - half)/half, (y as f32 - half)/half],
|
||||||
color: [1.,1.,1.],
|
color: [1.,1.,1.],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
|
@ -242,7 +243,7 @@ impl StreamSource{
|
||||||
let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32;
|
let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32;
|
||||||
let y = i * 0xFFF / lines;
|
let y = i * 0xFFF / lines;
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[offset, y as f32],
|
position:[(offset as f32 - half)/half, (y as f32 - half)/half],
|
||||||
color: [0., 0., 0.],
|
color: [0., 0., 0.],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
|
@ -250,7 +251,7 @@ impl StreamSource{
|
||||||
// go back and forth, so galvo has it easier
|
// go back and forth, so galvo has it easier
|
||||||
let x = if i % 2 == 0 { j } else {0xFFF - j};
|
let x = if i % 2 == 0 { j } else {0xFFF - j};
|
||||||
points.push(laser::Point{
|
points.push(laser::Point{
|
||||||
position:[x as f32, y as f32],
|
position:[(x as f32 - half)/half, (y as f32 - half)/half],
|
||||||
color: [1.,1.,1.],
|
color: [1.,1.,1.],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue