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 another 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 
328 {
329  LIB_PIN* cur_pin = (LIB_PIN*) aItem;
330  wxPoint startPos;
331 
333 
334  LIB_PART* part = GetCurPart();
335 
336  // Clear pin flags and mark pins for moving. All pins having the same location
337  // orientation, and body style are flagged.
338  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
339  {
340  pin->ClearFlags();
341 
342  if( !SynchronizePins() )
343  continue;
344 
345  if( pin == cur_pin )
346  continue;
347 
348  if( pin->GetPosition() == cur_pin->GetPosition() &&
349  pin->GetOrientation() == cur_pin->GetOrientation() &&
350  pin->GetConvert() == cur_pin->GetConvert()
351  )
352  {
353  pin->SetFlags( IS_LINKED | IS_MOVED );
354  }
355  }
356 
357  cur_pin->SetFlags( IS_LINKED | IS_MOVED );
358 
359  PinPreviousPos = OldPos = cur_pin->GetPosition();
360  startPos.x = OldPos.x;
361  startPos.y = -OldPos.y;
362 
363  SetCrossHairPosition( startPos );
365 
366  MSG_PANEL_ITEMS items;
367 
368  cur_pin->GetMsgPanelInfo( items );
369  SetMsgPanel( items );
371 
372  // Refresh the screen to avoid color artifacts when drawing
373  // the pin in Edit mode and moving it from its start position
374  m_canvas->Refresh();
375 }
376 
377 
378 /* Move pin to the current mouse position. This function is called by the
379  * cursor management code. */
380 static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
381  bool aErase )
382 {
383  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
384 
385  if( parent == NULL )
386  return;
387 
388  LIB_PIN* cur_pin = (LIB_PIN*) parent->GetDrawItem();
389 
390  if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T )
391  return;
392 
393  wxPoint pinpos = cur_pin->GetPosition();
395 
396  if( parent->GetShowElectricalType() )
397  show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
398 
399  // In LIB_PIN::Draw() a void* parameter used as flag to pass show_opts.
400  // Build it:
401  void* showOptions = reinterpret_cast<void*>( show_opts );
402 
403  // Erase pin in old position
404  if( aErase )
405  {
406  cur_pin->Move( PinPreviousPos );
407  cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode,
408  showOptions, DefaultTransform );
409  }
410 
411  // Redraw pin in new position
412  cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
413  cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode,
414  showOptions, DefaultTransform );
415 
416  PinPreviousPos = cur_pin->GetPosition();
417 
418  /* Keep the original position for existing pin (for Undo command)
419  * and the current position for a new pin */
420  if( !cur_pin->IsNew() )
421  cur_pin->Move( pinpos );
422 }
423 
424 
425 /*
426  * Create a new pin.
427  */
429 {
430  LIB_PART* part = GetCurPart();
431 
432  if( !part )
433  return;
434 
435  part->ClearStatus();
436 
437  LIB_PIN* pin = new LIB_PIN( part );
438 
439  SetDrawItem( pin );
440 
441  pin->SetFlags( IS_NEW );
442  pin->SetUnit( m_unit );
443  pin->SetConvert( m_convert );
444 
445  // Flag pins to consider
446  if( SynchronizePins() )
447  pin->SetFlags( IS_LINKED );
448 
449  pin->Move( GetCrossHairPosition( true ) );
450  pin->SetLength( GetLastPinLength() );
452  pin->SetType( LastPinType );
453  pin->SetShape( LastPinShape );
457  pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
458  pin->SetVisible( LastPinVisible );
459  PinPreviousPos = pin->GetPosition();
461  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
462  cmd.SetId( ID_LIBEDIT_EDIT_PIN );
463  GetEventHandler()->ProcessEvent( cmd );
465  m_canvas->SetIgnoreMouseEvents( false );
466 
467  if( pin->GetFlags() & IS_CANCELLED )
468  {
469  deleteItem( DC, pin );
470  }
471  else
472  {
475 
476  if( DC )
477  {
479 
480  if( GetShowElectricalType() )
481  show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
482 
483  // In LIB_PIN::Draw() a void* parameter used as flag to pass show_opts.
484  // Build it:
485  void* showOptions = reinterpret_cast<void*>( show_opts );
486 
487  pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, GR_COPY,
488  showOptions, DefaultTransform );
489  }
490 
491  }
492 }
493 
494 
496 {
497  int ii;
498  LIB_PIN* newPin;
499 
500  // if "synchronize pins edition" option is off, do not create any similar pin for other
501  // units and/or shapes: each unit is edited regardless other units or body
502  if( !SynchronizePins() )
503  return;
504 
505  if( aPin->GetUnit() == 0 ) // Pin common to all units: no need to create similar pins.
506  return;
507 
508  // When units are interchangeable, all units are expected to have similar pins
509  // at the same position
510  // to facilitate pin edition, create pins for all other units for the current body style
511  // at the same position as aPin
512 
513  for( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ )
514  {
515  if( ii == aPin->GetUnit() )
516  continue;
517 
518  newPin = (LIB_PIN*) aPin->Clone();
519 
520  // To avoid mistakes, gives this pin a new pin number because
521  // it does no have the save pin number as the master pin
522  // Because we do not know the actual number, give it a temporary number
523  wxString unknownNum;
524  unknownNum.Printf( "%s-U%c", aPin->GetNumber(), wxChar( 'A' + ii - 1 ) );
525  newPin->SetNumber( unknownNum );
526 
527  newPin->SetUnit( ii );
528  aPin->GetParent()->AddDrawItem( newPin );
529  }
530 }
531 
532 
533 /* aMasterPin is the "template" pin
534  * aId is a param to select what should be mofified:
535  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
536  * Change pins text name size
537  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
538  * Change pins text num size
539  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
540  * Change pins length.
541  *
542  * If aMasterPin is selected ( .m_flag == IS_SELECTED ),
543  * only the other selected pins are modified
544  */
545 void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
546 
547 {
548  LIB_PART* part = GetCurPart();
549 
550  if( !part || !aMasterPin )
551  return;
552 
553  if( aMasterPin->Type() != LIB_PIN_T )
554  return;
555 
556  bool selected = aMasterPin->IsSelected();
557 
558  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
559  {
560  if( pin->GetConvert() && pin->GetConvert() != m_convert )
561  continue;
562 
563  // Is it the "selected mode" ?
564  if( selected && !pin->IsSelected() )
565  continue;
566 
567  switch( aId )
568  {
570  pin->SetNumberTextSize( aMasterPin->GetNumberTextSize() );
571  break;
572 
574  pin->SetNameTextSize( aMasterPin->GetNameTextSize() );
575  break;
576 
578  pin->SetLength( aMasterPin->GetLength() );
579  break;
580  }
581 
582  // Clear the flag IS_CHANGED, which was set by previous changes (if any)
583  // but not used here.
584  pin->ClearFlags( IS_CHANGED );
585  }
586 
587  // Now changes are made, call OnModify() to validate thes changes and set
588  // the global change for UI
589  OnModify();
590 }
591 
592 
593 // Create a new pin based on the previous pin with an incremented pin number.
594 void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
595 {
596  wxString msg;
597 
598  LIB_PART* part = GetCurPart();
599 
600  if( !part || !SourcePin || SourcePin->Type() != LIB_PIN_T )
601  return;
602 
603  LIB_PIN* pin = (LIB_PIN*) SourcePin->Clone();
604 
605  pin->ClearFlags();
606  pin->SetFlags( IS_NEW );
607  wxPoint step;
608 
609  switch( pin->GetOrientation() )
610  {
611  case PIN_UP:
612  step.x = GetRepeatPinStep();
613  break;
614 
615  case PIN_DOWN:
616  step.x = GetRepeatPinStep();
617  break;
618 
619  case PIN_LEFT:
620  step.y = - GetRepeatPinStep();
621  break;
622 
623  case PIN_RIGHT:
624  step.y = - GetRepeatPinStep();
625  break;
626  }
627 
628  pin->Move( pin->GetPosition() + step );
629  wxString nextName = pin->GetName();
631  pin->SetName( nextName );
632 
633  msg = pin->GetNumber();
635  pin->SetNumber( msg );
636 
637  SetDrawItem( pin );
638 
639  if( SynchronizePins() )
640  pin->SetFlags( IS_LINKED );
641 
642  wxPoint savepos = GetCrossHairPosition();
643  m_canvas->CrossHairOff( DC );
644 
645  SetCrossHairPosition( wxPoint( pin->GetPosition().x, -pin->GetPosition().y ) );
646 
647  // Add this new pin in list, and creates pins for others parts if needed
648  SetDrawItem( pin );
650  PlacePin();
651  m_lastDrawItem = pin;
652 
653  SetCrossHairPosition( savepos );
654  m_canvas->CrossHairOn( DC );
655 
656  MSG_PANEL_ITEMS items;
657  pin->GetMsgPanelInfo( items );
658  SetMsgPanel( items );
659  OnModify( );
660 }
661 
662 
663 // helper function to sort pins by pin num
664 bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
665 {
666  int test = ref->GetNumber().Cmp( tst->GetNumber() );
667 
668  if( test == 0 )
669  {
670  test = ref->GetConvert() - tst->GetConvert();
671  }
672 
673  if( test == 0 )
674  {
675  test = ref->GetUnit() - tst->GetUnit();
676  }
677 
678  return test < 0;
679 }
680 
681 
682 void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
683 {
684  LIB_PART* part = GetCurPart();
685 
686  if( !part )
687  return;
688 
689  const int MIN_GRID_SIZE = 25;
690 
691  LIB_PINS pinList;
692 
693  part->GetPins( pinList );
694 
695  if( pinList.size() == 0 )
696  {
697  DisplayInfoMessage( this, _( "No pins!" ) );
698  return;
699  }
700 
701  // Sort pins by pin num, so 2 duplicate pins
702  // (pins with the same number) will be consecutive in list
703  sort( pinList.begin(), pinList.end(), sort_by_pin_number );
704 
705  // Test for duplicates:
706  DIALOG_DISPLAY_HTML_TEXT_BASE error_display( this, wxID_ANY,
707  _( "Marker Information" ),
708  wxDefaultPosition,
709  wxSize( 750, 600 ) );
710 
711  int dup_error = 0;
712 
713  for( unsigned ii = 1; ii < pinList.size(); ii++ )
714  {
715  LIB_PIN* curr_pin = pinList[ii];
716  LIB_PIN* pin = pinList[ii - 1];
717 
718  if( pin->GetNumber() != curr_pin->GetNumber()
719  || pin->GetConvert() != curr_pin->GetConvert() )
720  continue;
721 
722  dup_error++;
723 
724  /* TODO I dare someone to find a way to make happy translators on
725  this thing! Lorenzo */
726 
727  wxString msg = wxString::Format( _(
728  "<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>"
729  " conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
730  GetChars( curr_pin->GetNumber() ),
731  GetChars( curr_pin->GetName() ),
732  curr_pin->GetPosition().x / 1000.0,
733  -curr_pin->GetPosition().y / 1000.0,
734  GetChars( pin->GetNumber() ),
735  GetChars( pin->GetName() ),
736  pin->GetPosition().x / 1000.0,
737  -pin->GetPosition().y / 1000.0
738  );
739 
740  if( part->GetUnitCount() > 1 )
741  {
742  msg += wxString::Format( _( " in units %c and %c" ),
743  'A' + curr_pin->GetUnit() - 1,
744  'A' + pin->GetUnit() - 1 );
745  }
746 
747  if( m_showDeMorgan )
748  {
749  if( curr_pin->GetConvert() )
750  msg += _( " of converted" );
751  else
752  msg += _( " of normal" );
753  }
754 
755  msg += wxT( ".<br>" );
756 
757  error_display.m_htmlWindow->AppendToPage( msg );
758  }
759 
760  // Test for off grid pins:
761  int offgrid_error = 0;
762 
763  for( unsigned ii = 0; ii < pinList.size(); ii++ )
764  {
765  LIB_PIN* pin = pinList[ii];
766 
767  if( ( (pin->GetPosition().x % MIN_GRID_SIZE) == 0 ) &&
768  ( (pin->GetPosition().y % MIN_GRID_SIZE) == 0 ) )
769  continue;
770 
771  // "pin" is off grid here.
772  offgrid_error++;
773 
774  wxString msg = wxString::Format( _(
775  "<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
776  GetChars( pin->GetNumber() ),
777  GetChars( pin->GetName() ),
778  pin->GetPosition().x / 1000.0,
779  -pin->GetPosition().y / 1000.0
780  );
781 
782  if( part->GetUnitCount() > 1 )
783  {
784  msg += wxString::Format( _( " in symbol %c" ), 'A' + pin->GetUnit() - 1 );
785  }
786 
787  if( m_showDeMorgan )
788  {
789  if( pin->GetConvert() )
790  msg += _( " of converted" );
791  else
792  msg += _( " of normal" );
793  }
794 
795  msg += wxT( ".<br>" );
796 
797  error_display.m_htmlWindow->AppendToPage( msg );
798  }
799 
800  if( !dup_error && !offgrid_error )
801  DisplayInfoMessage( this, _( "No off grid or duplicate pins were found." ) );
802  else
803  error_display.ShowModal();
804 }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:106
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
void OnCheckComponent(wxCommandEvent &event)
Definition: pinedit.cpp:682
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:266
void SetLength(int aLength, bool aTestOtherPins=true)
Set the pin length.
Definition: lib_pin.cpp:363
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:1547
static int LastPinNameSize
Definition: pinedit.cpp:67
void SetLength(const wxString &length)
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 by a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
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:227
static wxArrayString GetOrientationNames()
Get a list of pin orientation names.
Definition: lib_pin.cpp:1886
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:298
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:458
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:205
bool IsModified() const
Definition: base_struct.h:228
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:161
void SetPinPositionY(const wxString &aSize)
void SetPinNameTextSize(const wxString &size)
void GlobalSetPins(LIB_PIN *aMasterPin, int aId)
Definition: pinedit.cpp:545
bool IsSelected() const
Definition: base_struct.h:232
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:1948
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:1734
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:514
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:360
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:1906
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:293
int GetNumberTextSize() const
Definition: lib_pin.h:218
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
const wxString & GetNumber() const
Definition: lib_pin.h:193
void RepeatPinItem(wxDC *DC, LIB_PIN *Pin)
Definition: pinedit.cpp:594
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:450
#define IS_NEW
New item, just created.
Definition: base_struct.h:109
void SetNumber(const wxString &aNumber)
Set the pin number.
Definition: lib_pin.cpp:222
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:105
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:264
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:831
void SetAddToAllBodyStyles(bool apply)
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:370
Define a library symbol object.
void SetVisible(bool aVisible)
Set or clear the visibility flag for the pin.
Definition: lib_pin.cpp:481
unsigned STATUS_FLAGS
Definition: base_struct.h:142
void CreateImagePins(LIB_PIN *aPin)
Adds copies of aPin in components with multiple units in all units.
Definition: pinedit.cpp:495
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:180
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:265
static wxPoint PinPreviousPos
Definition: pinedit.cpp:57
void CreatePin(wxDC *DC)
Definition: pinedit.cpp:428
void SetPinPosition(wxPoint aPosition)
move this and all linked pins to the new position used in pin edition.
Definition: lib_pin.cpp:393
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:57
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
void deleteItem(wxDC *aDC, LIB_ITEM *aItem)
Deletes the currently selected draw item.
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:106
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:272
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:420
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:122
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:327
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:1591
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:265
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:269
static void DrawMovePin(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPositon, bool aErase)
Definition: pinedit.cpp:380
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:194
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:216
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:233
void SetPadName(const wxString &number)
bool GetShowElectricalType()
bool sort_by_pin_number(const LIB_PIN *ref, const LIB_PIN *tst)
Definition: pinedit.cpp:664
void SetNumberTextSize(int aSize, bool aTestOtherPins=true)
Set the size of the pin number text.
Definition: lib_pin.cpp:241
void StartMovePin(LIB_ITEM *aPin)
Prepare the displacement of a pin.
Definition: pinedit.cpp:327
int GetConvert() const
static int GetOrientationCode(int aIndex)
Get the orientation code by index used to set the pin orientation.
Definition: lib_pin.cpp:1897
#define IS_MOVED
Item being moved.
Definition: base_struct.h:108