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 <sch_draw_panel.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 #include <sch_view.h>
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;
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  pin->EnableEditMode( true, !SynchronizePins() );
103 
104  DIALOG_LIB_EDIT_PIN dlg( this, pin );
105 
106  if( dlg.ShowModal() == wxID_CANCEL )
107  {
108  if( pin->IsNew() )
109  {
110  pin->SetFlags( IS_CANCELLED );
112  }
113  return;
114  }
115 
116  if( pin->IsModified() || pin->IsNew() )
117  {
118  GetCanvas()->GetView()->Update( pin );
119  GetCanvas()->Refresh();
120  OnModify( );
121 
122  MSG_PANEL_ITEMS items;
123  pin->GetMsgPanelInfo( m_UserUnits, items );
124  SetMsgPanel( items );
125  }
126 
127  pin->EnableEditMode( false );
128 
129  // Restore pin flags, that can be changed by the dialog editor
130  pin->ClearFlags();
131  pin->SetFlags( item_flags );
132 
133  // Save the pin properties to use for the next new pin.
136  LastPinOrient = pin->GetOrientation();
137  LastPinLength = pin->GetLength();
138  LastPinShape = pin->GetShape();
139  LastPinType = pin->GetType();
140  LastPinCommonConvert = pin->GetConvert() == 0;
141  LastPinCommonUnit = pin->GetUnit() == 0;
142  LastPinVisible = pin->IsVisible();
143 }
144 
148 static void AbortPinMove( EDA_DRAW_PANEL* aPanel, wxDC* DC )
149 {
150  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
151  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
152 
153 
154  if( parent == NULL )
155  return;
156 
157  LIB_PIN* pin = (LIB_PIN*) parent->GetDrawItem();
158 
159  if( pin == NULL || pin->Type() != LIB_PIN_T )
160  return;
161 
162  pin->ClearFlags();
163 
164  if( pin->IsNew() )
165  delete pin;
166  else
167  parent->RestoreComponent();
168 
169  panel->GetView()->ClearPreview();
170  panel->GetView()->ClearHiddenFlags();
171 
172  // clear edit flags
173  parent->SetDrawItem( NULL );
174  parent->SetLastDrawItem( NULL );
175 }
176 
177 
182 {
183  LIB_PIN* cur_pin = (LIB_PIN*) GetDrawItem();
184 
185  DBG(printf("PlacePin!\n");)
186 
187  // Some tests
188  if( !cur_pin || cur_pin->Type() != LIB_PIN_T )
189  {
190  wxMessageBox( wxT( "LIB_EDIT_FRAME::PlacePin() error" ) );
191  return;
192  }
193 
194  wxPoint newpos;
195  newpos = GetCrossHairPosition( true );
196 
197  LIB_PART* part = GetCurPart();
198 
199  // Test for another pin in same new position in other units:
200  bool ask_for_pin = true;
201 
202  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
203  {
204  if( pin == cur_pin || newpos != pin->GetPosition() || pin->GetFlags() )
205  continue;
206 
207  // test for same body style
208  if( pin->GetConvert() && pin->GetConvert() != cur_pin->GetConvert() )
209  continue;
210 
211  if( ask_for_pin && SynchronizePins() )
212  {
214  wxString msg;
215  msg.Printf( _( "This position is already occupied by another pin, in unit %d." ),
216  pin->GetUnit() );
217 
218  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
219  dlg.SetOKLabel( _( "Create Pin Anyway" ) );
220  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
221 
222  bool status = dlg.ShowModal() == wxID_OK;
223 
225  m_canvas->SetIgnoreMouseEvents( false );
226 
227  if( !status )
228  {
229  RebuildView();
230  return;
231  }
232  else
233  ask_for_pin = false;
234  }
235  }
236 
237  // Create Undo from GetTempCopyComponent() if exists ( i.e. after a pin move)
238  // or from m_component (pin add ...)
239  if( GetTempCopyComponent() )
241  else
242  SaveCopyInUndoList( part );
243 
244  m_canvas->SetMouseCapture( NULL, NULL );
245  cur_pin->Move( newpos );
246 
247  if( cur_pin->IsNew() )
248  {
249  LastPinOrient = cur_pin->GetOrientation();
250  LastPinType = cur_pin->GetType();
251  LastPinShape = cur_pin->GetShape();
252 
253  if( SynchronizePins() )
254  CreateImagePins( cur_pin );
255 
256  m_lastDrawItem = cur_pin;
257  part->AddDrawItem( GetDrawItem() );
258  }
259 
260  // Put linked pins in new position, and clear flags
261  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
262  {
263  if( pin->GetFlags() == 0 )
264  continue;
265 
266  pin->Move( cur_pin->GetPosition() );
267  pin->ClearFlags();
268  }
269 
270  SetDrawItem( NULL );
271 
272  RebuildView();
273  GetCanvas()->Refresh();
274  OnModify();
275 }
276 
277 
279 {
280  LIB_PIN* cur_pin = (LIB_PIN*) aItem;
281 
283 
284  LIB_PART* part = GetCurPart();
285 
286  // Clear pin flags and mark pins for moving. All pins having the same location
287  // orientation, and body style are flagged.
288  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
289  {
290  pin->ClearFlags();
291 
292  if( !SynchronizePins() )
293  continue;
294 
295  if( pin == cur_pin )
296  continue;
297 
298  if( pin->GetPosition() == cur_pin->GetPosition() &&
299  pin->GetOrientation() == cur_pin->GetOrientation() &&
300  pin->GetConvert() == cur_pin->GetConvert() )
301  {
302  pin->SetFlags( IS_LINKED | IS_MOVED );
303  }
304  }
305 
306  cur_pin->SetFlags( IS_LINKED | IS_MOVED );
307 
308  MSG_PANEL_ITEMS items;
309 
310  cur_pin->GetMsgPanelInfo( m_UserUnits, items );
311  SetMsgPanel( items );
312 
314 }
315 
316 
317 /* Move pin to the current mouse position. This function is called by the
318  * cursor management code. */
319 static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
320  bool aErase )
321 {
322  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
323 
324  if( parent == NULL )
325  return;
326 
327  LIB_PIN* cur_pin = (LIB_PIN*) parent->GetDrawItem();
328 
329  if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T )
330  return;
331 
332  auto p = aPanel->GetParent()->GetCrossHairPosition( true );
333 
334  // Redraw pin in new position
335  cur_pin->Move(p);
336 
337  auto view = parent->GetCanvas()->GetView();
338 
339  view->Hide( cur_pin );
340  view->ClearPreview();
341  view->AddToPreview( cur_pin->Clone() );
342 }
343 
344 
345 /*
346  * Create a new pin.
347  */
349 {
350  LIB_PART* part = GetCurPart();
351 
352  if( !part )
353  return;
354 
355  part->ClearStatus();
356 
357  LIB_PIN* pin = new LIB_PIN( part );
358 
359  SetDrawItem( pin );
360 
361  pin->SetFlags( IS_NEW );
362  pin->SetUnit( m_unit );
363  pin->SetConvert( m_convert );
364 
365  // Flag pins to consider
366  if( SynchronizePins() )
367  pin->SetFlags( IS_LINKED );
368 
369  pin->Move( GetCrossHairPosition( ) );
370  pin->SetLength( GetLastPinLength() );
372  pin->SetType( LastPinType );
373  pin->SetShape( LastPinShape );
377  pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
378  pin->SetVisible( LastPinVisible );
380  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
381  cmd.SetId( ID_LIBEDIT_EDIT_PIN );
382  GetEventHandler()->ProcessEvent( cmd );
384  m_canvas->SetIgnoreMouseEvents( false );
385 
386  if( pin->GetFlags() & IS_CANCELLED )
387  {
388  deleteItem( DC, pin );
389  }
390  else
391  {
394  }
395 }
396 
397 
399 {
400  int ii;
401  LIB_PIN* newPin;
402 
403  // if "synchronize pins editing" option is off, do not create any similar pin for other
404  // units and/or shapes: each unit is edited regardless other units or body
405  if( !SynchronizePins() )
406  return;
407 
408  if( aPin->GetUnit() == 0 ) // Pin common to all units: no need to create similar pins.
409  return;
410 
411  // When units are interchangeable, all units are expected to have similar pins
412  // at the same position
413  // to facilitate pin editing, create pins for all other units for the current body style
414  // at the same position as aPin
415 
416  for( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ )
417  {
418  if( ii == aPin->GetUnit() )
419  continue;
420 
421  newPin = (LIB_PIN*) aPin->Clone();
422 
423  // To avoid mistakes, gives this pin a new pin number because
424  // it does no have the save pin number as the master pin
425  // Because we do not know the actual number, give it a temporary number
426  wxString unknownNum;
427  unknownNum.Printf( "%s-U%c", aPin->GetNumber(), wxChar( 'A' + ii - 1 ) );
428  newPin->SetNumber( unknownNum );
429 
430  newPin->SetUnit( ii );
431  aPin->GetParent()->AddDrawItem( newPin );
432  }
433 }
434 
435 
436 /* aMasterPin is the "template" pin
437  * aId is a param to select what should be mofified:
438  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
439  * Change pins text name size
440  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
441  * Change pins text num size
442  * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
443  * Change pins length.
444  *
445  * If aMasterPin is selected ( .m_flag == IS_SELECTED ),
446  * only the other selected pins are modified
447  */
448 void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
449 
450 {
451  LIB_PART* part = GetCurPart();
452 
453  if( !part || !aMasterPin )
454  return;
455 
456  if( aMasterPin->Type() != LIB_PIN_T )
457  return;
458 
459  bool selected = aMasterPin->IsSelected();
460 
461  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
462  {
463  if( pin->GetConvert() && pin->GetConvert() != m_convert )
464  continue;
465 
466  // Is it the "selected mode" ?
467  if( selected && !pin->IsSelected() )
468  continue;
469 
470  switch( aId )
471  {
473  pin->SetNumberTextSize( aMasterPin->GetNumberTextSize() );
474  break;
475 
477  pin->SetNameTextSize( aMasterPin->GetNameTextSize() );
478  break;
479 
481  pin->SetLength( aMasterPin->GetLength() );
482  break;
483  }
484 
485  // Clear the flag IS_CHANGED, which was set by previous changes (if any)
486  // but not used here.
487  pin->ClearFlags( IS_CHANGED );
488  }
489 
490  // Now changes are made, call OnModify() to validate thes changes and set
491  // the global change for UI
492  RebuildView();
493  GetCanvas()->Refresh();
494  OnModify();
495 }
496 
497 
498 // Create a new pin based on the previous pin with an incremented pin number.
499 void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
500 {
501  wxString msg;
502 
503  LIB_PART* part = GetCurPart();
504 
505  if( !part || !SourcePin || SourcePin->Type() != LIB_PIN_T )
506  return;
507 
508  LIB_PIN* pin = (LIB_PIN*) SourcePin->Clone();
509 
510  pin->ClearFlags();
511  pin->SetFlags( IS_NEW );
512  wxPoint step;
513 
514  switch( pin->GetOrientation() )
515  {
516  case PIN_UP:
517  step.x = GetRepeatPinStep();
518  break;
519 
520  case PIN_DOWN:
521  step.x = GetRepeatPinStep();
522  break;
523 
524  case PIN_LEFT:
525  step.y = - GetRepeatPinStep();
526  break;
527 
528  case PIN_RIGHT:
529  step.y = - GetRepeatPinStep();
530  break;
531  }
532 
533  pin->Move( pin->GetPosition() + step );
534  wxString nextName = pin->GetName();
536  pin->SetName( nextName );
537 
538  msg = pin->GetNumber();
540  pin->SetNumber( msg );
541 
542  SetDrawItem( pin );
543 
544  if( SynchronizePins() )
545  pin->SetFlags( IS_LINKED );
546 
547  wxPoint savepos = GetCrossHairPosition();
548  m_canvas->CrossHairOff( DC );
549 
550  SetCrossHairPosition( wxPoint( pin->GetPosition().x, -pin->GetPosition().y ) );
551 
552  // Add this new pin in list, and creates pins for others parts if needed
553  SetDrawItem( pin );
555  PlacePin();
556  m_lastDrawItem = pin;
557 
558  SetCrossHairPosition( savepos );
559  m_canvas->CrossHairOn( DC );
560 
561  MSG_PANEL_ITEMS items;
562  pin->GetMsgPanelInfo( m_UserUnits, items );
563  SetMsgPanel( items );
564 
565  RebuildView();
566  GetCanvas()->Refresh();
567  OnModify();
568 }
569 
570 
571 // helper function to sort pins by pin num
572 bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
573 {
574  int test = ref->GetNumber().Cmp( tst->GetNumber() );
575 
576  if( test == 0 )
577  {
578  test = ref->GetConvert() - tst->GetConvert();
579  }
580 
581  if( test == 0 )
582  {
583  test = ref->GetUnit() - tst->GetUnit();
584  }
585 
586  return test < 0;
587 }
588 
589 
590 void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
591 {
592  LIB_PART* part = GetCurPart();
593 
594  if( !part )
595  return;
596 
597  const int MIN_GRID_SIZE = 25;
598 
599  LIB_PINS pinList;
600 
601  part->GetPins( pinList );
602 
603  if( pinList.size() == 0 )
604  {
605  DisplayInfoMessage( this, _( "No pins!" ) );
606  return;
607  }
608 
609  // Sort pins by pin num, so 2 duplicate pins
610  // (pins with the same number) will be consecutive in list
611  sort( pinList.begin(), pinList.end(), sort_by_pin_number );
612 
613  // Test for duplicates:
614  DIALOG_DISPLAY_HTML_TEXT_BASE error_display( this, wxID_ANY,
615  _( "Marker Information" ),
616  wxDefaultPosition,
617  wxSize( 750, 600 ) );
618 
619  int dup_error = 0;
620 
621  for( unsigned ii = 1; ii < pinList.size(); ii++ )
622  {
623  LIB_PIN* curr_pin = pinList[ii];
624  LIB_PIN* pin = pinList[ii - 1];
625 
626  if( pin->GetNumber() != curr_pin->GetNumber()
627  || pin->GetConvert() != curr_pin->GetConvert() )
628  continue;
629 
630  dup_error++;
631 
632  /* TODO I dare someone to find a way to make happy translators on
633  this thing! Lorenzo */
634 
635  wxString msg = wxString::Format( _(
636  "<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>"
637  " conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
638  GetChars( curr_pin->GetNumber() ),
639  GetChars( curr_pin->GetName() ),
640  curr_pin->GetPosition().x / 1000.0,
641  -curr_pin->GetPosition().y / 1000.0,
642  GetChars( pin->GetNumber() ),
643  GetChars( pin->GetName() ),
644  pin->GetPosition().x / 1000.0,
645  -pin->GetPosition().y / 1000.0
646  );
647 
648  if( part->GetUnitCount() > 1 )
649  {
650  msg += wxString::Format( _( " in units %c and %c" ),
651  'A' + curr_pin->GetUnit() - 1,
652  'A' + pin->GetUnit() - 1 );
653  }
654 
655  if( m_showDeMorgan )
656  {
657  if( curr_pin->GetConvert() )
658  msg += _( " of converted" );
659  else
660  msg += _( " of normal" );
661  }
662 
663  msg += wxT( ".<br>" );
664 
665  error_display.m_htmlWindow->AppendToPage( msg );
666  }
667 
668  // Test for off grid pins:
669  int offgrid_error = 0;
670 
671  for( unsigned ii = 0; ii < pinList.size(); ii++ )
672  {
673  LIB_PIN* pin = pinList[ii];
674 
675  if( ( (pin->GetPosition().x % MIN_GRID_SIZE) == 0 ) &&
676  ( (pin->GetPosition().y % MIN_GRID_SIZE) == 0 ) )
677  continue;
678 
679  // "pin" is off grid here.
680  offgrid_error++;
681 
682  wxString msg = wxString::Format( _(
683  "<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
684  GetChars( pin->GetNumber() ),
685  GetChars( pin->GetName() ),
686  pin->GetPosition().x / 1000.0,
687  -pin->GetPosition().y / 1000.0
688  );
689 
690  if( part->GetUnitCount() > 1 )
691  {
692  msg += wxString::Format( _( " in symbol %c" ), 'A' + pin->GetUnit() - 1 );
693  }
694 
695  if( m_showDeMorgan )
696  {
697  if( pin->GetConvert() )
698  msg += _( " of converted" );
699  else
700  msg += _( " of normal" );
701  }
702 
703  msg += wxT( ".<br>" );
704 
705  error_display.m_htmlWindow->AppendToPage( msg );
706  }
707 
708  if( !dup_error && !offgrid_error )
709  DisplayInfoMessage( this, _( "No off grid or duplicate pins were found." ) );
710  else
711  error_display.ShowModal();
712 }
static void AbortPinMove(EDA_DRAW_PANEL *Panel, wxDC *DC)
Clean up after aborting a move pin command.
Definition: pinedit.cpp:148
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:111
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1488
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
void OnCheckComponent(wxCommandEvent &event)
Definition: pinedit.cpp:590
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
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:1553
void DoNotShowCheckbox(wxString file, int line)
Shows the &#39;do not show again&#39; checkbox
Definition: confirm.cpp:60
static int LastPinNameSize
Definition: pinedit.cpp:67
int GetRepeatPinStep() const
static int m_convert
static bool LastPinCommonUnit
Definition: pinedit.cpp:62
void RestoreComponent()
Restore the current edited component from its temporary copy.
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:44
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:219
void ClearTempCopyComponent()
Delete temporary copy of the current component and clear pointer.
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 OnEditPin(wxCommandEvent &event)
Definition: pinedit.cpp:94
static bool LastPinCommonConvert
Definition: pinedit.cpp:61
bool IsModified() const
Definition: base_struct.h:220
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 GlobalSetPins(LIB_PIN *aMasterPin, int aId)
Definition: pinedit.cpp:448
bool IsSelected() const
Definition: base_struct.h:224
Implementing DIALOG_LIB_EDIT_PIN_BASE.
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen...
static int LastPinLength
Definition: pinedit.cpp:66
int GetRepeatDeltaLabel() const
Definition: lib_pin.h:55
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void EnableEditMode(bool aEnable, bool aEditPinByPin=false)
Enable or clear pin editing mode.
Definition: lib_pin.cpp:514
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
int GetNameTextSize() const
Definition: lib_pin.h:192
int GetOrientation() const
Definition: lib_pin.h:221
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:286
int GetNumberTextSize() const
Definition: lib_pin.h:219
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
const wxString & GetNumber() const
Definition: lib_pin.h:194
void RepeatPinItem(wxDC *DC, LIB_PIN *Pin)
Definition: pinedit.cpp:499
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:166
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void SetNumber(const wxString &aNumber)
Set the pin number.
Definition: lib_pin.cpp:222
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
virtual EDA_DRAW_FRAME * GetParent() const =0
static int GetPinNumDefaultSize()
GRAPHIC_PINSHAPE
Definition: pin_shape.h:35
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:110
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:256
void SetDrawItem(LIB_ITEM *drawItem)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CrossHairOn(wxDC *DC=nullptr)
Class LIB_ITEM definition.
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
SCH_DRAW_PANEL * GetCanvas() const override
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:251
#define MIN_GRID_SIZE
void TempCopyComponent()
Create a temporary copy of the current edited component.
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:147
void CreateImagePins(LIB_PIN *aPin)
Adds copies of aPin in components with multiple units in all units.
Definition: pinedit.cpp:398
virtual void CrossHairOff(wxDC *DC=nullptr)
static ELECTRICAL_PINTYPE LastPinType
Definition: pinedit.cpp:58
void SetLastDrawItem(LIB_ITEM *drawItem)
static int GetLastPinNumSize()
Definition: pinedit.cpp:86
static LIB_ITEM * m_lastDrawItem
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
static int LastPinOrient
Definition: pinedit.cpp:59
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:362
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
KIGFX::SCH_VIEW * GetView() const
void CreatePin(wxDC *DC)
Definition: pinedit.cpp:348
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:463
int GetUnitCount() const
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:181
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void SetUnit(int aUnit)
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:61
void ClearStatus()
Clears the status flag all draw objects in this part.
The symbol library editor main window.
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
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
#define IS_CANCELLED
flag set when edit dialogs are canceled when editing a
Definition: base_struct.h:127
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
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_pin.cpp:1597
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
int ShowModal() override
Definition: confirm.cpp:102
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
bool SynchronizePins()
Pin editing (add, delete, move...) can be synchronized between units when units are interchangeable b...
Definition of class LIB_EDIT_FRAME.
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:319
#define DBG(x)
Definition: fctsys.h:33
static bool m_showDeMorgan
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
static wxPoint OldPos
Definition: pinedit.cpp:57
void SetNameTextSize(int aSize, bool aTestOtherPins=true)
Set the aSize of the pin name text.
Definition: lib_pin.cpp:194
Message panel definition file.
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:120
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:277
int GetLength()
Definition: lib_pin.h:301
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:235
bool sort_by_pin_number(const LIB_PIN *ref, const LIB_PIN *tst)
Definition: pinedit.cpp:572
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:278
int GetConvert() const
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113