kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #18009
Re: Inserting new pins based on pin orientation in eeschema
JP and Simon, thanks for your feedback. It was late when I sent the email
and I didn't trust myself to refactor. I just updated the calculation. :)
JP,
Good point about making sure the update is consistent with the library
standards. If the user is using the default grid and default text heights,
the spacing will be in accordance with the library maintainer's standards.
Having been burned in the past with different tools' component libraries, I
often roll my own. It's less efficient, but that's my workflow. I'm sure
this will change moving forward, but there are probably other users with
the same attitude. If the consensus is force 100 mil spacing for all pins,
that's fine and it simplifies the code, but as a user, I prefer versatility
even when not needed. I'm not married to either solution. I just want the
feature to work without having to do block copies to handle orientation.
Simon,
Since the design freeze is in effect, I was hoping to sneak this change in
under the wire, making sure it was decoupled from other changes and
minimizing impact. After the freeze, I was thinking of addressing the
direction. Maybe using SHIFT-INSERT to reverse the direction. That SHIFT
usage would be consistent with most development tools. As far as the
message box idea, I agree in principle. However, it would need some form
of "Don't show me again" to be implemented. This would need to persist at
least through the session, which could be implemented as a static. Best
case would be in some permanent storage. Do you know where I would look
for persistent settings?
Thanks.
-Ed
On Wed, Apr 22, 2015 at 2:59 AM, jp charras <jp.charras@xxxxxxxxxx> wrote:
> Le 22/04/2015 08:42, Simon Richter a écrit :
> > Hi,
> >
> > On 22.04.2015 08:25, jp charras wrote:
> >
> >>
> https://github.com/KiCad/kicad-library/blob/master/KiCad_Library_Convent
> >>
> >>
> ion.txt
> >
> >> Automatic insertion of pins have to comply with that.
> >
> > Good point. Would it make sense to leave this to the user still,
> > but somehow warn them (e.g. in the config dialog, if you enter
> > anything but 100 mils)?
> >
> > I think there might be users who want to use their own in-house
> > standard.
> >
> > Simon
>
> The issue is due to the fact repeat parameters are common to the
> schematic editor and the library editor.
>
> I am currently working on it to have separate parameters, because you
> can run only the lib editor, and it has its own constraints.
>
>
> --
> Jean-Pierre CHARRAS
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
=== modified file 'eeschema/pinedit.cpp'
--- eeschema/pinedit.cpp 2015-03-03 10:50:50 +0000
+++ eeschema/pinedit.cpp 2015-04-22 11:27:53 +0000
@@ -558,6 +558,47 @@
}
+/**
+ * Returns the offset for a new pin based on the text size and current
+ * grid size.
+ * @param aPin is a pin instance to be moved.
+ * @return the x-offset to be applied.
+ */
+wxPoint CalculatePinOffset(LIB_PIN* aPin, int aXGridSize, int aYGridSize)
+{
+ int maxTextHeight = ( aPin->GetNumberTextSize() > aPin->GetNameTextSize() )
+ ? aPin->GetNumberTextSize() : aPin->GetNameTextSize();
+
+ // The following integer math calculates the minimum spacing on the
+ // grid that will fit the pin name and number text.
+ int xOffset = aXGridSize * ( 1 + ( maxTextHeight / aXGridSize ) );
+ int yOffset = aYGridSize * ( 1 + ( maxTextHeight / aYGridSize ) );
+
+ switch( aPin->GetOrientation() )
+ {
+ case PIN_UP:
+ yOffset = 0;
+ break;
+
+ case PIN_DOWN:
+ xOffset = -xOffset;
+ yOffset = 0;
+ break;
+
+ case PIN_LEFT:
+ xOffset = 0;
+ break;
+
+ case PIN_RIGHT:
+ xOffset = 0;
+ yOffset = -yOffset;
+ break;
+ }
+
+ return wxPoint( xOffset, yOffset );
+}
+
+
// Create a new pin based on the previous pin with an incremented pin number.
void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
{
@@ -572,7 +613,11 @@
pin->ClearFlags();
pin->SetFlags( IS_NEW );
- pin->Move( pin->GetPosition() + wxPoint( g_RepeatStep.x, -g_RepeatStep.y ) );
+
+ wxPoint pinOffset = CalculatePinOffset( pin, GetScreen()->GetGrid().m_Size.x,
+ GetScreen()->GetGrid().m_Size.y );
+
+ pin->Move( pin->GetPosition() + pinOffset );
wxString nextName = pin->GetName();
IncrementLabelMember( nextName );
pin->SetName( nextName );
Follow ups
References