mirror of https://codeberg.org/topola/topola.git
egui: add "Autoroute" button
Not functional yet as I still haven't implemented `Autorouter::autoroute()`
This commit is contained in:
parent
5664b73494
commit
9c332bdde3
|
|
@ -4,9 +4,9 @@ use spade::InsertionError;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
autorouter::ratsnest::{Ratsnest, RatsnestVertexIndex},
|
autorouter::ratsnest::{Ratsnest, RatsnestVertexIndex},
|
||||||
drawing::rules::RulesTrait,
|
drawing::{dot::FixedDotIndex, rules::RulesTrait},
|
||||||
layout::Layout,
|
layout::{connectivity::BandIndex, Layout},
|
||||||
router::Router,
|
router::{Router, RouterObserverTrait, RoutingError},
|
||||||
triangulation::GetVertexIndex,
|
triangulation::GetVertexIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -23,13 +23,13 @@ impl<R: RulesTrait> Autorouter<R> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autoroute(&mut self) {
|
pub fn autoroute(&mut self, observer: &mut impl RouterObserverTrait<R>) {
|
||||||
//for ratline in self.overlay.ratsnest().graph().edge_references() {
|
//for ratline in self.overlay.ratsnest().graph().edge_references() {
|
||||||
|
|
||||||
// For now, let's only take the first ratline.
|
// For now, let's only take the first ratline.
|
||||||
let ratline = self.ratsnest.graph().edge_references().next().unwrap();
|
let ratline = self.ratsnest.graph().edge_references().next().unwrap();
|
||||||
|
|
||||||
self.route(
|
/*self.route(
|
||||||
self.ratsnest
|
self.ratsnest
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(ratline.source())
|
.node_weight(ratline.source())
|
||||||
|
|
@ -40,13 +40,29 @@ impl<R: RulesTrait> Autorouter<R> {
|
||||||
.node_weight(ratline.target())
|
.node_weight(ratline.target())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index(),
|
.vertex_index(),
|
||||||
);
|
observer,
|
||||||
|
);*/
|
||||||
|
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn route(&mut self, from: RatsnestVertexIndex, to: RatsnestVertexIndex) {
|
fn route(
|
||||||
todo!();
|
&mut self,
|
||||||
|
from: RatsnestVertexIndex,
|
||||||
|
to: RatsnestVertexIndex,
|
||||||
|
observer: &mut impl RouterObserverTrait<R>,
|
||||||
|
) -> Result<BandIndex, RoutingError> {
|
||||||
|
let from_dot = self.terminating_dot(from);
|
||||||
|
let to_dot = self.terminating_dot(to);
|
||||||
|
|
||||||
|
self.router.route_band(from_dot, to_dot, 3.0, observer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn terminating_dot(&mut self, vertex: RatsnestVertexIndex) -> FixedDotIndex {
|
||||||
|
match vertex {
|
||||||
|
RatsnestVertexIndex::FixedDot(dot) => dot,
|
||||||
|
RatsnestVertexIndex::Zone(zone) => self.router.layout_mut().zone_apex(zone),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn router(&self) -> &Router<R> {
|
pub fn router(&self) -> &Router<R> {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
|
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::Autorouter,
|
autorouter::Autorouter,
|
||||||
drawing::{graph::MakePrimitive, primitive::MakePrimitiveShape, Drawing},
|
drawing::{graph::MakePrimitive, primitive::MakePrimitiveShape, rules::RulesTrait, Drawing},
|
||||||
dsn::{design::DsnDesign, rules::DsnRules},
|
dsn::{design::DsnDesign, rules::DsnRules},
|
||||||
geometry::{
|
geometry::{
|
||||||
compound::CompoundManagerTrait,
|
compound::CompoundManagerTrait,
|
||||||
|
|
@ -17,6 +17,12 @@ use topola::{
|
||||||
},
|
},
|
||||||
layout::{zone::MakePolyShape, Layout},
|
layout::{zone::MakePolyShape, Layout},
|
||||||
math::Circle,
|
math::Circle,
|
||||||
|
router::{
|
||||||
|
draw::DrawException,
|
||||||
|
navmesh::{NavmeshEdgeReference, VertexIndex},
|
||||||
|
tracer::{Trace, Tracer},
|
||||||
|
RouterObserverTrait,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{overlay::Overlay, painter::Painter};
|
use crate::{overlay::Overlay, painter::Painter};
|
||||||
|
|
@ -61,6 +67,22 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct EmptyRouterObserver;
|
||||||
|
|
||||||
|
impl<R: RulesTrait> RouterObserverTrait<R> for EmptyRouterObserver {
|
||||||
|
fn on_rework(&mut self, _tracer: &Tracer<R>, _trace: &Trace) {}
|
||||||
|
fn before_probe(&mut self, _tracer: &Tracer<R>, _trace: &Trace, _edge: NavmeshEdgeReference) {}
|
||||||
|
fn on_probe(
|
||||||
|
&mut self,
|
||||||
|
_tracer: &Tracer<R>,
|
||||||
|
_trace: &Trace,
|
||||||
|
_edge: NavmeshEdgeReference,
|
||||||
|
_result: Result<(), DrawException>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: VertexIndex) {}
|
||||||
|
}
|
||||||
|
|
||||||
impl eframe::App for App {
|
impl eframe::App for App {
|
||||||
/// Called to save state before shutdown.
|
/// Called to save state before shutdown.
|
||||||
fn save(&mut self, storage: &mut dyn eframe::Storage) {
|
fn save(&mut self, storage: &mut dyn eframe::Storage) {
|
||||||
|
|
@ -112,7 +134,16 @@ impl eframe::App for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.add_space(16.0);
|
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
if ui.button("Autoroute").clicked() {
|
||||||
|
if let Some(ref mut autorouter) = &mut self.autorouter {
|
||||||
|
autorouter.autoroute(&mut EmptyRouterObserver {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
egui::widgets::global_dark_light_mode_buttons(ui);
|
egui::widgets::global_dark_light_mode_buttons(ui);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -197,4 +197,8 @@ impl<R: RulesTrait> Router<R> {
|
||||||
pub fn layout(&self) -> &Layout<R> {
|
pub fn layout(&self) -> &Layout<R> {
|
||||||
&self.layout
|
&self.layout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn layout_mut(&mut self) -> &mut Layout<R> {
|
||||||
|
&mut self.layout
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue