Browse Source

Increment references when creating an array.

While it's not always correct, not doing so is pretty much always
incorrect.

Fixes: lp:1625964
* https://bugs.launchpad.net/kicad/+bug/1625964
pull/13/head
Jeff Young 7 years ago
parent
commit
e55bb9e748
  1. 6
      pcbnew/array_creator.cpp
  2. 8
      pcbnew/class_module.cpp
  3. 8
      pcbnew/class_module.h

6
pcbnew/array_creator.cpp

@ -79,9 +79,13 @@ void ARRAY_CREATOR::Invoke()
}
else
{
// PCB items keep the same numbering
new_item = getBoard()->Duplicate( item );
// Incrementing the reference number won't always be correct, but leaving
// it the same is always incorrect.
if( new_item->Type() == PCB_MODULE_T )
static_cast<MODULE*>( new_item )->IncrementReference( ptN );
// @TODO: we should merge zones. This is a bit tricky, because
// the undo command needs saving old area, if it is merged.
}

8
pcbnew/class_module.cpp

@ -1346,6 +1346,14 @@ wxString MODULE::GetReferencePrefix() const
}
void MODULE::IncrementReference( int aDelta )
{
SetReference( wxString::Format( wxT( "%s%i" ),
GetReferencePrefix(),
getTrailingInt( GetReference() ) + aDelta ) );
}
// Calculate the area of aPolySet, after fracturation, because
// polygons with no hole are expected.
static double polygonArea( SHAPE_POLY_SET& aPolySet )

8
pcbnew/class_module.h

@ -473,7 +473,7 @@ public:
}
/**
* Function GetReference prefix
* Function GetReferencePrefix
* Gets the alphabetic prefix of the module reference - e.g.
* R1 -> R
* IC34 -> IC
@ -481,6 +481,12 @@ public:
*/
wxString GetReferencePrefix() const;
/**
* Function IncrementReference
* Bumps the current reference by aDelta.
*/
void IncrementReference( int aDelta );
/**
* Function GetValue
* @return const wxString& - the value text.

Loading…
Cancel
Save