use brep_render::controls::{BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT};
use brep_render::engine_state::EngineState;
use brep_render::pick::PickCandidate;
use brep_render::style::MultiSelectMode;
use brep_render::render::{FrameParams, GpuScene, RenderCore, COLOR_FORMAT};
use eframe::egui;
use eframe::egui_wgpu;
use std::sync::Arc;
struct ViewportPaint {
pipeline: wgpu::RenderPipeline,
bind_group: wgpu::BindGroup,
}
struct ViewportCallback;
struct Offscreen {
view: wgpu::TextureView,
w: u32,
h: u32,
}
struct CandidatePopup {
anchor: egui::Pos2,
candidates: Vec<PickCandidate>,
}
pub struct Viewport {
core: RenderCore,
gpu_scene: GpuScene,
egui_renderer: Arc<egui::mutex::RwLock<egui_wgpu::Renderer>>,
blit_layout: wgpu::BindGroupLayout,
blit_sampler: wgpu::Sampler,
blit_pipeline: wgpu::RenderPipeline,
offscreen: Option<Offscreen>,
dragging: bool,
gizmo_dragging: bool,
component_gizmo_dragging: bool,
dim_dragging: Option<String>,
sketch_dragging: bool,
sketch_handdrawing: bool,
last_rect: Option<egui::Rect>,
candidate_popup: Option<CandidatePopup>,
candidate_popup_fresh: bool,
candidate_popup_rect: Option<egui::Rect>,
candidate_hits: Vec<egui::Rect>,
editing_dim: Option<(serde_json::Value, String)>,
dim_edit_fresh: bool,
editing_feature_dim: Option<(String, String, String)>,
feature_dim_edit_fresh: bool,
constraint_dragging: bool,
constraint_label_hovered: Option<String>,
pmi_label_hovered: Option<String>,
pmi_label_dragging: Option<String>,
pmi_label_hits: Vec<(String, egui::Rect)>,
}
impl Viewport {
pub fn forget_document(&mut self) {
self.gpu_scene = GpuScene::default();
self.close_candidate_popup();
self.candidate_hits.clear();
self.editing_dim = None;
self.editing_feature_dim = None;
self.constraint_label_hovered = None;
self.pmi_label_hovered = None;
self.pmi_label_dragging = None;
self.pmi_label_hits.clear();
self.dragging = false;
self.gizmo_dragging = false;
self.component_gizmo_dragging = false;
self.dim_dragging = None;
self.sketch_dragging = false;
self.sketch_handdrawing = false;
self.constraint_dragging = false;
}
pub fn close_candidate_popup(&mut self) -> bool {
let was_open = self.candidate_popup.is_some();
self.candidate_popup = None;
self.candidate_popup_rect = None;
was_open
}
}
mod blit;
mod interaction;
mod labels;
pub static HIT_KEYS: &[crate::automation::hit_keys::HitKeyDoc] = &[
crate::automation::hit_keys::HitKeyDoc { panel: "candidate", prefix: "", meaning: "one rect per entry of the open pick-candidate popup, keyed by index", command: None },
crate::automation::hit_keys::HitKeyDoc { panel: "pmilabel", prefix: "", meaning: "one rect per PMI label chip, keyed by annotation id", command: None },
];