Dual-purpose IsMovableFromAnchorPoint to keep from moving symbols off-grid.
Fixes https://gitlab.com/kicad/code/kicad/issues/11360
This commit is contained in:
parent
ac8e2d0768
commit
8358685920
|
@ -251,6 +251,27 @@ void SCH_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SYMBOL::IsMovableFromAnchorPoint() const
|
||||
{
|
||||
// If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
|
||||
// going to end up moving the symbol's pins off-grid.
|
||||
|
||||
// The minimal grid size allowed to place a pin is 25 mils
|
||||
const int min_grid_size = Mils2iu( 25 );
|
||||
|
||||
for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
|
||||
{
|
||||
if( ( ( pin->GetPosition().x - m_pos.x ) % min_grid_size ) != 0 )
|
||||
return false;
|
||||
|
||||
if( ( ( pin->GetPosition().y - m_pos.y ) % min_grid_size ) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::SetLibId( const LIB_ID& aLibId )
|
||||
{
|
||||
if( m_lib_id != aLibId )
|
||||
|
|
|
@ -147,9 +147,10 @@ public:
|
|||
* they are big. However, this annoyed some users and we now have a preference which
|
||||
* controls warping on move in general, so this was switched to true for symbols.
|
||||
*
|
||||
* @return true for a symbol.
|
||||
* @note We now use this to keep poorly-formed symbols from getting dragged off-grid. If
|
||||
* the symbol contains off-grid pins we will not allow it to be moved from its anchor.
|
||||
*/
|
||||
bool IsMovableFromAnchorPoint() const override { return true; }
|
||||
bool IsMovableFromAnchorPoint() const override;
|
||||
|
||||
void SetLibId( const LIB_ID& aName );
|
||||
|
||||
|
|
Loading…
Reference in New Issue