@@ -95,14 +95,14 @@ pub struct ConnectionManager {
9595}
9696
9797impl ConnectionManager {
98- pub fn new ( db : & Circuit , canvas_config : & CanvasConfig ) -> Self {
98+ pub fn new ( circuit : & Circuit , canvas_config : & CanvasConfig ) -> Self {
9999 let mut new = Self {
100100 dirty_instances : Default :: default ( ) ,
101101 spatial_index : Default :: default ( ) ,
102102 pin_position_cache : Default :: default ( ) ,
103103 canvas_config : canvas_config. clone ( ) ,
104104 } ;
105- new. rebuild_spatial_index ( db ) ;
105+ new. rebuild_spatial_index ( circuit ) ;
106106 new
107107 }
108108
@@ -119,14 +119,14 @@ impl ConnectionManager {
119119 }
120120
121121 /// Update the spatial index for all pins in the database
122- pub fn rebuild_spatial_index ( & mut self , db : & Circuit ) {
122+ pub fn rebuild_spatial_index ( & mut self , circuit : & Circuit ) {
123123 self . spatial_index . clear ( ) ;
124124 self . pin_position_cache . clear ( ) ;
125125
126126 // Index all pins by their grid cell
127- for ( instance_id, _) in & db . types {
128- for pin in db . pins_of ( instance_id) {
129- let pos = db . pin_position ( pin, & self . canvas_config ) ;
127+ for ( instance_id, _) in & circuit . types {
128+ for pin in circuit . pins_of ( instance_id) {
129+ let pos = circuit . pin_position ( pin, & self . canvas_config ) ;
130130 let cell = GridCell :: from_pos ( pos) ;
131131
132132 self . spatial_index . entry ( cell) . or_default ( ) . push ( pin) ;
@@ -137,9 +137,9 @@ impl ConnectionManager {
137137 }
138138
139139 /// Update spatial index for specific pins that have moved
140- fn update_spatial_index_for_pins ( & mut self , db : & Circuit , pins : & [ Pin ] ) {
140+ fn update_spatial_index_for_pins ( & mut self , circuit : & Circuit , pins : & [ Pin ] ) {
141141 for & pin in pins {
142- let new_pos = db . pin_position ( pin, & self . canvas_config ) ;
142+ let new_pos = circuit . pin_position ( pin, & self . canvas_config ) ;
143143
144144 // Remove from old cell if position changed
145145 if let Some ( old_pos) = self . pin_position_cache . get ( & pin)
@@ -161,10 +161,10 @@ impl ConnectionManager {
161161 }
162162
163163 /// Find potential connections for a pin using spatial indexing
164- pub fn find_connections_for_pin ( & self , db : & Circuit , pin : Pin ) -> Vec < Connection > {
164+ pub fn find_connections_for_pin ( & self , circuit : & Circuit , pin : Pin ) -> Vec < Connection > {
165165 let mut wire_connections = Vec :: new ( ) ;
166166 let mut non_wire_connections = Vec :: new ( ) ;
167- let pin_pos = db . pin_position ( pin, & self . canvas_config ) ;
167+ let pin_pos = circuit . pin_position ( pin, & self . canvas_config ) ;
168168 let cell = GridCell :: from_pos ( pin_pos) ;
169169
170170 // Check this cell and neighboring cells
@@ -175,7 +175,7 @@ impl ConnectionManager {
175175 continue ;
176176 }
177177
178- let other_pos = db . pin_position ( other_pin, & self . canvas_config ) ;
178+ let other_pos = circuit . pin_position ( other_pin, & self . canvas_config ) ;
179179 let distance = ( pin_pos - other_pos) . length ( ) ;
180180
181181 // First pin will move to attach
@@ -186,7 +186,7 @@ impl ConnectionManager {
186186 } ;
187187
188188 if distance <= SNAP_THRESHOLD && self . validate_connection ( connection) {
189- let is_wire = matches ! ( db . ty( other_pin. ins) , InstanceKind :: Wire ) ;
189+ let is_wire = matches ! ( circuit . ty( other_pin. ins) , InstanceKind :: Wire ) ;
190190 if is_wire {
191191 wire_connections. push ( connection) ;
192192 } else {
@@ -198,7 +198,7 @@ impl ConnectionManager {
198198 }
199199
200200 // For wire pins, prefer non-wire connections over wire connections
201- if matches ! ( db . ty( pin. ins) , InstanceKind :: Wire ) && !non_wire_connections. is_empty ( ) {
201+ if matches ! ( circuit . ty( pin. ins) , InstanceKind :: Wire ) && !non_wire_connections. is_empty ( ) {
202202 non_wire_connections
203203 } else {
204204 let mut all = non_wire_connections;
@@ -281,21 +281,21 @@ impl ConnectionManager {
281281 }
282282 }
283283
284- pub fn pins_to_update ( & mut self , db : & Circuit ) -> Vec < Pin > {
284+ pub fn pins_to_update ( & mut self , circuit : & Circuit ) -> Vec < Pin > {
285285 let mut pins_to_update = Vec :: new ( ) ;
286286
287287 for & instance_id in & self . dirty_instances {
288- for pin in db . pins_of ( instance_id) {
288+ for pin in circuit . pins_of ( instance_id) {
289289 pins_to_update. push ( pin) ;
290290 }
291291 }
292292 pins_to_update. sort_unstable ( ) ;
293293 pins_to_update. dedup ( ) ;
294294
295- if pins_to_update. len ( ) > db . types . len ( ) / 4 {
296- self . rebuild_spatial_index ( db ) ;
295+ if pins_to_update. len ( ) > circuit . types . len ( ) / 4 {
296+ self . rebuild_spatial_index ( circuit ) ;
297297 } else {
298- self . update_spatial_index_for_pins ( db , & pins_to_update) ;
298+ self . update_spatial_index_for_pins ( circuit , & pins_to_update) ;
299299 }
300300 pins_to_update
301301 }
0 commit comments