KiCad PCB EDA Suite
pinedit.cpp File Reference

Eeschema pin edit code. More...

#include <fctsys.h>
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <base_units.h>
#include <msgpanel.h>
#include <lib_edit_frame.h>
#include <eeschema_id.h>
#include <class_libentry.h>
#include <lib_pin.h>
#include <general.h>
#include <../common/dialogs/dialog_display_info_HTML_base.h>
#include <dialog_lib_edit_pin.h>
#include <sch_view.h>

Go to the source code of this file.

Functions

void IncrementLabelMember (wxString &name, int aIncrement)
 
static void AbortPinMove (EDA_DRAW_PANEL *aPanel, wxDC *DC)
 Clean up after aborting a move pin command. More...
 
static void DrawMovePin (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPositon, bool aErase)
 
static int GetLastPinLength ()
 
static int GetLastPinNameSize ()
 
static int GetLastPinNumSize ()
 
bool sort_by_pin_number (const LIB_PIN *ref, const LIB_PIN *tst)
 

Variables

static wxPoint OldPos
 
static ELECTRICAL_PINTYPE LastPinType = PIN_INPUT
 
static int LastPinOrient = PIN_RIGHT
 
static GRAPHIC_PINSHAPE LastPinShape = PINSHAPE_LINE
 
static bool LastPinCommonConvert = false
 
static bool LastPinCommonUnit = false
 
static bool LastPinVisible = true
 
static int LastPinLength = -1
 
static int LastPinNameSize = -1
 
static int LastPinNumSize = -1
 

Detailed Description

Eeschema pin edit code.

Definition in file pinedit.cpp.

Function Documentation

static void AbortPinMove ( EDA_DRAW_PANEL Panel,
wxDC *  DC 
)
static

Clean up after aborting a move pin command.

Definition at line 148 of file pinedit.cpp.

References EDA_ITEM::ClearFlags(), LIB_EDIT_FRAME::GetDrawItem(), EDA_DRAW_PANEL::GetParent(), EDA_ITEM::IsNew(), LIB_PIN_T, LIB_EDIT_FRAME::RestoreComponent(), LIB_EDIT_FRAME::SetDrawItem(), LIB_EDIT_FRAME::SetLastDrawItem(), and EDA_ITEM::Type().

Referenced by LIB_EDIT_FRAME::CreatePin(), and LIB_EDIT_FRAME::StartMovePin().

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 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
void RestoreComponent()
Restore the current edited component from its temporary copy.
bool IsNew() const
Definition: base_struct.h:219
void SetDrawItem(LIB_ITEM *drawItem)
void SetLastDrawItem(LIB_ITEM *drawItem)
The symbol library editor main window.
LIB_ITEM * GetDrawItem() const
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
static void DrawMovePin ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPositon,
bool  aErase 
)
static

Definition at line 319 of file pinedit.cpp.

References LIB_PIN::Clone(), SCH_BASE_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetDrawItem(), EDA_DRAW_PANEL::GetParent(), SCH_DRAW_PANEL::GetView(), KIGFX::VIEW::Hide(), LIB_PIN_T, LIB_PIN::Move(), and EDA_ITEM::Type().

Referenced by LIB_EDIT_FRAME::CreatePin(), and LIB_EDIT_FRAME::StartMovePin().

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 }
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
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
virtual EDA_DRAW_FRAME * GetParent() const =0
SCH_DRAW_PANEL * GetCanvas() const override
KIGFX::SCH_VIEW * GetView() const
The symbol library editor main window.
LIB_ITEM * GetDrawItem() const
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_pin.cpp:1597
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
static int GetLastPinLength ( )
static

Definition at line 70 of file pinedit.cpp.

References LIB_EDIT_FRAME::GetDefaultPinLength(), and LastPinLength.

Referenced by LIB_EDIT_FRAME::CreatePin().

71 {
72  if( LastPinLength == -1 )
74 
75  return LastPinLength;
76 }
static int GetDefaultPinLength()
static int LastPinLength
Definition: pinedit.cpp:66
static int GetLastPinNameSize ( )
static

Definition at line 78 of file pinedit.cpp.

References LIB_EDIT_FRAME::GetPinNameDefaultSize(), and LastPinNameSize.

Referenced by LIB_EDIT_FRAME::CreatePin().

79 {
80  if( LastPinNameSize == -1 )
82 
83  return LastPinNameSize;
84 }
static int LastPinNameSize
Definition: pinedit.cpp:67
static int GetPinNameDefaultSize()
static int GetLastPinNumSize ( )
static

Definition at line 86 of file pinedit.cpp.

References LIB_EDIT_FRAME::GetPinNumDefaultSize(), and LastPinNumSize.

Referenced by LIB_EDIT_FRAME::CreatePin().

87 {
88  if( LastPinNumSize == -1 )
90 
91  return LastPinNumSize;
92 }
static int LastPinNumSize
Definition: pinedit.cpp:68
static int GetPinNumDefaultSize()
void IncrementLabelMember ( wxString &  name,
int  aIncrement 
)

Definition at line 286 of file edit_label.cpp.

Referenced by LIB_EDIT_FRAME::RepeatPinItem().

287 {
288  int ii, nn;
289  long number = 0;
290 
291  ii = name.Len() - 1; nn = 0;
292 
293  if( !isdigit( name.GetChar( ii ) ) )
294  return;
295 
296  while( (ii >= 0) && isdigit( name.GetChar( ii ) ) )
297  {
298  ii--; nn++;
299  }
300 
301  ii++; /* digits are starting at ii position */
302  wxString litt_number = name.Right( nn );
303 
304  if( litt_number.ToLong( &number ) )
305  {
306  number += aIncrement;
307  name.Remove( ii ); name << number;
308  }
309 }
const char * name
Definition: DXF_plotter.cpp:61
bool sort_by_pin_number ( const LIB_PIN ref,
const LIB_PIN tst 
)

Definition at line 572 of file pinedit.cpp.

References LIB_ITEM::GetConvert(), LIB_PIN::GetNumber(), and LIB_ITEM::GetUnit().

Referenced by LIB_EDIT_FRAME::OnCheckComponent().

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 }
int GetUnit() const
const wxString & GetNumber() const
Definition: lib_pin.h:194
int GetConvert() const

Variable Documentation

bool LastPinCommonConvert = false
static

Definition at line 61 of file pinedit.cpp.

Referenced by LIB_EDIT_FRAME::CreatePin(), and LIB_EDIT_FRAME::OnEditPin().

bool LastPinCommonUnit = false
static

Definition at line 62 of file pinedit.cpp.

Referenced by LIB_EDIT_FRAME::CreatePin(), and LIB_EDIT_FRAME::OnEditPin().

int LastPinLength = -1
static

Definition at line 66 of file pinedit.cpp.

Referenced by GetLastPinLength(), and LIB_EDIT_FRAME::OnEditPin().

int LastPinNameSize = -1
static

Definition at line 67 of file pinedit.cpp.

Referenced by GetLastPinNameSize(), and LIB_EDIT_FRAME::OnEditPin().

int LastPinNumSize = -1
static

Definition at line 68 of file pinedit.cpp.

Referenced by GetLastPinNumSize(), and LIB_EDIT_FRAME::OnEditPin().

int LastPinOrient = PIN_RIGHT
static
bool LastPinVisible = true
static

Definition at line 63 of file pinedit.cpp.

Referenced by LIB_EDIT_FRAME::CreatePin(), and LIB_EDIT_FRAME::OnEditPin().

wxPoint OldPos
static

Definition at line 57 of file pinedit.cpp.