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-2017 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 <fctsys.h>
33 #include <gr_basic.h>
34 #include <common.h>
35 #include <kicad_string.h>
36 #include <eeschema_id.h>
37 #include <pgm_base.h>
38 #include <kiway.h>
39 #include <sch_draw_panel.h>
40 #include <sch_item.h>
41 #include <gr_text.h>
42 #include <sch_edit_frame.h>
43 #include <plotter.h>
44 
45 #include <netlist.h>
46 #include <netlist_object.h>
47 #include <class_library.h>
48 #include <sch_junction.h>
49 #include <sch_bus_entry.h>
50 #include <sch_line.h>
51 #include <sch_marker.h>
52 #include <sch_no_connect.h>
53 #include <sch_sheet.h>
54 #include <sch_component.h>
55 #include <sch_text.h>
56 #include <lib_pin.h>
57 #include <symbol_lib_table.h>
58 #include <tool/common_tools.h>
59 
60 #include <thread>
61 #include <algorithm>
62 #include <future>
63 #include <array>
64 
65 // TODO(JE) Debugging only
66 #include <profile.h>
67 
68 #include <boost/foreach.hpp>
69 
70 #define EESCHEMA_FILE_STAMP "EESchema"
71 
72 /* Default zoom values. Limited to these values to keep a decent size
73  * to menus
74  */
75 static double SchematicZoomList[] =
76 {
77  0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 11.0,
78  13.0, 16.0, 20.0, 26.0, 32.0, 48.0, 64.0, 80.0, 128.0
79 };
80 
81 /* Default grid sizes for the schematic editor.
82  * Do NOT add others values (mainly grid values in mm), because they
83  * can break the schematic: Because wires and pins are considered as
84  * connected when the are to the same coordinate we cannot mix
85  * coordinates in mils (internal units) and mm (that cannot exactly
86  * converted in mils in many cases). In fact schematic must only use
87  * 50 and 25 mils to place labels, wires and components others values
88  * are useful only for graphic items (mainly in library editor) so use
89  * integer values in mils only. The 100 mil grid is added to help
90  * conform to the KiCad Library Convention. Which states: "Using a
91  * 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
92 */
94  { ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
95  { ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
96  { ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
97  { ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
98  { ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
99  { ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
100  { ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
101 };
102 
103 
106  KIWAY_HOLDER( aKiway, KIWAY_HOLDER::HOLDER_TYPE::SCREEN ),
107  m_paper( wxT( "A4" ) )
108 {
110 
111  SetZoom( 32 );
112 
113  for( unsigned zoom : SchematicZoomList )
114  m_ZoomList.push_back( zoom );
115 
116  for( GRID_TYPE grid : SchematicGridList )
117  AddGrid( grid );
118 
119  // Set the default grid size, now that the grid list is populated
120  SetGrid( wxRealPoint( 50, 50 ) );
121 
122  m_refCount = 0;
123 
124  // Suitable for schematic only. For libedit and viewlib, must be set to true
125  m_Center = false;
126 
127  InitDataPoints( m_paper.GetSizeIU() );
128 }
129 
130 
132 {
134 
135  // Now delete items in draw list. We do that only if the list is not empty,
136  // because if the list was appended to another list (see SCH_SCREEN::Append( SCH_SCREEN* aScreen )
137  // it is empty but as no longer the ownership (m_drawList.meOwner == false) of items, and calling
138  // FreeDrawList() with m_drawList.meOwner == false will generate a debug alert in debug mode
139  if( GetDrawItems() )
140  FreeDrawList();
141 }
142 
143 
145 {
146  m_refCount++;
147 }
148 
149 
151 {
152  wxCHECK_RET( m_refCount != 0,
153  wxT( "Screen reference count already zero. Bad programmer!" ) );
154  m_refCount--;
155 }
156 
157 
159 {
160  wxCHECK_RET( aScreen, "Invalid screen object." );
161 
162  // No need to decend the hierarchy. Once the top level screen is copied, all of it's
163  // children are copied as well.
164  m_drawList.Append( aScreen->m_drawList );
165 
166  // This screen owns the objects now. This prevents the object from being delete when
167  // aSheet is deleted.
168  aScreen->m_drawList.SetOwnership( false );
169 }
170 
171 
173 {
174  FreeDrawList();
175 
176  // Clear the project settings
178 
179  m_titles.Clear();
180 }
181 
182 
184 {
186 }
187 
188 
190 {
191  m_drawList.Remove( aItem );
192 }
193 
194 
196 {
197  wxCHECK_RET( aItem, wxT( "Cannot delete invalid item from screen." ) );
198 
199  SetModify();
200 
201  if( aItem->Type() == SCH_SHEET_PIN_T )
202  {
203  // This structure is attached to a sheet, get the parent sheet object.
204  SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
205  SCH_SHEET* sheet = sheetPin->GetParent();
206  wxCHECK_RET( sheet, wxT( "Sheet label parent not properly set, bad programmer!" ) );
207  sheet->RemovePin( sheetPin );
208  return;
209  }
210  else
211  {
212  m_drawList.Remove( aItem );
213  delete aItem;
214  }
215 }
216 
217 
219 {
220  SCH_ITEM* itemList = m_drawList.begin();
221 
222  while( itemList )
223  {
224  if( itemList == aItem )
225  return true;
226 
227  itemList = itemList->Next();
228  }
229 
230  return false;
231 }
232 
233 
234 SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const
235 {
236  KICAD_T types[] = { aType, EOT };
237 
238  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
239  {
240  switch( item->Type() )
241  {
242  case SCH_COMPONENT_T:
243  {
244  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
245 
246  for( int i = REFERENCE; i < component->GetFieldCount(); i++ )
247  {
248  SCH_FIELD* field = component->GetField( i );
249 
250  if( field->IsType( types ) && field->HitTest( aPosition, aAccuracy ) )
251  return field;
252  }
253 
254  break;
255  }
256  case SCH_SHEET_T:
257  {
258  SCH_SHEET* sheet = (SCH_SHEET*)item;
259 
260  SCH_SHEET_PIN* pin = sheet->GetPin( aPosition );
261 
262  if( pin && pin->IsType( types ) )
263  return pin;
264 
265  break;
266  }
267  default:
268  break;
269  }
270 
271  if( item->IsType( types ) && item->HitTest( aPosition, aAccuracy ) )
272  return item;
273  }
274 
275  return NULL;
276 }
277 
278 
280 {
281  SCH_ITEM* item;
282  SCH_ITEM* next_item;
283 
284  for( item = m_drawList.begin(); item; item = next_item )
285  {
286  next_item = item->Next();
287 
288  switch( item->Type() )
289  {
290  case SCH_JUNCTION_T:
291  case SCH_LINE_T:
292  Remove( item );
293  delete item;
294  break;
295 
296  default:
297  break;
298  }
299  }
300 
301  m_drawList.Append( aWireList );
302 }
303 
304 
306 {
307  wxCHECK_RET( (aSegment) && (aSegment->Type() == SCH_LINE_T),
308  wxT( "Invalid object pointer." ) );
309 
310  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
311  {
312  if( item->HasFlag( CANDIDATE ) )
313  continue;
314 
315  if( item->Type() == SCH_JUNCTION_T )
316  {
317  SCH_JUNCTION* junction = (SCH_JUNCTION*) item;
318 
319  if( aSegment->IsEndPoint( junction->GetPosition() ) )
320  item->SetFlags( CANDIDATE );
321 
322  continue;
323  }
324 
325  if( item->Type() != SCH_LINE_T )
326  continue;
327 
328  SCH_LINE* segment = (SCH_LINE*) item;
329 
330  if( aSegment->IsEndPoint( segment->GetStartPoint() )
331  && !GetPin( segment->GetStartPoint(), NULL, true ) )
332  {
333  item->SetFlags( CANDIDATE );
334  MarkConnections( segment );
335  }
336 
337  if( aSegment->IsEndPoint( segment->GetEndPoint() )
338  && !GetPin( segment->GetEndPoint(), NULL, true ) )
339  {
340  item->SetFlags( CANDIDATE );
341  MarkConnections( segment );
342  }
343  }
344 }
345 
346 
347 bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
348 {
349  enum { WIRES, BUSSES } layers;
350 
351  bool has_nonparallel[ sizeof( layers ) ] = { false };
352  int end_count[ sizeof( layers ) ] = { 0 };
353  int pin_count = 0;
354 
355  std::vector<SCH_LINE*> lines[ sizeof( layers ) ];
356 
357  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
358  {
359  if( item->GetEditFlags() & STRUCT_DELETED )
360  continue;
361 
362  if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) )
363  return false;
364 
365  if( ( item->Type() == SCH_LINE_T ) && ( item->HitTest( aPosition, 0 ) ) )
366  {
367  if( item->GetLayer() == LAYER_WIRE )
368  lines[ WIRES ].push_back( (SCH_LINE*) item );
369  else if( item->GetLayer() == LAYER_BUS )
370  lines[ BUSSES ].push_back( (SCH_LINE*) item );
371  }
372 
373  if( ( item->Type() == SCH_COMPONENT_T ) && ( item->IsConnected( aPosition ) ) )
374  pin_count++;
375  }
376 
377  for( int i : { WIRES, BUSSES } )
378  {
379  bool removed_overlapping = false;
380  end_count[i] = lines[i].size();
381 
382  for( auto line = lines[i].begin(); line < lines[i].end(); line++ )
383  {
384  // Consider ending on a line to be equivalent to two endpoints because
385  // we will want to split the line if anything else connects
386  if( !(*line)->IsEndPoint( aPosition ) )
387  end_count[i]++;
388 
389  for( auto second_line = lines[i].end() - 1; second_line > line; second_line-- )
390  {
391  if( !(*line)->IsParallel( *second_line ) )
392  has_nonparallel[i] = true;
393  else if( !removed_overlapping
394  && (*line)->IsSameQuadrant( *second_line, aPosition ) )
395  {
401  removed_overlapping = true;
402  end_count[i]--;
403  }
404  }
405  }
406  }
407 
408  // If there are three or more endpoints
409  if( pin_count && pin_count + end_count[WIRES] > 2 )
410  return true;
411 
412  // If there is at least one segment that ends on a non-parallel line or
413  // junction of two other lines
414  if( has_nonparallel[WIRES] && end_count[WIRES] > 2 )
415  return true;
416 
417  // Check for bus - bus junction requirements
418  if( has_nonparallel[BUSSES] && end_count[BUSSES] > 2 )
419  return true;
420 
421  return false;
422 }
423 
424 
425 bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
426 {
427  wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false,
428  wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) );
429 
430  SCH_SHEET_PIN* label;
431  SCH_TEXT* text;
432  SCH_CONNECTION conn;
433 
434  switch( aLayer )
435  {
436  case LAYER_BUS:
437 
438  if( GetBus( aPosition ) )
439  return true;
440 
441  label = GetSheetLabel( aPosition );
442 
443  if( label && conn.IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) )
444  return true;
445 
446  text = GetLabel( aPosition );
447 
448  if( text && conn.IsBusLabel( text->GetText() ) && text->IsConnected( aPosition )
449  && (text->Type() != SCH_LABEL_T) )
450  return true;
451 
452  break;
453 
454  case LAYER_NOTES:
455 
456  if( GetLine( aPosition ) )
457  return true;
458 
459  break;
460 
461  case LAYER_WIRE:
463  return true;
464 
465  if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) )
466  return true;
467 
468  if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) )
469  return true;
470 
471  if( GetPin( aPosition, NULL, true ) )
472  return true;
473 
474  if( GetWire( aPosition ) )
475  return true;
476 
477  text = GetLabel( aPosition );
478 
479  if( text && text->IsConnected( aPosition ) && !conn.IsBusLabel( text->GetText() ) )
480  return true;
481 
482  label = GetSheetLabel( aPosition );
483 
484  if( label && label->IsConnected( aPosition ) && !conn.IsBusLabel( label->GetText() ) )
485  return true;
486 
487  break;
488 
489  default:
490  break;
491  }
492 
493  return false;
494 }
495 
496 
497 void SCH_SCREEN::UpdateSymbolLinks( bool aForce )
498 {
499  // Initialize or reinitialize the pointer to the LIB_PART for each component
500  // found in m_drawList, but only if needed (change in lib or schematic)
501  // therefore the calculation time is usually very low.
502  if( m_drawList.GetCount() )
503  {
504  SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
505  int mod_hash = libs->GetModifyHash();
507 
509 
510  // Must we resolve?
511  if( (m_modification_sync != mod_hash) || aForce )
512  {
513  SCH_COMPONENT::ResolveAll( c, *libs, Prj().SchLibs()->GetCacheLibrary() );
514 
515  m_modification_sync = mod_hash; // note the last mod_hash
516  }
517  // Resolving will update the pin caches but we must ensure that this happens
518  // even if the libraries don't change.
519  else
521  }
522 }
523 
524 
525 void SCH_SCREEN::Print( wxDC* aDC )
526 {
527  std::vector< SCH_ITEM* > junctions;
528 
529  // Ensure links are up to date, even if a library was reloaded for some reason:
531 
532  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
533  {
534  if( item->IsMoving() || item->IsResized() )
535  continue;
536 
537  if( item->Type() == SCH_JUNCTION_T )
538  junctions.push_back( item );
539  else
540  item->Print( aDC, wxPoint( 0, 0 ) );
541  }
542 
543  for( auto item : junctions )
544  item->Print( aDC, wxPoint( 0, 0 ) );
545 }
546 
547 
548 void SCH_SCREEN::Plot( PLOTTER* aPlotter )
549 {
550  // Ensure links are up to date, even if a library was reloaded for some reason:
551  std::vector< SCH_ITEM* > junctions;
552  std::vector< SCH_ITEM* > bitmaps;
553  std::vector< SCH_ITEM* > other;
554 
555  // Ensure links are up to date, even if a library was reloaded for some reason:
557 
558  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
559  {
560  if( item->IsMoving() || item->IsResized() )
561  continue;
562 
563  if( item->Type() == SCH_JUNCTION_T )
564  junctions.push_back( item );
565  else if( item->Type() == SCH_BITMAP_T )
566  bitmaps.push_back( item );
567  else
568  // uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
569  // if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) )
570  other.push_back( item );
571  }
572 
573  // Bitmaps are drawn first to ensure they are in the background
574  // This is particularly important for the wxPostscriptDC (used in *nix printers) as
575  // the bitmap PS command clears the screen
576  for( auto item : bitmaps )
577  {
578  aPlotter->SetCurrentLineWidth( item->GetPenSize() );
579  item->Plot( aPlotter );
580  }
581 
582  for( auto item : other )
583  {
584  aPlotter->SetCurrentLineWidth( item->GetPenSize() );
585  item->Plot( aPlotter );
586  }
587 
588  for( auto item : junctions )
589  {
590  aPlotter->SetCurrentLineWidth( item->GetPenSize() );
591  item->Plot( aPlotter );
592  }
593 }
594 
595 
597 {
598  if( aItemCount == 0 )
599  return;
600 
601  for( auto& command : aList.m_CommandsList )
602  {
603  command->ClearListAndDeleteItems();
604  delete command;
605  }
606 
607  aList.m_CommandsList.clear();
608 }
609 
610 
612 {
613  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
614  item->ClearTempFlags();
615 }
616 
617 
618 LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent,
619  bool aEndPointOnly ) const
620 {
621  SCH_ITEM* item;
622  SCH_COMPONENT* component = NULL;
623  LIB_PIN* pin = NULL;
624 
625  for( item = m_drawList.begin(); item; item = item->Next() )
626  {
627  if( item->Type() != SCH_COMPONENT_T )
628  continue;
629 
630  component = (SCH_COMPONENT*) item;
631 
632  if( aEndPointOnly )
633  {
634  pin = NULL;
635 
636  auto part = component->GetPartRef().lock();
637 
638  if( !part )
639  continue;
640 
641  for( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
642  {
643  // Skip items not used for this part.
644  if( component->GetUnit() && pin->GetUnit() &&
645  ( pin->GetUnit() != component->GetUnit() ) )
646  continue;
647 
648  if( component->GetConvert() && pin->GetConvert() &&
649  ( pin->GetConvert() != component->GetConvert() ) )
650  continue;
651 
652  if(component->GetPinPhysicalPosition( pin ) == aPosition )
653  break;
654  }
655  if( pin )
656  break;
657  }
658  else
659  {
660  pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T );
661 
662  if( pin )
663  break;
664  }
665  }
666 
667  if( pin && aComponent )
668  *aComponent = component;
669 
670  return pin;
671 }
672 
673 
674 SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName )
675 {
676  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
677  {
678  if( item->Type() != SCH_SHEET_T )
679  continue;
680 
681  SCH_SHEET* sheet = (SCH_SHEET*) item;
682 
683  if( aName.CmpNoCase( sheet->GetName() ) == 0 )
684  return sheet;
685  }
686 
687  return NULL;
688 }
689 
690 
691 SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
692 {
693  SCH_SHEET_PIN* sheetPin = NULL;
694 
695  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
696  {
697  if( item->Type() != SCH_SHEET_T )
698  continue;
699 
700  SCH_SHEET* sheet = (SCH_SHEET*) item;
701  sheetPin = sheet->GetPin( aPosition );
702 
703  if( sheetPin )
704  break;
705  }
706 
707  return sheetPin;
708 }
709 
710 
711 int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const
712 {
713  SCH_ITEM* item;
714  int count = 0;
715 
716  for( item = m_drawList.begin(); item; item = item->Next() )
717  {
718  if( item->Type() == SCH_JUNCTION_T && !aTestJunctions )
719  continue;
720 
721  if( item->IsConnected( aPos ) )
722  count++;
723  }
724 
725  return count;
726 }
727 
728 
730 {
731  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
732  {
733  if( item->Type() == SCH_COMPONENT_T )
734  {
735  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
736 
737  component->ClearAnnotation( aSheetPath );
738 
739  // Clear the modified component flag set by component->ClearAnnotation
740  // because we do not use it here and we should not leave this flag set,
741  // when an editing is finished:
742  component->ClearFlags();
743  }
744  }
745 }
746 
747 
749 {
750  if( GetClientSheetPathsCount() <= 1 ) // No need for alternate reference
751  return;
752 
753  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
754  {
755  if( item->Type() != SCH_COMPONENT_T )
756  continue;
757 
758  // Add (when not existing) all sheet path entries
759  for( unsigned int ii = 0; ii < m_clientSheetPathList.GetCount(); ii++ )
760  ((SCH_COMPONENT*)item)->AddSheetPathReferenceEntryIfMissing( m_clientSheetPathList[ii] );
761  }
762 }
763 
764 
766 {
767  SCH_ITEM* item = m_drawList.begin();
768 
769  while( item )
770  {
771  if( ( item->Type() == SCH_SHEET_T ) || ( item->Type() == SCH_COMPONENT_T ) )
772  aItems.push_back( item );
773 
774  item = item->Next();
775  }
776 }
777 
778 
780 {
781  SCH_ITEM* item;
782  std::vector< DANGLING_END_ITEM > endPoints;
783  bool hasStateChanged = false;
784 
785  for( item = m_drawList.begin(); item; item = item->Next() )
786  item->GetEndPoints( endPoints );
787 
788  for( item = m_drawList.begin(); item; item = item->Next() )
789  {
790  if( item->UpdateDanglingState( endPoints ) )
791  hasStateChanged = true;
792  }
793 
794  return hasStateChanged;
795 }
796 
797 
798 SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
799 {
801 
802  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
803  {
804  if( item->IsType( types ) && item->HitTest( aPosition ) )
805  return (SCH_LINE*) item;
806  }
807 
808  return nullptr;
809 }
810 
811 
812 SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer,
813  SCH_LINE_TEST_T aSearchType )
814 {
815  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
816  {
817  if( item->Type() != SCH_LINE_T )
818  continue;
819 
820  if( item->GetLayer() != aLayer )
821  continue;
822 
823  if( !item->HitTest( aPosition, aAccuracy ) )
824  continue;
825 
826  switch( aSearchType )
827  {
828  case ENTIRE_LENGTH_T:
829  return (SCH_LINE*) item;
830 
832  if( !( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
833  return (SCH_LINE*) item;
834  break;
835 
836  case END_POINTS_ONLY_T:
837  if( ( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
838  return (SCH_LINE*) item;
839  }
840  }
841 
842  return NULL;
843 }
844 
845 
846 SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
847 {
848  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
849  {
850  switch( item->Type() )
851  {
852  case SCH_LABEL_T:
853  case SCH_GLOBAL_LABEL_T:
854  case SCH_HIER_LABEL_T:
855  if( item->HitTest( aPosition, aAccuracy ) )
856  return (SCH_TEXT*) item;
857 
858  default:
859  ;
860  }
861  }
862 
863  return NULL;
864 }
865 
866 
867 bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
868  const wxString& aFootPrint, bool aSetVisible )
869 {
870  SCH_COMPONENT* component;
871  bool found = false;
872 
873  for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
874  {
875  if( item->Type() != SCH_COMPONENT_T )
876  continue;
877 
878  component = (SCH_COMPONENT*) item;
879 
880  if( aReference.CmpNoCase( component->GetRef( aSheetPath ) ) == 0 )
881  {
882  // Found: Init Footprint Field
883 
884  /* Give a reasonable value to the field position and
885  * orientation, if the text is empty at position 0, because
886  * it is probably not yet initialized
887  */
888  SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
889  if( fpfield->GetText().IsEmpty()
890  && ( fpfield->GetTextPos() == component->GetPosition() ) )
891  {
892  fpfield->SetTextAngle( component->GetField( VALUE )->GetTextAngle() );
893  fpfield->SetTextPos( component->GetField( VALUE )->GetTextPos() );
894  fpfield->SetTextSize( component->GetField( VALUE )->GetTextSize() );
895 
896  if( fpfield->GetTextAngle() == 0.0 )
897  fpfield->Offset( wxPoint( 0, 100 ) );
898  else
899  fpfield->Offset( wxPoint( 100, 0 ) );
900  }
901 
902  fpfield->SetText( aFootPrint );
903  fpfield->SetVisible( aSetVisible );
904 
905  found = true;
906  }
907  }
908 
909  return found;
910 }
911 
912 
913 void SCH_SCREEN::AddBusAlias( std::shared_ptr<BUS_ALIAS> aAlias )
914 {
915  m_aliases.insert( aAlias );
916 }
917 
918 
919 bool SCH_SCREEN::IsBusAlias( const wxString& aLabel )
920 {
921  SCH_SHEET_LIST aSheets( g_RootSheet );
922  for( unsigned i = 0; i < aSheets.size(); i++ )
923  {
924  for( auto alias : aSheets[i].LastScreen()->GetBusAliases() )
925  {
926  if( alias->GetName() == aLabel )
927  {
928  return true;
929  }
930  }
931  }
932 
933  return false;
934 }
935 
936 
937 std::shared_ptr<BUS_ALIAS> SCH_SCREEN::GetBusAlias( const wxString& aLabel )
938 {
939  SCH_SHEET_LIST aSheets( g_RootSheet );
940  for( unsigned i = 0; i < aSheets.size(); i++ )
941  {
942  for( auto alias : aSheets[i].LastScreen()->GetBusAliases() )
943  {
944  if( alias->GetName() == aLabel )
945  {
946  return alias;
947  }
948  }
949  }
950 
951  return NULL;
952 }
953 
954 
955 #if defined(DEBUG)
956 void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
957 {
958  // for now, make it look like XML, expand on this later.
959  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
960 
961  for( EDA_ITEM* item = m_drawList.begin(); item; item = item->Next() )
962  {
963  item->Show( nestLevel+1, os );
964  }
965 
966  NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
967 }
968 #endif
969 
970 
972 {
973  m_index = 0;
974  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
975 }
976 
977 
979 {
980 }
981 
982 
984 {
985  m_index = 0;
986 
987  if( m_screens.size() > 0 )
988  return m_screens[0];
989 
990  return NULL;
991 }
992 
993 
995 {
996  if( m_index < m_screens.size() )
997  m_index++;
998 
999  return GetScreen( m_index );
1000 }
1001 
1002 
1003 SCH_SCREEN* SCH_SCREENS::GetScreen( unsigned int aIndex ) const
1004 {
1005  if( aIndex < m_screens.size() )
1006  return m_screens[ aIndex ];
1007 
1008  return NULL;
1009 }
1010 
1011 
1013 {
1014  if( aScreen == NULL )
1015  return;
1016 
1017  for( unsigned int i = 0; i < m_screens.size(); i++ )
1018  {
1019  if( m_screens[i] == aScreen )
1020  return;
1021  }
1022 
1023  m_screens.push_back( aScreen );
1024 }
1025 
1026 
1028 {
1029  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1030  {
1031  SCH_SCREEN* screen = aSheet->GetScreen();
1032 
1033  addScreenToList( screen );
1034 
1035  EDA_ITEM* strct = screen->GetDrawItems();
1036 
1037  while( strct )
1038  {
1039  if( strct->Type() == SCH_SHEET_T )
1040  {
1041  buildScreenList( ( SCH_SHEET* )strct );
1042  }
1043 
1044  strct = strct->Next();
1045  }
1046  }
1047 }
1048 
1049 
1051 {
1052  for( size_t i = 0; i < m_screens.size(); i++ )
1053  m_screens[i]->ClearAnnotation( NULL );
1054 }
1055 
1056 
1058 {
1059  // Clear the annotation for the components inside new sheetpaths
1060  // not already in aInitialSheetList
1061  SCH_SCREENS screensList( g_RootSheet ); // The list of screens, shared by sheet paths
1062  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1063 
1064  // Search for new sheet paths, not existing in aInitialSheetPathList
1065  // and existing in sheetpathList
1066  SCH_SHEET_LIST sheetpathList( g_RootSheet );
1067 
1068  for( SCH_SHEET_PATH& sheetpath: sheetpathList )
1069  {
1070  bool path_exists = false;
1071 
1072  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1073  {
1074  if( existing_sheetpath.Path() == sheetpath.Path() )
1075  {
1076  path_exists = true;
1077  break;
1078  }
1079  }
1080 
1081  if( !path_exists )
1082  {
1083  // A new sheet path is found: clear the annotation corresponding to this new path:
1084  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1085 
1086  // Clear annotation and create the AR for this path, if not exists,
1087  // when the screen is shared by sheet paths.
1088  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1089  // reference default value and takes the latest displayed value
1090  curr_screen->EnsureAlternateReferencesExist();
1091  curr_screen->ClearAnnotation( &sheetpath );
1092  }
1093  }
1094 }
1095 
1096 
1098 {
1099  EDA_ITEMS items;
1100  int count = 0;
1101 
1102  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1103  {
1104  return a->GetTimeStamp() < b->GetTimeStamp();
1105  };
1106 
1107  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1108 
1109  for( size_t i = 0; i < m_screens.size(); i++ )
1110  m_screens[i]->GetHierarchicalItems( items );
1111 
1112  if( items.size() < 2 )
1113  return 0;
1114 
1115  for( auto item : items )
1116  {
1117  int failed = 0;
1118 
1119  while( !unique_stamps.insert( item ).second )
1120  {
1121  failed = 1;
1122 
1123  // for a component, update its Time stamp and its paths
1124  // (m_PathsAndReferences field)
1125  if( item->Type() == SCH_COMPONENT_T )
1126  static_cast<SCH_COMPONENT*>( item )->SetTimeStamp( GetNewTimeStamp() );
1127 
1128  // for a sheet, update only its time stamp (annotation of its
1129  // components will be lost)
1130  // @todo: see how to change sheet paths for its cmp list (can
1131  // be possible in most cases)
1132  else
1133  item->SetTimeStamp( GetNewTimeStamp() );
1134  }
1135 
1136  count += failed;
1137  }
1138 
1139  return count;
1140 }
1141 
1142 
1144 {
1145  SCH_ITEM* item;
1146  SCH_ITEM* nextItem;
1147  SCH_MARKER* marker;
1148  SCH_SCREEN* screen;
1149 
1150  for( screen = GetFirst(); screen; screen = GetNext() )
1151  {
1152  for( item = screen->GetDrawItems(); item; item = nextItem )
1153  {
1154  nextItem = item->Next();
1155 
1156  if( item->Type() != SCH_MARKER_T )
1157  continue;
1158 
1159  marker = (SCH_MARKER*) item;
1160 
1161  if( marker->GetMarkerType() != aMarkerType )
1162  continue;
1163 
1164  screen->DeleteItem( marker );
1165  }
1166  }
1167 }
1168 
1169 
1171  enum MARKER_BASE::MARKER_SEVERITY aSeverity )
1172 {
1173  int count = 0;
1174 
1175  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1176  {
1177  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
1178  {
1179  if( item->Type() != SCH_MARKER_T )
1180  continue;
1181 
1182  SCH_MARKER* marker = (SCH_MARKER*) item;
1183 
1184  if( ( aMarkerType != MARKER_BASE::MARKER_UNSPEC ) &&
1185  ( marker->GetMarkerType() != aMarkerType ) )
1186  continue;
1187 
1188  if( aSeverity == MARKER_BASE::MARKER_SEVERITY_UNSPEC ||
1189  aSeverity == marker->GetErrorLevel() )
1190  count++;
1191  }
1192  }
1193 
1194  return count;
1195 }
1196 
1197 
1199 {
1200  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1201  screen->UpdateSymbolLinks( aForce );
1202 }
1203 
1204 
1206 {
1207  std::vector<SCH_SCREEN*> screens;
1208  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1209  screens.push_back( screen );
1210 
1211  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
1212  screens.size() );
1213 
1214  std::atomic<size_t> nextScreen( 0 );
1215  std::vector<std::future<size_t>> returns( parallelThreadCount );
1216 
1217  auto update_lambda = [&screens, &nextScreen]() -> size_t
1218  {
1219  for( auto i = nextScreen++; i < screens.size(); i = nextScreen++ )
1220  screens[i]->TestDanglingEnds();
1221 
1222  return 1;
1223  };
1224 
1225  if( parallelThreadCount == 1 )
1226  update_lambda();
1227  else
1228  {
1229  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1230  returns[ii] = std::async( std::launch::async, update_lambda );
1231 
1232  // Finalize the threads
1233  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1234  returns[ii].wait();
1235  }
1236 
1237 }
1238 
1239 
1241 {
1242  SCH_COMPONENT* symbol;
1243  SCH_ITEM* item;
1244  SCH_ITEM* nextItem;
1245  SCH_SCREEN* screen;
1246  unsigned cnt = 0;
1247 
1248  for( screen = GetFirst(); screen; screen = GetNext() )
1249  {
1250  for( item = screen->GetDrawItems(); item; item = nextItem )
1251  {
1252  nextItem = item->Next();
1253 
1254  if( item->Type() != SCH_COMPONENT_T )
1255  continue;
1256 
1257  cnt += 1;
1258  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1259  wxASSERT( symbol );
1260 
1261  if( !symbol->GetLibId().GetLibNickname().empty() )
1262  return false;
1263  }
1264  }
1265 
1266  if( cnt == 0 )
1267  return false;
1268 
1269  return true;
1270 }
1271 
1272 
1273 size_t SCH_SCREENS::GetLibNicknames( wxArrayString& aLibNicknames )
1274 {
1275  SCH_COMPONENT* symbol;
1276  SCH_ITEM* item;
1277  SCH_ITEM* nextItem;
1278  SCH_SCREEN* screen;
1279  wxString nickname;
1280 
1281  for( screen = GetFirst(); screen; screen = GetNext() )
1282  {
1283  for( item = screen->GetDrawItems(); item; item = nextItem )
1284  {
1285  nextItem = item->Next();
1286 
1287  if( item->Type() != SCH_COMPONENT_T )
1288  continue;
1289 
1290  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1291  wxASSERT( symbol );
1292 
1293  if( !symbol )
1294  continue;
1295 
1296  nickname = symbol->GetLibId().GetLibNickname();
1297 
1298  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1299  aLibNicknames.Add( nickname );;
1300  }
1301  }
1302 
1303  return aLibNicknames.GetCount();
1304 }
1305 
1306 
1307 int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString& aTo )
1308 {
1309  SCH_COMPONENT* symbol;
1310  SCH_ITEM* item;
1311  SCH_ITEM* nextItem;
1312  SCH_SCREEN* screen;
1313  int cnt = 0;
1314 
1315  for( screen = GetFirst(); screen; screen = GetNext() )
1316  {
1317  for( item = screen->GetDrawItems(); item; item = nextItem )
1318  {
1319  nextItem = item->Next();
1320 
1321  if( item->Type() != SCH_COMPONENT_T )
1322  continue;
1323 
1324  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1325  wxASSERT( symbol );
1326 
1327  if( symbol->GetLibId().GetLibNickname() != aFrom )
1328  continue;
1329 
1330  LIB_ID id = symbol->GetLibId();
1331  id.SetLibNickname( aTo );
1332  symbol->SetLibId( id );
1333  cnt++;
1334  }
1335  }
1336 
1337  return cnt;
1338 }
1339 
1340 
1341 bool SCH_SCREENS::HasSchematic( const wxString& aSchematicFileName )
1342 {
1343  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1344  {
1345  if( screen->GetFileName() == aSchematicFileName )
1346  return true;
1347  }
1348 
1349  return false;
1350 }
1351 
1352 
1354 {
1355  SCH_SHEET_LIST sheetList( g_RootSheet );
1356 
1357  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1358  curr_screen->GetClientSheetPaths().Clear();
1359 
1360  for( SCH_SHEET_PATH& sheetpath: sheetList )
1361  {
1362  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1363 
1364  // SEarch for the used_screen in list and add this unique sheet path:
1365  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1366  {
1367  if( used_screen == curr_screen )
1368  {
1369  curr_screen->GetClientSheetPaths().Add( sheetpath.Path() );
1370  break;
1371  }
1372  }
1373  }
1374 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:150
Class SCH_SHEET_LIST.
void Collect(EDA_ITEM *aItem, const KICAD_T aScanList[])
Function Collect scans a DLIST using this class's Inspector method, which does the collection.
static void UpdatePins(const EE_COLLECTOR &aComponents)
Update the pin cache for all components in aComponents.
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
Class 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
bool IsType(const KICAD_T aScanTypes[]) override
Function IsType Checks whether the item is one of the listed types.
Definition: sch_field.h:76
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:994
int m_ScreenNumber
Definition: base_screen.h:135
SCH_SHEET_PIN * GetPin(const wxPoint &aPosition)
Return the sheet pin item found at aPosition in the sheet.
Definition: sch_sheet.cpp:381
PART_REF & GetPartRef()
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:158
T * Remove(T *aElement)
Function Remove removes aElement from the list, but does not delete it.
Definition: dlist.h:211
wxPoint GetStartPoint() const
Definition: sch_line.h:95
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:347
virtual void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList)
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points.
Definition: sch_item.h:273
SCH_ITEM * Next() const
Definition: sch_item.h:153
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
static double SchematicZoomList[]
Definition: sch_screen.cpp:75
SCH_SHEET * GetSheet(const wxString &aName)
Returns a sheet object pointer that is named aName.
Definition: sch_screen.cpp:674
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
int GetClientSheetPathsCount()
Definition: sch_screen.h:145
void AddGrid(const GRID_TYPE &aGrid)
void Append(T *aNewElement)
Function Append adds aNewElement to the end of the list.
Definition: dlist.h:177
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:497
wxArrayString & GetClientSheetPaths()
Definition: sch_screen.h:147
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
int CountConnectedItems(const wxPoint &aPos, bool aTestJunctions) const
Definition: sch_screen.cpp:711
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
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:70
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:937
double GetTextAngle() const
Definition: eda_text.h:158
SCH_SCREEN(KIWAY *aKiway)
Constructor.
Definition: sch_screen.cpp:104
virtual bool IsType(const KICAD_T aScanTypes[])
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:294
T * begin() const
Definition: dlist.h:218
void Clear()
Definition: title_block.h:116
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:189
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
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:44
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:748
SCH_SCREENS(SCH_SHEET *aSheet=NULL)
Definition: sch_screen.cpp:971
#define CANDIDATE
flag indicating that the structure is connected
Definition: base_struct.h:130
void DeleteAll()
Function DeleteAll deletes all items on the list and leaves the list empty.
Definition: dlist.cpp:44
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:91
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:281
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
LIB_PIN * GetPin(const wxPoint &aPosition, SCH_COMPONENT **aComponent=NULL, bool aEndPointOnly=false) const
Test the screen for a component pin item at aPosition.
Definition: sch_screen.cpp:618
EDA_ITEM * Next() const
Definition: base_struct.h:218
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
static GRID_TYPE SchematicGridList[]
Definition: sch_screen.cpp:93
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:63
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:812
unsigned int m_index
Definition: sch_screen.h:495
Class UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList)
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_item.h:288
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
int GetUnit() const
Definition: lib_item.h:301
#define VALUE
void SetLibId(const LIB_ID &aName, PART_LIBS *aLibs=NULL)
int GetUnit() const
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:187
TITLE_BLOCK m_titles
Definition: sch_screen.h:84
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
PAGE_INFO m_paper
The size of the paper to print or plot on.
Definition: sch_screen.h:82
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:126
void GetHierarchicalItems(EDA_ITEMS &aItems)
Add all schematic sheet and component objects in the screen to aItems.
Definition: sch_screen.cpp:765
wxString GetName() const
Definition: sch_sheet.h:272
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:100
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:195
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:642
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_LINE_TEST_T
Definition: sch_screen.h:52
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
void MarkConnections(SCH_LINE *aSegment)
Add all wires and junctions connected to aSegment which are not connected any component pin to aItemL...
Definition: sch_screen.cpp:305
const wxSize & GetTextSize() const
Definition: eda_text.h:223
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:234
void Clear()
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:172
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
timestamp_t GetTimeStamp() const
Definition: base_struct.h:216
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:274
bool HasSchematic(const wxString &aSchematicFileName)
Check if one of the schematics in the list of screens is aSchematicFileName.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_field.cpp:396
SCH_SHEET_PIN * GetSheetLabel(const wxPoint &aPosition)
Test the screen if aPosition is a sheet label object.
Definition: sch_screen.cpp:691
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:88
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
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:86
Class SCH_SHEET_PATH.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
int GetConvert() const
Definition: lib_item.h:304
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
int GetFieldCount() const
Return the number of fields in this symbol.
void FreeDrawList()
Free all the items from the schematic associated with the screen.
Definition: sch_screen.cpp:183
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void Plot(PLOTTER *aPlotter)
Plot all the schematic objects to aPlotter.
Definition: sch_screen.cpp:548
int GetMarkerCount(enum MARKER_BASE::TYPEMARKER aMarkerType, enum MARKER_BASE::MARKER_SEVERITY aSeverity)
Return the number of ERC markers of aMarkerType from all of the screens in the list.
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
DLIST< SCH_ITEM > m_drawList
Object list for the screen.
Definition: sch_screen.h:89
void buildScreenList(SCH_SHEET *aSheet)
void DecRefCount()
Definition: sch_screen.cpp:150
Base plotter engine class.
Definition: plotter.h:97
void addScreenToList(SCH_SCREEN *aScreen)
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer)
Test if aPosition is a connection point on aLayer.
Definition: sch_screen.cpp:425
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:846
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Adds a bus alias definition (and transfers ownership of the pointer)
Definition: sch_screen.cpp:913
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:154
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:187
#define max(a, b)
Definition: auxiliary.h:86
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool failed
Definition: json11.cpp:651
Class EE_TYPE_COLLECTOR merely gathers up all SCH_ITEMs of a given set of KICAD_T type(s).
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:779
std::unordered_set< std::shared_ptr< BUS_ALIAS > > m_aliases
List of bus aliases stored in this screen.
Definition: sch_screen.h:95
size_t i
Definition: json11.cpp:649
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
wxPoint GetPosition() const override
Function GetPosition.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
The common library.
SCH_LINE * GetWireOrBus(const wxPoint &aPosition)
Return a wire or bus item located at aPosition.
Definition: sch_screen.cpp:798
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
int m_NumberOfScreens
Definition: base_screen.h:136
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void SetOwnership(bool Iown)
Function SetOwnership controls whether the list owns the objects and is responsible for deleteing the...
Definition: dlist.h:119
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:729
int ReplaceDuplicateTimeStamps()
Test all sheet and component objects in the schematic for duplicate time stamps and replaces them as ...
void ReplaceWires(DLIST< SCH_ITEM > &aWireList)
Replace all of the wires, buses, and junctions in the screen with aWireList.
Definition: sch_screen.cpp:279
boost::ptr_vector< WIRE > WIRES
Definition: specctra.h:2950
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:919
int GetConvert() const
void Print(wxDC *aDC)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:525
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:983
SCH_SCREEN * GetScreen(unsigned int aIndex) const
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:611
virtual void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Free the undo or redo list from aList element.
Definition: sch_screen.cpp:596
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:218
const LIB_ID & GetLibId() const
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const
size_t GetLibNicknames(wxArrayString &aLibNicknames)
Fetch all of the symbol library nickames into aLibNicknames.
static void ResolveAll(const EE_COLLECTOR &aComponents, SYMBOL_LIB_TABLE &aLibTable, PART_LIB *aCacheLib=NULL)
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Definitions of the SCH_TEXT class and derivatives for Eeschema.
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
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
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:79
void IncRefCount()
Definition: sch_screen.cpp:144
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
bool empty() const
Definition: utf8.h:108
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_screen.h:113
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:867
SCH_LINE * GetBus(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Definition: sch_screen.h:419
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152
wxPoint GetEndPoint() const
Definition: sch_line.h:98