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-2016 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 // wxLogDebug( wxT( "Destroying sheet " ) + m_name );
86 
87  // also, look at the associated sheet & its reference count
88  // perhaps it should be deleted also.
89  if( m_screen )
90  {
92 
93  if( m_screen->GetRefCount() == 0 )
94  delete m_screen;
95  }
96 }
97 
98 
100 {
101  return new SCH_SHEET( *this );
102 }
103 
104 
106 {
107  if( aScreen == m_screen )
108  return;
109 
110  if( m_screen != NULL )
111  {
113 
114  if( m_screen->GetRefCount() == 0 )
115  {
116  delete m_screen;
117  m_screen = NULL;
118  }
119  }
120 
121  m_screen = aScreen;
122 
123  if( m_screen )
125 }
126 
127 
129 {
130  if( m_screen == NULL )
131  return 0;
132 
133  return m_screen->GetRefCount();
134 }
135 
136 
138 {
139  SCH_SHEET* sheet = dynamic_cast< SCH_SHEET* >( GetParent() );
140 
141  if( sheet == NULL )
142  return this;
143 
144  // Recurse until a sheet is found with no parent which is the root sheet.
145  return sheet->GetRootSheet();
146 }
147 
148 
149 bool SCH_SHEET::Save( FILE* aFile ) const
150 {
151  if( fprintf( aFile, "$Sheet\n" ) == EOF
152  || fprintf( aFile, "S %-4d %-4d %-4d %-4d\n",
153  m_pos.x, m_pos.y, m_size.x, m_size.y ) == EOF )
154  return false;
155 
156  //save the unique timestamp, like other schematic parts.
157  if( fprintf( aFile, "U %8.8lX\n", (unsigned long) m_TimeStamp ) == EOF )
158  return false;
159 
160  /* Save schematic sheetname and filename. */
161  if( !m_name.IsEmpty() )
162  {
163  if( fprintf( aFile, "F0 %s %d\n", EscapedUTF8( m_name ).c_str(),
164  m_sheetNameSize ) == EOF )
165  return false;
166  }
167 
168  if( !m_fileName.IsEmpty() )
169  {
170  if( fprintf( aFile, "F1 %s %d\n", EscapedUTF8( m_fileName ).c_str(),
171  m_fileNameSize ) == EOF )
172  return false;
173  }
174 
175  /* Save the list of labels in the sheet. */
176 
177  for( const SCH_SHEET_PIN& label : m_pins )
178  {
179  if( !label.Save( aFile ) )
180  return false;
181  }
182 
183  if( fprintf( aFile, "$EndSheet\n" ) == EOF )
184  return false;
185 
186  return true;
187 }
188 
189 
190 bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
191 {
192  int fieldNdx, size;
193  SCH_SHEET_PIN* sheetPin;
194  char* ptcar;
195  unsigned long timeStamp = 0UL;
196 
198 
199  // sheets are added to the GetDrawItems() like other schematic components.
200  // however, in order to preserve the hierarchy (through m_Parent pointers),
201  // a duplicate of the sheet is added to m_SubSheet array.
202  // must be a duplicate, references just work for a two-layer structure.
203  // this is accomplished through the Sync() function.
204 
205  if( ((char*)aLine)[0] == '$' ) // line should be "$Sheet"
206  {
207  if( !aLine.ReadLine() )
208  {
209  aErrorMsg.Printf( wxT( "Read File Error" ) );
210  return false;
211  }
212  }
213 
214  /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position
215  * ( upper left corner ) et nn,mm = sheet size */
216  if( ( sscanf( &((char*)aLine)[1], "%d %d %d %d",
217  &m_pos.x, &m_pos.y, &m_size.x, &m_size.y ) != 4 )
218  || ( ((char*)aLine)[0] != 'S' ) )
219  {
220  aErrorMsg.Printf( wxT( " ** Eeschema file sheet struct error at line %d, aborted\n" ),
221  aLine.LineNumber() );
222 
223  aErrorMsg << FROM_UTF8( ((char*)aLine) );
224  return false;
225  }
226 
227  /* Read fields */
228  for( ; ; ) /* Analysis of lines "Fn" text. */
229  {
230  if( !aLine.ReadLine() )
231  return false;
232 
233  if( ((char*)aLine)[0] == 'U' )
234  {
235  sscanf( ((char*)aLine) + 1, "%lX", &timeStamp );
236 
237  m_TimeStamp = (time_t) timeStamp;
238 
239  if( m_TimeStamp == 0 ) // zero is not unique!
241 
242  continue;
243  }
244 
245  if( ((char*)aLine)[0] != 'F' )
246  break;
247 
248  sscanf( ((char*)aLine) + 1, "%d", &fieldNdx );
249 
250  /* Read the field:
251  * If fieldNdx> = 2: Fn "text" t s posx posy
252  * If F0 "text" for SheetName
253  * F1 and "text" for filename
254  */
255  ptcar = ((char*)aLine);
256 
257  while( *ptcar && ( *ptcar != '"' ) )
258  ptcar++;
259 
260  if( *ptcar != '"' )
261  {
262  aErrorMsg.Printf( wxT( "Eeschema file sheet label F%d at line %d, aborted\n" ),
263  fieldNdx, aLine.LineNumber() );
264  aErrorMsg << FROM_UTF8( (char*) aLine );
265  return false;
266  }
267 
268  wxString sheetName;
269  ptcar += ReadDelimitedText( &sheetName, ptcar );
270 
271  if( *ptcar == 0 )
272  {
273  aErrorMsg.Printf( wxT( "Eeschema file sheet field F at line %d, aborted\n" ),
274  aLine.LineNumber() );
275  aErrorMsg << FROM_UTF8( (char*) aLine );
276  return false;
277  }
278 
279  if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) )
280  {
281  if( sscanf( ptcar, "%d", &size ) != 1 )
282  {
283  aErrorMsg.Printf( wxT( "Eeschema file sheet Label error line %d, aborted\n" ),
284  aLine.LineNumber() );
285 
286  aErrorMsg << FROM_UTF8( (char*) aLine );
287  }
288 
289  if( size == 0 )
290  size = GetDefaultTextSize();
291 
292  if( fieldNdx == 0 )
293  {
294  m_name = sheetName;
295  m_sheetNameSize = size;
296  }
297  else
298  {
299  SetFileName( sheetName );
300  m_fileNameSize = size;
301  }
302  }
303 
304  if( fieldNdx > 1 )
305  {
306  sheetPin = new SCH_SHEET_PIN( this );
307 
308  if( !sheetPin->Load( aLine, aErrorMsg ) )
309  {
310  delete sheetPin;
311  sheetPin = NULL;
312  return false;
313  }
314 
315  AddPin( sheetPin );
316  }
317  }
318 
319  if( strncasecmp( "$End", ((char*)aLine), 4 ) != 0 )
320  {
321  aErrorMsg.Printf( wxT( "**Eeschema file end_sheet struct error at line %d, aborted\n" ),
322  aLine.LineNumber() );
323  aErrorMsg << FROM_UTF8( ((char*)aLine) );
324  return false;
325  }
326 
327  return true;
328 }
329 
330 
332 {
333  wxCHECK_RET( aItem->Type() == SCH_SHEET_T,
334  wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ),
335  GetChars( aItem->GetClass() ) ) );
336 
337  SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
338 
339  std::swap( m_pos, sheet->m_pos );
340  std::swap( m_size, sheet->m_size );
341  std::swap( m_name, sheet->m_name );
342  std::swap( m_sheetNameSize, sheet->m_sheetNameSize );
343  std::swap( m_fileNameSize, sheet->m_fileNameSize );
344  m_pins.swap( sheet->m_pins );
345 
346  // Ensure sheet labels have their .m_Parent member pointing really on their
347  // parent, after swapping.
348  for( SCH_SHEET_PIN& sheetPin : m_pins )
349  {
350  sheetPin.SetParent( this );
351  }
352 
353  for( SCH_SHEET_PIN& sheetPin : sheet->m_pins )
354  {
355  sheetPin.SetParent( sheet );
356  }
357 }
358 
359 
361 {
362  wxASSERT( aSheetPin != NULL );
363  wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
364 
365  m_pins.push_back( aSheetPin );
366  renumberPins();
367 }
368 
369 
371 {
372  wxASSERT( aSheetPin != NULL );
373  wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
374 
375  SCH_SHEET_PINS::iterator i;
376 
377  for( i = m_pins.begin(); i < m_pins.end(); ++i )
378  {
379  if( *i == aSheetPin )
380  {
381  m_pins.erase( i );
382  renumberPins();
383  return;
384  }
385  }
386 
387  wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ),
388  GetChars( aSheetPin->GetShownText() ), GetChars( m_name ) );
389 }
390 
391 
392 bool SCH_SHEET::HasPin( const wxString& aName )
393 {
394  for( SCH_SHEET_PIN pin : m_pins )
395  {
396  if( pin.GetText().CmpNoCase( aName ) == 0 )
397  return true;
398  }
399 
400  return false;
401 }
402 
403 
405 {
406  for( SCH_SHEET_PIN pin : m_pins )
407  {
408  if( pin.GetEdge() > 1 )
409  return true;
410  }
411  return false;
412 }
413 
414 
416 {
417  for( SCH_SHEET_PIN pin : m_pins )
418  {
419  /* Search the schematic for a hierarchical label corresponding to this sheet label. */
420  EDA_ITEM* DrawStruct = m_screen->GetDrawItems();
421  const SCH_HIERLABEL* HLabel = NULL;
422 
423  for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
424  {
425  if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
426  continue;
427 
428  HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct );
429 
430  if( pin.GetText().CmpNoCase( HLabel->GetText() ) == 0 )
431  break; // Found!
432 
433  HLabel = NULL;
434  }
435 
436  if( HLabel == NULL ) // Corresponding hierarchical label not found.
437  return true;
438  }
439 
440  return false;
441 }
442 
443 
445 {
446  int width = MIN_SHEET_WIDTH;
447 
448  for( size_t i = 0; i < m_pins.size(); i++ )
449  {
450  int edge = m_pins[i].GetEdge();
451 
452  // Make sure pin is on right or left side of sheet.
453  if( edge >= 2 )
454  continue;
455 
456  EDA_RECT rect = m_pins[i].GetBoundingBox();
457 
458  if( width < rect.GetWidth() )
459  width = rect.GetWidth();
460 
461  for( size_t j = 0; j < m_pins.size(); j++ )
462  {
463  if( (i == j) || (m_pins[i].GetPosition().y != m_pins[j].GetPosition().y) )
464  continue;
465 
466  if( width < rect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth() )
467  {
468  width = rect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth();
469  break;
470  }
471  }
472  }
473 
474  return width;
475 }
476 
477 
479 {
480  int height = MIN_SHEET_HEIGHT;
481 
482  for( size_t i = 0; i < m_pins.size(); i++ )
483  {
484  int pinY = m_pins[i].GetPosition().y - m_pos.y;
485 
486  if( pinY > height )
487  height = pinY;
488  }
489 
490  return height;
491 }
492 
493 
498 {
499  SCH_SHEET_PINS::iterator i = m_pins.begin();
500 
501  while( i != m_pins.end() )
502  {
503  /* Search the schematic for a hierarchical label corresponding to this sheet label. */
504  EDA_ITEM* DrawStruct = m_screen->GetDrawItems();
505  const SCH_HIERLABEL* HLabel = NULL;
506 
507  for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
508  {
509  if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
510  continue;
511 
512  HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct );
513 
514  if( i->GetText().CmpNoCase( HLabel->GetText() ) == 0 )
515  break; // Found!
516 
517  HLabel = NULL;
518  }
519 
520  if( HLabel == NULL ) // Hlabel not found: delete sheet label.
521  i = m_pins.erase( i );
522  else
523  ++i;
524  }
525 }
526 
527 
529 {
530  for( SCH_SHEET_PIN& pin : m_pins )
531  {
532  if( pin.HitTest( aPosition, 0 ) )
533  return &pin;
534  }
535 
536  return NULL;
537 }
538 
539 
541 {
542  return GetDefaultLineThickness();
543 }
544 
545 
547 {
548  wxPoint pos = m_pos;
549 
550  if( IsVerticalOrientation() )
551  {
552  pos.x -= 8;
553  pos.y += m_size.y;
554  }
555  else
556  {
557  pos.y -= 8;
558  }
559 
560  return pos;
561 }
562 
563 
565 {
566  wxPoint pos = m_pos;
567  int margin = GetPenSize() + 4;
568 
569  if( IsVerticalOrientation() )
570  {
571  pos.x += m_size.x + margin;
572  pos.y += m_size.y;
573  }
574  else
575  {
576  pos.y += m_size.y + margin;
577  }
578 
579  return pos;
580 }
581 
582 
583 void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
584  const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
585 {
586  COLOR4D txtcolor;
587  wxString Text;
588  COLOR4D color;
589  int name_orientation;
590  wxPoint pos_sheetname,pos_filename;
591  wxPoint pos = m_pos + aOffset;
592  int lineWidth = GetPenSize();
593  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
594 
595  if( aColor != COLOR4D::UNSPECIFIED )
596  color = aColor;
597  else
598  color = GetLayerColor( m_Layer );
599 
600  GRSetDrawMode( aDC, aDrawMode );
601 
602  GRRect( clipbox, aDC, pos.x, pos.y,
603  pos.x + m_size.x, pos.y + m_size.y, lineWidth, color );
604 
605  pos_sheetname = GetSheetNamePosition() + aOffset;
606  pos_filename = GetFileNamePosition() + aOffset;
607 
608  if( IsVerticalOrientation() )
609  name_orientation = TEXT_ANGLE_VERT;
610  else
611  name_orientation = TEXT_ANGLE_HORIZ;
612 
613  /* Draw text : SheetName */
614  if( aColor != COLOR4D::UNSPECIFIED )
615  txtcolor = aColor;
616  else
617  txtcolor = GetLayerColor( LAYER_SHEETNAME );
618 
619  Text = wxT( "Sheet: " ) + m_name;
620  DrawGraphicText( clipbox, aDC, pos_sheetname,
621  txtcolor, Text, name_orientation,
622  wxSize( m_sheetNameSize, m_sheetNameSize ),
624  false, false );
625 
626  /* Draw text : FileName */
627  if( aColor != COLOR4D::UNSPECIFIED )
628  txtcolor = aColor;
629  else
630  txtcolor = GetLayerColor( LAYER_SHEETFILENAME );
631 
632  Text = wxT( "File: " ) + m_fileName;
633  DrawGraphicText( clipbox, aDC, pos_filename,
634  txtcolor, Text, name_orientation,
635  wxSize( m_fileNameSize, m_fileNameSize ),
637  false, false );
638 
639 
640  /* Draw text : SheetLabel */
641  for( SCH_SHEET_PIN& sheetPin : m_pins )
642  {
643  if( !sheetPin.IsMoving() )
644  sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
645  }
646 }
647 
648 
650 {
651  wxPoint end;
652  EDA_RECT box( m_pos, m_size );
653  int lineWidth = GetPenSize();
654 
655  // Determine length of texts
656  wxString text = wxT( "Sheet: " ) + m_name;
657  int textlen = GraphicTextWidth( text, wxSize( m_sheetNameSize, m_sheetNameSize ),
658  false, false );
659 
660  text = wxT( "File: " ) + m_fileName;
661  int textlen2 = GraphicTextWidth( text, wxSize( m_fileNameSize, m_fileNameSize ),
662  false, false );
663 
664  // Calculate bounding box X size:
665  textlen = std::max( textlen, textlen2 );
666  end.x = std::max( m_size.x, textlen );
667 
668  // Calculate bounding box pos:
669  end.y = m_size.y;
670  end += m_pos;
671 
672  // Move upper and lower limits to include texts:
673  box.SetY( box.GetY() - ( KiROUND( m_sheetNameSize * 1.3 ) + 8 ) );
674  end.y += KiROUND( m_fileNameSize * 1.3 ) + 8;
675 
676  box.SetEnd( end );
677  box.Inflate( lineWidth / 2 );
678 
679  return box;
680 }
681 
682 
684 {
685  int n = 0;
686 
687  if( m_screen )
688  {
689  EDA_ITEM* bs;
690 
691  for( bs = m_screen->GetDrawItems(); bs != NULL; bs = bs->Next() )
692  {
693  if( bs->Type() == SCH_COMPONENT_T )
694  {
695  SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
696 
697  if( Cmp->GetField( VALUE )->GetText().GetChar( 0 ) != '#' )
698  n++;
699  }
700 
701  if( bs->Type() == SCH_SHEET_T )
702  {
703  SCH_SHEET* sheet = (SCH_SHEET*) bs;
704  n += sheet->ComponentCount();
705  }
706  }
707  }
708 
709  return n;
710 }
711 
712 
713 bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
714 {
715  if( m_screen )
716  {
717  EDA_ITEM* item = m_screen->GetDrawItems();
718 
719  while( item )
720  {
721  if( item->Type() == SCH_SHEET_T )
722  {
723  SCH_SHEET* sheet = (SCH_SHEET*) item;
724 
725  if( sheet->m_screen
726  && sheet->m_screen->GetFileName().CmpNoCase( aFilename ) == 0 )
727  {
728  *aScreen = sheet->m_screen;
729  return true;
730  }
731 
732  if( sheet->SearchHierarchy( aFilename, aScreen ) )
733  return true;
734  }
735 
736  item = item->Next();
737  }
738  }
739 
740  return false;
741 }
742 
743 
745 {
746  if( m_screen )
747  {
748  aList->push_back( this );
749 
750  if( m_screen == aScreen )
751  return true;
752 
753  EDA_ITEM* strct = m_screen->GetDrawItems();
754 
755  while( strct )
756  {
757  if( strct->Type() == SCH_SHEET_T )
758  {
759  SCH_SHEET* ss = (SCH_SHEET*) strct;
760 
761  if( ss->LocatePathOfScreen( aScreen, aList ) )
762  return true;
763  }
764 
765  strct = strct->Next();
766  }
767 
768  aList->pop_back();
769  }
770 
771  return false;
772 }
773 
774 
776 {
777  bool success = true;
778 
779  SCH_SCREEN* screen = NULL;
780 
781  if( !m_screen )
782  {
784 
785  if( screen )
786  {
787  SetScreen( screen );
788 
789  //do not need to load the sub-sheets - this has already been done.
790  }
791  else
792  {
793  SetScreen( new SCH_SCREEN( &aFrame->Kiway() ) );
794 
795  success = aFrame->LoadOneEEFile( m_screen, m_fileName );
796 
797  if( success )
798  {
799  EDA_ITEM* bs = m_screen->GetDrawItems();
800 
801  while( bs )
802  {
803  if( bs->Type() == SCH_SHEET_T )
804  {
805  SCH_SHEET* sheet = (SCH_SHEET*) bs;
806 
807  // Set the parent to this sheet. This effectively creates a method
808  // to find the root sheet from any sheet so a pointer to the root
809  // sheet does not need to be stored globally. Note: this is not the
810  // same as a hierarchy. Complex hierarchies can have multiple copies
811  // of a sheet. This only provides a simple tree to find the root sheet.
812  sheet->SetParent( this );
813 
814  if( !sheet->Load( aFrame ) )
815  success = false;
816  }
817 
818  bs = bs->Next();
819  }
820  }
821  }
822  }
823 
824  return success;
825 }
826 
827 
829 {
830  int count = 1; //1 = this!!
831 
832  if( m_screen )
833  {
834  EDA_ITEM* strct = m_screen->GetDrawItems();
835 
836  for( ; strct; strct = strct->Next() )
837  {
838  if( strct->Type() == SCH_SHEET_T )
839  {
840  SCH_SHEET* subsheet = (SCH_SHEET*) strct;
841  count += subsheet->CountSheets();
842  }
843  }
844  }
845  return count;
846 }
847 
848 
849 wxString SCH_SHEET::GetFileName( void ) const
850 {
851  return m_fileName;
852 }
853 
854 
856 {
857  aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) );
858  aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) );
859 
860 #if 0 // Set to 1 to display the sheet time stamp (mainly for test)
861  wxString msg;
862  msg.Printf( wxT( "%.8X" ), m_TimeStamp );
863  aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), msg, BLUE ) );
864 #endif
865 }
866 
867 
868 void SCH_SHEET::Rotate(wxPoint aPosition)
869 {
870  RotatePoint( &m_pos, aPosition, 900 );
871  RotatePoint( &m_size.x, &m_size.y, 900 );
872 
873  if( m_size.x < 0 )
874  {
875  m_pos.x += m_size.x;
876  m_size.x = -m_size.x;
877  }
878 
879  if( m_size.y < 0 )
880  {
881  m_pos.y += m_size.y;
882  m_size.y = -m_size.y;
883  }
884 
885  for( SCH_SHEET_PIN& sheetPin : m_pins )
886  {
887  sheetPin.Rotate( aPosition );
888  }
889 }
890 
891 
892 void SCH_SHEET::MirrorX( int aXaxis_position )
893 {
894  MIRROR( m_pos.y, aXaxis_position );
895  m_pos.y -= m_size.y;
896 
897  for( SCH_SHEET_PIN& sheetPin : m_pins )
898  {
899  sheetPin.MirrorX( aXaxis_position );
900  }
901 }
902 
903 
904 void SCH_SHEET::MirrorY( int aYaxis_position )
905 {
906  MIRROR( m_pos.x, aYaxis_position );
907  m_pos.x -= m_size.x;
908 
909  for( SCH_SHEET_PIN& label : m_pins )
910  {
911  label.MirrorY( aYaxis_position );
912  }
913 }
914 
915 void SCH_SHEET::SetPosition( const wxPoint& aPosition )
916 {
917  // Remember the sheet and all pin sheet positions must be
918  // modified. So use Move function to do that.
919  Move( aPosition - m_pos );
920 }
921 
922 
923 
924 void SCH_SHEET::Resize( const wxSize& aSize )
925 {
926  if( aSize == m_size )
927  return;
928 
929  m_size = aSize;
930 
931  /* Move the sheet labels according to the new sheet size. */
932  for( SCH_SHEET_PIN& label : m_pins )
933  {
934  label.ConstrainOnEdge( label.GetPosition() );
935  }
936 }
937 
938 
939 bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
940 {
941  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
942 
943  // Ignore the sheet file name if searching to replace.
944  if( !(aSearchData.GetFlags() & FR_SEARCH_REPLACE)
945  && SCH_ITEM::Matches( m_fileName, aSearchData ) )
946  {
947  if( aFindLocation )
948  *aFindLocation = GetFileNamePosition();
949 
950  return true;
951  }
952 
953  if( SCH_ITEM::Matches( m_name, aSearchData ) )
954  {
955  if( aFindLocation )
956  *aFindLocation = GetSheetNamePosition();
957 
958  return true;
959  }
960 
961  return false;
962 }
963 
964 
965 bool SCH_SHEET::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
966 {
967  return EDA_ITEM::Replace( aSearchData, m_name );
968 }
969 
970 
972 {
973  int id = 2;
974 
975  for( SCH_SHEET_PIN& pin : m_pins )
976  {
977  pin.SetNumber( id );
978  id++;
979  }
980 }
981 
982 
983 void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
984 {
985  for( unsigned ii = 0; ii < GetPins().size(); ii++ )
986  {
987  SCH_SHEET_PIN &pinsheet = GetPins()[ii];
988 
989  wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_PIN_T, continue,
990  wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
991 
992  pinsheet.GetEndPoints( aItemList );
993  }
994 }
995 
996 
997 bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
998 {
999  bool currentState = IsDangling();
1000 
1001  for( SCH_SHEET_PIN& pinsheet : GetPins() )
1002  {
1003  pinsheet.IsDanglingStateChanged( aItemList );
1004  }
1005 
1006  return currentState != IsDangling();
1007 }
1008 
1009 
1011 {
1012  // If any hierarchical label in the sheet is dangling, then the sheet is dangling.
1013  for( size_t i = 0; i < GetPins().size(); i++ )
1014  {
1015  if( GetPins()[i].IsDangling() )
1016  return true;
1017  }
1018 
1019  return false;
1020 }
1021 
1022 
1023 bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
1024 {
1025  bool previousState = IsSelected();
1026 
1028 
1029  if( aRect.Intersects( boundingBox ) )
1030  SetFlags( SELECTED );
1031  else
1032  ClearFlags( SELECTED );
1033 
1034  return previousState != IsSelected();
1035 }
1036 
1037 
1038 void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
1039 {
1040  for( size_t i = 0; i < GetPins().size(); i++ )
1041  aPoints.push_back( GetPins()[i].GetPosition() );
1042 }
1043 
1044 
1045 SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICAD_T aFilterTypes[] )
1046 {
1047  KICAD_T stype;
1048 
1049  for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
1050  {
1051  // If caller wants to inspect my type
1052  if( stype == Type() )
1053  {
1054  if( SEARCH_QUIT == aInspector( this, NULL ) )
1055  return SEARCH_QUIT;
1056  }
1057  else if( stype == SCH_SHEET_PIN_T )
1058  {
1059  // Test the sheet labels.
1060  for( size_t i = 0; i < m_pins.size(); i++ )
1061  {
1062  if( SEARCH_QUIT == aInspector( &m_pins[ i ], this ) )
1063  return SEARCH_QUIT;
1064  }
1065  }
1066  }
1067 
1068  return SEARCH_CONTINUE;
1069 }
1070 
1071 
1073 {
1074  wxString tmp;
1075  tmp.Printf( _( "Hierarchical Sheet %s" ), GetChars( m_name ) );
1076  return tmp;
1077 }
1078 
1079 
1081 {
1082  return add_hierarchical_subsheet_xpm;
1083 }
1084 
1085 
1086 bool SCH_SHEET::HitTest( const wxPoint& aPosition, int aAccuracy ) const
1087 {
1088  EDA_RECT rect = GetBoundingBox();
1089 
1090  rect.Inflate( aAccuracy );
1091 
1092  return rect.Contains( aPosition );
1093 }
1094 
1095 
1096 bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1097 {
1098  EDA_RECT rect = aRect;
1099 
1100  rect.Inflate( aAccuracy );
1101 
1102  if( aContained )
1103  return rect.Contains( GetBoundingBox() );
1104 
1105  return rect.Intersects( GetBoundingBox() );
1106 }
1107 
1108 
1110 {
1111  return wxPoint( m_pos.x + m_size.GetWidth(), m_pos.y + m_size.GetHeight() );
1112 }
1113 
1114 
1116  SCH_SHEET_PATH* aSheetPath )
1117 {
1118  SCH_SHEET_PATH sheetPath = *aSheetPath;
1119  sheetPath.push_back( this );
1120 
1121  for( size_t i = 0; i < m_pins.size(); i++ )
1122  {
1123  NETLIST_OBJECT* item = new NETLIST_OBJECT();
1124  item->m_SheetPathInclude = sheetPath;
1125  item->m_SheetPath = *aSheetPath;
1126  item->m_Comp = &m_pins[i];
1127  item->m_Link = this;
1128  item->m_Type = NET_SHEETLABEL;
1129  item->m_Label = m_pins[i].GetText();
1130  item->m_Start = item->m_End = m_pins[i].GetPosition();
1131  aNetListItems.push_back( item );
1132 
1133  if( IsBusLabel( m_pins[i].GetText() ) )
1134  item->ConvertBusToNetListItems( aNetListItems );
1135  }
1136 }
1137 
1138 
1139 void SCH_SHEET::Plot( PLOTTER* aPlotter )
1140 {
1141  COLOR4D txtcolor = COLOR4D::UNSPECIFIED;
1142  wxSize size;
1143  wxString Text;
1144  int name_orientation;
1145  wxPoint pos_sheetname, pos_filename;
1146  wxPoint pos;
1147 
1148  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
1149 
1150  int thickness = GetPenSize();
1151  aPlotter->SetCurrentLineWidth( thickness );
1152 
1153  aPlotter->MoveTo( m_pos );
1154  pos = m_pos;
1155  pos.x += m_size.x;
1156 
1157  aPlotter->LineTo( pos );
1158  pos.y += m_size.y;
1159 
1160  aPlotter->LineTo( pos );
1161  pos = m_pos;
1162  pos.y += m_size.y;
1163 
1164  aPlotter->LineTo( pos );
1165  aPlotter->FinishTo( m_pos );
1166 
1167  if( IsVerticalOrientation() )
1168  {
1169  pos_sheetname = wxPoint( m_pos.x - 8, m_pos.y + m_size.y );
1170  pos_filename = wxPoint( m_pos.x + m_size.x + 4, m_pos.y + m_size.y );
1171  name_orientation = TEXT_ANGLE_VERT;
1172  }
1173  else
1174  {
1175  pos_sheetname = wxPoint( m_pos.x, m_pos.y - 4 );
1176  pos_filename = wxPoint( m_pos.x, m_pos.y + m_size.y + 4 );
1177  name_orientation = TEXT_ANGLE_HORIZ;
1178  }
1179 
1180  /* Draw texts: SheetName */
1181  Text = m_name;
1182  size = wxSize( m_sheetNameSize, m_sheetNameSize );
1183 
1184  //pos = m_pos; pos.y -= 4;
1185  thickness = GetDefaultLineThickness();
1186  thickness = Clamp_Text_PenSize( thickness, size, false );
1187 
1188  aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) );
1189 
1190  bool italic = false;
1191  aPlotter->Text( pos_sheetname, txtcolor, Text, name_orientation, size,
1193  thickness, italic, false );
1194 
1195  /*Draw texts : FileName */
1196  Text = GetFileName();
1197  size = wxSize( m_fileNameSize, m_fileNameSize );
1198  thickness = GetDefaultLineThickness();
1199  thickness = Clamp_Text_PenSize( thickness, size, false );
1200 
1201  aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) );
1202 
1203  aPlotter->Text( pos_filename, txtcolor, Text, name_orientation, size,
1205  thickness, italic, false );
1206 
1207  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
1208 
1209  /* Draw texts : SheetLabel */
1210  for( size_t i = 0; i < m_pins.size(); i++ )
1211  {
1212  m_pins[i].Plot( aPlotter );
1213  }
1214 }
1215 
1216 
1218 {
1219  wxLogDebug( wxT( "Sheet assignment operator." ) );
1220 
1221  wxCHECK_MSG( Type() == aItem.Type(), *this,
1222  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1223  GetClass() );
1224 
1225  if( &aItem != this )
1226  {
1227  SCH_ITEM::operator=( aItem );
1228 
1229  SCH_SHEET* sheet = (SCH_SHEET*) &aItem;
1230 
1231  m_pos = sheet->m_pos;
1232  m_size = sheet->m_size;
1233  m_name = sheet->m_name;
1235  m_fileNameSize = sheet->m_fileNameSize;
1236  m_pins = sheet->m_pins;
1237 
1238  // Ensure sheet labels have their #m_Parent member pointing really on their
1239  // parent, after assigning.
1240  for( SCH_SHEET_PIN& sheetPin : m_pins )
1241  {
1242  sheetPin.SetParent( this );
1243  }
1244  }
1245 
1246  return *this;
1247 }
1248 
1249 
1250 #if defined(DEBUG)
1251 
1252 void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
1253 {
1254  // XML output:
1255  wxString s = GetClass();
1256 
1257  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
1258  << TO_UTF8( m_name ) << '"' << ">\n";
1259 
1260  // show all the pins, and check the linked list integrity
1261  for( const SCH_SHEET_PIN& label : m_pins )
1262  {
1263  label.Show( nestLevel + 1, os );
1264  }
1265 
1266  NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
1267 }
1268 
1269 #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:198
#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:1217
const wxString traceFindItem
Flag to enable find item tracing using the WXTRACE environment variable.
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_sheet.cpp:190
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:713
SCH_SHEET_PIN * GetPin(const wxPoint &aPosition)
Return the sheet pin item found at aPosition in the sheet.
Definition: sch_sheet.cpp:528
bool IsDangling() const override
Definition: sch_sheet.cpp:1010
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:169
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:983
int CountSheets()
Function CountSheets calculates the number of sheets found in "this" this number includes the full su...
Definition: sch_sheet.cpp:828
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:478
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:400
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:105
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:1109
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:997
wxSize m_size
The size of the sheet.
Definition: sch_sheet.h:245
bool IsSelected() const
Definition: base_struct.h:221
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:208
SCH_SHEET * GetRootSheet()
Function GetRootSheet.
Definition: sch_sheet.cpp:137
int ComponentCount()
Function ComponentCount count our own components, without the power components.
Definition: sch_sheet.cpp:683
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:855
EDA_ITEM * Next() const
Definition: base_struct.h:206
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:939
NETLIST_ITEM_T m_Type
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:166
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:540
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:360
#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:203
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:227
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:104
#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:120
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
void renumberPins()
Renumber the sheet pins in the sheet.
Definition: sch_sheet.cpp:971
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:370
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:54
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:649
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_sheet.cpp:892
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213
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:1045
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:1072
Class SCH_SHEET_PIN defines a sheet pin (label) used in sheets to create hierarchical schematics...
Definition: sch_sheet.h:62
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:128
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:497
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:868
wxString GetFileName(void) const
Function GetFileName return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:849
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:564
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:1038
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:415
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:744
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:583
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:331
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:99
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_sheet.cpp:1139
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:444
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:904
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.cpp:915
wxPoint GetSheetNamePosition()
Function GetSheetNamePosition.
Definition: sch_sheet.cpp:546
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:151
int GetWidth() const
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:48
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:404
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:1080
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
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:392
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:149
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:68
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:1023
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:965
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:924
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:1086
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:1115
Definition: colors.h:62