KiCad PCB EDA Suite
sch_screen.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <common.h>
33 #include <eda_rect.h>
34 #include <eeschema_id.h>
35 #include <fctsys.h>
36 #include <gr_basic.h>
37 #include <gr_text.h>
38 #include <id.h>
39 #include <kicad_string.h>
40 #include <kiway.h>
41 #include <pgm_base.h>
42 #include <plotter.h>
43 #include <project.h>
44 #include <sch_draw_panel.h>
45 #include <sch_edit_frame.h>
46 #include <sch_item.h>
47 
48 #include <class_library.h>
49 #include <connection_graph.h>
50 #include <lib_pin.h>
51 #include <netlist.h>
52 #include <netlist_object.h>
53 #include <sch_bus_entry.h>
54 #include <sch_component.h>
55 #include <sch_junction.h>
56 #include <sch_line.h>
57 #include <sch_marker.h>
58 #include <sch_no_connect.h>
59 #include <sch_rtree.h>
60 #include <sch_sheet.h>
61 #include <sch_text.h>
62 #include <symbol_lib_table.h>
63 #include <tool/common_tools.h>
64 
65 #include <thread>
66 #include <algorithm>
67 #include <future>
68 #include <array>
69 
70 // TODO(JE) Debugging only
71 #include <profile.h>
72 
73 #define EESCHEMA_FILE_STAMP "EESchema"
74 #define ZOOM_FACTOR( x ) ( x * IU_PER_MILS )
75 
76 
77 /* Default zoom values. Limited to these values to keep a decent size
78  * to menus
79  */
80 static double SchematicZoomList[] =
81 {
82  ZOOM_FACTOR( 0.5 ),
83  ZOOM_FACTOR( 0.7 ),
84  ZOOM_FACTOR( 1.0 ),
85  ZOOM_FACTOR( 1.5 ),
86  ZOOM_FACTOR( 2.0 ),
87  ZOOM_FACTOR( 3.0 ),
88  ZOOM_FACTOR( 4.0 ),
89  ZOOM_FACTOR( 6.0 ),
90  ZOOM_FACTOR( 8.0 ),
91  ZOOM_FACTOR( 11.0 ),
92  ZOOM_FACTOR( 13.0 ),
93  ZOOM_FACTOR( 16.0 ),
94  ZOOM_FACTOR( 20.0 ),
95  ZOOM_FACTOR( 26.0 ),
96  ZOOM_FACTOR( 32.0 ),
97  ZOOM_FACTOR( 48.0 ),
98  ZOOM_FACTOR( 64.0 ),
99  ZOOM_FACTOR( 80.0 ),
100  ZOOM_FACTOR( 128.0 )
101 };
102 
103 
104 /* Default grid sizes for the schematic editor.
105  * Do NOT add others values (mainly grid values in mm), because they
106  * can break the schematic: Because wires and pins are considered as
107  * connected when the are to the same coordinate we cannot mix
108  * coordinates in mils (internal units) and mm (that cannot exactly
109  * converted in mils in many cases). In fact schematic must only use
110  * 50 and 25 mils to place labels, wires and components others values
111  * are useful only for graphic items (mainly in library editor) so use
112  * integer values in mils only. The 100 mil grid is added to help
113  * conform to the KiCad Library Convention. Which states: "Using a
114  * 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
115 */
117  { ID_POPUP_GRID_LEVEL_100, wxRealPoint( Mils2iu( 100 ), Mils2iu( 100 ) ) },
118  { ID_POPUP_GRID_LEVEL_50, wxRealPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) },
119  { ID_POPUP_GRID_LEVEL_25, wxRealPoint( Mils2iu( 25 ), Mils2iu( 25 ) ) },
120  { ID_POPUP_GRID_LEVEL_10, wxRealPoint( Mils2iu( 10 ), Mils2iu( 10 ) ) },
121  { ID_POPUP_GRID_LEVEL_5, wxRealPoint( Mils2iu( 5 ), Mils2iu( 5 ) ) },
122  { ID_POPUP_GRID_LEVEL_2, wxRealPoint( Mils2iu( 2 ), Mils2iu( 2 ) ) },
123  { ID_POPUP_GRID_LEVEL_1, wxRealPoint( Mils2iu( 1 ), Mils2iu( 1 ) ) },
124 };
125 
126 
129  KIWAY_HOLDER( aKiway, KIWAY_HOLDER::HOLDER_TYPE::SCREEN ),
130  m_paper( wxT( "A4" ) )
131 {
133 
134  SetZoom( 32 );
135 
136  for( unsigned zoom : SchematicZoomList )
137  m_ZoomList.push_back( zoom );
138 
139  for( GRID_TYPE grid : SchematicGridList )
140  AddGrid( grid );
141 
142  // Set the default grid size, now that the grid list is populated
143  SetGrid( wxRealPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) );
144 
145  m_refCount = 0;
146 
147  // Suitable for schematic only. For libedit and viewlib, must be set to true
148  m_Center = false;
149 
150  InitDataPoints( m_paper.GetSizeIU() );
151 }
152 
153 
155 {
157  FreeDrawList();
158 }
159 
160 
162 {
163  m_refCount++;
164 }
165 
166 
168 {
169  wxCHECK_RET( m_refCount != 0,
170  wxT( "Screen reference count already zero. Bad programmer!" ) );
171  m_refCount--;
172 }
173 
174 
176 {
177  if( aItem->Type() != SCH_SHEET_PIN_T && aItem->Type() != SCH_FIELD_T )
178  {
179  m_rtree.insert( aItem );
181  }
182 }
183 
184 
186 {
187  wxCHECK_RET( aScreen, "Invalid screen object." );
188 
189  // No need to descend the hierarchy. Once the top level screen is copied, all of it's
190  // children are copied as well.
191  for( auto aItem : aScreen->m_rtree )
192  Append( aItem );
193 
194  aScreen->Clear( false );
195 }
196 
197 
198 void SCH_SCREEN::Clear( bool aFree )
199 {
200  if( aFree )
201  FreeDrawList();
202  else
203  m_rtree.clear();
204 
205  // Clear the project settings
207 
208  m_titles.Clear();
209 }
210 
211 
213 {
214  // We don't know which order we will encounter dependent items (e.g. pins or fields), so
215  // we store the items to be deleted until we've fully cleared the tree before deleting
216  std::vector<SCH_ITEM*> delete_list;
217 
218  std::copy_if( m_rtree.begin(), m_rtree.end(), std::back_inserter( delete_list ),
219  []( SCH_ITEM* aItem )
220  {
221  return ( aItem->Type() != SCH_SHEET_PIN_T && aItem->Type() != SCH_FIELD_T );
222  } );
223 
224  m_rtree.clear();
225 
226  for( auto item : delete_list )
227  delete item;
228 }
229 
230 
232 {
233  if( Remove( aItem ) )
234  Append( aItem );
235 }
236 
237 
239 {
240  return m_rtree.remove( aItem );
241 }
242 
243 
245 {
246  wxCHECK_RET( aItem, wxT( "Cannot delete invalid item from screen." ) );
247 
248  SetModify();
249  Remove( aItem );
250 
251  if( aItem->Type() == SCH_SHEET_PIN_T )
252  {
253  // This structure is attached to a sheet, get the parent sheet object.
254  SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
255  SCH_SHEET* sheet = sheetPin->GetParent();
256  wxCHECK_RET( sheet, wxT( "Sheet label parent not properly set, bad programmer!" ) );
257  sheet->RemovePin( sheetPin );
258  return;
259  }
260  else
261  {
262  delete aItem;
263  }
264 }
265 
266 
268 {
269  return m_rtree.contains( aItem, true );
270 }
271 
272 
273 SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType )
274 {
275  EDA_RECT bbox;
276  bbox.SetOrigin( aPosition );
277  bbox.Inflate( aAccuracy );
278 
279  for( auto item : Items().Overlapping( aType, bbox ) )
280  {
281  if( item->HitTest( aPosition, aAccuracy ) )
282  return item;
283  }
284 
285  return nullptr;
286 }
287 
288 
289 std::set<SCH_ITEM*> SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
290 {
291  std::set<SCH_ITEM*> retval;
292  std::stack<SCH_LINE*> to_search;
293 
294  wxCHECK_MSG( ( aSegment ) && ( aSegment->Type() == SCH_LINE_T ), retval,
295  wxT( "Invalid object pointer." ) );
296 
297  to_search.push( aSegment );
298 
299  while( !to_search.empty() )
300  {
301  auto test_item = to_search.top();
302  to_search.pop();
303 
304  for( auto item : Items().Overlapping( SCH_JUNCTION_T, test_item->GetBoundingBox() ) )
305  {
306  if( test_item->IsEndPoint( item->GetPosition() ) )
307  retval.insert( item );
308  }
309 
310  for( auto item : Items().Overlapping( SCH_LINE_T, test_item->GetBoundingBox() ) )
311  {
312  // Skip connecting lines on different layers (e.g. busses)
313  if( test_item->GetLayer() != item->GetLayer() )
314  continue;
315 
316  auto line = static_cast<SCH_LINE*>( item );
317 
318  if( ( test_item->IsEndPoint( line->GetStartPoint() )
319  && !GetPin( line->GetStartPoint(), NULL, true ) )
320  || ( test_item->IsEndPoint( line->GetEndPoint() )
321  && !GetPin( line->GetEndPoint(), nullptr, true ) ) )
322  {
323  auto result = retval.insert( line );
324 
325  if( result.second )
326  to_search.push( line );
327  }
328  }
329  }
330 
331  return retval;
332 }
333 
334 
335 bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
336 {
337  enum { WIRES, BUSSES } layers;
338 
339  bool has_nonparallel[ sizeof( layers ) ] = { false };
340  int end_count[ sizeof( layers ) ] = { 0 };
341  int pin_count = 0;
342 
343  std::vector<SCH_LINE*> lines[ sizeof( layers ) ];
344 
345  for( auto item : Items().Overlapping( aPosition ) )
346  {
347  if( item->GetEditFlags() & STRUCT_DELETED )
348  continue;
349 
350  if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) )
351  return false;
352 
353  if( ( item->Type() == SCH_LINE_T ) && ( item->HitTest( aPosition, 0 ) ) )
354  {
355  if( item->GetLayer() == LAYER_WIRE )
356  lines[WIRES].push_back( (SCH_LINE*) item );
357  else if( item->GetLayer() == LAYER_BUS )
358  lines[BUSSES].push_back( (SCH_LINE*) item );
359  }
360 
361  if( ( ( item->Type() == SCH_COMPONENT_T ) || ( item->Type() == SCH_SHEET_T ) )
362  && ( item->IsConnected( aPosition ) ) )
363  pin_count++;
364  }
365 
366  for( int i : { WIRES, BUSSES } )
367  {
368  bool removed_overlapping = false;
369  bool mid_point = false;
370 
371  for( auto line = lines[i].begin(); line < lines[i].end(); line++ )
372  {
373  if( !(*line)->IsEndPoint( aPosition ) )
374  mid_point = true;
375  else
376  end_count[i]++;
377 
378  for( auto second_line = lines[i].end() - 1; second_line > line; second_line-- )
379  {
380  if( !(*line)->IsParallel( *second_line ) )
381  has_nonparallel[i] = true;
382  else if( !removed_overlapping
383  && (*line)->IsSameQuadrant( *second_line, aPosition ) )
384  {
385  removed_overlapping = true;
386  }
387  }
388  }
389 
393  if( mid_point )
394  end_count[i] += 2;
395 
398  if( removed_overlapping )
399  end_count[i]--;
400  }
401 
402  // If there are three or more endpoints
403  if( pin_count && pin_count + end_count[WIRES] > 2 )
404  return true;
405 
406  // If there is at least one segment that ends on a non-parallel line or
407  // junction of two other lines
408  if( has_nonparallel[WIRES] && end_count[WIRES] > 2 )
409  return true;
410 
411  // Check for bus - bus junction requirements
412  if( has_nonparallel[BUSSES] && end_count[BUSSES] > 2 )
413  return true;
414 
415  return false;
416 }
417 
418 
419 bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
420 {
421  wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false,
422  wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) );
423 
424  SCH_SHEET_PIN* label;
425  SCH_TEXT* text;
426  SCH_CONNECTION conn;
427 
428  switch( aLayer )
429  {
430  case LAYER_BUS:
431 
432  if( GetBus( aPosition ) )
433  return true;
434 
435  label = GetSheetLabel( aPosition );
436 
437  if( label && conn.IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) )
438  return true;
439 
440  text = GetLabel( aPosition );
441 
442  if( text && conn.IsBusLabel( text->GetText() ) && text->IsConnected( aPosition )
443  && (text->Type() != SCH_LABEL_T) )
444  return true;
445 
446  break;
447 
448  case LAYER_NOTES:
449 
450  if( GetLine( aPosition ) )
451  return true;
452 
453  break;
454 
455  case LAYER_WIRE:
456  if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_WIRE_ENTRY_T) )
457  return true;
458 
459  if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) )
460  return true;
461 
462  if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) )
463  return true;
464 
465  if( GetPin( aPosition, NULL, true ) )
466  return true;
467 
468  if( GetWire( aPosition ) )
469  return true;
470 
471  text = GetLabel( aPosition );
472 
473  if( text && text->IsConnected( aPosition ) && !conn.IsBusLabel( text->GetText() ) )
474  return true;
475 
476  label = GetSheetLabel( aPosition );
477 
478  if( label && label->IsConnected( aPosition ) && !conn.IsBusLabel( label->GetText() ) )
479  return true;
480 
481  break;
482 
483  default:
484  break;
485  }
486 
487  return false;
488 }
489 
490 
491 void SCH_SCREEN::UpdateSymbolLinks( bool aForce )
492 {
493  // Initialize or reinitialize the pointer to the LIB_PART for each component
494  // found in m_drawList, but only if needed (change in lib or schematic)
495  // therefore the calculation time is usually very low.
496  if( !IsEmpty() )
497  {
498  std::vector<SCH_COMPONENT*> cmps;
499  SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
500  int mod_hash = libs->GetModifyHash();
501 
502  for( auto aItem : Items().OfType( SCH_COMPONENT_T ) )
503  cmps.push_back( static_cast<SCH_COMPONENT*>( aItem ) );
504 
505  for( auto cmp : cmps )
506  Remove( cmp );
507 
508  // Must we resolve?
509  if( (m_modification_sync != mod_hash) || aForce )
510  {
511  SCH_COMPONENT::ResolveAll( cmps, *libs, Prj().SchLibs()->GetCacheLibrary() );
512 
513  m_modification_sync = mod_hash; // note the last mod_hash
514  }
515  // Resolving will update the pin caches but we must ensure that this happens
516  // even if the libraries don't change.
517  else
518  {
519  for( auto cmp : cmps )
520  cmp->UpdatePins();
521  }
522 
523  // Changing the symbol may adjust the bbox of the symbol. This re-inserts the
524  // item with the new bbox
525  for( auto cmp : cmps )
526  Append( cmp );
527  }
528 }
529 
530 
531 void SCH_SCREEN::Print( wxDC* aDC )
532 {
533  // Ensure links are up to date, even if a library was reloaded for some reason:
534  std::vector< SCH_ITEM* > junctions;
535  std::vector<SCH_ITEM*> bitmaps;
536  std::vector<SCH_ITEM*> other;
537 
538  // Ensure links are up to date, even if a library was reloaded for some reason:
540 
541  for( auto item : Items() )
542  {
543  if( item->IsMoving() || item->IsResized() )
544  continue;
545 
546  if( item->Type() == SCH_JUNCTION_T )
547  junctions.push_back( item );
548  else if( item->Type() == SCH_BITMAP_T )
549  bitmaps.push_back( item );
550  else
551  other.push_back( item );
552  }
553 
555  std::sort( other.begin(), other.end(), []( const SCH_ITEM* a, const SCH_ITEM* b ) {
556  if( a->Type() == b->Type() )
557  return a->GetLayer() > b->GetLayer();
558 
559  return a->Type() > b->Type();
560  } );
561 
562  for( auto item : bitmaps )
563  item->Print( aDC, wxPoint( 0, 0 ) );
564 
565  for( auto item : other )
566  item->Print( aDC, wxPoint( 0, 0 ) );
567 
568  for( auto item : junctions )
569  item->Print( aDC, wxPoint( 0, 0 ) );
570 }
571 
572 
573 void SCH_SCREEN::Plot( PLOTTER* aPlotter )
574 {
575  // Ensure links are up to date, even if a library was reloaded for some reason:
576  std::vector< SCH_ITEM* > junctions;
577  std::vector< SCH_ITEM* > bitmaps;
578  std::vector< SCH_ITEM* > other;
579 
580  // Ensure links are up to date, even if a library was reloaded for some reason:
582 
583  for( auto item : Items() )
584  {
585  if( item->IsMoving() || item->IsResized() )
586  continue;
587 
588  if( item->Type() == SCH_JUNCTION_T )
589  junctions.push_back( item );
590  else if( item->Type() == SCH_BITMAP_T )
591  bitmaps.push_back( item );
592  else
593  other.push_back( item );
594  }
595 
597  std::sort( other.begin(), other.end(), []( const SCH_ITEM* a, const SCH_ITEM* b ) {
598  if( a->Type() == b->Type() )
599  return a->GetLayer() > b->GetLayer();
600 
601  return a->Type() > b->Type();
602  } );
603 
604  // Bitmaps are drawn first to ensure they are in the background
605  // This is particularly important for the wxPostscriptDC (used in *nix printers) as
606  // the bitmap PS command clears the screen
607  for( auto item : bitmaps )
608  {
609  aPlotter->SetCurrentLineWidth( item->GetPenSize() );
610  item->Plot( aPlotter );
611  }
612 
613  for( auto item : other )
614  {
615  aPlotter->SetCurrentLineWidth( item->GetPenSize() );
616  item->Plot( aPlotter );
617  }
618 
619  for( auto item : junctions )
620  {
621  aPlotter->SetCurrentLineWidth( item->GetPenSize() );
622  item->Plot( aPlotter );
623  }
624 }
625 
626 
628 {
629  if( aItemCount == 0 )
630  return;
631 
632  for( auto& command : aList.m_CommandsList )
633  {
634  command->ClearListAndDeleteItems();
635  delete command;
636  }
637 
638  aList.m_CommandsList.clear();
639 }
640 
641 
643 {
644  for( auto item : Items() )
645  item->ClearTempFlags();
646 }
647 
648 
649 LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent,
650  bool aEndPointOnly )
651 {
652  SCH_COMPONENT* component = NULL;
653  LIB_PIN* pin = NULL;
654 
655  for( SCH_ITEM* item : Items().Overlapping( SCH_COMPONENT_T, aPosition ) )
656  {
657  component = static_cast<SCH_COMPONENT*>( item );
658 
659  if( aEndPointOnly )
660  {
661  pin = NULL;
662 
663  if( !component->GetPartRef() )
664  continue;
665 
666  for( pin = component->GetPartRef()->GetNextPin(); pin;
667  pin = component->GetPartRef()->GetNextPin( pin ) )
668  {
669  // Skip items not used for this part.
670  if( component->GetUnit() && pin->GetUnit() &&
671  ( pin->GetUnit() != component->GetUnit() ) )
672  continue;
673 
674  if( component->GetConvert() && pin->GetConvert() &&
675  ( pin->GetConvert() != component->GetConvert() ) )
676  continue;
677 
678  if(component->GetPinPhysicalPosition( pin ) == aPosition )
679  break;
680  }
681  if( pin )
682  break;
683  }
684  else
685  {
686  pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T );
687 
688  if( pin )
689  break;
690  }
691  }
692 
693  if( pin && aComponent )
694  *aComponent = component;
695 
696  return pin;
697 }
698 
699 
701 {
702  SCH_SHEET_PIN* sheetPin = nullptr;
703 
704  for( SCH_ITEM* item : Items().OfType( SCH_SHEET_T ) )
705  {
706  auto sheet = static_cast<SCH_SHEET*>( item );
707 
708  sheetPin = sheet->GetPin( aPosition );
709 
710  if( sheetPin )
711  break;
712  }
713 
714  return sheetPin;
715 }
716 
717 
718 size_t SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions )
719 {
720  size_t count = 0;
721 
722  for( SCH_ITEM* item : Items() )
723  {
724  if( ( item->Type() != SCH_JUNCTION_T || aTestJunctions ) && item->IsConnected( aPos ) )
725  count++;
726  }
727 
728  return count;
729 }
730 
731 
733 {
734 
735  for( SCH_ITEM* item : Items().OfType( SCH_COMPONENT_T ) )
736  {
737  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
738 
739  component->ClearAnnotation( aSheetPath );
740 
741  // Clear the modified component flag set by component->ClearAnnotation
742  // because we do not use it here and we should not leave this flag set,
743  // when an editing is finished:
744  component->ClearFlags();
745  }
746 }
747 
748 
750 {
751  if( GetClientSheetPathsCount() <= 1 ) // No need for alternate reference
752  return;
753 
754  for( SCH_ITEM* item : Items().OfType( SCH_COMPONENT_T ) )
755  {
756  auto component = static_cast<SCH_COMPONENT*>( item );
757 
758  // Add (when not existing) all sheet path entries
759  for( unsigned int ii = 0; ii < m_clientSheetPathList.GetCount(); ii++ )
760  component->AddSheetPathReferenceEntryIfMissing( m_clientSheetPathList[ii] );
761  }
762 }
763 
764 
766 {
767  for( SCH_ITEM* item : Items() )
768  {
769  if( ( item->Type() == SCH_SHEET_T ) || ( item->Type() == SCH_COMPONENT_T ) )
770  aItems.push_back( item );
771  }
772 }
773 
774 
776 {
777  std::vector< DANGLING_END_ITEM > endPoints;
778  bool hasStateChanged = false;
779 
780  for( SCH_ITEM* item : Items() )
781  item->GetEndPoints( endPoints );
782 
783  for( SCH_ITEM* item : Items() )
784  {
785  if( item->UpdateDanglingState( endPoints, aPath ) )
786  hasStateChanged = true;
787  }
788 
789  return hasStateChanged;
790 }
791 
792 
793 SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer,
794  SCH_LINE_TEST_T aSearchType )
795 {
796  for( SCH_ITEM* item : Items() )
797  {
798  if( item->Type() != SCH_LINE_T )
799  continue;
800 
801  if( item->GetLayer() != aLayer )
802  continue;
803 
804  if( !item->HitTest( aPosition, aAccuracy ) )
805  continue;
806 
807  switch( aSearchType )
808  {
809  case ENTIRE_LENGTH_T:
810  return (SCH_LINE*) item;
811 
813  if( !( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
814  return (SCH_LINE*) item;
815  break;
816 
817  case END_POINTS_ONLY_T:
818  if( ( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
819  return (SCH_LINE*) item;
820  }
821  }
822 
823  return NULL;
824 }
825 
826 
827 SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
828 {
829  for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) )
830  {
831  switch( item->Type() )
832  {
833  case SCH_LABEL_T:
834  case SCH_GLOBAL_LABEL_T:
835  case SCH_HIER_LABEL_T:
836  if( item->HitTest( aPosition, aAccuracy ) )
837  return (SCH_TEXT*) item;
838 
839  default:
840  ;
841  }
842  }
843 
844  return NULL;
845 }
846 
847 
848 bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
849  const wxString& aFootPrint, bool aSetVisible )
850 {
851  SCH_COMPONENT* component;
852  bool found = false;
853 
854  for( SCH_ITEM* item : Items().OfType( SCH_COMPONENT_T ) )
855  {
856  component = static_cast<SCH_COMPONENT*>( item );
857 
858  if( aReference.CmpNoCase( component->GetRef( aSheetPath ) ) == 0 )
859  {
860  // Found: Init Footprint Field
861 
862  /* Give a reasonable value to the field position and
863  * orientation, if the text is empty at position 0, because
864  * it is probably not yet initialized
865  */
866  SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
867  if( fpfield->GetText().IsEmpty()
868  && ( fpfield->GetTextPos() == component->GetPosition() ) )
869  {
870  fpfield->SetTextAngle( component->GetField( VALUE )->GetTextAngle() );
871  fpfield->SetTextPos( component->GetField( VALUE )->GetTextPos() );
872  fpfield->SetTextSize( component->GetField( VALUE )->GetTextSize() );
873 
874  if( fpfield->GetTextAngle() == 0.0 )
875  fpfield->Offset( wxPoint( 0, Mils2iu( 100 ) ) );
876  else
877  fpfield->Offset( wxPoint( Mils2iu( 100 ), 0 ) );
878  }
879 
880  fpfield->SetText( aFootPrint );
881  fpfield->SetVisible( aSetVisible );
882 
883  found = true;
884  }
885  }
886 
887  return found;
888 }
889 
890 
891 void SCH_SCREEN::AddBusAlias( std::shared_ptr<BUS_ALIAS> aAlias )
892 {
893  m_aliases.insert( aAlias );
894 }
895 
896 
897 bool SCH_SCREEN::IsBusAlias( const wxString& aLabel )
898 {
899  SCH_SHEET_LIST aSheets( g_RootSheet );
900  for( unsigned i = 0; i < aSheets.size(); i++ )
901  {
902  for( const auto& alias : aSheets[i].LastScreen()->GetBusAliases() )
903  {
904  if( alias->GetName() == aLabel )
905  {
906  return true;
907  }
908  }
909  }
910 
911  return false;
912 }
913 
914 
915 std::shared_ptr<BUS_ALIAS> SCH_SCREEN::GetBusAlias( const wxString& aLabel )
916 {
917  SCH_SHEET_LIST aSheets( g_RootSheet );
918  for( unsigned i = 0; i < aSheets.size(); i++ )
919  {
920  for( auto alias : aSheets[i].LastScreen()->GetBusAliases() )
921  {
922  if( alias->GetName() == aLabel )
923  {
924  return alias;
925  }
926  }
927  }
928 
929  return NULL;
930 }
931 
932 
933 #if defined(DEBUG)
934 void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
935 {
936  // for now, make it look like XML, expand on this later.
937  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
938 
939  for( const SCH_ITEM* item : Items() )
940  item->Show( nestLevel + 1, os );
941 
942  NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
943 }
944 #endif
945 
946 
948 {
949  m_index = 0;
950  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
951 }
952 
953 
955 {
956 }
957 
958 
960 {
961  m_index = 0;
962 
963  if( m_screens.size() > 0 )
964  return m_screens[0];
965 
966  return NULL;
967 }
968 
969 
971 {
972  if( m_index < m_screens.size() )
973  m_index++;
974 
975  return GetScreen( m_index );
976 }
977 
978 
979 SCH_SCREEN* SCH_SCREENS::GetScreen( unsigned int aIndex ) const
980 {
981  if( aIndex < m_screens.size() )
982  return m_screens[ aIndex ];
983 
984  return NULL;
985 }
986 
987 
989 {
990  if( aScreen == NULL )
991  return;
992 
993  for( const SCH_SCREEN* screen : m_screens )
994  {
995  if( screen == aScreen )
996  return;
997  }
998 
999  m_screens.push_back( aScreen );
1000 }
1001 
1002 
1004 {
1005  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1006  {
1007  SCH_SCREEN* screen = aSheet->GetScreen();
1008 
1009  addScreenToList( screen );
1010 
1011  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1012  buildScreenList( static_cast<SCH_SHEET*>( item ) );
1013  }
1014 }
1015 
1016 
1018 {
1019  for( SCH_SCREEN* screen : m_screens )
1020  screen->ClearAnnotation( NULL );
1021 }
1022 
1023 
1025 {
1026  // Clear the annotation for the components inside new sheetpaths
1027  // not already in aInitialSheetList
1028  SCH_SCREENS screensList( g_RootSheet ); // The list of screens, shared by sheet paths
1029  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1030 
1031  // Search for new sheet paths, not existing in aInitialSheetPathList
1032  // and existing in sheetpathList
1033  SCH_SHEET_LIST sheetpathList( g_RootSheet );
1034 
1035  for( SCH_SHEET_PATH& sheetpath: sheetpathList )
1036  {
1037  bool path_exists = false;
1038 
1039  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1040  {
1041  if( existing_sheetpath.Path() == sheetpath.Path() )
1042  {
1043  path_exists = true;
1044  break;
1045  }
1046  }
1047 
1048  if( !path_exists )
1049  {
1050  // A new sheet path is found: clear the annotation corresponding to this new path:
1051  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1052 
1053  // Clear annotation and create the AR for this path, if not exists,
1054  // when the screen is shared by sheet paths.
1055  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1056  // reference default value and takes the latest displayed value
1057  curr_screen->EnsureAlternateReferencesExist();
1058  curr_screen->ClearAnnotation( &sheetpath );
1059  }
1060  }
1061 }
1062 
1063 
1065 {
1066  EDA_ITEMS items;
1067  int count = 0;
1068 
1069  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1070  {
1071  return a->m_Uuid < b->m_Uuid;
1072  };
1073 
1074  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1075 
1076  for( SCH_SCREEN* screen : m_screens )
1077  screen->GetHierarchicalItems( items );
1078 
1079  if( items.size() < 2 )
1080  return 0;
1081 
1082  for( EDA_ITEM* item : items )
1083  {
1084  if( !unique_stamps.insert( item ).second )
1085  {
1086  // Reset to fully random UUID. This may lose reference, but better to be
1087  // deterministic about it rather than to have duplicate UUIDs with random
1088  // side-effects.
1089  const_cast<KIID&>( item->m_Uuid ) = KIID();
1090  count++;
1091  }
1092  }
1093 
1094  return count;
1095 }
1096 
1097 
1099 {
1100  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1101  {
1102  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1103  {
1104  if( item == aMarker )
1105  {
1106  screen->DeleteItem( item );
1107  return;
1108  }
1109  }
1110  }
1111 }
1112 
1113 
1114 void SCH_SCREENS::DeleteMarkers( enum MARKER_BASE::TYPEMARKER aMarkerType, int aErrorCode )
1115 {
1116  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1117  {
1118  std::vector<SCH_ITEM*> markers;
1119 
1120  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1121  {
1122  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1123  RC_ITEM* rcItem = marker->GetRCItem();
1124 
1125  if( marker->GetMarkerType() == aMarkerType &&
1126  ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode ) )
1127  {
1128  markers.push_back( item );
1129  }
1130  }
1131 
1132  for( SCH_ITEM* marker : markers )
1133  screen->DeleteItem( marker );
1134  }
1135 }
1136 
1137 
1139 {
1140  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED );
1141 }
1142 
1143 
1145 {
1146  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1147  screen->UpdateSymbolLinks( aForce );
1148 
1149  SCH_SHEET_LIST sheets( g_RootSheet );
1150 
1151  // All of the library symbols have been replaced with copies so the connection graph
1152  // pointer are stale.
1153  if( g_ConnectionGraph )
1154  g_ConnectionGraph->Recalculate( sheets, true );
1155 }
1156 
1157 
1159 {
1160  std::vector<SCH_SCREEN*> screens;
1161  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1162  screens.push_back( screen );
1163 
1164  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
1165  screens.size() );
1166 
1167  std::atomic<size_t> nextScreen( 0 );
1168  std::vector<std::future<size_t>> returns( parallelThreadCount );
1169 
1170  auto update_lambda = [&screens, &nextScreen]() -> size_t
1171  {
1172  for( auto i = nextScreen++; i < screens.size(); i = nextScreen++ )
1173  screens[i]->TestDanglingEnds();
1174 
1175  return 1;
1176  };
1177 
1178  if( parallelThreadCount == 1 )
1179  update_lambda();
1180  else
1181  {
1182  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1183  returns[ii] = std::async( std::launch::async, update_lambda );
1184 
1185  // Finalize the threads
1186  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1187  returns[ii].wait();
1188  }
1189 }
1190 
1191 
1193 {
1194  SCH_SCREEN* screen;
1195  unsigned cnt = 0;
1196 
1197  for( screen = GetFirst(); screen; screen = GetNext() )
1198  {
1199  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1200  {
1201  cnt++;
1202  auto symbol = static_cast<SCH_COMPONENT*>( item );
1203 
1204  if( !symbol->GetLibId().GetLibNickname().empty() )
1205  return false;
1206  }
1207  }
1208 
1209  return cnt != 0;
1210 }
1211 
1212 
1213 size_t SCH_SCREENS::GetLibNicknames( wxArrayString& aLibNicknames )
1214 {
1215  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1216  {
1217  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1218  {
1219  auto symbol = static_cast<SCH_COMPONENT*>( item );
1220  auto& nickname = symbol->GetLibId().GetLibNickname();
1221 
1222  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1223  aLibNicknames.Add( nickname );
1224  }
1225  }
1226 
1227  return aLibNicknames.GetCount();
1228 }
1229 
1230 
1231 int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString& aTo )
1232 {
1233  SCH_SCREEN* screen;
1234  int cnt = 0;
1235 
1236  for( screen = GetFirst(); screen; screen = GetNext() )
1237  {
1238  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1239  {
1240  auto symbol = static_cast<SCH_COMPONENT*>( item );
1241 
1242  if( symbol->GetLibId().GetLibNickname() != aFrom )
1243  continue;
1244 
1245  LIB_ID id = symbol->GetLibId();
1246  id.SetLibNickname( aTo );
1247  symbol->SetLibId( id );
1248  cnt++;
1249  }
1250  }
1251 
1252  return cnt;
1253 }
1254 
1255 
1256 bool SCH_SCREENS::HasSchematic( const wxString& aSchematicFileName )
1257 {
1258  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1259  {
1260  if( screen->GetFileName() == aSchematicFileName )
1261  return true;
1262  }
1263 
1264  return false;
1265 }
1266 
1267 
1268 bool SCH_SCREENS::CanCauseCaseSensitivityIssue( const wxString& aSchematicFileName ) const
1269 {
1270  wxString lhsLower;
1271  wxString rhsLower;
1272  wxFileName lhs;
1273  wxFileName rhs = aSchematicFileName;
1274 
1275  wxCHECK( rhs.IsAbsolute(), false );
1276 
1277  for( const SCH_SCREEN* screen : m_screens )
1278  {
1279  lhs = screen->GetFileName();
1280 
1281  if( lhs.GetPath() != rhs.GetPath() )
1282  continue;
1283 
1284  lhsLower = lhs.GetFullName().Lower();
1285  rhsLower = rhs.GetFullName().Lower();
1286 
1287  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1288  return true;
1289  }
1290 
1291  return false;
1292 }
1293 
1294 
1296 {
1297  SCH_SHEET_LIST sheetList( g_RootSheet );
1298 
1299  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1300  curr_screen->GetClientSheetPaths().Clear();
1301 
1302  for( SCH_SHEET_PATH& sheetpath: sheetList )
1303  {
1304  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1305 
1306  // SEarch for the used_screen in list and add this unique sheet path:
1307  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1308  {
1309  if( used_screen == curr_screen )
1310  {
1311  curr_screen->GetClientSheetPaths().Add( sheetpath.PathAsString() );
1312  break;
1313  }
1314  }
1315  }
1316 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:150
SCH_SHEET_LIST.
void insert(SCH_ITEM *aItem)
Function Insert() Inserts an item into the tree.
Definition: sch_rtree.h:62
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
KIWAY_HOLDER is a mix in class which holds the location of a wxWindow's KIWAY.
Definition: kiway_holder.h:39
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:237
LIB_PIN * GetPin(const wxPoint &aPosition, SCH_COMPONENT **aComponent=NULL, bool aEndPointOnly=false)
Test the screen for a component pin item at aPosition.
Definition: sch_screen.cpp:649
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:238
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
int m_ScreenNumber
Definition: base_screen.h:135
void DeleteAllMarkers(enum MARKER_BASE::TYPEMARKER aMarkerType)
Delete all electronic rules check markers of aMarkerType from all the screens in the list.
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
Definition: sch_sheet.h:167
RC_ITEM * GetRCItem()
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:181
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:335
static double SchematicZoomList[]
Definition: sch_screen.cpp:80
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false)
Updates the connection graph for the given list of sheets.
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
int GetClientSheetPathsCount()
Definition: sch_screen.h:179
void AddGrid(const GRID_TYPE &aGrid)
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:82
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in m_drawL...
Definition: sch_screen.cpp:491
wxArrayString & GetClientSheetPaths()
Definition: sch_screen.h:181
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
bool IsEmpty()
Definition: sch_screen.h:137
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
EE_TYPE Overlapping(const EDA_RECT &aRect)
Definition: sch_rtree.h:224
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
void SetVisible(bool aVisible)
Definition: eda_text.h:169
int m_refCount
Number of sheets referencing this screen.
Definition: sch_screen.h:91
int ChangeSymbolLibNickname(const wxString &aFrom, const wxString &aTo)
Change all of the symbol library nicknames.
static std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aLabel)
Returns a pointer to a bus alias object for the given label, or null if one doesn't exist.
Definition: sch_screen.cpp:915
double GetTextAngle() const
Definition: eda_text.h:158
SCH_SCREEN(KIWAY *aKiway)
Constructor.
Definition: sch_screen.cpp:127
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
void Clear()
Definition: title_block.h:116
LIB_ITEM * GetDrawItem(const wxPoint &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the component library item at aPosition that is part of this component.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:749
#define ZOOM_FACTOR(x)
Definition: sch_screen.cpp:74
SCH_SCREENS(SCH_SHEET *aSheet=NULL)
Definition: sch_screen.cpp:947
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
int m_modification_sync
inequality with PART_LIBS::GetModificationHash() will trigger ResolveAll().
Definition: sch_screen.h:112
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:198
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
bool contains(SCH_ITEM *aItem, bool aRobust=false)
Determine if a given item exists in the tree.
Definition: sch_rtree.h:122
static GRID_TYPE SchematicGridList[]
Definition: sch_screen.cpp:116
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:65
SCH_LINE * GetLine(const wxPoint &aPosition, int aAccuracy=0, int aLayer=LAYER_NOTES, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Return a line item located at aPosition.
Definition: sch_screen.cpp:793
unsigned int m_index
Definition: sch_screen.h:495
UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
Definition: common.h:65
int GetUnit() const
Definition: lib_item.h:309
#define VALUE
int GetUnit() const
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:240
TITLE_BLOCK m_titles
Definition: sch_screen.h:105
static void ResolveAll(std::vector< SCH_COMPONENT * > &aComponents, SYMBOL_LIB_TABLE &aLibTable, PART_LIB *aCacheLib=NULL)
bool remove(SCH_ITEM *aItem)
Function Remove() Removes an item from the tree.
Definition: sch_rtree.h:78
PAGE_INFO m_paper
The size of the paper to print or plot on.
Definition: sch_screen.h:103
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
void GetHierarchicalItems(EDA_ITEMS &aItems)
Add all schematic sheet and component objects in the screen to aItems.
Definition: sch_screen.cpp:765
#define NULL
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
bool m_Center
Center on screen.
Definition: base_screen.h:121
void DeleteItem(SCH_ITEM *aItem)
Removes aItem from the linked list and deletes the object.
Definition: sch_screen.cpp:244
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:603
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_LINE_TEST_T
Definition: sch_screen.h:61
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
iterator end()
Definition: sch_rtree.h:253
const wxSize & GetTextSize() const
Definition: eda_text.h:223
EE_RTREE m_rtree
Definition: sch_screen.h:110
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
int GetErrorCode() const
Definition: rc_item.h:273
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
bool HasSchematic(const wxString &aSchematicFileName)
Check if one of the schematics in the list of screens is aSchematicFileName.
SCH_SHEET_PIN * GetSheetLabel(const wxPoint &aPosition)
Test the screen if aPosition is a sheet label object.
Definition: sch_screen.cpp:700
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
SCH_LINE * GetWire(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Definition: sch_screen.h:413
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
Definition: base_screen.cpp:88
SCH_SHEET_PATH.
std::unique_ptr< LIB_PART > & GetPartRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
void DeleteMarker(SCH_MARKER *aMarker)
Delete a specific marker.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
int GetConvert() const
Definition: lib_item.h:312
size_t CountConnectedItems(const wxPoint &aPos, bool aTestJunctions)
Definition: sch_screen.cpp:718
void FreeDrawList()
Free all the items from the schematic associated with the screen.
Definition: sch_screen.cpp:212
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
void Plot(PLOTTER *aPlotter)
Plot all the schematic objects to aPlotter.
Definition: sch_screen.cpp:573
YYCODETYPE lhs
const KIID m_Uuid
Definition: base_struct.h:169
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:224
void buildScreenList(SCH_SHEET *aSheet)
void DecRefCount()
Definition: sch_screen.cpp:167
Base plotter engine class.
Definition: plotter.h:104
void addScreenToList(SCH_SCREEN *aScreen)
Definition: sch_screen.cpp:988
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer)
Test if aPosition is a connection point on aLayer.
Definition: sch_screen.cpp:419
see class PGM_BASE
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the ful...
void TestDanglingEnds()
SCH_TEXT * GetLabel(const wxPoint &aPosition, int aAccuracy=0)
Return a label item located at aPosition.
Definition: sch_screen.cpp:827
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Adds a bus alias definition (and transfers ownership of the pointer)
Definition: sch_screen.cpp:891
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494
GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:175
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:98
iterator begin()
Definition: sch_rtree.h:248
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
std::unordered_set< std::shared_ptr< BUS_ALIAS > > m_aliases
List of bus aliases stored in this screen.
Definition: sch_screen.h:116
EE_RTREE & Items()
Definition: sch_screen.h:127
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
wxPoint GetPosition() const override
Function GetPosition.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
The common library.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
int m_NumberOfScreens
Definition: base_screen.h:136
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:732
int ReplaceDuplicateTimeStamps()
Test all sheet and component objects in the schematic for duplicate time stamps and replaces them as ...
boost::ptr_vector< WIRE > WIRES
Definition: specctra.h:2950
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T)
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:273
static bool IsBusAlias(const wxString &aLabel)
Returns true if the given string is a valid bus alias in a loaded screen.
Definition: sch_screen.cpp:897
bool CanCauseCaseSensitivityIssue(const wxString &aSchematicFileName) const
Check aSchematicFileName for a potential file name case sensitivity issue.
int GetConvert() const
void Print(wxDC *aDC)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:531
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
SCH_SCREEN * GetScreen(unsigned int aIndex) const
Definition: sch_screen.cpp:979
SCH_SHEET * g_RootSheet
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:642
void Update(SCH_ITEM *aItem)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:231
virtual void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Free the undo or redo list from aList element.
Definition: sch_screen.cpp:627
Definition for part library class.
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
void SetModify()
Definition: base_screen.h:224
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
Definition of the NETLIST_OBJECT class.
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:267
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const
size_t GetLibNicknames(wxArrayString &aLibNicknames)
Fetch all of the symbol library nickames into aLibNicknames.
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
void clear()
Function RemoveAll() Removes all items from the RTree.
Definition: sch_rtree.h:108
bool IsConnected(const wxPoint &aPoint) const
Function IsConnected tests the item to see if it is connected to aPoint.
Definition: sch_item.cpp:119
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491
void DeleteMarkers(enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode)
Delete all markers of a particular type and error code.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:138
wxArrayString m_clientSheetPathList
the list of scheet paths sharing this screen used in some annotation calculations to update alternate...
Definition: sch_screen.h:100
void IncRefCount()
Definition: sch_screen.cpp:161
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
bool TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr)
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:775
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_screen.h:147
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
bool SetComponentFootprint(SCH_SHEET_PATH *aSheetPath, const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Search this screen for a symbol with aReference and set the footprint field to aFootPrint if found.
Definition: sch_screen.cpp:848
std::set< SCH_ITEM * > MarkConnections(SCH_LINE *aSegment)
Return all wires and junctions connected to aSegment which are not connected any component pin.
Definition: sch_screen.cpp:289
SCH_LINE * GetBus(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Definition: sch_screen.h:419