Skip to content

Commit

Permalink
current work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddyFunk committed Aug 11, 2023
1 parent 09e464d commit 4808219
Show file tree
Hide file tree
Showing 3 changed files with 318 additions and 101 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cgmath = "0.18.0"
half = "2.3.1"
rfd = "0.11.4"
regex = "1.9.1"
egui_dock = "0.6"

# feature "persistence":
serde = { version = "1.0.171", optional = true, features = ["derive"] }
Expand Down
143 changes: 70 additions & 73 deletions src/apps/slice_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,22 +346,19 @@ impl SliceRenderer {
}
}

impl eframe::App for SliceRenderer {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
egui::ScrollArea::both()
.auto_shrink([false; 2])
.show(ui, |ui| {
egui::Frame::canvas(ui.style()).show(ui, |ui| {
self.custom_painting(ctx, ui);
});
});
});
}
}
// impl eframe::App for SliceRenderer {
// fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
// egui::CentralPanel::default().show(ctx, |ui| {
// egui::Frame::canvas(ui.style()).show(ui, |ui| {
// self.custom_painting(ctx, ui);
// });
// });
// }
// }

impl SliceRenderer {
fn custom_painting(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) {
// pub fn custom_painting(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) {
pub fn custom_painting(&mut self, ui: &mut egui::Ui) {
let availbale_size = ui.available_size_before_wrap();
let (rect, _response) = ui.allocate_exact_size(availbale_size, egui::Sense::hover());

Expand Down Expand Up @@ -410,65 +407,65 @@ impl SliceRenderer {

ui.painter().add(callback);

// Paint overlay
egui::Area::new("Slice Renderer Overlay")
.anchor(egui::Align2::LEFT_TOP, [12.0, 12.0])
.show(ctx, |ui| {
match self.axis {
VolumeAxis::X => ui.add(
egui::Slider::new(&mut self.slice_position, 1..=self.dimensions.0)
.text("Slice Position"),
),
VolumeAxis::Y => ui.add(
egui::Slider::new(&mut self.slice_position, 1..=self.dimensions.1)
.text("Slice Position"),
),
VolumeAxis::Z => ui.add(
egui::Slider::new(&mut self.slice_position, 1..=self.dimensions.2)
.text("Slice Position"),
),
};

if ui
.add(egui::RadioButton::new(self.axis == VolumeAxis::X, "X-Axis"))
.clicked()
{
self.axis = VolumeAxis::X;
self.slice_position = self.dimensions.0 / 2;
let height = self.dimensions.1 as f32 * self.spacing.1;
let width = self.dimensions.2 as f32 * self.spacing.2;
self.scale = egui::Rect::from_two_pos(
egui::Pos2::new(-width, -height),
egui::Pos2::new(width, height),
);
}
if ui
.add(egui::RadioButton::new(self.axis == VolumeAxis::Y, "Y-Axis"))
.clicked()
{
self.axis = VolumeAxis::Y;
self.slice_position = self.dimensions.1 / 2;
let height = self.dimensions.0 as f32 * self.spacing.0;
let width = self.dimensions.2 as f32 * self.spacing.2;
self.scale = egui::Rect::from_two_pos(
egui::Pos2::new(-width, -height),
egui::Pos2::new(width, height),
);
}
if ui
.add(egui::RadioButton::new(self.axis == VolumeAxis::Z, "Z-Axis"))
.clicked()
{
self.axis = VolumeAxis::Z;
self.slice_position = self.dimensions.2 / 2;
let height = self.dimensions.0 as f32 * self.spacing.0;
let width = self.dimensions.1 as f32 * self.spacing.1;
self.scale = egui::Rect::from_two_pos(
egui::Pos2::new(-width, -height),
egui::Pos2::new(width, height),
);
}
});
// // Paint overlay
// egui::Area::new("Slice Renderer Overlay")
// .anchor(egui::Align2::LEFT_TOP, [12.0, 12.0])
// .show(ctx, |ui| {
// match self.axis {
// VolumeAxis::X => ui.add(
// egui::Slider::new(&mut self.slice_position, 1..=self.dimensions.0)
// .text("Slice Position"),
// ),
// VolumeAxis::Y => ui.add(
// egui::Slider::new(&mut self.slice_position, 1..=self.dimensions.1)
// .text("Slice Position"),
// ),
// VolumeAxis::Z => ui.add(
// egui::Slider::new(&mut self.slice_position, 1..=self.dimensions.2)
// .text("Slice Position"),
// ),
// };

// if ui
// .add(egui::RadioButton::new(self.axis == VolumeAxis::X, "X-Axis"))
// .clicked()
// {
// self.axis = VolumeAxis::X;
// self.slice_position = self.dimensions.0 / 2;
// let height = self.dimensions.1 as f32 * self.spacing.1;
// let width = self.dimensions.2 as f32 * self.spacing.2;
// self.scale = egui::Rect::from_two_pos(
// egui::Pos2::new(-width, -height),
// egui::Pos2::new(width, height),
// );
// }
// if ui
// .add(egui::RadioButton::new(self.axis == VolumeAxis::Y, "Y-Axis"))
// .clicked()
// {
// self.axis = VolumeAxis::Y;
// self.slice_position = self.dimensions.1 / 2;
// let height = self.dimensions.0 as f32 * self.spacing.0;
// let width = self.dimensions.2 as f32 * self.spacing.2;
// self.scale = egui::Rect::from_two_pos(
// egui::Pos2::new(-width, -height),
// egui::Pos2::new(width, height),
// );
// }
// if ui
// .add(egui::RadioButton::new(self.axis == VolumeAxis::Z, "Z-Axis"))
// .clicked()
// {
// self.axis = VolumeAxis::Z;
// self.slice_position = self.dimensions.2 / 2;
// let height = self.dimensions.0 as f32 * self.spacing.0;
// let width = self.dimensions.1 as f32 * self.spacing.1;
// self.scale = egui::Rect::from_two_pos(
// egui::Pos2::new(-width, -height),
// egui::Pos2::new(width, height),
// );
// }
// });
}
}

Expand Down
Loading

0 comments on commit 4808219

Please sign in to comment.