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-2017 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 
30 #include <fctsys.h>
31 #include <class_drawpanel.h>
32 #include <drawtxt.h>
33 #include <trigo.h>
34 #include <richio.h>
35 #include <schframe.h>
36 #include <plot_common.h>
37 #include <kicad_string.h>
38 #include <msgpanel.h>
39 
40 #include <sch_sheet.h>
41 #include <sch_sheet_path.h>
42 #include <sch_component.h>
43 #include <class_netlist_object.h>
44 
45 
47  SCH_ITEM( NULL, SCH_SHEET_T )
48 {
50  m_pos = pos;
55  m_screen = NULL;
56  m_name.Printf( wxT( "Sheet%8.8lX" ), (long) m_TimeStamp );
57  m_fileName.Printf( wxT( "file%8.8lX.sch" ), (long) m_TimeStamp );
58 }
59 
60 
61 SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
62  SCH_ITEM( aSheet )
63 {
64  m_pos = aSheet.m_pos;
65  m_size = aSheet.m_size;
66  m_Layer = aSheet.m_Layer;
67  SetTimeStamp( aSheet.m_TimeStamp );
70  m_screen = aSheet.m_screen;
71  m_name = aSheet.m_name;
72  m_fileName = aSheet.m_fileName;
73  m_pins = aSheet.m_pins;
74 
75  for( size_t i = 0; i < m_pins.size(); i++ )
76  m_pins[i].SetParent( this );
77 
78  if( m_screen )
80 }
81 
82 
84 {
85  // also, look at the associated sheet & its reference count
86  // perhaps it should be deleted also.
87  if( m_screen )
88  {
90 
91  if( m_screen->GetRefCount() == 0 )
92  delete m_screen;
93  }
94 }
95 
96 
98 {
99  return new SCH_SHEET( *this );
100 }
101 
102 
104 {
105  if( aScreen == m_screen )
106  return;
107 
108  if( m_screen != NULL )
109  {
111 
112  if( m_screen->GetRefCount() == 0 )
113  {
114  delete m_screen;
115  m_screen = NULL;
116  }
117  }
118 
119  m_screen = aScreen;
120 
121  if( m_screen )
123 }
124 
125 
127 {
128  if( m_screen == NULL )
129  return 0;
130 
131  return m_screen->GetRefCount();
132 }
133 
134 
136 {
137  SCH_SHEET* sheet = dynamic_cast< SCH_SHEET* >( GetParent() );
138 
139  if( sheet == NULL )
140  return this;
141 
142  // Recurse until a sheet is found with no parent which is the root sheet.
143  return sheet->GetRootSheet();
144 }
145 
146 
147 bool SCH_SHEET::Save( FILE* aFile ) const
148 {
149  if( fprintf( aFile, "$Sheet\n" ) == EOF
150  || fprintf( aFile, "S %-4d %-4d %-4d %-4d\n",
151  m_pos.x, m_pos.y, m_size.x, m_size.y ) == EOF )
152  return false;
153 
154  //save the unique timestamp, like other schematic parts.
155  if( fprintf( aFile, "U %8.8lX\n", (unsigned long) m_TimeStamp ) == EOF )
156  return false;
157 
158  /* Save schematic sheetname and filename. */
159  if( !m_name.IsEmpty() )
160  {
161  if( fprintf( aFile, "F0 %s %d\n", EscapedUTF8( m_name ).c_str(),
162  m_sheetNameSize ) == EOF )
163  return false;
164  }
165 
166  if( !m_fileName.IsEmpty() )
167  {
168  if( fprintf( aFile, "F1 %s %d\n", EscapedUTF8( m_fileName ).c_str(),
169  m_fileNameSize ) == EOF )
170  return false;
171  }
172 
173  /* Save the list of labels in the sheet. */
174 
175  for( const SCH_SHEET_PIN& label : m_pins )
176  {
177  if( !label.Save( aFile ) )
178  return false;
179  }
180 
181  if( fprintf( aFile, "$EndSheet\n" ) == EOF )
182  return false;
183 
184  return true;
185 }
186 
187 
188 bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
189 {
190  int fieldNdx, size;
191  SCH_SHEET_PIN* sheetPin;
192  char* ptcar;
193  unsigned long timeStamp = 0UL;
194 
196 
197  // sheets are added to the GetDrawItems() like other schematic components.
198  // however, in order to preserve the hierarchy (through m_Parent pointers),
199  // a duplicate of the sheet is added to m_SubSheet array.
200  // must be a duplicate, references just work for a two-layer structure.
201  // this is accomplished through the Sync() function.
202 
203  if( ((char*)aLine)[0] == '$' ) // line should be "$Sheet"
204  {
205  if( !aLine.ReadLine() )
206  {
207  aErrorMsg.Printf( wxT( "Read File Error" ) );
208  return false;
209  }
210  }
211 
212  /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position
213  * ( upper left corner ) et nn,mm = sheet size */
214  if( ( sscanf( &((char*)aLine)[1], "%d %d %d %d",
215  &m_pos.x, &m_pos.y, &m_size.x, &m_size.y ) != 4 )
216  || ( ((char*)aLine)[0] != 'S' ) )
217  {
218  aErrorMsg.Printf( wxT( " ** Eeschema file sheet struct error at line %d, aborted\n" ),
219  aLine.LineNumber() );
220 
221  aErrorMsg << FROM_UTF8( ((char*)aLine) );
222  return false;
223  }
224 
225  /* Read fields */
226  for( ; ; ) /* Analysis of lines "Fn" text. */
227  {
228  if( !aLine.ReadLine() )
229  return false;
230 
231  if( ((char*)aLine)[0] == 'U' )
232  {
233  sscanf( ((char*)aLine) + 1, "%lX", &timeStamp );
234 
235  m_TimeStamp = (time_t) timeStamp;
236 
237  if( m_TimeStamp == 0 ) // zero is not unique!
239 
240  continue;
241  }
242 
243  if( ((char*)aLine)[0] != 'F' )
244  break;
245 
246  sscanf( ((char*)aLine) + 1, "%d", &fieldNdx );
247 
248  /* Read the field:
249  * If fieldNdx> = 2: Fn "text" t s posx posy
250  * If F0 "text" for SheetName
251  * F1 and "text" for filename
252  */
253  ptcar = ((char*)aLine);
254 
255  while( *ptcar && ( *ptcar != '"' ) )
256  ptcar++;
257 
258  if( *ptcar != '"' )
259  {
260  aErrorMsg.Printf( wxT( "Eeschema file sheet label F%d at line %d, aborted\n" ),
261  fieldNdx, aLine.LineNumber() );
262  aErrorMsg << FROM_UTF8( (char*) aLine );
263  return false;
264  }
265 
266  wxString sheetName;
267  ptcar += ReadDelimitedText( &sheetName, ptcar );
268 
269  if( *ptcar == 0 )
270  {
271  aErrorMsg.Printf( wxT( "Eeschema file sheet field F at line %d, aborted\n" ),
272  aLine.LineNumber() );
273  aErrorMsg << FROM_UTF8( (char*) aLine );
274  return false;
275  }
276 
277  if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) )
278  {
279  if( sscanf( ptcar, "%d", &size ) != 1 )
280  {
281  aErrorMsg.Printf( wxT( "Eeschema file sheet Label error line %d, aborted\n" ),
282  aLine.LineNumber() );
283 
284  aErrorMsg << FROM_UTF8( (char*) aLine );
285  }
286 
287  if( size == 0 )
288  size = GetDefaultTextSize();
289 
290  if( fieldNdx == 0 )
291  {
292  m_name = sheetName;
293  m_sheetNameSize = size;
294  }
295  else
296  {
297  SetFileName( sheetName );
298  m_fileNameSize = size;
299  }
300  }
301 
302  if( fieldNdx > 1 )
303  {
304  sheetPin = new SCH_SHEET_PIN( this );
305 
306  if( !sheetPin->Load( aLine, aErrorMsg ) )
307  {
308  delete sheetPin;
309  sheetPin = NULL;
310  return false;
311  }
312 
313  AddPin( sheetPin );
314  }
315  }
316 
317  if( strncasecmp( "$End", ((char*)aLine), 4 ) != 0 )
318  {
319  aErrorMsg.Printf( wxT( "**Eeschema file end_sheet struct error at line %d, aborted\n" ),
320  aLine.LineNumber() );
321  aErrorMsg << FROM_UTF8( ((char*)aLine) );
322  return false;
323  }
324 
325  return true;
326 }
327 
328 
330 {
331  wxCHECK_RET( aItem->Type() == SCH_SHEET_T,
332  wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ),
333  GetChars( aItem->GetClass() ) ) );
334 
335  SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
336 
337  std::swap( m_pos, sheet->m_pos );
338  std::swap( m_size, sheet->m_size );
339  std::swap( m_name, sheet->m_name );
340  std::swap( m_sheetNameSize, sheet->m_sheetNameSize );
341  std::swap( m_fileNameSize, sheet->m_fileNameSize );
342  m_pins.swap( sheet->m_pins );
343 
344  // Ensure sheet labels have their .m_Parent member pointing really on their
345  // parent, after swapping.
346  for( SCH_SHEET_PIN& sheetPin : m_pins )
347  {
348  sheetPin.SetParent( this );
349  }
350 
351  for( SCH_SHEET_PIN& sheetPin : sheet->m_pins )
352  {
353  sheetPin.SetParent( sheet );
354  }
355 }
356 
357 
359 {
360  wxASSERT( aSheetPin != NULL );
361  wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
362 
363  m_pins.push_back( aSheetPin );
364  renumberPins();
365 }
366 
367 
369 {
370  wxASSERT( aSheetPin != NULL );
371  wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
372 
373  SCH_SHEET_PINS::iterator i;
374 
375  for( i = m_pins.begin(); i < m_pins.end(); ++i )
376  {
377  if( *i == aSheetPin )
378  {
379  m_pins.erase( i );
380  renumberPins();
381  return;
382  }
383  }
384 
385  wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ),
386  GetChars( aSheetPin->GetShownText() ), GetChars( m_name ) );
387 }
388 
389 
390 bool SCH_SHEET::HasPin( const wxString& aName )
391 {
392  for( SCH_SHEET_PIN pin : m_pins )
393  {
394  if( pin.GetText().CmpNoCase( aName ) == 0 )
395  return true;
396  }
397 
398  return false;
399 }
400 
401 
403 {
404  for( SCH_SHEET_PIN pin : m_pins )
405  {
406  if( pin.GetEdge() > 1 )
407  return true;
408  }
409  return false;
410 }
411 
412 
414 {
415  for( SCH_SHEET_PIN pin : m_pins )
416  {
417  /* Search the schematic for a hierarchical label corresponding to this sheet label. */
418  EDA_ITEM* DrawStruct = m_screen->GetDrawItems();
419  const SCH_HIERLABEL* HLabel = NULL;
420 
421  for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
422  {
423  if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
424  continue;
425 
426  HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct );
427 
428  if( pin.GetText().CmpNoCase( HLabel->GetText() ) == 0 )
429  break; // Found!
430 
431  HLabel = NULL;
432  }
433 
434  if( HLabel == NULL ) // Corresponding hierarchical label not found.
435  return true;
436  }
437 
438  return false;
439 }
440 
441 
443 {
444  int width = MIN_SHEET_WIDTH;
445 
446  for( size_t i = 0; i < m_pins.size(); i++ )
447  {
448  int edge = m_pins[i].GetEdge();
449  EDA_RECT pinRect = m_pins[i].GetBoundingBox();
450 
451  wxASSERT( edge != SCH_SHEET_PIN::SHEET_UNDEFINED_SIDE );
452 
454  {
455  if( width < pinRect.GetRight() - m_pos.x )
456  width = pinRect.GetRight() - m_pos.x;
457  }
458  else
459  {
460  if( width < pinRect.GetWidth() )
461  width = pinRect.GetWidth();
462 
463  for( size_t j = 0; j < m_pins.size(); j++ )
464  {
465  // Check for pin directly across from the current pin.
466  if( (i == j) || (m_pins[i].GetPosition().y != m_pins[j].GetPosition().y) )
467  continue;
468 
469  if( width < pinRect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth() )
470  {
471  width = pinRect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth();
472  break;
473  }
474  }
475  }
476  }
477 
478  return width;
479 }
480 
481 
483 {
484  int height = MIN_SHEET_HEIGHT;
485 
486  for( size_t i = 0; i < m_pins.size(); i++ )
487  {
488  int edge = m_pins[i].GetEdge();
489  EDA_RECT pinRect = m_pins[i].GetBoundingBox();
490 
491  // Make sure pin is on top or bottom side of sheet.
493  {
494  if( height < pinRect.GetBottom() - m_pos.y )
495  height = pinRect.GetBottom() - m_pos.y;
496  }
497  else
498  {
499  if( height < pinRect.GetHeight() )
500  height = pinRect.GetHeight();
501 
502  for( size_t j = 0; j < m_pins.size(); j++ )
503  {
504  // Check for pin directly above or below the current pin.
505  if( (i == j) || (m_pins[i].GetPosition().x != m_pins[j].GetPosition().x) )
506  continue;
507 
508  if( height < pinRect.GetHeight() + m_pins[j].GetBoundingBox().GetHeight() )
509  {
510  height = pinRect.GetHeight() + m_pins[j].GetBoundingBox().GetHeight();
511  break;
512  }
513  }
514  }
515  }
516 
517  return height;
518 }
519 
520 
522 {
523  SCH_SHEET_PINS::iterator i = m_pins.begin();
524 
525  while( i != m_pins.end() )
526  {
527  /* Search the schematic for a hierarchical label corresponding to this sheet label. */
528  EDA_ITEM* DrawStruct = m_screen->GetDrawItems();
529  const SCH_HIERLABEL* HLabel = NULL;
530 
531  for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
532  {
533  if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
534  continue;
535 
536  HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct );
537 
538  if( i->GetText().CmpNoCase( HLabel->GetText() ) == 0 )
539  break; // Found!
540 
541  HLabel = NULL;
542  }
543 
544  if( HLabel == NULL ) // Hlabel not found: delete sheet label.
545  i = m_pins.erase( i );
546  else
547  ++i;
548  }
549 }
550 
551 
553 {
554  for( SCH_SHEET_PIN& pin : m_pins )
555  {
556  if( pin.HitTest( aPosition, 0 ) )
557  return &pin;
558  }
559 
560  return NULL;
561 }
562 
563 
565 {
566  return GetDefaultLineThickness();
567 }
568 
569 
571 {
572  wxPoint pos = m_pos;
573 
574  if( IsVerticalOrientation() )
575  {
576  pos.x -= 8;
577  pos.y += m_size.y;
578  }
579  else
580  {
581  pos.y -= 8;
582  }
583 
584  return pos;
585 }
586 
587 
589 {
590  wxPoint pos = m_pos;
591  int margin = GetPenSize() + 4;
592 
593  if( IsVerticalOrientation() )
594  {
595  pos.x += m_size.x + margin;
596  pos.y += m_size.y;
597  }
598  else
599  {
600  pos.y += m_size.y + margin;
601  }
602 
603  return pos;
604 }
605 
606 
607 void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
608  const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
609 {
610  COLOR4D txtcolor;
611  wxString Text;
612  COLOR4D color;
613  int name_orientation;
614  wxPoint pos_sheetname,pos_filename;
615  wxPoint pos = m_pos + aOffset;
616  int lineWidth = GetPenSize();
617  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
618 
619  if( aColor != COLOR4D::UNSPECIFIED )
620  color = aColor;
621  else
622  color = GetLayerColor( m_Layer );
623 
624  GRSetDrawMode( aDC, aDrawMode );
625 
626  GRRect( clipbox, aDC, pos.x, pos.y,
627  pos.x + m_size.x, pos.y + m_size.y, lineWidth, color );
628 
629  pos_sheetname = GetSheetNamePosition() + aOffset;
630  pos_filename = GetFileNamePosition() + aOffset;
631 
632  if( IsVerticalOrientation() )
633  name_orientation = TEXT_ANGLE_VERT;
634  else
635  name_orientation = TEXT_ANGLE_HORIZ;
636 
637  /* Draw text : SheetName */
638  if( aColor != COLOR4D::UNSPECIFIED )
639  txtcolor = aColor;
640  else
641  txtcolor = GetLayerColor( LAYER_SHEETNAME );
642 
643  Text = wxT( "Sheet: " ) + m_name;
644  DrawGraphicText( clipbox, aDC, pos_sheetname,
645  txtcolor, Text, name_orientation,
646  wxSize( m_sheetNameSize, m_sheetNameSize ),
648  false, false );
649 
650  /* Draw text : FileName */
651  if( aColor != COLOR4D::UNSPECIFIED )
652  txtcolor = aColor;
653  else
654  txtcolor = GetLayerColor( LAYER_SHEETFILENAME );
655 
656  Text = wxT( "File: " ) + m_fileName;
657  DrawGraphicText( clipbox, aDC, pos_filename,
658  txtcolor, Text, name_orientation,
659  wxSize( m_fileNameSize, m_fileNameSize ),
661  false, false );
662 
663  /* Draw text : SheetLabel */
664  for( SCH_SHEET_PIN& sheetPin : m_pins )
665  {
666  if( !sheetPin.IsMoving() )
667  sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
668  }
669 
670 
671 #if 0
672  // Only for testing purposes, draw the component bounding box
674  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
675  GRFilledCircle( aPanel->GetClipBox(), aDC, m_pos.x, m_pos.y, 10, 0, color, color );
676 #endif
677 }
678 
679 
681 {
682  wxPoint end;
683  EDA_RECT box( m_pos, m_size );
684  int lineWidth = GetPenSize();
685 
686  // Determine length of texts
687  wxString text = wxT( "Sheet: " ) + m_name;
688  int textlen = GraphicTextWidth( text, wxSize( m_sheetNameSize, m_sheetNameSize ),
689  false, false );
690 
691  text = wxT( "File: " ) + m_fileName;
692  int textlen2 = GraphicTextWidth( text, wxSize( m_fileNameSize, m_fileNameSize ),
693  false, false );
694 
695  // Calculate bounding box X size:
696  textlen = std::max( textlen, textlen2 );
697  end.x = std::max( m_size.x, textlen );
698 
699  // Calculate bounding box pos:
700  end.y = m_size.y;
701  end += m_pos;
702 
703  // Move upper and lower limits to include texts:
704  box.SetY( box.GetY() - ( KiROUND( m_sheetNameSize * 1.3 ) + 8 ) );
705  end.y += KiROUND( m_fileNameSize * 1.3 ) + 8;
706 
707  box.SetEnd( end );
708  box.Inflate( lineWidth / 2 );
709 
710  return box;
711 }
712 
713 
715 {
716  int n = 0;
717 
718  if( m_screen )
719  {
720  EDA_ITEM* bs;
721 
722  for( bs = m_screen->GetDrawItems(); bs != NULL; bs = bs->Next() )
723  {
724  if( bs->Type() == SCH_COMPONENT_T )
725  {
726  SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
727 
728  if( Cmp->GetField( VALUE )->GetText().GetChar( 0 ) != '#' )
729  n++;
730  }
731 
732  if( bs->Type() == SCH_SHEET_T )
733  {
734  SCH_SHEET* sheet = (SCH_SHEET*) bs;
735  n += sheet->ComponentCount();
736  }
737  }
738  }
739 
740  return n;
741 }
742 
743 
744 bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
745 {
746  if( m_screen )
747  {
748  EDA_ITEM* item = m_screen->GetDrawItems();
749 
750  while( item )
751  {
752  if( item->Type() == SCH_SHEET_T )
753  {
754  SCH_SHEET* sheet = (SCH_SHEET*) item;
755 
756  if( sheet->m_screen
757  && sheet->m_screen->GetFileName().CmpNoCase( aFilename ) == 0 )
758  {
759  *aScreen = sheet->m_screen;
760  return true;
761  }
762 
763  if( sheet->SearchHierarchy( aFilename, aScreen ) )
764  return true;
765  }
766 
767  item = item->Next();
768  }
769  }
770 
771  return false;
772 }
773 
774 
776 {
777  if( m_screen )
778  {
779  aList->push_back( this );
780 
781  if( m_screen == aScreen )
782  return true;
783 
784  EDA_ITEM* strct = m_screen->GetDrawItems();
785 
786  while( strct )
787  {
788  if( strct->Type() == SCH_SHEET_T )
789  {
790  SCH_SHEET* ss = (SCH_SHEET*) strct;
791 
792  if( ss->LocatePathOfScreen( aScreen, aList ) )
793  return true;
794  }
795 
796  strct = strct->Next();
797  }
798 
799  aList->pop_back();
800  }
801 
802  return false;
803 }
804 
805 
807 {
808  bool success = true;
809 
810  SCH_SCREEN* screen = NULL;
811 
812  if( !m_screen )
813  {
815 
816  if( screen )
817  {
818  SetScreen( screen );
819 
820  //do not need to load the sub-sheets - this has already been done.
821  }
822  else
823  {
824  SetScreen( new SCH_SCREEN( &aFrame->Kiway() ) );
825 
826  success = aFrame->LoadOneEEFile( m_screen, m_fileName );
827 
828  if( success )
829  {
830  EDA_ITEM* bs = m_screen->GetDrawItems();
831 
832  while( bs )
833  {
834  if( bs->Type() == SCH_SHEET_T )
835  {
836  SCH_SHEET* sheet = (SCH_SHEET*) bs;
837 
838  // Set the parent to this sheet. This effectively creates a method
839  // to find the root sheet from any sheet so a pointer to the root
840  // sheet does not need to be stored globally. Note: this is not the
841  // same as a hierarchy. Complex hierarchies can have multiple copies
842  // of a sheet. This only provides a simple tree to find the root sheet.
843  sheet->SetParent( this );
844 
845  if( !sheet->Load( aFrame ) )
846  success = false;
847  }
848 
849  bs = bs->Next();
850  }
851  }
852  }
853  }
854 
855  return success;
856 }
857 
858 
860 {
861  int count = 1; //1 = this!!
862 
863  if( m_screen )
864  {
865  EDA_ITEM* strct = m_screen->GetDrawItems();
866 
867  for( ; strct; strct = strct->Next() )
868  {
869  if( strct->Type() == SCH_SHEET_T )
870  {
871  SCH_SHEET* subsheet = (SCH_SHEET*) strct;
872  count += subsheet->CountSheets();
873  }
874  }
875  }
876  return count;
877 }
878 
879 
880 wxString SCH_SHEET::GetFileName( void ) const
881 {
882  return m_fileName;
883 }
884 
885 
887 {
888  aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) );
889  aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) );
890 
891 #if 0 // Set to 1 to display the sheet time stamp (mainly for test)
892  wxString msg;
893  msg.Printf( wxT( "%.8X" ), m_TimeStamp );
894  aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), msg, BLUE ) );
895 #endif
896 }
897 
898 
899 void SCH_SHEET::Rotate(wxPoint aPosition)
900 {
901  RotatePoint( &m_pos, aPosition, 900 );
902  RotatePoint( &m_size.x, &m_size.y, 900 );
903 
904  if( m_size.x < 0 )
905  {
906  m_pos.x += m_size.x;
907  m_size.x = -m_size.x;
908  }
909 
910  if( m_size.y < 0 )
911  {
912  m_pos.y += m_size.y;
913  m_size.y = -m_size.y;
914  }
915 
916  for( SCH_SHEET_PIN& sheetPin : m_pins )
917  {
918  sheetPin.Rotate( aPosition );
919  }
920 }
921 
922 
923 void SCH_SHEET::MirrorX( int aXaxis_position )
924 {
925  MIRROR( m_pos.y, aXaxis_position );
926  m_pos.y -= m_size.y;
927 
928  for( SCH_SHEET_PIN& sheetPin : m_pins )
929  {
930  sheetPin.MirrorX( aXaxis_position );
931  }
932 }
933 
934 
935 void SCH_SHEET::MirrorY( int aYaxis_position )
936 {
937  MIRROR( m_pos.x, aYaxis_position );
938  m_pos.x -= m_size.x;
939 
940  for( SCH_SHEET_PIN& label : m_pins )
941  {
942  label.MirrorY( aYaxis_position );
943  }
944 }
945 
946 void SCH_SHEET::SetPosition( const wxPoint& aPosition )
947 {
948  // Remember the sheet and all pin sheet positions must be
949  // modified. So use Move function to do that.
950  Move( aPosition - m_pos );
951 }
952 
953 
954 
955 void SCH_SHEET::Resize( const wxSize& aSize )
956 {
957  if( aSize == m_size )
958  return;
959 
960  m_size = aSize;
961 
962  /* Move the sheet labels according to the new sheet size. */
963  for( SCH_SHEET_PIN& label : m_pins )
964  {
965  label.ConstrainOnEdge( label.GetPosition() );
966  }
967 }
968 
969 
970 bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
971 {
972  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
973 
974  // Ignore the sheet file name if searching to replace.
975  if( !(aSearchData.GetFlags() & FR_SEARCH_REPLACE)
976  && SCH_ITEM::Matches( m_fileName, aSearchData ) )
977  {
978  if( aFindLocation )
979  *aFindLocation = GetFileNamePosition();
980 
981  return true;
982  }
983 
984  if( SCH_ITEM::Matches( m_name, aSearchData ) )
985  {
986  if( aFindLocation )
987  *aFindLocation = GetSheetNamePosition();
988 
989  return true;
990  }
991 
992  return false;
993 }
994 
995 
996 bool SCH_SHEET::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
997 {
998  return EDA_ITEM::Replace( aSearchData, m_name );
999 }
1000 
1001 
1003 {
1004  int id = 2;
1005 
1006  for( SCH_SHEET_PIN& pin : m_pins )
1007  {
1008  pin.SetNumber( id );
1009  id++;
1010  }
1011 }
1012 
1013 
1014 void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
1015 {
1016  for( unsigned ii = 0; ii < GetPins().size(); ii++ )
1017  {
1018  SCH_SHEET_PIN &pinsheet = GetPins()[ii];
1019 
1020  wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_PIN_T, continue,
1021  wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
1022 
1023  pinsheet.GetEndPoints( aItemList );
1024  }
1025 }
1026 
1027 
1028 bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
1029 {
1030  bool currentState = IsDangling();
1031 
1032  for( SCH_SHEET_PIN& pinsheet : GetPins() )
1033  {
1034  pinsheet.IsDanglingStateChanged( aItemList );
1035  }
1036 
1037  return currentState != IsDangling();
1038 }
1039 
1040 
1042 {
1043  // If any hierarchical label in the sheet is dangling, then the sheet is dangling.
1044  for( size_t i = 0; i < GetPins().size(); i++ )
1045  {
1046  if( GetPins()[i].IsDangling() )
1047  return true;
1048  }
1049 
1050  return false;
1051 }
1052 
1053 
1054 bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
1055 {
1056  bool previousState = IsSelected();
1057 
1059 
1060  if( aRect.Intersects( boundingBox ) )
1061  SetFlags( SELECTED );
1062  else
1063  ClearFlags( SELECTED );
1064 
1065  return previousState != IsSelected();
1066 }
1067 
1068 
1069 void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
1070 {
1071  for( size_t i = 0; i < GetPins().size(); i++ )
1072  aPoints.push_back( GetPins()[i].GetPosition() );
1073 }
1074 
1075 
1076 SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICAD_T aFilterTypes[] )
1077 {
1078  KICAD_T stype;
1079 
1080  for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
1081  {
1082  // If caller wants to inspect my type
1083  if( stype == Type() )
1084  {
1085  if( SEARCH_QUIT == aInspector( this, NULL ) )
1086  return SEARCH_QUIT;
1087  }
1088  else if( stype == SCH_SHEET_PIN_T )
1089  {
1090  // Test the sheet labels.
1091  for( size_t i = 0; i < m_pins.size(); i++ )
1092  {
1093  if( SEARCH_QUIT == aInspector( &m_pins[ i ], this ) )
1094  return SEARCH_QUIT;
1095  }
1096  }
1097  }
1098 
1099  return SEARCH_CONTINUE;
1100 }
1101 
1102 
1104 {
1105  wxString tmp;
1106  tmp.Printf( _( "Hierarchical Sheet %s" ), GetChars( m_name ) );
1107  return tmp;
1108 }
1109 
1110 
1112 {
1113  return add_hierarchical_subsheet_xpm;
1114 }
1115 
1116 
1117 bool SCH_SHEET::HitTest( const wxPoint& aPosition, int aAccuracy ) const
1118 {
1119  EDA_RECT rect = GetBoundingBox();
1120 
1121  rect.Inflate( aAccuracy );
1122 
1123  return rect.Contains( aPosition );
1124 }
1125 
1126 
1127 bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1128 {
1129  EDA_RECT rect = aRect;
1130 
1131  rect.Inflate( aAccuracy );
1132 
1133  if( aContained )
1134  return rect.Contains( GetBoundingBox() );
1135 
1136  return rect.Intersects( GetBoundingBox() );
1137 }
1138 
1139 
1141 {
1142  return wxPoint( m_pos.x + m_size.GetWidth(), m_pos.y + m_size.GetHeight() );
1143 }
1144 
1145 
1147  SCH_SHEET_PATH* aSheetPath )
1148 {
1149  SCH_SHEET_PATH sheetPath = *aSheetPath;
1150  sheetPath.push_back( this );
1151 
1152  for( size_t i = 0; i < m_pins.size(); i++ )
1153  {
1154  NETLIST_OBJECT* item = new NETLIST_OBJECT();
1155  item->m_SheetPathInclude = sheetPath;
1156  item->m_SheetPath = *aSheetPath;
1157  item->m_Comp = &m_pins[i];
1158  item->m_Link = this;
1159  item->m_Type = NET_SHEETLABEL;
1160  item->m_Label = m_pins[i].GetText();
1161  item->m_Start = item->m_End = m_pins[i].GetPosition();
1162  aNetListItems.push_back( item );
1163 
1164  if( IsBusLabel( m_pins[i].GetText() ) )
1165  item->ConvertBusToNetListItems( aNetListItems );
1166  }
1167 }
1168 
1169 
1170 void SCH_SHEET::Plot( PLOTTER* aPlotter )
1171 {
1172  COLOR4D txtcolor = COLOR4D::UNSPECIFIED;
1173  wxSize size;
1174  wxString Text;
1175  int name_orientation;
1176  wxPoint pos_sheetname, pos_filename;
1177  wxPoint pos;
1178 
1179  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
1180 
1181  int thickness = GetPenSize();
1182  aPlotter->SetCurrentLineWidth( thickness );
1183 
1184  aPlotter->MoveTo( m_pos );
1185  pos = m_pos;
1186  pos.x += m_size.x;
1187 
1188  aPlotter->LineTo( pos );
1189  pos.y += m_size.y;
1190 
1191  aPlotter->LineTo( pos );
1192  pos = m_pos;
1193  pos.y += m_size.y;
1194 
1195  aPlotter->LineTo( pos );
1196  aPlotter->FinishTo( m_pos );
1197 
1198  if( IsVerticalOrientation() )
1199  {
1200  pos_sheetname = wxPoint( m_pos.x - 8, m_pos.y + m_size.y );
1201  pos_filename = wxPoint( m_pos.x + m_size.x + 4, m_pos.y + m_size.y );
1202  name_orientation = TEXT_ANGLE_VERT;
1203  }
1204  else
1205  {
1206  pos_sheetname = wxPoint( m_pos.x, m_pos.y - 4 );
1207  pos_filename = wxPoint( m_pos.x, m_pos.y + m_size.y + 4 );
1208  name_orientation = TEXT_ANGLE_HORIZ;
1209  }
1210 
1211  /* Draw texts: SheetName */
1212  Text = m_name;
1213  size = wxSize( m_sheetNameSize, m_sheetNameSize );
1214 
1215  //pos = m_pos; pos.y -= 4;
1216  thickness = GetDefaultLineThickness();
1217  thickness = Clamp_Text_PenSize( thickness, size, false );
1218 
1219  aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) );
1220 
1221  bool italic = false;
1222  aPlotter->Text( pos_sheetname, txtcolor, Text, name_orientation, size,
1224  thickness, italic, false );
1225 
1226  /*Draw texts : FileName */
1227  Text = GetFileName();
1228  size = wxSize( m_fileNameSize, m_fileNameSize );
1229  thickness = GetDefaultLineThickness();
1230  thickness = Clamp_Text_PenSize( thickness, size, false );
1231 
1232  aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) );
1233 
1234  aPlotter->Text( pos_filename, txtcolor, Text, name_orientation, size,
1236  thickness, italic, false );
1237 
1238  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
1239 
1240  /* Draw texts : SheetLabel */
1241  for( size_t i = 0; i < m_pins.size(); i++ )
1242  {
1243  m_pins[i].Plot( aPlotter );
1244  }
1245 }
1246 
1247 
1249 {
1250  wxLogDebug( wxT( "Sheet assignment operator." ) );
1251 
1252  wxCHECK_MSG( Type() == aItem.Type(), *this,
1253  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1254  GetClass() );
1255 
1256  if( &aItem != this )
1257  {
1258  SCH_ITEM::operator=( aItem );
1259 
1260  SCH_SHEET* sheet = (SCH_SHEET*) &aItem;
1261 
1262  m_pos = sheet->m_pos;
1263  m_size = sheet->m_size;
1264  m_name = sheet->m_name;
1266  m_fileNameSize = sheet->m_fileNameSize;
1267  m_pins = sheet->m_pins;
1268 
1269  // Ensure sheet labels have their #m_Parent member pointing really on their
1270  // parent, after assigning.
1271  for( SCH_SHEET_PIN& sheetPin : m_pins )
1272  {
1273  sheetPin.SetParent( this );
1274  }
1275  }
1276 
1277  return *this;
1278 }
1279 
1280 
1281 #if defined(DEBUG)
1282 
1283 void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
1284 {
1285  // XML output:
1286  wxString s = GetClass();
1287 
1288  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
1289  << TO_UTF8( m_name ) << '"' << ">\n";
1290 
1291  // show all the pins, and check the linked list integrity
1292  for( const SCH_SHEET_PIN& label : m_pins )
1293  {
1294  label.Show( nestLevel + 1, os );
1295  }
1296 
1297  NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
1298 }
1299 
1300 #endif
Definition: colors.h:57
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
Definition of the SCH_SHEET class for Eeschema.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:91
bool IsBusLabel(const wxString &aLabel)
Function IsBusLabel test if aLabel has a bus notation.
SCH_LAYER_ID m_Layer
SCH_ITEM & operator=(const SCH_ITEM &aSheet)
Definition: sch_sheet.cpp:1248
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_sheet.cpp:188
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void DrawGraphicText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
Definition: drawtxt.cpp:122
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Function SearchHierarchy search the existing hierarchy for an instance of screen "FileName".
Definition: sch_sheet.cpp:744
SCH_SHEET_PIN * GetPin(const wxPoint &aPosition)
Return the sheet pin item found at aPosition in the sheet.
Definition: sch_sheet.cpp:552
bool IsDangling() const override
Definition: sch_sheet.cpp:1041
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
SCH_SHEET_PINS & GetPins()
Definition: sch_sheet.h:348
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:159
PNG memory record (file in memory).
Definition: bitmap_types.h:38
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
SCH_SHEET_PATH m_SheetPathInclude
bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:503
virtual void SetColor(COLOR4D color)=0
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:183
unsigned long timeStamp(wxXmlNode *aTree)
Make a unique time stamp.
bool Contains(const wxPoint &aPoint) const
Function Contains.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points...
Definition: sch_sheet.cpp:1014
int CountSheets()
Function CountSheets calculates the number of sheets found in "this" this number includes the full su...
Definition: sch_sheet.cpp:859
friend class SCH_SHEET_PIN
Definition: sch_sheet.h:218
int GetMinHeight() const
Function GetMinHeight returns the minimum height that the sheet can be resized based on the sheet pin...
Definition: sch_sheet.cpp:482
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:414
int m_sheetNameSize
The height of the text used to draw the sheet name.
Definition: sch_sheet.h:236
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i...
void SetScreen(SCH_SCREEN *aScreen)
Function SetScreen sets the screen associated with this sheet to aScreen.
Definition: sch_sheet.cpp:103
const wxString & GetFileName() const
wxPoint GetResizePosition() const
Function GetResizePos returns the position of the lower right corner of the sheet in drawing units...
Definition: sch_sheet.cpp:1140
time_t GetNewTimeStamp()
Definition: common.cpp:166
bool IsDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_sheet.cpp:1028
int GetHeight() const
wxSize m_size
The size of the sheet.
Definition: sch_sheet.h:245
bool IsSelected() const
Definition: base_struct.h:235
wxString m_name
This is equivalent to the reference designator for components and is stored in F0 sheet pin in the sc...
Definition: sch_sheet.h:233
EDA_ITEM * GetParent() const
Definition: base_struct.h:222
SCH_SHEET * GetRootSheet()
Function GetRootSheet.
Definition: sch_sheet.cpp:135
int ComponentCount()
Function ComponentCount count our own components, without the power components.
Definition: sch_sheet.cpp:714
int GetRefCount() const
Schematic editor (Eeschema) main window.
Definition: schframe.h:117
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
SCH_SHEET_PATH m_SheetPath
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: sch_sheet.cpp:886
EDA_ITEM * Next() const
Definition: base_struct.h:220
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_sheet.cpp:970
NETLIST_ITEM_T m_Type
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:564
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:833
wxPoint m_pos
The position of the sheet.
Definition: sch_sheet.h:242
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:358
#define TEXT_ANGLE_VERT
Definition: common.h:92
search types array terminator (End Of Types)
Definition: typeinfo.h:94
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:47
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:217
wxString m_fileName
The file name is also in the SCH_SCREEN object associated with the sheet.
Definition: sch_sheet.h:229
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: drawtxt.cpp:229
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:118
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
BOX2I boundingBox(T aObject)
boundingBox template method
Definition: shape_index.h:59
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
std::string EscapedUTF8(const wxString &aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:137
#define SELECTED
Definition: base_struct.h:134
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
void renumberPins()
Renumber the sheet pins in the sheet.
Definition: sch_sheet.cpp:1002
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_sheet.h:259
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:368
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
const wxString traceFindItem
Flag to enable finding schematic item debug output.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:680
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_sheet.cpp:923
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:227
SCH_SHEET_PINS m_pins
The list of sheet connection points.
Definition: sch_sheet.h:225
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void SetEnd(int x, int y)
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
Definition: drawtxt.cpp:67
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: colors.h:59
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
Definition: sch_sheet.cpp:1076
EDA_RECT * GetClipBox()
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
int GraphicTextWidth(const wxString &aText, const wxSize &aSize, bool aItalic, bool aBold)
Function GraphicTextWidth.
Definition: drawtxt.cpp:88
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_sheet.cpp:1103
Class SCH_SHEET_PIN defines a sheet pin (label) used in sheets to create hierarchical schematics...
Definition: sch_sheet.h:62
int GetBottom() const
Class SCH_SHEET_PATH.
int GetScreenCount() const
Function GetScreenCount returns the number of times the associated screen for the sheet is being used...
Definition: sch_sheet.cpp:126
int GetRight() const
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:521
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:582
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:899
wxString GetFileName(void) const
Function GetFileName return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:880
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Operator assignment is used to assign the members of aItem to another object.
void SetY(int val)
wxPoint GetFileNamePosition()
Function GetFileNamePosition.
Definition: sch_sheet.cpp:588
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
SCH_SHEET(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_sheet.cpp:46
Definition of the NETLIST_OBJECT class.
Field Value of part, i.e. "3.3K".
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_sheet.cpp:1069
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:413
void DecRefCount()
Definition: sch_screen.cpp:133
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Function LocatePathOfScreen search the existing hierarchy for an instance of screen "FileName"...
Definition: sch_sheet.cpp:775
Base plotter engine class.
Definition: plot_common.h:86
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_sheet.cpp:607
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
Definition the SCH_COMPONENT class for Eeschema.
int m_fileNameSize
The height of the text used to draw the file name.
Definition: sch_sheet.h:239
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_sheet.cpp:329
virtual char * ReadLine()=0
Function ReadLine reads a line of text into the buffer and increments the line number counter...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:97
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_sheet.cpp:1170
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points...
#define max(a, b)
Definition: auxiliary.h:86
int GetMinWidth() const
Function GetMinWidth returns the minimum width of the sheet based on the widths of the sheet pin text...
Definition: sch_sheet.cpp:442
bool LoadOneEEFile(SCH_SCREEN *aScreen, const wxString &aFullFileName, bool append=false)
Function LoadOneEEFile loads the schematic (.sch) file aFullFileName into aScreen.
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_sheet.cpp:935
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.cpp:946
wxPoint GetSheetNamePosition()
Function GetSheetNamePosition.
Definition: sch_sheet.cpp:570
Perform a search for a item that has replaceable text.
Class EDA_RECT handles the component boundary box.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
SCH_SCREEN * m_screen
Screen that contains the physical data for the sheet.
Definition: sch_sheet.h:222
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
int GetWidth() const
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:48
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:402
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
int GetY() const
virtual wxString GetClass() const override
Function GetClass returns the class name.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_sheet.cpp:1111
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
This file is part of the common libary.
bool HasPin(const wxString &aName)
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:390
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_sheet.cpp:147
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
int ReadDelimitedText(wxString *aDest, const char *aSource)
Function ReadDelimitedText copies bytes from aSource delimited string segment to aDest wxString...
Definition: string.cpp:43
SEARCH_RESULT
Definition: base_struct.h:82
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Message panel definition file.
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_sheet.cpp:1054
bool Replace(wxFindReplaceData &aSearchData, void *aAuxData=NULL) override
Function Replace performs a text replace using the find and replace criteria in aSearchData on items ...
Definition: sch_sheet.cpp:996
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_sheet.h:518
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void IncRefCount()
Definition: sch_screen.cpp:127
void ConvertBusToNetListItems(NETLIST_OBJECT_LIST &aNetListItems)
Function ConvertBusToNetListItems breaks the text of a bus label type net list object into as many me...
int GetDefaultTextSize()
Default size for text in general.
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:955
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_sheet.cpp:1117
void GetNetListItem(NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
Function GetNetListItem creates a new NETLIST_OBJECT for the schematic object and adds it to aNetList...
Definition: sch_sheet.cpp:1146
Definition: colors.h:62