KiCad PCB EDA Suite
pinedit.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <gr_basic.h>
33 #include <class_drawpanel.h>
34 #include <confirm.h>
35 #include <base_units.h>
36 #include <msgpanel.h>
37 
38 #include <lib_edit_frame.h>
39 #include <eeschema_id.h>
40 #include <class_libentry.h>
41 #include <lib_pin.h>
42 #include <general.h>
43 #include <confirm.h>
44 
45 #include <../common/dialogs/dialog_display_info_HTML_base.h>
46 #include <dialog_lib_edit_pin.h>
47 
48 
49 extern void IncrementLabelMember( wxString& name, int aIncrement );
50 
51 
52 static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC );
53 static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase );
54 
55 
56 static wxPoint OldPos;
59 static int LastPinOrient = PIN_RIGHT;
61 static bool LastPinCommonConvert = false;
62 static bool LastPinCommonUnit = false;
63 static bool LastPinVisible = true;
64 
65 // The -1 is a non-valid value to trigger delayed initialization
66 static int LastPinLength = -1;
67 static int LastPinNameSize = -1;
68 static int LastPinNumSize = -1;
69 
70 static int GetLastPinLength()
71 {
72  if( LastPinLength == -1 )
74 
75  return LastPinLength;
76 }
77 
78 static int GetLastPinNameSize()
79 {
80  if( LastPinNameSize == -1 )
82 
83  return LastPinNameSize;
84 }
85 
86 static int GetLastPinNumSize()
87 {
88  if( LastPinNumSize == -1 )
90 
91  return LastPinNumSize;
92 }
93 
94 void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
95 {
96  if( GetDrawItem() == NULL || GetDrawItem()->Type() != LIB_PIN_T )
97  return;
98 
99  STATUS_FLAGS item_flags = GetDrawItem()->GetFlags(); // save flags to restore them after editing
100  LIB_PIN* pin = (LIB_PIN*) GetDrawItem();
101 
102  DIALOG_LIB_EDIT_PIN dlg( this, pin );
103 
104  wxString units = GetUnitsLabel( g_UserUnit );
105  dlg.SetDlgUnitsLabel( units );
106 
109  dlg.SetStyle( pin->GetShape() );
110  dlg.SetElectricalType( pin->GetType() );
111  dlg.SetPinName( pin->GetName() );
115  dlg.SetPadName( pin->GetNumber() );
117 
118  dlg.SetLength( StringFromValue( g_UserUnit, pin->GetLength() ) );
119  dlg.SetAddToAllParts( pin->GetUnit() == 0 );
120  dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 );
121  dlg.SetVisible( pin->IsVisible() );
122 
123  /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier
124  * versions for the flex grid sizer in wxGTK that prevents the last
125  * column from being sized correctly. It doesn't cause any problems
126  * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__
127  * #endif.
128  */
129  dlg.Layout();
130  dlg.Fit();
131  dlg.SetMinSize( dlg.GetSize() );
132 
133  if( dlg.ShowModal() == wxID_CANCEL )
134  {
135  if( pin->IsNew() )
136  {
137  pin->SetFlags( IS_CANCELLED );
139  }
140  return;
141  }
142 
143  // Test the pin position validity: to avoid issues in schematic,
144  // it must be on a 50 mils grid
145  wxPoint pinpos;
146  pinpos.x = ValueFromString( g_UserUnit, dlg.GetPinPositionX() );
147  pinpos.y = -ValueFromString( g_UserUnit, dlg.GetPinPositionY() );
148  const int acceptable_mingrid = 50;
149 
150  if( (pinpos.x % acceptable_mingrid) || (pinpos.y % acceptable_mingrid) )
151  {
152  wxString msg;
153  msg.Printf( _( "This pin is not on a %d mils grid\n"
154  "It will be not easy to connect in schematic\n"
155  "Do you want to continue?"), acceptable_mingrid );
156 
157  if( !IsOK( this, msg ) )
158  return;
159  }
160 
161 
162  // Save the pin properties to use for the next new pin.
167  LastPinShape = dlg.GetStyle();
171  LastPinVisible = dlg.GetVisible();
172 
173  if( !pin->InEditMode() )
174  SaveCopyInUndoList( pin->GetParent() );
175 
176  pin->EnableEditMode( true, SynchronizePins()? false : true );
177  pin->SetName( dlg.GetPinName() );
179  pin->SetNumber( dlg.GetPadName() );
181  pin->SetOrientation( LastPinOrient );
182  pin->SetLength( GetLastPinLength() );
183  pin->SetPinPosition( pinpos );
184 
185  pin->SetType( LastPinType );
186  pin->SetShape( LastPinShape );
187  pin->SetConversion( ( LastPinCommonConvert ) ? 0 : m_convert );
188  pin->SetPartNumber( ( LastPinCommonUnit ) ? 0 : m_unit );
189  pin->SetVisible( LastPinVisible );
190 
191  if( pin->IsModified() || pin->IsNew() )
192  {
193  OnModify( );
194 
195  MSG_PANEL_ITEMS items;
196  pin->GetMsgPanelInfo( items );
197  SetMsgPanel( items );
198  m_canvas->Refresh();
199  }
200 
201  pin->EnableEditMode( false );
202 
203  // Restore pin flags, that can be changed by the dialog editor
204  pin->ClearFlags();
205  pin->SetFlags( item_flags );
206 }
207 
211 static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC )
212 {
213  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
214 
215  if( parent == NULL )
216  return;
217 
218  LIB_PIN* pin = (LIB_PIN*) parent->GetDrawItem();
219 
220  if( pin == NULL || pin->Type() != LIB_PIN_T )
221  return;
222 
223  pin->ClearFlags();
224 
225  if( pin->IsNew() )
226  delete pin;
227  else
228  parent->RestoreComponent();
229 
230  // clear edit flags
231  parent->SetDrawItem( NULL );
232  parent->SetLastDrawItem( NULL );
233  Panel->Refresh( true );
234 }
235 
236 
241 {
242  LIB_PIN* cur_pin = (LIB_PIN*) GetDrawItem();
243 
244  // Some tests
245  if( !cur_pin || cur_pin->Type() != LIB_PIN_T )
246  {
247  wxMessageBox( wxT( "LIB_EDIT_FRAME::PlacePin() error" ) );
248  return;
249  }
250 
251  wxPoint newpos;
252  newpos = GetCrossHairPosition( true );
253 
254  LIB_PART* part = GetCurPart();
255 
256  // Test for an other pin in same new position in other units:
257  bool ask_for_pin = true;
258 
259  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
260  {
261  if( pin == cur_pin || newpos != pin->GetPosition() || pin->GetFlags() )
262  continue;
263 
264  // test for same body style
265  if( pin->GetConvert() && pin->GetConvert() != cur_pin->GetConvert() )
266  continue;
267 
268  if( ask_for_pin && SynchronizePins() )
269  {
271  wxString msg;
272  msg.Printf( _( "This position is already occupied by another pin, in unit %d.\n"
273  "Continue?" ), pin->GetUnit() );
274 
275  bool status = IsOK( this, msg );
276 
278  m_canvas->SetIgnoreMouseEvents( false );
279 
280  if( !status )
281  return;
282  else
283  ask_for_pin = false;
284  }
285  }
286 
287  // Create Undo from GetTempCopyComponent() if exists ( i.e. after a pin move)
288  // or from m_component (pin add ...)
289  if( GetTempCopyComponent() )
291  else
292  SaveCopyInUndoList( part );
293 
294  m_canvas->SetMouseCapture( NULL, NULL );
295  cur_pin->Move( newpos );
296 
297  if( cur_pin->IsNew() )
298  {
299  LastPinOrient = cur_pin->GetOrientation();
300  LastPinType = cur_pin->GetType();
301  LastPinShape = cur_pin->GetShape();
302 
303  if( SynchronizePins() )
304  CreateImagePins( cur_pin );
305 
306  m_lastDrawItem = cur_pin;
307  part->AddDrawItem( GetDrawItem() );
308  }
309 
310  // Put linked pins in new position, and clear flags
311  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
312  {
313  if( pin->GetFlags() == 0 )
314  continue;
315 
316  pin->Move( cur_pin->GetPosition() );
317  pin->ClearFlags();
318  }
319 
320  SetDrawItem( NULL );
321 
322  OnModify();
323  m_canvas->Refresh();
324 }
325 
326 
334 {
335  LIB_PIN* cur_pin = (LIB_PIN*) GetDrawItem();
336  wxPoint startPos;
337 
339 
340  LIB_PART* part = GetCurPart();
341 
342  // Clear pin flags and mark pins for moving. All pins having the same location
343  // orientation, and body style are flagged.
344  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
345  {
346  pin->ClearFlags();
347 
348  if( !SynchronizePins() )
349  continue;
350 
351  if( pin == cur_pin )
352  continue;
353 
354  if( pin->GetPosition() == cur_pin->GetPosition() &&
355  pin->GetOrientation() == cur_pin->GetOrientation() &&
356  pin->GetConvert() == cur_pin->GetConvert()
357  )
358  {
359  pin->SetFlags( IS_LINKED | IS_MOVED );
360  }
361  }
362 
363  cur_pin->SetFlags( IS_LINKED | IS_MOVED );
364 
365  PinPreviousPos = OldPos = cur_pin->GetPosition();
366  startPos.x = OldPos.x;
367  startPos.y = -OldPos.y;
368 
369  SetCrossHairPosition( startPos );
371 
372  MSG_PANEL_ITEMS items;
373 
374  cur_pin->GetMsgPanelInfo( items );
375  SetMsgPanel( items );
377 
378  // Refresh the screen to avoid color artifacts when drawing
379  // the pin in Edit mode and moving it from its start position
380  m_canvas->Refresh();
381 }
382 
383 
384 /* Move pin to the current mouse position. This function is called by the
385  * cursor management code. */
386 static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
387  bool aErase )
388 {
389  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
390 
391  if( parent == NULL )
392  return;
393 
394  LIB_PIN* cur_pin = (LIB_PIN*) parent->GetDrawItem();
395 
396  if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T )
397  return;
398 
399  wxPoint pinpos = cur_pin->GetPosition();
401 
402  if( parent->GetShowElectricalType() )
403  show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
404 
405  // In LIB_PIN::Draw() a void* parameter used as flag to pass show_opts.
406  // Build it:
407  void* showOptions = reinterpret_cast<void*>( show_opts );
408 
409  // Erase pin in old position
410  if( aErase )
411  {
412  cur_pin->Move( PinPreviousPos );
413  cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode,
414  showOptions, DefaultTransform );
415  }
416 
417  // Redraw pin in new position
418  cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
419  cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode,
420  showOptions, DefaultTransform );
421 
422  PinPreviousPos = cur_pin->GetPosition();
423 
424  /* Keep the original position for existing pin (for Undo command)
425  * and the current position for a new pin */
426  if( !cur_pin->IsNew() )
427  cur_pin->Move( pinpos );
428 }
429 
430 
431 /*
432  * Create a new pin.
433  */
435 {
436  LIB_PART* part = GetCurPart();
437 
438  if( !part )
439  return;
440 
441  part->ClearStatus();
442 
443  LIB_PIN* pin = new LIB_PIN( part );
444 
445  SetDrawItem( pin );
446 
447  pin->SetFlags( IS_NEW );
448  pin->SetUnit( m_unit );
449  pin->SetConvert( m_convert );
450 
451  // Flag pins to consider
452  if( SynchronizePins() )
453  pin->SetFlags( IS_LINKED );
454 
455  pin->Move( GetCrossHairPosition( true ) );
456  pin->SetLength( GetLastPinLength() );
458  pin->SetType( LastPinType );
459  pin->SetShape( LastPinShape );
463  pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
464  pin->SetVisible( LastPinVisible );
465  PinPreviousPos = pin->GetPosition();
467  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
468  cmd.SetId( ID_LIBEDIT_EDIT_PIN );
469  GetEventHandler()->ProcessEvent( cmd );
471  m_canvas->SetIgnoreMouseEvents( false );
472 
473  if( pin->GetFlags() & IS_CANCELLED )
474  {
475  deleteItem( DC );
476  }
477  else
478  {
481 
482  if( DC )
483  {
485 
486  if( GetShowElectricalType() )
487  show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
488 
489  // In LIB_PIN::Draw() a void* parameter used as flag to pass show_opts.
490  // Build it:
491  void* showOptions = reinterpret_cast<void*>( show_opts );
492 
493  pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, GR_COPY,
494  showOptions, DefaultTransform );
495  }
496 
497  }
498 }
499 
500 
502 {
503  int ii;
504  LIB_PIN* newPin;
505 
506  // if "synchronize pins edition" option is off, do not create any similar pin for other
507  // units and/or shapes: each unit is edited regardless other units or body
508  if( !SynchronizePins() )
509  return;
510 
511  if( aPin->GetUnit() == 0 ) // Pin common to all units: no need to create similar pins.
512  return;
513 
514  // When units are interchangeable, all units are expected to have similar pins
515  // at the same position
516  // to facilitate pin edition, create pins for all other units for the current body style
517  // at the same position as aPin
518 
519  for( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ )
520  {
521  if( ii == aPin->GetUnit() )
522  continue;
523 
524  newPin = (LIB_PIN*) aPin->Clone();
525 
526  // To avoid mistakes, gives this pin a new pin number because
527  // it does no have the save pin number as the master pin
528  // Because we do not know the actual number, give it a temporary number
529  wxString unknownNum;
530  unknownNum.Printf( "%s-U%c", aPin->GetNumber(), wxChar( 'A' + ii - 1 ) );
531  newPin->SetNumber( unknownNum );
532 
533  newPin->SetUnit( ii );
534  aPin->GetParent()->AddDrawItem( newPin );
535  }
536 }
537 
538 
539 /* aMasterPin is the "template" pin
540  * aId is a param to select what should be mofified:
541  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
542  * Change pins text name size
543  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
544  * Change pins text num size
545  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
546  * Change pins length.
547  *
548  * If aMasterPin is selected ( .m_flag == IS_SELECTED ),
549  * only the other selected pins are modified
550  */
551 void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
552 
553 {
554  LIB_PART* part = GetCurPart();
555 
556  if( !part || !aMasterPin )
557  return;
558 
559  if( aMasterPin->Type() != LIB_PIN_T )
560  return;
561 
562  bool selected = aMasterPin->IsSelected();
563 
564  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
565  {
566  if( pin->GetConvert() && pin->GetConvert() != m_convert )
567  continue;
568 
569  // Is it the "selected mode" ?
570  if( selected && !pin->IsSelected() )
571  continue;
572 
573  switch( aId )
574  {
576  pin->SetNumberTextSize( aMasterPin->GetNumberTextSize() );
577  break;
578 
580  pin->SetNameTextSize( aMasterPin->GetNameTextSize() );
581  break;
582 
584  pin->SetLength( aMasterPin->GetLength() );
585  break;
586  }
587 
588  // Clear the flag IS_CHANGED, which was set by previous changes (if any)
589  // but not used here.
590  pin->ClearFlags( IS_CHANGED );
591  }
592 
593  // Now changes are made, call OnModify() to validate thes changes and set
594  // the global change for UI
595  OnModify();
596 }
597 
598 
599 // Create a new pin based on the previous pin with an incremented pin number.
600 void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
601 {
602  wxString msg;
603 
604  LIB_PART* part = GetCurPart();
605 
606  if( !part || !SourcePin || SourcePin->Type() != LIB_PIN_T )
607  return;
608 
609  LIB_PIN* pin = (LIB_PIN*) SourcePin->Clone();
610 
611  pin->ClearFlags();
612  pin->SetFlags( IS_NEW );
613  wxPoint step;
614 
615  switch( pin->GetOrientation() )
616  {
617  case PIN_UP:
618  step.x = GetRepeatPinStep();
619  break;
620 
621  case PIN_DOWN:
622  step.x = GetRepeatPinStep();
623  break;
624 
625  case PIN_LEFT:
626  step.y = - GetRepeatPinStep();
627  break;
628 
629  case PIN_RIGHT:
630  step.y = - GetRepeatPinStep();
631  break;
632  }
633 
634  pin->Move( pin->GetPosition() + step );
635  wxString nextName = pin->GetName();
637  pin->SetName( nextName );
638 
639  msg = pin->GetNumber();
641  pin->SetNumber( msg );
642 
643  SetDrawItem( pin );
644 
645  if( SynchronizePins() )
646  pin->SetFlags( IS_LINKED );
647 
648  wxPoint savepos = GetCrossHairPosition();
649  m_canvas->CrossHairOff( DC );
650 
651  SetCrossHairPosition( wxPoint( pin->GetPosition().x, -pin->GetPosition().y ) );
652 
653  // Add this new pin in list, and creates pins for others parts if needed
654  SetDrawItem( pin );
656  PlacePin();
657  m_lastDrawItem = pin;
658 
659  SetCrossHairPosition( savepos );
660  m_canvas->CrossHairOn( DC );
661 
662  MSG_PANEL_ITEMS items;
663  pin->GetMsgPanelInfo( items );
664  SetMsgPanel( items );
665  OnModify( );
666 }
667 
668 
669 // helper function to sort pins by pin num
670 bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
671 {
672  int test = ref->GetNumber().Cmp( tst->GetNumber() );
673 
674  if( test == 0 )
675  {
676  test = ref->GetConvert() - tst->GetConvert();
677  }
678 
679  if( test == 0 )
680  {
681  test = ref->GetUnit() - tst->GetUnit();
682  }
683 
684  return test < 0;
685 }
686 
687 
688 void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
689 {
690  LIB_PART* part = GetCurPart();
691 
692  if( !part )
693  return;
694 
695  const int MIN_GRID_SIZE = 25;
696 
697  LIB_PINS pinList;
698 
699  part->GetPins( pinList );
700 
701  if( pinList.size() == 0 )
702  {
703  DisplayInfoMessage( this, _( "No pins!" ) );
704  return;
705  }
706 
707  // Sort pins by pin num, so 2 duplicate pins
708  // (pins with the same number) will be consecutive in list
709  sort( pinList.begin(), pinList.end(), sort_by_pin_number );
710 
711  // Test for duplicates:
712  DIALOG_DISPLAY_HTML_TEXT_BASE error_display( this, wxID_ANY,
713  _( "Marker Information" ),
714  wxDefaultPosition,
715  wxSize( 750, 600 ) );
716 
717  int dup_error = 0;
718 
719  for( unsigned ii = 1; ii < pinList.size(); ii++ )
720  {
721  LIB_PIN* curr_pin = pinList[ii];
722  LIB_PIN* pin = pinList[ii - 1];
723 
724  if( pin->GetNumber() != curr_pin->GetNumber()
725  || pin->GetConvert() != curr_pin->GetConvert()
726  || pin->GetUnit() != curr_pin->GetUnit() )
727  continue;
728 
729  dup_error++;
730 
731  /* TODO I dare someone to find a way to make happy translators on
732  this thing! Lorenzo */
733 
734  wxString msg = wxString::Format( _(
735  "<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>"
736  " conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
737  GetChars( curr_pin->GetNumber() ),
738  GetChars( curr_pin->GetName() ),
739  curr_pin->GetPosition().x / 1000.0,
740  -curr_pin->GetPosition().y / 1000.0,
741  GetChars( pin->GetNumber() ),
742  GetChars( pin->GetName() ),
743  pin->GetPosition().x / 1000.0,
744  -pin->GetPosition().y / 1000.0
745  );
746 
747  if( part->GetUnitCount() > 1 )
748  {
749  msg += wxString::Format( _( " in symbol %c" ), 'A' + curr_pin->GetUnit() - 1 );
750  }
751 
752  if( m_showDeMorgan )
753  {
754  if( curr_pin->GetConvert() )
755  msg += _( " of converted" );
756  else
757  msg += _( " of normal" );
758  }
759 
760  msg += wxT( ".<br>" );
761 
762  error_display.m_htmlWindow->AppendToPage( msg );
763  }
764 
765  // Test for off grid pins:
766  int offgrid_error = 0;
767 
768  for( unsigned ii = 0; ii < pinList.size(); ii++ )
769  {
770  LIB_PIN* pin = pinList[ii];
771 
772  if( ( (pin->GetPosition().x % MIN_GRID_SIZE) == 0 ) &&
773  ( (pin->GetPosition().y % MIN_GRID_SIZE) == 0 ) )
774  continue;
775 
776  // "pin" is off grid here.
777  offgrid_error++;
778 
779  wxString msg = wxString::Format( _(
780  "<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
781  GetChars( pin->GetNumber() ),
782  GetChars( pin->GetName() ),
783  pin->GetPosition().x / 1000.0,
784  -pin->GetPosition().y / 1000.0
785  );
786 
787  if( part->GetUnitCount() > 1 )
788  {
789  msg += wxString::Format( _( " in symbol %c" ), 'A' + pin->GetUnit() - 1 );
790  }
791 
792  if( m_showDeMorgan )
793  {
794  if( pin->GetConvert() )
795  msg += _( " of converted" );
796  else
797  msg += _( " of normal" );
798  }
799 
800  msg += wxT( ".<br>" );
801 
802  error_display.m_htmlWindow->AppendToPage( msg );
803  }
804 
805  if( !dup_error && !offgrid_error )
806  DisplayInfoMessage( this, _( "No off grid or duplicate pins were found." ) );
807  else
808  error_display.ShowModal();
809 }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:124
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
void OnCheckComponent(wxCommandEvent &event)
Definition: pinedit.cpp:688
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:284
void SetLength(int aLength, bool aTestOtherPins=true)
Set the pin length.
Definition: lib_pin.cpp:362
static int GetLastPinLength()
Definition: pinedit.cpp:70
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_pin.cpp:1542
static int LastPinNameSize
Definition: pinedit.cpp:67
void SetLength(const wxString &length)
void StartMovePin(wxDC *DC)
Prepare the displacement of a pin.
Definition: pinedit.cpp:333
int GetRepeatPinStep() const
wxString GetPadNameTextSize(void)
static int m_convert
void SetAddToAllParts(bool apply)
static bool LastPinCommonUnit
Definition: pinedit.cpp:62
void RestoreComponent()
Restore the current edited component from its temporary copy.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
int GetUnit() const
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:245
static wxArrayString GetOrientationNames()
Get a list of pin orientation names.
Definition: lib_pin.cpp:1881
void ClearTempCopyComponent()
Delete temporary copy of the current component and clear pointer.
Subclass of DIALOG_LIB_EDIT_PIN_BASE, which is generated by wxFormBuilder.
static int GetLastPinNameSize()
Definition: pinedit.cpp:78
void SetShape(GRAPHIC_PINSHAPE aShape)
Set the shape of the pin to aShape.
Definition: lib_pin.cpp:297
void SetStyle(GRAPHIC_PINSHAPE style)
void OnEditPin(wxCommandEvent &event)
Definition: pinedit.cpp:94
static bool LastPinCommonConvert
Definition: pinedit.cpp:61
wxString GetUnitsLabel(EDA_UNITS_T aUnit)
Get a human readable units string.
Definition: base_units.cpp:457
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:204
bool IsModified() const
Definition: base_struct.h:246
static int LastPinNumSize
Definition: pinedit.cpp:68
static int GetDefaultPinLength()
void SetName(const wxString &aName, bool aTestOtherPins=true)
Set the pin name.
Definition: lib_pin.cpp:160
void SetPinPositionY(const wxString &aSize)
void SetPinNameTextSize(const wxString &size)
void GlobalSetPins(LIB_PIN *aMasterPin, int aId)
Definition: pinedit.cpp:551
bool IsSelected() const
Definition: base_struct.h:250
Implementing DIALOG_LIB_EDIT_PIN_BASE.
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
bool InEditMode() const
Return the draw item editing mode status.
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen...
static const BITMAP_DEF * GetOrientationSymbols()
Get a list of pin orientation bitmaps for menus and dialogs.
Definition: lib_pin.cpp:1943
static int LastPinLength
Definition: pinedit.cpp:66
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_pin.cpp:1729
int GetRepeatDeltaLabel() const
Definition: lib_pin.h:55
void EnableEditMode(bool aEnable, bool aEditPinByPin=false)
Enable or clear pin editing mode.
Definition: lib_pin.cpp:513
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:361
int GetNameTextSize() const
Definition: lib_pin.h:191
void SetOrientationList(const wxArrayString &list, const BITMAP_DEF *aBitmaps)
int GetOrientation() const
Definition: lib_pin.h:220
static int GetOrientationCodeIndex(int aCode)
Get the index of the orientation code.
Definition: lib_pin.cpp:1901
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:293
int GetNumberTextSize() const
Definition: lib_pin.h:218
const wxString & GetNumber() const
Definition: lib_pin.h:193
void RepeatPinItem(wxDC *DC, LIB_PIN *Pin)
Definition: pinedit.cpp:600
void SetElectricalType(ELECTRICAL_PINTYPE type)
ELECTRICAL_PINTYPE GetElectricalType(void)
static bool LastPinVisible
Definition: pinedit.cpp:63
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
const wxString & GetName() const
Definition: lib_pin.h:165
void SetConversion(int aConversion)
Set the body style (conversion) of the pin.
Definition: lib_pin.cpp:449
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
void SetNumber(const wxString &aNumber)
Set the pin number.
Definition: lib_pin.cpp:221
void SetPadNameTextSize(const wxString &size)
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
static int GetPinNumDefaultSize()
void SetOrientation(int orientation)
GRAPHIC_PINSHAPE
Definition: pin_shape.h:35
void SetVisible(bool visible)
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:123
LIB_PART * GetParent() const
Class DIALOG_DISPLAY_HTML_TEXT_BASE.
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:282
void SetDrawItem(LIB_ITEM *drawItem)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:790
void SetAddToAllBodyStyles(bool apply)
void deleteItem(wxDC *aDC)
Deletes the currently selected draw item.
Class LIB_ITEM definition.
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:250
void SetPinPositionX(const wxString &aSize)
void TempCopyComponent()
Create a temporary copy of the current edited component.
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:369
Define a library symbol object.
void SetVisible(bool aVisible)
Set or clear the visibility flag for the pin.
Definition: lib_pin.cpp:480
unsigned STATUS_FLAGS
Definition: base_struct.h:160
void CreateImagePins(LIB_PIN *aPin)
Adds copies of aPin in components with multiple units in all units.
Definition: pinedit.cpp:501
static ELECTRICAL_PINTYPE LastPinType
Definition: pinedit.cpp:58
void SetLastDrawItem(LIB_ITEM *drawItem)
#define MIN_GRID_SIZE
static int GetLastPinNumSize()
Definition: pinedit.cpp:86
static LIB_ITEM * m_lastDrawItem
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:181
static int LastPinOrient
Definition: pinedit.cpp:59
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:361
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:266
static wxPoint PinPreviousPos
Definition: pinedit.cpp:57
void CreatePin(wxDC *DC)
Definition: pinedit.cpp:434
void SetPinPosition(wxPoint aPosition)
move this and all linked pins to the new position used in pin edition.
Definition: lib_pin.cpp:392
LIB_PART * GetTempCopyComponent()
static GRAPHIC_PINSHAPE LastPinShape
Definition: pinedit.cpp:60
void SetConvert(int aConvert)
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_pin.h:462
int GetUnitCount() const
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
void PlacePin()
Place at cursor location the pin currently moved (i.e.
Definition: pinedit.cpp:240
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void SetUnit(int aUnit)
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:60
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:273
void ClearStatus()
Clears the status flag all draw objects in this part.
void SetPartNumber(int aPart)
Set the pin part number.
Definition: lib_pin.cpp:419
The symbol library editor main window.
GRAPHIC_PINSHAPE GetStyle(void)
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
TRANSFORM DefaultTransform
Definition: eeschema.cpp:58
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform)
Draw an item.
static int m_unit
const char * name
Definition: DXF_plotter.cpp:61
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
static int GetPinNameDefaultSize()
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
wxString GetPinNameTextSize(void)
#define IS_CANCELLED
flag set when edit dialogs are canceled when editing a
Definition: base_struct.h:140
void SaveCopyInUndoList(EDA_ITEM *ItemToCopy, UNDO_REDO_T undoType=UR_LIBEDIT)
Create a copy of the current component, and save it in the undo list.
LIB_ITEM * GetDrawItem() const
void SetIgnoreMouseEvents(bool aIgnore)
void SetType(ELECTRICAL_PINTYPE aType, bool aTestOtherPins=true)
Set the electrical type of the pin.
Definition: lib_pin.cpp:326
static void AbortPinMove(EDA_DRAW_PANEL *Panel, wxDC *DC)
Clean up after aborting a move pin command.
Definition: pinedit.cpp:211
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_pin.cpp:1586
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
bool SynchronizePins()
Pin edition (add, delete, move...) can be synchronized between units when units are interchangeable b...
Definition of class LIB_EDIT_FRAME.
void SetDlgUnitsLabel(const wxString &units)
void SetOrientation(int aOrientation, bool aTestOtherPins=true)
Set orientation on the pin.
Definition: lib_pin.cpp:268
static void DrawMovePin(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPositon, bool aErase)
Definition: pinedit.cpp:386
static bool m_showDeMorgan
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
static wxPoint OldPos
Definition: pinedit.cpp:56
wxString GetPinName(void)
void SetNameTextSize(int aSize, bool aTestOtherPins=true)
Set the aSize of the pin name text.
Definition: lib_pin.cpp:193
Message panel definition file.
void SetPinName(const wxString &name)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:272
int GetLength()
Definition: lib_pin.h:300
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:234
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:289
void SetPadName(const wxString &number)
bool GetShowElectricalType()
bool sort_by_pin_number(const LIB_PIN *ref, const LIB_PIN *tst)
Definition: pinedit.cpp:670
void SetNumberTextSize(int aSize, bool aTestOtherPins=true)
Set the size of the pin number text.
Definition: lib_pin.cpp:240
int GetConvert() const
static int GetOrientationCode(int aIndex)
Get the orientation code by index used to set the pin orientation.
Definition: lib_pin.cpp:1892
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126