fix issue with plot buttons running out of usable display space
This commit is contained in:
parent
94a930fe3b
commit
7b29447fa6
|
|
@ -1618,29 +1618,23 @@ impl App {
|
||||||
.on_submit(Message::ProbeSubmitAngle(i))
|
.on_submit(Message::ProbeSubmitAngle(i))
|
||||||
.size(10)
|
.size(10)
|
||||||
.width(Length::Fixed(40.0));
|
.width(Length::Fixed(40.0));
|
||||||
|
let mode_picker = iced::widget::pick_list(
|
||||||
|
probe::PROBE_MODES,
|
||||||
|
Some(p.mode),
|
||||||
|
move |m| Message::ProbeSetMode(i, m),
|
||||||
|
)
|
||||||
|
.text_size(10)
|
||||||
|
.width(Length::Fixed(78.0));
|
||||||
let mode_row = row![
|
let mode_row = row![
|
||||||
button(text(p.label.clone()).size(11)).style(button::secondary),
|
text(p.label.clone()).size(11),
|
||||||
button(text("<").size(10)).on_press(Message::ProbeRotateBy(i, -15.0)).style(button::secondary),
|
button(text("<").size(10)).on_press(Message::ProbeRotateBy(i, -15.0)).style(button::secondary),
|
||||||
angle_input,
|
angle_input,
|
||||||
text("deg").size(10),
|
text("deg").size(10),
|
||||||
button(text(">").size(10)).on_press(Message::ProbeRotateBy(i, 15.0)).style(button::secondary),
|
button(text(">").size(10)).on_press(Message::ProbeRotateBy(i, 15.0)).style(button::secondary),
|
||||||
button(text("|B|").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Magnitude))
|
mode_picker,
|
||||||
.style(if p.mode == probe::ProbeMode::Magnitude { button::primary } else { button::secondary }),
|
|
||||||
button(text("Bx").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Bx))
|
|
||||||
.style(if p.mode == probe::ProbeMode::Bx { button::primary } else { button::secondary }),
|
|
||||||
button(text("By").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::By))
|
|
||||||
.style(if p.mode == probe::ProbeMode::By { button::primary } else { button::secondary }),
|
|
||||||
button(text("ang").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Angle))
|
|
||||||
.style(if p.mode == probe::ProbeMode::Angle { button::primary } else { button::secondary }),
|
|
||||||
button(text("Pri").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Primary))
|
|
||||||
.style(if p.mode == probe::ProbeMode::Primary { button::primary } else { button::secondary }),
|
|
||||||
button(text("Per").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Perpendicular))
|
|
||||||
.style(if p.mode == probe::ProbeMode::Perpendicular { button::primary } else { button::secondary }),
|
|
||||||
button(text("Diff").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Differential))
|
|
||||||
.style(if p.mode == probe::ProbeMode::Differential { button::primary } else { button::secondary }),
|
|
||||||
button(text("wav").size(10)).on_press(Message::ProbeExportWav(i)).style(button::secondary),
|
button(text("wav").size(10)).on_press(Message::ProbeExportWav(i)).style(button::secondary),
|
||||||
button(text("x").size(10)).on_press(Message::ProbeRemove(i)).style(button::danger),
|
button(text("x").size(10)).on_press(Message::ProbeRemove(i)).style(button::danger),
|
||||||
].spacing(2);
|
].spacing(2).align_y(Alignment::Center);
|
||||||
let plot_canvas: Element<'_, Message> =
|
let plot_canvas: Element<'_, Message> =
|
||||||
plot::view::<Message>(p, samples, sim.frame_idx, sim.buffer_size.max(1));
|
plot::view::<Message>(p, samples, sim.frame_idx, sim.buffer_size.max(1));
|
||||||
let pane = column![mode_row, plot_canvas]
|
let pane = column![mode_row, plot_canvas]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
//! point-sample probes for the magnetic field, time-series plotted per frame in a panel below the canvas.
|
//! point-sample probes for the magnetic field, time-series plotted per frame in a panel below the canvas.
|
||||||
|
|
||||||
/// signal extracted from the (bx, by) sample at a probe location for waveform plotting.
|
/// signal extracted from the (bx, by) sample at a probe location for waveform plotting.
|
||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||||
pub enum ProbeMode {
|
pub enum ProbeMode {
|
||||||
#[default]
|
#[default]
|
||||||
Magnitude,
|
Magnitude,
|
||||||
|
|
@ -13,6 +13,16 @@ pub enum ProbeMode {
|
||||||
Differential,
|
Differential,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const PROBE_MODES: &[ProbeMode] = &[
|
||||||
|
ProbeMode::Magnitude,
|
||||||
|
ProbeMode::Bx,
|
||||||
|
ProbeMode::By,
|
||||||
|
ProbeMode::Angle,
|
||||||
|
ProbeMode::Primary,
|
||||||
|
ProbeMode::Perpendicular,
|
||||||
|
ProbeMode::Differential,
|
||||||
|
];
|
||||||
|
|
||||||
impl ProbeMode {
|
impl ProbeMode {
|
||||||
pub fn label(self) -> &'static str {
|
pub fn label(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
|
|
@ -55,6 +65,12 @@ pub struct Probe {
|
||||||
pub selected: bool,
|
pub selected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for ProbeMode {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str(self.label())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// returns a saturated palette color from a small cycling palette suitable for probe markers and matching plot lines.
|
/// returns a saturated palette color from a small cycling palette suitable for probe markers and matching plot lines.
|
||||||
pub fn palette_color(idx: usize) -> [u8; 4] {
|
pub fn palette_color(idx: usize) -> [u8; 4] {
|
||||||
const PALETTE: &[[u8; 4]] = &[
|
const PALETTE: &[[u8; 4]] = &[
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue