KiCad PCB EDA Suite
sch_sheet.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <core/mirror.h>
26 #include <sch_draw_panel.h>
27 #include <gr_text.h>
28 #include <trigo.h>
29 #include <sch_edit_frame.h>
30 #include <plotter.h>
31 #include <kicad_string.h>
32 #include <widgets/msgpanel.h>
33 #include <math/util.h> // for KiROUND
34 #include <sch_sheet.h>
35 #include <sch_sheet_path.h>
36 #include <sch_symbol.h>
37 #include <sch_painter.h>
38 #include <schematic.h>
40 #include <trace_helpers.h>
41 #include <pgm_base.h>
42 
43 
44 const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx )
45 {
46  static void* locale = nullptr;
47  static wxString sheetnameDefault;
48  static wxString sheetfilenameDefault;
49  static wxString fieldDefault;
50 
51  // Fetching translations can take a surprising amount of time when loading libraries,
52  // so only do it when necessary.
53  if( Pgm().GetLocale() != locale )
54  {
55  sheetnameDefault = _( "Sheet name" );
56  sheetfilenameDefault = _( "Sheet file" );
57  fieldDefault = _( "Field%d" );
58  locale = Pgm().GetLocale();
59  }
60 
61  // Fixed values for the mandatory fields
62  switch( aFieldNdx )
63  {
64  case SHEETNAME: return sheetnameDefault;
65  case SHEETFILENAME: return sheetfilenameDefault;
66  default: return wxString::Format( fieldDefault, aFieldNdx );
67  }
68 }
69 
70 
71 SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const wxPoint& pos ) :
72  SCH_ITEM( aParent, SCH_SHEET_T )
73 {
75  m_pos = pos;
76  m_size = wxSize( Mils2iu( MIN_SHEET_WIDTH ), Mils2iu( MIN_SHEET_HEIGHT ) );
77  m_screen = NULL;
78 
79  for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
80  {
81  m_fields.emplace_back( pos, i, this, GetDefaultFieldName( i ) );
82  m_fields.back().SetVisible( true );
83 
84  if( i == SHEETNAME )
85  m_fields.back().SetLayer( LAYER_SHEETNAME );
86  else if( i == SHEETFILENAME )
87  m_fields.back().SetLayer( LAYER_SHEETFILENAME );
88  else
89  m_fields.back().SetLayer( LAYER_SHEETFIELDS );
90  }
91 
93 
94  m_borderWidth = 0;
95  m_borderColor = COLOR4D::UNSPECIFIED;
96  m_backgroundColor = COLOR4D::UNSPECIFIED;
97 }
98 
99 
100 SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
101  SCH_ITEM( aSheet )
102 {
103  m_pos = aSheet.m_pos;
104  m_size = aSheet.m_size;
105  m_layer = aSheet.m_layer;
106  const_cast<KIID&>( m_Uuid ) = aSheet.m_Uuid;
107  m_fields = aSheet.m_fields;
109  m_screen = aSheet.m_screen;
110 
111  for( SCH_SHEET_PIN* pin : aSheet.m_pins )
112  {
113  m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) );
114  m_pins.back()->SetParent( this );
115  }
116 
117  for( SCH_FIELD& field : m_fields )
118  field.SetParent( this );
119 
120  m_borderWidth = aSheet.m_borderWidth;
121  m_borderColor = aSheet.m_borderColor;
123  m_instances = aSheet.m_instances;
124 
125  if( m_screen )
127 }
128 
129 
131 {
132  // also, look at the associated sheet & its reference count
133  // perhaps it should be deleted also.
134  if( m_screen )
135  {
137 
138  if( m_screen->GetRefCount() == 0 )
139  delete m_screen;
140  }
141 
142  // We own our pins; delete them
143  for( SCH_SHEET_PIN* pin : m_pins )
144  delete pin;
145 }
146 
147 
149 {
150  return new SCH_SHEET( *this );
151 }
152 
153 
155 {
156  if( aScreen == m_screen )
157  return;
158 
159  if( m_screen != NULL )
160  {
162 
163  if( m_screen->GetRefCount() == 0 )
164  {
165  delete m_screen;
166  m_screen = NULL;
167  }
168  }
169 
170  m_screen = aScreen;
171 
172  if( m_screen )
174 }
175 
176 
178 {
179  if( m_screen == NULL )
180  return 0;
181 
182  return m_screen->GetRefCount();
183 }
184 
185 
187 {
188  wxCHECK_MSG( Schematic(), false, "Can't call IsRootSheet without setting a schematic" );
189 
190  return &Schematic()->Root() == this;
191 }
192 
193 
194 void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
195 {
196  for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
197  aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
198 
199  for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields.size(); ++i )
200  aVars->push_back( m_fields[i].GetName() );
201 
202  aVars->push_back( wxT( "#" ) );
203  aVars->push_back( wxT( "##" ) );
205 }
206 
207 
208 bool SCH_SHEET::ResolveTextVar( wxString* token, int aDepth ) const
209 {
210  for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
211  {
212  if( token->IsSameAs( m_fields[i].GetCanonicalName().Upper() ) )
213  {
214  *token = m_fields[i].GetShownText( aDepth + 1 );
215  return true;
216  }
217  }
218 
219  for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields.size(); ++i )
220  {
221  if( token->IsSameAs( m_fields[i].GetName() ) )
222  {
223  *token = m_fields[i].GetShownText( aDepth + 1 );
224  return true;
225  }
226  }
227 
228  PROJECT *project = &Schematic()->Prj();
229 
230  if( m_screen->GetTitleBlock().TextVarResolver( token, project ) )
231  {
232  return true;
233  }
234 
235  if( token->IsSameAs( wxT( "#" ) ) )
236  {
237  for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() )
238  {
239  if( sheet.Last() == this ) // Current sheet path found
240  {
241  *token = wxString::Format( "%s", sheet.GetPageNumber() );
242  return true;
243  }
244  }
245  }
246  else if( token->IsSameAs( wxT( "##" ) ) )
247  {
248  SCH_SHEET_LIST sheetList = Schematic()->GetSheets();
249  *token = wxString::Format( wxT( "%d" ), (int) sheetList.size() );
250  return true;
251  }
252 
253  return false;
254 }
255 
256 
258 {
259  return m_borderWidth == 0 && m_borderColor == COLOR4D::UNSPECIFIED;
260 }
261 
262 
264 {
265  wxCHECK_RET( aItem->Type() == SCH_SHEET_T,
266  wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ),
267  aItem->GetClass() ) );
268 
269  SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
270 
271  std::swap( m_pos, sheet->m_pos );
272  std::swap( m_size, sheet->m_size );
273  m_fields.swap( sheet->m_fields );
274  std::swap( m_fieldsAutoplaced, sheet->m_fieldsAutoplaced );
275  m_pins.swap( sheet->m_pins );
276 
277  // Update parent pointers after swapping.
278  for( SCH_SHEET_PIN* sheetPin : m_pins )
279  sheetPin->SetParent( this );
280 
281  for( SCH_SHEET_PIN* sheetPin : sheet->m_pins )
282  sheetPin->SetParent( sheet );
283 
284  for( SCH_FIELD& field : m_fields )
285  field.SetParent( this );
286 
287  for( SCH_FIELD& field : sheet->m_fields )
288  field.SetParent( sheet );
289 
290  std::swap( m_borderWidth, sheet->m_borderWidth );
291  std::swap( m_borderColor, sheet->m_borderColor );
292  std::swap( m_backgroundColor, sheet->m_backgroundColor );
293  std::swap( m_instances, sheet->m_instances );
294 }
295 
296 
298 {
299  wxASSERT( aSheetPin != NULL );
300  wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
301 
302  aSheetPin->SetParent( this );
303  m_pins.push_back( aSheetPin );
304  renumberPins();
305 }
306 
307 
308 void SCH_SHEET::RemovePin( const SCH_SHEET_PIN* aSheetPin )
309 {
310  wxASSERT( aSheetPin != NULL );
311  wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
312 
313  for( auto i = m_pins.begin(); i < m_pins.end(); ++i )
314  {
315  if( *i == aSheetPin )
316  {
317  m_pins.erase( i );
318  renumberPins();
319  return;
320  }
321  }
322 }
323 
324 
325 bool SCH_SHEET::HasPin( const wxString& aName ) const
326 {
327  for( SCH_SHEET_PIN* pin : m_pins )
328  {
329  if( pin->GetText().CmpNoCase( aName ) == 0 )
330  return true;
331  }
332 
333  return false;
334 }
335 
336 
337 bool SCH_SHEET::doIsConnected( const wxPoint& aPosition ) const
338 {
339  for( SCH_SHEET_PIN* sheetPin : m_pins )
340  {
341  if( sheetPin->GetPosition() == aPosition )
342  return true;
343  }
344 
345  return false;
346 }
347 
348 
350 {
351  int leftRight = 0;
352  int topBottom = 0;
353 
354  for( SCH_SHEET_PIN* pin : m_pins )
355  {
356  switch( pin->GetEdge() )
357  {
358  case SHEET_LEFT_SIDE: leftRight++; break;
359  case SHEET_RIGHT_SIDE: leftRight++; break;
360  case SHEET_TOP_SIDE: topBottom++; break;
361  case SHEET_BOTTOM_SIDE: topBottom++; break;
362  default: break;
363  }
364  }
365 
366  return topBottom > 0 && leftRight == 0;
367 }
368 
369 
371 {
372  for( SCH_SHEET_PIN* pin : m_pins )
373  {
374  /* Search the schematic for a hierarchical label corresponding to this sheet label. */
375  const SCH_HIERLABEL* HLabel = nullptr;
376  for( auto aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
377  {
378  if( !pin->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) )
379  {
380  HLabel = static_cast<SCH_HIERLABEL*>( aItem );
381  break;
382  }
383  }
384 
385  if( HLabel == nullptr ) // Corresponding hierarchical label not found.
386  return true;
387  }
388 
389  return false;
390 }
391 
392 
394 {
395  int width = Mils2iu( MIN_SHEET_WIDTH );
396 
397  for( size_t i = 0; i < m_pins.size(); i++ )
398  {
399  int edge = m_pins[i]->GetEdge();
400  EDA_RECT pinRect = m_pins[i]->GetBoundingBox();
401 
402  wxASSERT( edge != SHEET_UNDEFINED_SIDE );
403 
404  if( edge == SHEET_TOP_SIDE || edge == SHEET_BOTTOM_SIDE )
405  {
406  if( width < pinRect.GetRight() - m_pos.x )
407  width = pinRect.GetRight() - m_pos.x;
408  }
409  else
410  {
411  if( width < pinRect.GetWidth() )
412  width = pinRect.GetWidth();
413 
414  for( size_t j = 0; j < m_pins.size(); j++ )
415  {
416  // Check for pin directly across from the current pin.
417  if( (i == j) || (m_pins[i]->GetPosition().y != m_pins[j]->GetPosition().y) )
418  continue;
419 
420  if( width < pinRect.GetWidth() + m_pins[j]->GetBoundingBox().GetWidth() )
421  {
422  width = pinRect.GetWidth() + m_pins[j]->GetBoundingBox().GetWidth();
423  break;
424  }
425  }
426  }
427  }
428 
429  return width;
430 }
431 
432 
434 {
435  int height = Mils2iu( MIN_SHEET_HEIGHT );
436 
437  for( size_t i = 0; i < m_pins.size(); i++ )
438  {
439  int edge = m_pins[i]->GetEdge();
440  EDA_RECT pinRect = m_pins[i]->GetBoundingBox();
441 
442  // Make sure pin is on top or bottom side of sheet.
443  if( edge == SHEET_RIGHT_SIDE || edge == SHEET_LEFT_SIDE )
444  {
445  if( height < pinRect.GetBottom() - m_pos.y )
446  height = pinRect.GetBottom() - m_pos.y;
447  }
448  else
449  {
450  if( height < pinRect.GetHeight() )
451  height = pinRect.GetHeight();
452 
453  for( size_t j = 0; j < m_pins.size(); j++ )
454  {
455  // Check for pin directly above or below the current pin.
456  if( (i == j) || (m_pins[i]->GetPosition().x != m_pins[j]->GetPosition().x) )
457  continue;
458 
459  if( height < pinRect.GetHeight() + m_pins[j]->GetBoundingBox().GetHeight() )
460  {
461  height = pinRect.GetHeight() + m_pins[j]->GetBoundingBox().GetHeight();
462  break;
463  }
464  }
465  }
466  }
467 
468  return height;
469 }
470 
471 
473 {
474  auto i = m_pins.begin();
475 
476  while( i != m_pins.end() )
477  {
478  /* Search the schematic for a hierarchical label corresponding to this sheet label. */
479  const SCH_HIERLABEL* HLabel = NULL;
480 
481  for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
482  {
483  if( (*i)->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) == 0 )
484  {
485  HLabel = static_cast<SCH_HIERLABEL*>( aItem );
486  break;
487  }
488  }
489 
490  if( HLabel == NULL ) // Hlabel not found: delete sheet label.
491  i = m_pins.erase( i );
492  else
493  ++i;
494  }
495 }
496 
497 
498 SCH_SHEET_PIN* SCH_SHEET::GetPin( const wxPoint& aPosition )
499 {
500  for( SCH_SHEET_PIN* pin : m_pins )
501  {
502  if( pin->HitTest( aPosition ) )
503  return pin;
504  }
505 
506  return NULL;
507 }
508 
509 
511 {
512  return std::max( GetBorderWidth(), 1 );
513 }
514 
515 
516 void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
517 {
518  wxSize textSize = m_fields[ SHEETNAME ].GetTextSize();
519  int borderMargin = KiROUND( GetPenWidth() / 2.0 ) + 4;
520  int margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.5 );
521 
522  if( IsVerticalOrientation() )
523  {
524  m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( -margin, m_size.y ) );
525  m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
526  m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM );
527  m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_VERT );
528  }
529  else
530  {
531  m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( 0, -margin ) );
532  m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
533  m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM );
534  m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_HORIZ );
535  }
536 
537  textSize = m_fields[ SHEETFILENAME ].GetTextSize();
538  margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.4 );
539 
540  if( IsVerticalOrientation() )
541  {
542  m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( m_size.x + margin, m_size.y ) );
543  m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
544  m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP );
545  m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_VERT );
546  }
547  else
548  {
549  m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( 0, m_size.y + margin ) );
550  m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
551  m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP );
552  m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_HORIZ );
553  }
554 
556 }
557 
558 
559 void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
560 {
561  aCount = 4;
562  aLayers[0] = LAYER_HIERLABEL;
563  aLayers[1] = LAYER_SHEET;
564  aLayers[2] = LAYER_SHEET_BACKGROUND;
565  aLayers[3] = LAYER_SELECTION_SHADOWS;
566 }
567 
568 
570 {
571  wxPoint end;
572  EDA_RECT box( m_pos, m_size );
573  int lineWidth = GetPenWidth();
574  int textLength = 0;
575 
576  // Calculate bounding box X size:
577  end.x = std::max( m_size.x, textLength );
578 
579  // Calculate bounding box pos:
580  end.y = m_size.y;
581  end += m_pos;
582 
583  box.SetEnd( end );
584  box.Inflate( lineWidth / 2 );
585 
586  return box;
587 }
588 
589 
591 {
593 
594  for( const SCH_FIELD& field : m_fields )
595  box.Merge( field.GetBoundingBox() );
596 
597  return box;
598 }
599 
600 
602 {
603  EDA_RECT box( m_pos, m_size );
604  return box.GetCenter();
605 }
606 
607 
609 {
610  int n = 0;
611 
612  if( m_screen )
613  {
614  for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_COMPONENT_T ) )
615  {
616  SCH_COMPONENT* symbol = (SCH_COMPONENT*) aItem;
617 
618  if( symbol->GetField( VALUE_FIELD )->GetText().GetChar( 0 ) != '#' )
619  n++;
620  }
621 
622  for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
623  n += static_cast<const SCH_SHEET*>( aItem )->SymbolCount();
624  }
625 
626  return n;
627 }
628 
629 
630 bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
631 {
632  if( m_screen )
633  {
634  // Only check the root sheet once and don't recurse.
635  if( !GetParent() )
636  {
637  if( m_screen && m_screen->GetFileName().Cmp( aFilename ) == 0 )
638  {
639  *aScreen = m_screen;
640  return true;
641  }
642  }
643 
644  for( auto aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
645  {
646  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
647  SCH_SCREEN* screen = sheet->m_screen;
648 
649  // Must use the screen's path (which is always absolute) rather than the
650  // sheet's (which could be relative).
651  if( screen && screen->GetFileName().Cmp( aFilename ) == 0 )
652  {
653  *aScreen = screen;
654  return true;
655  }
656 
657  if( sheet->SearchHierarchy( aFilename, aScreen ) )
658  return true;
659  }
660  }
661 
662  return false;
663 }
664 
665 
667 {
668  if( m_screen )
669  {
670  aList->push_back( this );
671 
672  if( m_screen == aScreen )
673  return true;
674 
675  for( auto item : m_screen->Items().OfType( SCH_SHEET_T ) )
676  {
677  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
678 
679  if( sheet->LocatePathOfScreen( aScreen, aList ) )
680  {
681  return true;
682  }
683  }
684 
685  aList->pop_back();
686  }
687 
688  return false;
689 }
690 
691 
693 {
694  int count = 1; //1 = this!!
695 
696  if( m_screen )
697  {
698  for( auto aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
699  count += static_cast<SCH_SHEET*>( aItem )->CountSheets();
700  }
701 
702  return count;
703 }
704 
705 
707 {
708  aList.emplace_back( _( "Sheet Name" ), m_fields[ SHEETNAME ].GetText() );
709 
710  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
711  {
712  SCH_SHEET_PATH path = schframe->GetCurrentSheet();
713  path.push_back( this );
714 
715  aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false ) );
716  }
717 
718  aList.emplace_back( _( "File Name" ), m_fields[ SHEETFILENAME ].GetText() );
719 }
720 
721 
722 void SCH_SHEET::Rotate( wxPoint aPosition )
723 {
724  wxPoint prev = m_pos;
725 
726  RotatePoint( &m_pos, aPosition, 900 );
727  RotatePoint( &m_size.x, &m_size.y, 900 );
728 
729  if( m_size.x < 0 )
730  {
731  m_pos.x += m_size.x;
732  m_size.x = -m_size.x;
733  }
734 
735  if( m_size.y < 0 )
736  {
737  m_pos.y += m_size.y;
738  m_size.y = -m_size.y;
739  }
740 
741  // Pins must be rotated first as that's how we determine vertical vs horizontal
742  // orientation for auto-placement
743  for( SCH_SHEET_PIN* sheetPin : m_pins )
744  sheetPin->Rotate( aPosition );
745 
747  {
748  AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
749  }
750  else
751  {
752  // Move the fields to the new position because the component itself has moved.
753  for( SCH_FIELD& field : m_fields )
754  {
755  wxPoint pos = field.GetTextPos();
756  pos.x -= prev.x - m_pos.x;
757  pos.y -= prev.y - m_pos.y;
758  field.SetTextPos( pos );
759  }
760  }
761 }
762 
763 
764 void SCH_SHEET::MirrorVertically( int aCenter )
765 {
766  MIRROR( m_pos.y, aCenter );
767  m_pos.y -= m_size.y;
768 
769  for( SCH_SHEET_PIN* sheetPin : m_pins )
770  sheetPin->MirrorVertically( aCenter );
771 }
772 
773 
774 void SCH_SHEET::MirrorHorizontally( int aCenter )
775 {
776  MIRROR( m_pos.x, aCenter );
777  m_pos.x -= m_size.x;
778 
779  for( SCH_SHEET_PIN* sheetPin : m_pins )
780  sheetPin->MirrorHorizontally( aCenter );
781 }
782 
783 
784 void SCH_SHEET::SetPosition( const wxPoint& aPosition )
785 {
786  // Remember the sheet and all pin sheet positions must be
787  // modified. So use Move function to do that.
788  Move( aPosition - m_pos );
789 }
790 
791 
792 void SCH_SHEET::Resize( const wxSize& aSize )
793 {
794  if( aSize == m_size )
795  return;
796 
797  m_size = aSize;
798 
799  // Move the fields if we're in autoplace mode
801  AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
802 
803  // Move the sheet labels according to the new sheet size.
804  for( SCH_SHEET_PIN* sheetPin : m_pins )
805  sheetPin->ConstrainOnEdge( sheetPin->GetPosition() );
806 }
807 
808 
809 bool SCH_SHEET::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const
810 {
811  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
812 
813  // Sheets are searchable via the child field and pin item text.
814  return false;
815 }
816 
817 
819 {
820  int id = 2;
821 
822  for( SCH_SHEET_PIN* pin : m_pins )
823  {
824  pin->SetNumber( id );
825  id++;
826  }
827 }
828 
829 
830 void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
831 {
832  for( SCH_SHEET_PIN* sheetPin : m_pins )
833  {
834  wxCHECK2_MSG( sheetPin->Type() == SCH_SHEET_PIN_T, continue,
835  wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
836 
837  sheetPin->GetEndPoints( aItemList );
838  }
839 }
840 
841 
842 bool SCH_SHEET::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
843  const SCH_SHEET_PATH* aPath )
844 {
845  bool changed = false;
846 
847  for( SCH_SHEET_PIN* sheetPin : m_pins )
848  changed |= sheetPin->UpdateDanglingState( aItemList );
849 
850  return changed;
851 }
852 
853 
854 std::vector<wxPoint> SCH_SHEET::GetConnectionPoints() const
855 {
856  std::vector<wxPoint> retval;
857 
858  for( SCH_SHEET_PIN* sheetPin : m_pins )
859  retval.push_back( sheetPin->GetPosition() );
860 
861  return retval;
862 }
863 
864 
865 SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICAD_T aFilterTypes[] )
866 {
867  KICAD_T stype;
868 
869  for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
870  {
871  // If caller wants to inspect my type
872  if( stype == SCH_LOCATE_ANY_T || stype == Type() )
873  {
874  if( SEARCH_RESULT::QUIT == aInspector( this, NULL ) )
875  return SEARCH_RESULT::QUIT;
876  }
877 
878  if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T )
879  {
880  // Test the sheet fields.
881  for( SCH_FIELD& field : m_fields )
882  {
883  if( SEARCH_RESULT::QUIT == aInspector( &field, this ) )
884  return SEARCH_RESULT::QUIT;
885  }
886  }
887 
888  if( stype == SCH_LOCATE_ANY_T || stype == SCH_SHEET_PIN_T )
889  {
890  // Test the sheet labels.
891  for( SCH_SHEET_PIN* sheetPin : m_pins )
892  {
893  if( SEARCH_RESULT::QUIT == aInspector( sheetPin, this ) )
894  return SEARCH_RESULT::QUIT;
895  }
896  }
897  }
898 
900 }
901 
902 
903 void SCH_SHEET::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
904 {
905  for( SCH_FIELD& field : m_fields )
906  aFunction( &field );
907 
908  for( SCH_SHEET_PIN* pin : m_pins )
909  aFunction( pin );
910 }
911 
912 
913 wxString SCH_SHEET::GetSelectMenuText( EDA_UNITS aUnits ) const
914 {
915  return wxString::Format( _( "Hierarchical Sheet %s" ),
916  m_fields[ SHEETNAME ].GetText() );
917 }
918 
919 
921 {
923 }
924 
925 
926 bool SCH_SHEET::HitTest( const wxPoint& aPosition, int aAccuracy ) const
927 {
928  EDA_RECT rect = GetBodyBoundingBox();
929 
930  rect.Inflate( aAccuracy );
931 
932  return rect.Contains( aPosition );
933 }
934 
935 
936 bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
937 {
938  EDA_RECT rect = aRect;
939 
940  rect.Inflate( aAccuracy );
941 
942  if( aContained )
943  return rect.Contains( GetBodyBoundingBox() );
944 
945  return rect.Intersects( GetBodyBoundingBox() );
946 }
947 
948 
949 void SCH_SHEET::Plot( PLOTTER* aPlotter )
950 {
951  wxString msg;
952  wxPoint pos;
953  auto* settings = dynamic_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
954  bool override = settings ? settings->m_OverrideItemColors : false;
955  COLOR4D borderColor = GetBorderColor();
956  COLOR4D backgroundColor = GetBackgroundColor();
957 
958  if( override || borderColor == COLOR4D::UNSPECIFIED )
959  borderColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET );
960 
961  if( override || backgroundColor == COLOR4D::UNSPECIFIED )
962  backgroundColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET_BACKGROUND );
963 
964  aPlotter->SetColor( backgroundColor );
965  // Do not fill shape in B&W mode, otherwise texts are unreadable
966  bool fill = aPlotter->GetColorMode();
967 
969  1.0 );
970 
971  aPlotter->SetColor( borderColor );
972 
973  int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() );
974  aPlotter->SetCurrentLineWidth( penWidth );
975 
976  aPlotter->MoveTo( m_pos );
977  pos = m_pos;
978  pos.x += m_size.x;
979 
980  aPlotter->LineTo( pos );
981  pos.y += m_size.y;
982 
983  aPlotter->LineTo( pos );
984  pos = m_pos;
985  pos.y += m_size.y;
986 
987  aPlotter->LineTo( pos );
988  aPlotter->FinishTo( m_pos );
989 
990  for( SCH_FIELD field : m_fields )
991  field.Plot( aPlotter );
992 
993  /* Draw texts : SheetLabel */
994  for( SCH_SHEET_PIN* sheetPin : m_pins )
995  sheetPin->Plot( aPlotter );
996 }
997 
998 
999 void SCH_SHEET::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
1000 {
1001  wxDC* DC = aSettings->GetPrintDC();
1002  wxPoint pos = m_pos + aOffset;
1003  int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
1004  const auto* settings = dynamic_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
1005  bool override = settings && settings->m_OverrideItemColors;
1006  COLOR4D border = GetBorderColor();
1007  COLOR4D background = GetBackgroundColor();
1008 
1009  if( override || border == COLOR4D::UNSPECIFIED )
1010  border = aSettings->GetLayerColor( LAYER_SHEET );
1011 
1012  if( override || background == COLOR4D::UNSPECIFIED )
1013  background = aSettings->GetLayerColor( LAYER_SHEET_BACKGROUND );
1014 
1015  if( GetGRForceBlackPenState() ) // printing in black & white
1016  background = COLOR4D::UNSPECIFIED;
1017 
1018  if( background != COLOR4D::UNSPECIFIED )
1019  {
1020  GRFilledRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, 0,
1021  background, background );
1022  }
1023 
1024  GRRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, border );
1025 
1026  for( SCH_FIELD& field : m_fields )
1027  field.Print( aSettings, aOffset );
1028 
1029  /* Draw text : SheetLabel */
1030  for( SCH_SHEET_PIN* sheetPin : m_pins )
1031  sheetPin->Print( aSettings, aOffset );
1032 }
1033 
1034 
1036 {
1037  wxCHECK_MSG( Type() == aItem.Type(), *this,
1038  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1039  GetClass() );
1040 
1041  if( &aItem != this )
1042  {
1043  SCH_ITEM::operator=( aItem );
1044 
1045  SCH_SHEET* sheet = (SCH_SHEET*) &aItem;
1046 
1047  m_pos = sheet->m_pos;
1048  m_size = sheet->m_size;
1049  m_fields = sheet->m_fields;
1050 
1051  for( SCH_SHEET_PIN* pin : sheet->m_pins )
1052  {
1053  m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) );
1054  m_pins.back()->SetParent( this );
1055  }
1056 
1057  for( const SCH_SHEET_INSTANCE& instance : sheet->m_instances )
1058  m_instances.emplace_back( instance );
1059  }
1060 
1061  return *this;
1062 }
1063 
1064 
1065 bool SCH_SHEET::operator <( const SCH_ITEM& aItem ) const
1066 {
1067  if( Type() != aItem.Type() )
1068  return Type() < aItem.Type();
1069 
1070  auto sheet = static_cast<const SCH_SHEET*>( &aItem );
1071 
1072  if (m_fields[ SHEETNAME ].GetText() != sheet->m_fields[ SHEETNAME ].GetText() )
1073  return m_fields[ SHEETNAME ].GetText() < sheet->m_fields[ SHEETNAME ].GetText();
1074 
1075  if (m_fields[ SHEETFILENAME ].GetText() != sheet->m_fields[ SHEETFILENAME ].GetText() )
1076  return m_fields[ SHEETFILENAME ].GetText() < sheet->m_fields[ SHEETFILENAME ].GetText();
1077 
1078  return false;
1079 }
1080 
1081 
1082 bool SCH_SHEET::AddInstance( const KIID_PATH& aSheetPath )
1083 {
1084  // a empty sheet path is illegal:
1085  wxCHECK( aSheetPath.size() > 0, false );
1086 
1087  wxString path;
1088 
1089  for( const SCH_SHEET_INSTANCE& instance : m_instances )
1090  {
1091  // if aSheetPath is found, nothing to do:
1092  if( instance.m_Path == aSheetPath )
1093  return false;
1094  }
1095 
1096  SCH_SHEET_INSTANCE instance;
1097 
1098  instance.m_Path = aSheetPath;
1099 
1100  // This entry does not exist: add it with an empty page number.
1101  m_instances.emplace_back( instance );
1102  return true;
1103 }
1104 
1105 
1106 wxString SCH_SHEET::GetPageNumber( const SCH_SHEET_PATH& aInstance ) const
1107 {
1108  wxString pageNumber;
1109  KIID_PATH path = aInstance.Path();
1110 
1111  for( const SCH_SHEET_INSTANCE& instance : m_instances )
1112  {
1113  if( instance.m_Path == path )
1114  {
1115  pageNumber = instance.m_PageNumber;
1116  break;
1117  }
1118  }
1119 
1120  return pageNumber;
1121 }
1122 
1123 
1124 void SCH_SHEET::SetPageNumber( const SCH_SHEET_PATH& aInstance, const wxString& aPageNumber )
1125 {
1126  KIID_PATH path = aInstance.Path();
1127 
1128  for( SCH_SHEET_INSTANCE& instance : m_instances )
1129  {
1130  if( instance.m_Path == path )
1131  {
1132  instance.m_PageNumber = aPageNumber;
1133  break;
1134  }
1135  }
1136 }
1137 
1138 
1139 int SCH_SHEET::ComparePageNum( const wxString& aPageNumberA, const wxString aPageNumberB )
1140 {
1141  if( aPageNumberA == aPageNumberB )
1142  return 1;
1143 
1144  // First sort numerically if the page numbers are integers
1145  long pageA, pageB;
1146  bool isIntegerPageA = aPageNumberA.ToLong( &pageA );
1147  bool isIntegerPageB = aPageNumberB.ToLong( &pageB );
1148 
1149  if( isIntegerPageA && isIntegerPageB )
1150  {
1151  if( pageA > pageB )
1152  return 1;
1153  else if( pageA == pageB )
1154  return 0;
1155  else
1156  return -1;
1157  }
1158 
1159  // Numerical page numbers always before strings
1160  if( isIntegerPageA )
1161  return -1;
1162  else if( isIntegerPageB )
1163  return 1;
1164 
1165  // If not numeric, then sort as strings
1166  int result = aPageNumberA.Cmp( aPageNumberB );
1167 
1168  if( result == 0 )
1169  return 0;
1170  else if( result > 0 )
1171  return 1;
1172 
1173  return -1;
1174 }
1175 
1176 
1177 #if defined(DEBUG)
1178 
1179 void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
1180 {
1181  // XML output:
1182  wxString s = GetClass();
1183 
1184  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
1185  << TO_UTF8( m_fields[ SHEETNAME ].GetText() ) << '"' << ">\n";
1186 
1187  // show all the pins, and check the linked list integrity
1188  for( SCH_SHEET_PIN* sheetPin : m_pins )
1189  sheetPin->Show( nestLevel + 1, os );
1190 
1191  NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
1192 }
1193 
1194 #endif
void FinishTo(const wxPoint &pos)
Definition: plotter.h:267
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
const wxString & GetFileName() const
Definition: sch_screen.h:192
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_sheet.cpp:559
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:630
SCH_SHEET_PIN * GetPin(const wxPoint &aPosition)
Return the sheet pin item found at aPosition in the sheet.
Definition: sch_sheet.cpp:498
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:431
Container for project specific data.
Definition: project.h:62
PNG memory record (file in memory).
Definition: bitmap_def.h:29
KIGFX::COLOR4D m_borderColor
Definition: sch_sheet.h:233
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:71
virtual void SetColor(COLOR4D color)=0
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
Definition: sch_sheet.cpp:830
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:882
friend class SCH_SHEET_PIN
Definition: sch_sheet.h:221
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:154
void MirrorVertically(int aXaxis_position) override
Mirror item vertically about aCenter.
Definition: sch_sheet.cpp:764
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
Definition: sch_sheet.cpp:194
int GetWidth() const
Definition: eda_rect.h:114
wxSize m_size
Definition: sch_sheet.h:231
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_sheet.cpp:337
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:370
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:197
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:293
bool UsesDefaultStroke() const
Test this sheet to see if the default stroke is used to draw the outline.
Definition: sch_sheet.cpp:257
Schematic editor (Eeschema) main window.
static int ComparePageNum(const wxString &aPageNumberA, const wxString aPageNumberB)
Compares page numbers of schematic sheets.
Definition: sch_sheet.cpp:1139
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_sheet.cpp:913
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_sheet.cpp:1065
The base class for create windows for drawing purpose.
wxPoint m_pos
Definition: sch_sheet.h:230
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:297
static void GetContextualTextVars(wxArrayString *aVars)
Definition: title_block.cpp:73
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:203
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1124
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:94
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
std::vector< SCH_SHEET_INSTANCE > m_instances
Definition: sch_sheet.h:236
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:43
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:165
Field Value of part, i.e. "3.3K".
int GetBottom() const
Definition: eda_rect.h:119
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
void pop_back()
Forwarded method from std::vector.
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:296
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
Definition: sch_sheet.cpp:177
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
void LineTo(const wxPoint &pos)
Definition: plotter.h:262
void renumberPins()
Renumber the sheet pins in the sheet.
Definition: sch_sheet.cpp:818
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_sheet.cpp:706
wxString GetClass() const override
Return the class name.
Definition: sch_sheet.h:254
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:842
int GetBorderWidth() const
Definition: sch_sheet.h:290
SCH_LAYER_ID m_layer
Definition: sch_item.h:201
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_sheet.cpp:590
#define NULL
SCH_SHEET(EDA_ITEM *aParent=nullptr, const wxPoint &pos=wxPoint(0, 0))
Definition: sch_sheet.cpp:71
const BITMAP_OPAQUE add_hierarchical_subsheet_xpm[1]
int m_borderWidth
Definition: sch_sheet.h:232
void SetEnd(int x, int y)
Definition: eda_rect.h:187
int GetPenWidth() const override
Definition: sch_sheet.cpp:510
bool IsRootSheet() const
Definition: sch_sheet.cpp:186
std::vector< SCH_SHEET_PIN * > m_pins
Definition: sch_sheet.h:227
int GetRight() const
Definition: eda_rect.h:116
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
Definition: sch_sheet.cpp:433
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: sch_sheet.cpp:865
EDA_ITEM * GetParent() const
Definition: eda_item.h:164
const EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
Definition: sch_sheet.cpp:569
wxLogTrace helper definitions.
wxDC * GetPrintDC() const
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:44
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:85
int SymbolCount() const
Count our own components, without the power components.
Definition: sch_sheet.cpp:608
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_sheet.cpp:854
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:472
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:722
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
Definition: eda_item.cpp:193
int GetHeight() const
Definition: eda_rect.h:115
void MirrorHorizontally(int aYaxis_position) override
Mirror item horizontally about aCenter.
Definition: sch_sheet.cpp:774
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:308
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:99
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_sheet.cpp:999
const KIID m_Uuid
Definition: eda_item.h:524
void MoveTo(const wxPoint &pos)
Definition: plotter.h:257
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
std::vector< SCH_FIELD > m_fields
Definition: sch_sheet.h:228
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
Definition: sch_symbol.cpp:687
EDA_UNITS
Definition: eda_units.h:38
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:692
int GetMinWidth() const
Return the minimum width of the sheet based on the widths of the sheet pin text.
Definition: sch_sheet.cpp:393
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:111
void DecRefCount()
Definition: sch_screen.cpp:111
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:666
Base plotter engine class.
Definition: plotter.h:121
SCH_SHEET & Root() const
Definition: schematic.h:116
A simple container for sheet instance information.
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:155
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_sheet.cpp:263
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
Definition: sch_sheet.cpp:903
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:148
see class PGM_BASE
void Plot(PLOTTER *aPlotter) override
Plot the schematic item to aPlotter.
Definition: sch_sheet.cpp:949
const wxChar *const traceFindItem
Flag to enable find debug tracing.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
Definition: sch_sheet.cpp:842
#define _(s)
Definition: 3d_actions.cpp:33
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:349
void SetPosition(const wxPoint &aPosition) override
Definition: sch_sheet.cpp:784
EE_RTREE & Items()
Definition: sch_screen.h:162
KIGFX::COLOR4D m_backgroundColor
Definition: sch_sheet.h:234
Handle the component boundary box.
Definition: eda_rect.h:42
Schematic symbol object.
Definition: sch_symbol.h:79
SCH_SCREEN * m_screen
Definition: sch_sheet.h:224
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:44
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:222
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_sheet.cpp:920
int GetDefaultPenWidth() const
wxPoint GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:601
bool TextVarResolver(wxString *aToken, const PROJECT *aProject) const
Definition: title_block.cpp:91
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:208
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:516
const wxPoint GetCenter() const
Definition: eda_rect.h:109
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:209
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_sheet.cpp:809
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:325
SEARCH_RESULT
Definition: eda_item.h:40
Message panel definition file.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_sheet.h:514
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
wxString GetPageNumber(const SCH_SHEET_PATH &aInstance) const
Return the sheet page number for aInstance.
Definition: sch_sheet.cpp:1106
SCH_SHEET & operator=(const SCH_ITEM &aSheet)
Definition: sch_sheet.cpp:1035
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363
void IncRefCount()
Definition: sch_screen.cpp:105
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1082
int GetRefCount() const
Definition: sch_screen.h:203
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:792
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: sch_sheet.cpp:926
bool GetColorMode() const
Definition: plotter.h:152