← Back to team overview

kicad-developers team mailing list archive

Inserting new pins based on pin orientation in eeschema

 

I just updated the eeschema code to insert new pins based on orientation.
I have a few questions and wasn't able to find the answers in the code:

1. Where is the global variable g_RepeatStep set?  It is used to determine
horizontal and vertical step distances?

2. Am I using this global as it is intended?  It seems like the insert
function was half-implemented.  It currently applies a -100 mil offset when
you press the INSERT key.  There is no implementation in the X direction.

3.  If this is the correct usage, how would I set the default
g_RepeatStep.x value to 100 mils as well?

4.  Why is g_RepeatStep not initialized when running eeschema from the
command line?

Thanks.

-Ed

For context, I have added my patch below.

=== modified file 'eeschema/pinedit.cpp'
--- eeschema/pinedit.cpp    2015-03-03 10:50:50 +0000
+++ eeschema/pinedit.cpp    2015-04-21 20:15:06 +0000
@@ -572,7 +572,26 @@

     pin->ClearFlags();
     pin->SetFlags( IS_NEW );
-    pin->Move( pin->GetPosition() + wxPoint( g_RepeatStep.x,
-g_RepeatStep.y ) );
+
+    switch( pin->GetOrientation() )
+    {
+    case PIN_UP:
+        pin->Move( pin->GetPosition() + wxPoint( g_RepeatStep.x, 0 ) );
+        break;
+
+    case PIN_DOWN:
+        pin->Move( pin->GetPosition() + wxPoint( -g_RepeatStep.x, 0 ) );
+        break;
+
+    case PIN_LEFT:
+        pin->Move( pin->GetPosition() + wxPoint( 0, g_RepeatStep.y ) );
+        break;
+
+    case PIN_RIGHT:
+        pin->Move( pin->GetPosition() + wxPoint( 0, -g_RepeatStep.y ) );
+        break;
+    }
+
     wxString nextName = pin->GetName();
     IncrementLabelMember( nextName );
     pin->SetName( nextName );

Follow ups