KiCad PCB EDA Suite
class_module.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <gr_basic.h>
34 #include <wxstruct.h>
35 #include <plot_common.h>
36 #include <class_drawpanel.h>
37 #include <trigo.h>
38 #include <confirm.h>
39 #include <kicad_string.h>
40 #include <pcbnew.h>
41 #include <colors_selection.h>
42 #include <richio.h>
43 #include <filter_reader.h>
44 #include <macros.h>
45 #include <msgpanel.h>
46 #include <bitmaps.h>
47 
48 #include <class_board.h>
49 #include <class_edge_mod.h>
50 #include <class_module.h>
52 
53 #include <view/view.h>
54 
55 MODULE::MODULE( BOARD* parent ) :
57  m_initial_comments( 0 )
58 {
60  m_Layer = F_Cu;
61  m_Orient = 0;
63  m_arflag = 0;
64  m_CntRot90 = m_CntRot180 = 0;
65  m_Surface = 0.0;
66  m_Link = 0;
67  m_LastEditTime = 0;
68  m_LocalClearance = 0;
72  m_ZoneConnection = PAD_ZONE_CONN_INHERITED; // Use zone setting by default
73  m_ThermalWidth = 0; // Use zone setting by default
74  m_ThermalGap = 0; // Use zone setting by default
75 
76  // These are special and mandatory text fields
79 
80  m_3D_Drawings.clear();
81 }
82 
83 
84 MODULE::MODULE( const MODULE& aModule ) :
85  BOARD_ITEM_CONTAINER( aModule )
86 {
87  m_Pos = aModule.m_Pos;
88  m_fpid = aModule.m_fpid;
89  m_Attributs = aModule.m_Attributs;
91  m_Orient = aModule.m_Orient;
92  m_BoundaryBox = aModule.m_BoundaryBox;
93  m_CntRot90 = aModule.m_CntRot90;
94  m_CntRot180 = aModule.m_CntRot180;
96  m_Link = aModule.m_Link;
97  m_Path = aModule.m_Path; //is this correct behavior?
98 
104  m_ThermalWidth = aModule.m_ThermalWidth;
105  m_ThermalGap = aModule.m_ThermalGap;
106 
107  // Copy reference and value.
108  m_Reference = new TEXTE_MODULE( *aModule.m_Reference );
109  m_Reference->SetParent( this );
110  m_Value = new TEXTE_MODULE( *aModule.m_Value );
111  m_Value->SetParent( this );
112 
113  // Copy auxiliary data: Pads
114  for( D_PAD* pad = aModule.m_Pads; pad; pad = pad->Next() )
115  {
116  Add( new D_PAD( *pad ) );
117  }
118 
119  // Copy auxiliary data: Drawings
120  for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() )
121  {
122  switch( item->Type() )
123  {
124  case PCB_MODULE_TEXT_T:
125  case PCB_MODULE_EDGE_T:
126  Add( static_cast<BOARD_ITEM*>( item->Clone() ) );
127  break;
128 
129  default:
130  wxLogMessage( wxT( "Class MODULE copy constructor internal error: unknown type" ) );
131  break;
132  }
133  }
134 
135  // Copy auxiliary data: 3D_Drawings info
136  m_3D_Drawings = aModule.m_3D_Drawings;
137 
138  m_Doc = aModule.m_Doc;
139  m_KeyWord = aModule.m_KeyWord;
140 
141  m_arflag = 0;
142 
143  // Ensure auxiliary data is up to date
145 
147  new wxArrayString( *aModule.m_initial_comments ) : 0;
148 }
149 
150 
152 {
153  delete m_Reference;
154  delete m_Value;
155  delete m_initial_comments;
156 }
157 
158 
159 MODULE& MODULE::operator=( const MODULE& aOther )
160 {
161  BOARD_ITEM::operator=( aOther );
162 
163  m_Pos = aOther.m_Pos;
164  m_fpid = aOther.m_fpid;
165  m_Attributs = aOther.m_Attributs;
167  m_Orient = aOther.m_Orient;
168  m_BoundaryBox = aOther.m_BoundaryBox;
169  m_CntRot90 = aOther.m_CntRot90;
170  m_CntRot180 = aOther.m_CntRot180;
172  m_Link = aOther.m_Link;
173  m_Path = aOther.m_Path; //is this correct behavior?
174 
181  m_ThermalGap = aOther.m_ThermalGap;
182 
183  // Copy reference and value
184  *m_Reference = *aOther.m_Reference;
185  m_Reference->SetParent( this );
186  *m_Value = *aOther.m_Value;
187  m_Value->SetParent( this );
188 
189  // Copy auxiliary data: Pads
190  m_Pads.DeleteAll();
191 
192  for( D_PAD* pad = aOther.m_Pads; pad; pad = pad->Next() )
193  {
194  Add( new D_PAD( *pad ) );
195  }
196 
197  // Copy auxiliary data: Drawings
199 
200  for( BOARD_ITEM* item = aOther.m_Drawings; item; item = item->Next() )
201  {
202  switch( item->Type() )
203  {
204  case PCB_MODULE_TEXT_T:
205  case PCB_MODULE_EDGE_T:
206  Add( static_cast<BOARD_ITEM*>( item->Clone() ) );
207  break;
208 
209  default:
210  wxLogMessage( wxT( "MODULE::operator=() internal error: unknown type" ) );
211  break;
212  }
213  }
214 
215  // Copy auxiliary data: 3D_Drawings info
216  m_3D_Drawings.clear();
217  m_3D_Drawings = aOther.m_3D_Drawings;
218  m_Doc = aOther.m_Doc;
219  m_KeyWord = aOther.m_KeyWord;
220 
221  // Ensure auxiliary data is up to date
223 
224  return *this;
225 }
226 
227 
229 {
230  // Force the ORPHANED dummy net info for all pads.
231  // ORPHANED dummy net does not depend on a board
232  for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
233  pad->SetNetCode( NETINFO_LIST::ORPHANED );
234 }
235 
236 
237 void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
238  int dim_ancre, GR_DRAWMODE draw_mode )
239 {
240  GRSetDrawMode( DC, draw_mode );
241 
242  if( GetBoard()->IsElementVisible( LAYER_ANCHOR ) )
243  {
244  GRDrawAnchor( panel->GetClipBox(), DC, m_Pos.x, m_Pos.y,
245  dim_ancre,
247  }
248 }
249 
250 
251 void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
252 {
253  switch( aBoardItem->Type() )
254  {
255  case PCB_MODULE_TEXT_T:
256  // Only user texts can be added this way. Reference and value are not hold in the DLIST.
257  assert( static_cast<TEXTE_MODULE*>( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS );
258 
259  // no break
260 
261  case PCB_MODULE_EDGE_T:
262  if( aMode == ADD_APPEND )
263  m_Drawings.PushBack( aBoardItem );
264  else
265  m_Drawings.PushFront( aBoardItem );
266  break;
267 
268  case PCB_PAD_T:
269  if( aMode == ADD_APPEND )
270  m_Pads.PushBack( static_cast<D_PAD*>( aBoardItem ) );
271  else
272  m_Pads.PushFront( static_cast<D_PAD*>( aBoardItem ) );
273  break;
274 
275  default:
276  {
277  wxString msg;
278  msg.Printf( wxT( "MODULE::Add() needs work: BOARD_ITEM type (%d) not handled" ),
279  aBoardItem->Type() );
280  wxFAIL_MSG( msg );
281 
282  return;
283  }
284  }
285 
286  aBoardItem->SetParent( this );
287 
288  // Update relative coordinates, it can be done only after there is a parent object assigned
289  switch( aBoardItem->Type() )
290  {
291  case PCB_MODULE_TEXT_T:
292  static_cast<TEXTE_MODULE*>( aBoardItem )->SetLocalCoord();
293  break;
294 
295  case PCB_MODULE_EDGE_T:
296  static_cast<EDGE_MODULE*>( aBoardItem )->SetLocalCoord();
297  break;
298 
299  case PCB_PAD_T:
300  static_cast<D_PAD*>( aBoardItem )->SetLocalCoord();
301  break;
302 
303  default:
304  // Huh? It should have been filtered out by the previous switch
305  assert(false);
306  break;
307  }
308 }
309 
310 
311 void MODULE::Remove( BOARD_ITEM* aBoardItem )
312 {
313  switch( aBoardItem->Type() )
314  {
315  case PCB_MODULE_TEXT_T:
316  // Only user texts can be removed this way. Reference and value are not hold in the DLIST.
317  assert( static_cast<TEXTE_MODULE*>( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS );
318 
319  // no break
320 
321  case PCB_MODULE_EDGE_T:
322  m_Drawings.Remove( aBoardItem );
323  break;
324 
325  case PCB_PAD_T:
326  m_Pads.Remove( static_cast<D_PAD*>( aBoardItem ) );
327  break;
328 
329  default:
330  {
331  wxString msg;
332  msg.Printf( wxT( "MODULE::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
333  aBoardItem->Type() );
334  wxFAIL_MSG( msg );
335  }
336  }
337 }
338 
339 
340 void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings )
341 {
342  // Don't do anything foolish like trying to copy to yourself.
343  wxCHECK_RET( aModule != NULL && aModule != this, wxT( "Cannot copy to NULL or yourself." ) );
344 
345  // Not sure what to do with the value field. Use netlist for now.
346  aModule->SetPosition( GetPosition() );
347 
348  if( aModule->GetLayer() != GetLayer() )
349  aModule->Flip( aModule->GetPosition() );
350 
351  if( aModule->GetOrientation() != GetOrientation() )
352  aModule->Rotate( aModule->GetPosition(), GetOrientation() );
353 
354  aModule->SetLocked( IsLocked() );
355 
356  if( aCopyLocalSettings )
357  {
359  aModule->SetLocalClearance( GetLocalClearance() );
362  aModule->SetZoneConnection( GetZoneConnection() );
363  aModule->SetThermalWidth( GetThermalWidth() );
364  aModule->SetThermalGap( GetThermalGap() );
365  }
366 
367  for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
368  {
369  // Fix me: if aCopyLocalSettings == true, for "multiple" pads
370  // (set of pads having the same name/number) this is broken
371  // because we copy settings from the first pad found.
372  // When old and new footprints have very few differences, a better
373  // algo can be used.
374  D_PAD* oldPad = FindPadByName( pad->GetPadName() );
375 
376  if( oldPad )
377  oldPad->CopyNetlistSettings( pad, aCopyLocalSettings );
378  }
379 
380  // Not sure about copying description, keywords, 3D models or any other
381  // local user changes to footprint. Stick with the new footprint settings
382  // called out in the footprint loaded in the netlist.
383  aModule->CalculateBoundingBox();
384 }
385 
386 
387 void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
388  const wxPoint& aOffset )
389 {
390  if( (m_Flags & DO_NOT_DRAW) || (IsMoving()) )
391  return;
392 
393  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
394  {
395  if( pad->IsMoving() )
396  continue;
397 
398  pad->Draw( aPanel, aDC, aDrawMode, aOffset );
399  }
400 
401  BOARD* brd = GetBoard();
402 
403  // Draws footprint anchor
404  DrawAncre( aPanel, aDC, aOffset, DIM_ANCRE_MODULE, aDrawMode );
405 
406  // Draw graphic items
408  {
409  if( !(m_Reference->IsMoving()) )
410  m_Reference->Draw( aPanel, aDC, aDrawMode, aOffset );
411  }
412 
413  if( brd->IsElementVisible( LAYER_MOD_VALUES ) )
414  {
415  if( !(m_Value->IsMoving()) )
416  m_Value->Draw( aPanel, aDC, aDrawMode, aOffset );
417  }
418 
419  for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
420  {
421  if( item->IsMoving() )
422  continue;
423 
424  switch( item->Type() )
425  {
426  case PCB_MODULE_TEXT_T:
427  case PCB_MODULE_EDGE_T:
428  item->Draw( aPanel, aDC, aDrawMode, aOffset );
429  break;
430 
431  default:
432  break;
433  }
434  }
435 
436  // Enable these line to draw m_BoundaryBox (debug tests purposes only)
437 #if 0
438  GRRect( aPanel->GetClipBox(), aDC, m_BoundaryBox, 0, BROWN );
439 #endif
440 
441 }
442 
443 
444 void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
445  GR_DRAWMODE draw_mode )
446 {
447  for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
448  {
449  switch( item->Type() )
450  {
451  case PCB_MODULE_EDGE_T:
452  item->Draw( panel, DC, draw_mode, offset );
453  break;
454 
455  default:
456  break;
457  }
458  }
459 }
460 
461 
463 {
466 }
467 
468 
470 {
471  EDA_RECT area;
472 
473  area.SetOrigin( m_Pos );
474  area.SetEnd( m_Pos );
475  area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area
476 
477  for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() )
478  {
479  const EDGE_MODULE* edge = dyn_cast<const EDGE_MODULE*>( item );
480 
481  if( edge )
482  area.Merge( edge->GetBoundingBox() );
483  }
484 
485  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
486  area.Merge( pad->GetBoundingBox() );
487 
488  return area;
489 }
490 
491 
493 {
494  EDA_RECT area = GetFootprintRect();
495 
496  // Calculate extended area including text fields
497  area.Merge( m_Reference->GetBoundingBox() );
498  area.Merge( m_Value->GetBoundingBox() );
499 
500  // Add the Clearance shape size: (shape around the pads when the
501  // clearance is shown. Not optimized, but the draw cost is small
502  // (perhaps smaller than optimization).
503  BOARD* board = GetBoard();
504  if( board )
505  {
506  int biggest_clearance = board->GetDesignSettings().GetBiggestClearanceValue();
507  area.Inflate( biggest_clearance );
508  }
509 
510  return area;
511 }
512 
513 
514 void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
515 {
516  int nbpad;
517  wxString msg;
518 
519  aList.push_back( MSG_PANEL_ITEM( m_Reference->GetShownText(), m_Value->GetShownText(), DARKCYAN ) );
520 
521  // Display last date the component was edited (useful in Module Editor).
522  wxDateTime date( m_LastEditTime );
523 
524  if( m_LastEditTime && date.IsValid() )
525  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
526  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
527  else
528  msg = _( "Unknown" );
529 
530  aList.push_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
531 
532  // display schematic path
533  aList.push_back( MSG_PANEL_ITEM( _( "Netlist Path" ), m_Path, BROWN ) );
534 
535  // display the board side placement
536  aList.push_back( MSG_PANEL_ITEM( _( "Board Side" ),
537  IsFlipped()? _( "Back (Flipped)" ) : _( "Front" ), RED ) );
538 
539  EDA_ITEM* PtStruct = m_Pads;
540  nbpad = 0;
541 
542  while( PtStruct )
543  {
544  nbpad++;
545  PtStruct = PtStruct->Next();
546  }
547 
548  msg.Printf( wxT( "%d" ), nbpad );
549  aList.push_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
550 
551  msg = wxT( ".." );
552 
553  if( IsLocked() )
554  msg[0] = 'L';
555 
557  msg[1] = 'P';
558 
559  aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
560 
561  msg.Printf( wxT( "%.1f" ), GetOrientationDegrees() );
562  aList.push_back( MSG_PANEL_ITEM( _( "Rotation" ), msg, BROWN ) );
563 
564  // Controls on right side of the dialog
565  switch( m_Attributs & 255 )
566  {
567  case 0:
568  msg = _( "Normal" );
569  break;
570 
571  case MOD_CMS:
572  msg = _( "Insert" );
573  break;
574 
575  case MOD_VIRTUAL:
576  msg = _( "Virtual" );
577  break;
578 
579  default:
580  msg = wxT( "???" );
581  break;
582  }
583 
584  aList.push_back( MSG_PANEL_ITEM( _( "Attributes" ), msg, BROWN ) );
585  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), FROM_UTF8( m_fpid.Format().c_str() ), BLUE ) );
586 
587  if( m_3D_Drawings.empty() )
588  msg = _( "No 3D shape" );
589  else
590  msg = m_3D_Drawings.front().m_Filename;
591 
592  // Search the first active 3D shape in list
593 
594  aList.push_back( MSG_PANEL_ITEM( _( "3D-Shape" ), msg, RED ) );
595 
596  wxString doc, keyword;
597  doc.Printf( _( "Doc: %s" ), GetChars( m_Doc ) );
598  keyword.Printf( _( "Key Words: %s" ), GetChars( m_KeyWord ) );
599  aList.push_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
600 }
601 
602 
603 bool MODULE::HitTest( const wxPoint& aPosition ) const
604 {
605  return m_BoundaryBox.Contains( aPosition );
606 }
607 
608 
609 bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
610 {
611  EDA_RECT arect = aRect;
612  arect.Inflate( aAccuracy );
613 
614  if( aContained )
615  return arect.Contains( m_BoundaryBox );
616  else
617  {
618  // If the rect does not intersect the bounding box, skip any tests
619  if( !aRect.Intersects( GetBoundingBox() ) )
620  return false;
621 
622  // Determine if any elements in the MODULE intersect the rect
623  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
624  {
625  if( pad->HitTest( arect, false, 0 ) )
626  return true;
627  }
628 
629  for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
630  {
631  if( item->HitTest( arect, false, 0 ) )
632  return true;
633  }
634 
635  // No items were hit
636  return false;
637  }
638 }
639 
640 
641 D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
642 {
643  wxString buf;
644 
645  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
646  {
647  pad->StringPadName( buf );
648 #if 1
649  if( buf.CmpNoCase( aPadName ) == 0 ) // why case insensitive?
650 #else
651  if( buf == aPadName )
652 #endif
653  return pad;
654  }
655 
656  return NULL;
657 }
658 
659 
660 D_PAD* MODULE::GetPad( const wxPoint& aPosition, LSET aLayerMask )
661 {
662  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
663  {
664  // ... and on the correct layer.
665  if( !( pad->GetLayerSet() & aLayerMask ).any() )
666  continue;
667 
668  if( pad->HitTest( aPosition ) )
669  return pad;
670  }
671 
672  return NULL;
673 }
674 
675 
677 {
678  D_PAD* topLeftPad = m_Pads;
679 
680  for( D_PAD* p = m_Pads->Next(); p; p = p->Next() )
681  {
682  wxPoint pnt = p->GetPosition(); // GetPosition() returns the center of the pad
683 
684  if( ( pnt.x < topLeftPad->GetPosition().x ) ||
685  ( ( topLeftPad->GetPosition().x == pnt.x ) &&
686  ( pnt.y < topLeftPad->GetPosition().y ) ) )
687  {
688  topLeftPad = p;
689  }
690  }
691 
692  return topLeftPad;
693 }
694 
695 
696 unsigned MODULE::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
697 {
698  if( aIncludeNPTH )
699  return m_Pads.GetCount();
700 
701  unsigned cnt = 0;
702 
703  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
704  {
705  if( pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
706  continue;
707 
708  cnt++;
709  }
710 
711  return cnt;
712 }
713 
714 
715 unsigned MODULE::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
716 {
717  std::set<wxUint32> usedNames;
718 
719  // Create a set of used pad numbers
720  for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
721  {
722  // Skip pads not on copper layers (used to build complex
723  // solder paste shapes for instance)
724  if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none() )
725  continue;
726 
727  // Skip pads with no name, because they are usually "mechanical"
728  // pads, not "electrical" pads
729  if( pad->GetPadName().IsEmpty() )
730  continue;
731 
732  if( !aIncludeNPTH )
733  {
734  // skip NPTH
735  if( pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
736  {
737  continue;
738  }
739  }
740 
741  usedNames.insert( pad->GetPackedPadName() );
742  }
743 
744  return usedNames.size();
745 }
746 
747 
748 void MODULE::Add3DModel( S3D_INFO* a3DModel )
749 {
750  if( NULL == a3DModel )
751  return;
752 
753  if( !a3DModel->m_Filename.empty() )
754  m_3D_Drawings.push_back( *a3DModel );
755 
756  delete a3DModel;
757 }
758 
759 
760 // see class_module.h
761 SEARCH_RESULT MODULE::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
762 {
763  KICAD_T stype;
765  const KICAD_T* p = scanTypes;
766  bool done = false;
767 
768 #if 0 && defined(DEBUG)
769  std::cout << GetClass().mb_str() << ' ';
770 #endif
771 
772  while( !done )
773  {
774  stype = *p;
775 
776  switch( stype )
777  {
778  case PCB_MODULE_T:
779  result = inspector( this, testData ); // inspect me
780  ++p;
781  break;
782 
783  case PCB_PAD_T:
784  result = IterateForward( m_Pads, inspector, testData, p );
785  ++p;
786  break;
787 
788  case PCB_MODULE_TEXT_T:
789  result = inspector( m_Reference, testData );
790 
791  if( result == SEARCH_QUIT )
792  break;
793 
794  result = inspector( m_Value, testData );
795 
796  if( result == SEARCH_QUIT )
797  break;
798 
799  // m_Drawings can hold TYPETEXTMODULE also, so fall thru
800 
801  case PCB_MODULE_EDGE_T:
802  result = IterateForward( m_Drawings, inspector, testData, p );
803 
804  // skip over any types handled in the above call.
805  for( ; ; )
806  {
807  switch( stype = *++p )
808  {
809  case PCB_MODULE_TEXT_T:
810  case PCB_MODULE_EDGE_T:
811  continue;
812 
813  default:
814  ;
815  }
816 
817  break;
818  }
819 
820  break;
821 
822  default:
823  done = true;
824  break;
825  }
826 
827  if( result == SEARCH_QUIT )
828  break;
829  }
830 
831  return result;
832 }
833 
834 
836 {
837  wxString text;
838  text.Printf( _( "Footprint %s on %s" ),
839  GetChars ( GetReference() ),
840  GetChars ( GetLayerName() ) );
841 
842  return text;
843 }
844 
845 
847 {
848  return module_xpm;
849 }
850 
851 
853 {
854  return new MODULE( *this );
855 }
856 
857 
858 void MODULE::RunOnChildren( std::function<void (BOARD_ITEM*)> aFunction )
859 {
860  try
861  {
862  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
863  aFunction( static_cast<BOARD_ITEM*>( pad ) );
864 
865  for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() )
866  aFunction( drawing );
867 
868  aFunction( static_cast<BOARD_ITEM*>( m_Reference ) );
869  aFunction( static_cast<BOARD_ITEM*>( m_Value ) );
870  }
871  catch( std::bad_function_call& )
872  {
873  DisplayError( NULL, wxT( "Error running MODULE::RunOnChildren" ) );
874  }
875 }
876 
877 void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
878 {
879  aCount = 2;
880  aLayers[0] = LAYER_ANCHOR;
881 
882  switch( m_Layer )
883  {
884 
885  default:
886  wxASSERT_MSG( false, "Illegal layer" ); // do you really have modules placed on other layers?
887  // pass through
888  case F_Cu:
889  aLayers[1] = LAYER_MOD_FR;
890  break;
891 
892  case B_Cu:
893  aLayers[1] = LAYER_MOD_BK;
894  break;
895  }
896 }
897 
898 
899 unsigned int MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
900 {
901  int layer = ( m_Layer == F_Cu ) ? LAYER_MOD_FR :
903 
904  // Currently it is only for anchor layer
905  if( aView->IsLayerVisible( layer ) )
906  return 30;
907 
909 }
910 
911 
912 const BOX2I MODULE::ViewBBox() const
913 {
914  EDA_RECT fpRect = GetFootprintRect();
915 
916  return BOX2I( VECTOR2I( fpRect.GetOrigin() ), VECTOR2I( fpRect.GetSize() ) );
917 }
918 
919 
920 bool MODULE::IsLibNameValid( const wxString & aName )
921 {
922  const wxChar * invalids = StringLibNameInvalidChars( false );
923 
924  if( aName.find_first_of( invalids ) != std::string::npos )
925  return false;
926 
927  return true;
928 }
929 
930 
931 const wxChar* MODULE::StringLibNameInvalidChars( bool aUserReadable )
932 {
933  static const wxChar invalidChars[] = wxT("%$\t \"\\/");
934  static const wxChar invalidCharsReadable[] = wxT("% $ 'tab' 'space' \\ \" /");
935 
936  if( aUserReadable )
937  return invalidCharsReadable;
938  else
939  return invalidChars;
940 }
941 
942 
943 void MODULE::Move( const wxPoint& aMoveVector )
944 {
945  wxPoint newpos = m_Pos + aMoveVector;
946  SetPosition( newpos );
947 }
948 
949 
950 void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
951 {
952  wxPoint newpos = m_Pos;
953  RotatePoint( &newpos, aRotCentre, aAngle );
954  SetPosition( newpos );
955  SetOrientation( GetOrientation() + aAngle );
956 }
957 
958 
959 void MODULE::Flip( const wxPoint& aCentre )
960 {
961  // Move module to its final position:
962  wxPoint finalPos = m_Pos;
963  MIRROR( finalPos.y, aCentre.y );
964  SetPosition( finalPos );
965 
966  // Flip layer
967  SetLayer( FlipLayer( GetLayer() ) );
968 
969  // Reverse mirror orientation.
970  m_Orient = -m_Orient;
972 
973  // Mirror pads to other side of board about the x axis, i.e. vertically.
974  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
975  pad->Flip( m_Pos );
976 
977  // Mirror reference and value.
978  m_Reference->Flip( m_Pos );
979  m_Value->Flip( m_Pos );
980 
981  // Reverse mirror module graphics and texts.
982  for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
983  {
984  switch( item->Type() )
985  {
986  case PCB_MODULE_EDGE_T:
987  ( (EDGE_MODULE*) item )->Flip( m_Pos );
988  break;
989 
990  case PCB_MODULE_TEXT_T:
991  static_cast<TEXTE_MODULE*>( item )->Flip( m_Pos );
992  break;
993 
994  default:
995  wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) );
996  break;
997  }
998  }
999 
1001 }
1002 
1003 
1004 void MODULE::SetPosition( const wxPoint& newpos )
1005 {
1006  wxPoint delta = newpos - m_Pos;
1007 
1008  m_Pos += delta;
1009 
1010  m_Reference->EDA_TEXT::Offset( delta );
1011  m_Value->EDA_TEXT::Offset( delta );
1012 
1013  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
1014  {
1015  pad->SetPosition( pad->GetPosition() + delta );
1016  }
1017 
1018  for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
1019  {
1020  switch( item->Type() )
1021  {
1022  case PCB_MODULE_EDGE_T:
1023  {
1024  EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
1025  pt_edgmod->SetDrawCoord();
1026  break;
1027  }
1028 
1029  case PCB_MODULE_TEXT_T:
1030  {
1031  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
1032  text->EDA_TEXT::Offset( delta );
1033  break;
1034  }
1035 
1036  default:
1037  wxMessageBox( wxT( "Draw type undefined." ) );
1038  break;
1039  }
1040  }
1041 
1043 }
1044 
1045 
1046 void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
1047 {
1048  /* Move the reference point of the footprint
1049  * the footprints elements (pads, outlines, edges .. ) are moved
1050  * but:
1051  * - the footprint position is not modified.
1052  * - the relative (local) coordinates of these items are modified
1053  * - Draw coordinates are updated
1054  */
1055 
1056 
1057  // Update (move) the relative coordinates relative to the new anchor point.
1058  wxPoint moveVector = aMoveVector;
1059  RotatePoint( &moveVector, -GetOrientation() );
1060 
1061  // Update of the reference and value.
1062  m_Reference->SetPos0( m_Reference->GetPos0() + moveVector );
1064  m_Value->SetPos0( m_Value->GetPos0() + moveVector );
1065  m_Value->SetDrawCoord();
1066 
1067  // Update the pad local coordinates.
1068  for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
1069  {
1070  pad->SetPos0( pad->GetPos0() + moveVector );
1071  pad->SetDrawCoord();
1072  }
1073 
1074  // Update the draw element coordinates.
1075  for( EDA_ITEM* item = GraphicalItems(); item; item = item->Next() )
1076  {
1077  switch( item->Type() )
1078  {
1079  case PCB_MODULE_EDGE_T:
1080  {
1081  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
1082  edge->m_Start0 += moveVector;
1083  edge->m_End0 += moveVector;
1084  edge->SetDrawCoord();
1085  break;
1086  }
1087 
1088  case PCB_MODULE_TEXT_T:
1089  {
1090  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
1091  text->SetPos0( text->GetPos0() + moveVector );
1092  text->SetDrawCoord();
1093  break;
1094  }
1095 
1096  default:
1097  break;
1098  }
1099  }
1100 
1102 }
1103 
1104 
1105 void MODULE::SetOrientation( double newangle )
1106 {
1107  double angleChange = newangle - m_Orient; // change in rotation
1108 
1109  NORMALIZE_ANGLE_POS( newangle );
1110 
1111  m_Orient = newangle;
1112 
1113  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
1114  {
1115  pad->SetOrientation( pad->GetOrientation() + angleChange );
1116  pad->SetDrawCoord();
1117  }
1118 
1119  // Update of the reference and value.
1121  m_Value->SetDrawCoord();
1122 
1123  // Displace contours and text of the footprint.
1124  for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
1125  {
1126  if( item->Type() == PCB_MODULE_EDGE_T )
1127  {
1128  static_cast<EDGE_MODULE*>( item )->SetDrawCoord();
1129  }
1130  else if( item->Type() == PCB_MODULE_TEXT_T )
1131  {
1132  static_cast<TEXTE_MODULE*>( item )->SetDrawCoord();
1133  }
1134  }
1135 
1137 }
1138 
1140  bool aIncrementPadNumbers,
1141  bool aAddToModule )
1142 {
1143  BOARD_ITEM* new_item = NULL;
1144  D_PAD* new_pad = NULL;
1145 
1146  switch( aItem->Type() )
1147  {
1148  case PCB_PAD_T:
1149  {
1150  new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
1151 
1152  if( aAddToModule )
1153  Pads().PushBack( new_pad );
1154 
1155  new_item = new_pad;
1156  break;
1157  }
1158 
1159  case PCB_MODULE_TEXT_T:
1160  {
1161  const TEXTE_MODULE* old_text = static_cast<const TEXTE_MODULE*>( aItem );
1162 
1163  // do not duplicate value or reference fields
1164  // (there can only be one of each)
1165  if( old_text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
1166  {
1167  TEXTE_MODULE* new_text = new TEXTE_MODULE( *old_text );
1168 
1169  if( aAddToModule )
1170  GraphicalItems().PushBack( new_text );
1171 
1172  new_item = new_text;
1173  }
1174  break;
1175  }
1176 
1177  case PCB_MODULE_EDGE_T:
1178  {
1179  EDGE_MODULE* new_edge = new EDGE_MODULE(
1180  *static_cast<const EDGE_MODULE*>(aItem) );
1181 
1182  if( aAddToModule )
1183  GraphicalItems().PushBack( new_edge );
1184 
1185  new_item = new_edge;
1186  break;
1187  }
1188 
1189  case PCB_MODULE_T:
1190  // Ignore the module itself
1191  break;
1192 
1193  default:
1194  // Un-handled item for duplication
1195  wxASSERT_MSG( false, "Duplication not supported for items of class "
1196  + aItem->GetClass() );
1197  break;
1198  }
1199 
1200  if( aIncrementPadNumbers && new_pad )
1201  {
1202  new_pad->IncrementPadName( true, true );
1203  }
1204 
1205  return new_item;
1206 }
1207 
1208 
1209 wxString MODULE::GetNextPadName( bool aFillSequenceGaps ) const
1210 {
1211  std::set<int> usedNumbers;
1212 
1213  // Create a set of used pad numbers
1214  for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
1215  {
1216  int padNumber = getTrailingInt( pad->GetPadName() );
1217  usedNumbers.insert( padNumber );
1218  }
1219 
1220  const int nextNum = getNextNumberInSequence( usedNumbers, aFillSequenceGaps );
1221 
1222  return wxString::Format( wxT( "%i" ), nextNum );
1223 }
1224 
1225 
1227 {
1228  wxString prefix = GetReference();
1229 
1230  int strIndex = prefix.length() - 1;
1231  while( strIndex >= 0 )
1232  {
1233  const wxUniChar chr = prefix.GetChar( strIndex );
1234 
1235  // numeric suffix
1236  if( chr >= '0' && chr <= '9' )
1237  break;
1238 
1239  strIndex--;
1240  }
1241 
1242  prefix = prefix.Mid( 0, strIndex );
1243 
1244  return prefix;
1245 }
1246 
1247 
1249 {
1250  double padArea = 0.0;
1251  double moduleArea = GetFootprintRect().GetArea();
1252 
1253  for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
1254  padArea += pad->GetBoundingBox().GetArea();
1255 
1256  if( moduleArea == 0.0 )
1257  return 1.0;
1258 
1259  double ratio = padArea / moduleArea;
1260 
1261  return std::min( ratio, 1.0 );
1262 }
1263 
1264 // see convert_drawsegment_list_to_polygon.cpp:
1265 extern bool ConvertOutlineToPolygon( std::vector< DRAWSEGMENT* >& aSegList,
1266  SHAPE_POLY_SET& aPolygons, int aSegmentsByCircle,
1267  wxString* aErrorText);
1268 
1270 {
1273  // Build the courtyard area from graphic items on the courtyard.
1274  // Only PCB_MODULE_EDGE_T have meaning, graphic texts are ignored.
1275  // Collect items:
1276  std::vector< DRAWSEGMENT* > list_front;
1277  std::vector< DRAWSEGMENT* > list_back;
1278 
1279  for( BOARD_ITEM* item = GraphicalItems(); item; item = item->Next() )
1280  {
1281  if( item->GetLayer() == B_CrtYd && item->Type() == PCB_MODULE_EDGE_T )
1282  list_back.push_back( static_cast< DRAWSEGMENT* > ( item ) );
1283 
1284  if( item->GetLayer() == F_CrtYd && item->Type() == PCB_MODULE_EDGE_T )
1285  list_front.push_back( static_cast< DRAWSEGMENT* > ( item ) );
1286  }
1287 
1288  // Note: if no item found on courtyard layers, return true.
1289  // false is returned only when the shape defined on courtyard layers
1290  // is not convertible to a polygon
1291  if( !list_front.size() && !list_back.size() )
1292  return true;
1293 
1294  wxString error_msg;
1295 
1296  const int STEPS = 36; // for a segmentation of an arc of 360 degrees
1297  bool success = ConvertOutlineToPolygon( list_front, m_poly_courtyard_front,
1298  STEPS, &error_msg );
1299 
1300  if( success )
1301  success = ConvertOutlineToPolygon( list_back, m_poly_courtyard_back,
1302  STEPS, &error_msg );
1303 
1304  if( !error_msg.IsEmpty() )
1305  {
1306  error_msg.Prepend( GetReference() + ": " );
1307  wxLogMessage( error_msg );
1308  }
1309 
1310  return success;
1311 }
LIB_ID m_fpid
The LIB_ID of the MODULE.
Definition: class_module.h:672
Definition: colors.h:57
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:639
void Add(BOARD_ITEM *aBoardItem, ADD_MODE aMode=ADD_INSERT) override
>
bool BuildPolyCourtyard()
Used in DRC to build the courtyard area (a complex polygon) from graphic items put on the courtyard...
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:475
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
static SEARCH_RESULT IterateForward(EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function IterateForward walks through the object tree calling the inspector() on each object type req...
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
bool IsMoving() const
Definition: base_struct.h:218
wxString GetReferencePrefix() const
Function GetReference prefix Gets the alphabetic prefix of the module reference - e...
void SetThermalGap(int aGap)
Definition: class_module.h:181
int m_CntRot90
Horizontal automatic placement cost ( 0..10 ).
Definition: class_module.h:688
int GetThermalGap() const
Definition: class_module.h:182
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect...
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
SHAPE_POLY_SET m_poly_courtyard_back
Definition: class_module.h:706
T * Remove(T *aElement)
Function Remove removes aElement from the list, but does not delete it.
Definition: dlist.h:211
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
void SetLocalClearance(int aClearance)
Definition: class_module.h:167
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
void PushFront(T *aNewElement)
Function PushFront puts aNewElement at front of list sequence.
Definition: dlist.h:240
wxString m_KeyWord
Search keywords to find module in library.
Definition: class_module.h:681
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:404
wxString m_Path
Definition: class_module.h:682
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
int GetLocalClearance() const
Definition: class_module.h:166
int m_ThermalWidth
Definition: class_module.h:678
TEXT_TYPE GetType() const
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
bool ConvertOutlineToPolygon(std::vector< DRAWSEGMENT * > &aSegList, SHAPE_POLY_SET &aPolygons, int aSegmentsByCircle, wxString *aErrorText)
Function ConvertOutlineToPolygon build a polygon (with holes) from a DRAWSEGMENT list, which is expected to be a outline, therefore a closed main outline with perhaps closed inner outlines.
bool Contains(const wxPoint &aPoint) const
Function Contains.
const wxPoint & GetPos0() const
anchor of items having an anchor point (texts, footprints)
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw draws the footprint to the aDC.
double m_LocalSolderPasteMarginRatio
Solder mask margin ratio value of pad size.
Definition: class_module.h:697
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
Class BOARD to handle a board.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
Definition: colors.h:61
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:445
D_PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a D_PAD* with a matching name.
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aIncrementPadNumbers, bool aAddToModule=false)
Function Duplicate Duplicate a given item within the module, without adding to the board...
int m_LocalSolderPasteMargin
Solder paste margin absolute value.
Definition: class_module.h:696
int m_ThermalGap
Definition: class_module.h:679
show modules on back
int GetHeight() const
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:76
void SetOrigin(const wxPoint &pos)
std::list< S3D_INFO > m_3D_Drawings
Linked list of 3D models.
Definition: class_module.h:667
show modules values (when texts are visibles)
void GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
Definition: gr_basic.cpp:1267
void SetZoneConnection(ZoneConnection aType)
Definition: class_module.h:175
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
MODULE(BOARD *parent)
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
static const wxChar * StringLibNameInvalidChars(bool aUserReadable)
static function StringLibNameInvalidChars Test for validity of the name in a library of the footprint...
EDA_ITEM * Next() const
Definition: base_struct.h:206
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
double m_Surface
Bounding box area.
Definition: class_module.h:686
ZoneConnection GetZoneConnection() const
Definition: class_module.h:176
time_t m_Link
Temporary logical link used in edition.
Definition: class_module.h:687
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:222
void DeleteAll()
Function DeleteAll deletes all items on the list and leaves the list empty.
Definition: dlist.cpp:41
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
void MoveAnchorPosition(const wxPoint &aMoveVector)
Function MoveAnchorPosition Move the reference point of the footprint It looks like a move footprint:...
#define abs(a)
Definition: auxiliary.h:84
wxArrayString * m_initial_comments
leading s-expression comments in the module, lazily allocated only if needed for speed ...
Definition: class_module.h:700
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: class_module.h:173
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
void DrawAncre(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, int dim_ancre, GR_DRAWMODE draw_mode)
Function DrawAncre Draw the anchor cross (vertical) Must be done after the pads, because drawing the ...
double GetLocalSolderPasteMarginRatio() const
Definition: class_module.h:172
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
#define MODULE_PADS_LOCKED
In autoplace: module waiting for autoplace.
Definition: class_module.h:220
static const int delta[8][2]
Definition: solve.cpp:112
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
static int getNextNumberInSequence(const std::set< int > &aSeq, bool aFillSequenceGaps)
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
wxString m_Doc
File name and path for documentation file.
Definition: class_module.h:680
#define DIM_ANCRE_MODULE
Definition: pcbnew.h:59
wxPoint m_End0
This file contains miscellaneous commonly used macros and functions.
#define MODULE_is_PLACED
In autoplace: module automatically placed.
Definition: class_module.h:218
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
>
show modules on front
BOARD_ITEM * Next() const
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
int m_LocalClearance
Definition: class_module.h:694
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:104
PCB_LAYER_ID m_Layer
double m_Orient
Orientation in tenths of a degree, 900=90.0 degrees.
Definition: class_module.h:668
const wxPoint & GetOrigin() const
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
class MODULE, a footprint
Definition: typeinfo.h:101
void ClearAllNets()
Function ClearAllNets Clear (i.e.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
static int getTrailingInt(wxString aStr)
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
void Remove(BOARD_ITEM *aBoardItem) override
>
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
double GetArea() const
Function GetArea returns the area of the rectangle.
EDA_RECT m_BoundaryBox
Bounding box : coordinates on board, real orientation.
Definition: class_module.h:675
Class LSET is a set of PCB_LAYER_IDs.
double GetOrientationDegrees() const
Definition: class_module.h:148
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213
double GetOrientation() const
Definition: class_module.h:147
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
Class SHAPE_POLY_SET.
Base window classes and related definitions.
EDA_RECT GetFootprintRect() const
Function GetFootprintRect() Returns the area of the module footprint excluding any text...
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
void SetEnd(int x, int y)
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:214
virtual const BOX2I ViewBBox() const override
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
D_PAD * Next() const
Definition: class_pad.h:106
void SetThermalWidth(int aWidth)
Definition: class_module.h:178
int m_LocalSolderMaskMargin
Solder mask margin.
Definition: class_module.h:695
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
int m_arflag
Use to trace ratsnest and auto routing.
Definition: class_module.h:685
EDA_RECT * GetClipBox()
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
Definition: colors.h:60
void Flip(const wxPoint &aCentre) override
Flip entity during module flip.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
SHAPE_POLY_SET m_poly_courtyard_front
Used in DRC to test the courtyard area (a polygon which can be not basic Note also a footprint can ha...
Definition: class_module.h:705
virtual void SetPosition(const wxPoint &aPos) override
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
void SetPosition(const wxPoint &aPos) override
int GetLocalSolderMaskMargin() const
Definition: class_module.h:163
void DrawEdgesOnly(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode)
Function DrawEdgesOnly Draws the footprint edges only to the current Device Context.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw Draw the text according to the footprint pos and orient.
wxString GetNextPadName(bool aFillSequenceGaps) const
Function GetNextPadName returns the next available pad name in the module.
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:68
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:223
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Operator assignment is used to assign the members of aItem to another object.
void SetLocalSolderMaskMargin(int aMargin)
Definition: class_module.h:164
D_PAD * GetTopLeftPad()
void SetPos0(const wxPoint &aPos)
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
int GetLocalSolderPasteMargin() const
Definition: class_module.h:169
MODULE & operator=(const MODULE &aOther)
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
GetPadCount returns the number of pads.
default
Definition: class_module.h:75
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
static bool IsLibNameValid(const wxString &aName)
static function IsLibNameValid Test for validity of a name of a footprint to be used in a footprint l...
time_t m_LastEditTime
Definition: class_module.h:684
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
D_PAD * GetPad(const wxPoint &aPosition, LSET aLayerMask=LSET::AllLayersMask())
Function GetPad get a pad at aPosition on aLayerMask in the footprint.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void SetLocalSolderPasteMargin(int aMargin)
Definition: class_module.h:170
int m_CntRot180
Vertical automatic placement cost ( 0..10 ).
Definition: class_module.h:689
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
virtual wxString GetClass() const =0
Function GetClass returns the class name.
void SetLocked(bool isLocked) override
Function SetLocked sets the MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: class_module.h:233
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
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...
DLIST< BOARD_ITEM > m_Drawings
Linked list of graphical items.
Definition: class_module.h:666
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:411
int m_ModuleStatus
For autoplace: flags (LOCKED, AUTOPLACED)
Definition: class_module.h:674
void Move(const wxPoint &aMoveVector) override
Function Move move this object.
void SetOrientation(double newangle)
Virtual component: when created by copper shapes on board (Like edge card connectors, mounting hole...)
Definition: class_module.h:78
double PadCoverageRatio() const
Function PadCoverageRatio Calculates the ratio of total area of the footprint pads to the area of the...
void Add3DModel(S3D_INFO *a3DModel)
Function Add3DModel adds a3DModel definition to the end of the 3D model list.
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
wxString GetClass() const override
Function GetClass returns the class name.
Definition: class_module.h:547
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
void SetDrawCoord()
Set absolute coordinates.
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Class EDA_RECT handles the component boundary box.
TEXTE_MODULE * m_Value
Component value (74LS00, 22K..)
Definition: class_module.h:671
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
wxPoint m_Pos
Position of module on the board in internal units.
Definition: class_module.h:669
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
TEXTE_MODULE * m_Reference
Component reference designator value (U34, R18..)
Definition: class_module.h:670
void CopyNetlistSettings(MODULE *aModule, bool aCopyLocalSettings)
Function CopyNetlistSettings copies the netlist settings to aModule.
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
unsigned GetUniquePadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
GetUniquePadCount returns the number of unique pads.
Module description (excepted pads)
Definition: colors.h:45
Abstract interface for BOARD_ITEMs capable of storing other items inside.
wxPoint m_Start0
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
Class VIEW.
Definition: view.h:58
void StringPadName(wxString &text) const
Definition: class_pad.cpp:442
SEARCH_RESULT
Definition: base_struct.h:68
DLIST< D_PAD > m_Pads
Linked list of pads.
Definition: class_module.h:665
EDGE_MODULE class definition.
ZoneConnection m_ZoneConnection
Definition: class_module.h:683
Message panel definition file.
const wxSize & GetSize() const
INCLUDE_NPTH_T
Definition: class_module.h:61
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
void CopyNetlistSettings(D_PAD *aPad, bool aCopyLocalSettings)
Function CopyNetlistSettings copies the netlist settings to aPad, and the net name.
Definition: class_pad.cpp:486
show modules references (when texts are visibles)
int GetThermalWidth() const
Definition: class_module.h:179
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:125
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
#define min(a, b)
Definition: auxiliary.h:85
int m_Attributs
Flag bits ( see Mod_Attribut )
Definition: class_module.h:673
wxString m_Filename
The 3D shape filename in 3D library.
Definition: 3d_info.h:45
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Definition: colors.h:62