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