Do not include text when computing drag origin for a group
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9630
This commit is contained in:
parent
66d9e7073f
commit
ae24daa033
|
@ -139,3 +139,24 @@ bool SELECTION::AreAllItemsIdentical() const
|
|||
return r->Type() == m_items.front()->Type();
|
||||
} ) );
|
||||
}
|
||||
|
||||
|
||||
bool SELECTION::OnlyContains( std::vector<KICAD_T> aList ) const
|
||||
{
|
||||
return ( std::all_of( m_items.begin(), m_items.end(),
|
||||
[&]( const EDA_ITEM* r )
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
for( const KICAD_T& type : aList )
|
||||
{
|
||||
if( r->Type() == type )
|
||||
{
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
} ) );
|
||||
}
|
||||
|
|
|
@ -60,13 +60,19 @@ EE_GRID_HELPER::EE_GRID_HELPER( TOOL_MANAGER* aToolMgr ) :
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I EE_GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, int aLayer,
|
||||
VECTOR2I EE_GRID_HELPER::BestDragOrigin( const VECTOR2I& aMousePos, int aLayer,
|
||||
const EE_SELECTION& aItems )
|
||||
{
|
||||
clearAnchors();
|
||||
|
||||
// Text anchors are often off the connectivity grid. For now, this means
|
||||
// we can only consider anchors from text objects if they are the only thing
|
||||
// selected.
|
||||
bool includeText = ( aItems.Size() == 1
|
||||
|| aItems.OnlyContains( { SCH_TEXT_T, SCH_FIELD_T } ) );
|
||||
|
||||
for( EDA_ITEM* item : aItems )
|
||||
computeAnchors( static_cast<SCH_ITEM*>( item ), aMousePos, true );
|
||||
computeAnchors( static_cast<SCH_ITEM*>( item ), aMousePos, true, includeText );
|
||||
|
||||
double worldScale = m_toolMgr->GetView()->GetGAL()->GetWorldScale();
|
||||
double lineSnapMinCornerDistance = 50.0 / worldScale;
|
||||
|
@ -262,14 +268,19 @@ std::set<SCH_ITEM*> EE_GRID_HELPER::queryVisible( const BOX2I& aArea,
|
|||
}
|
||||
|
||||
|
||||
void EE_GRID_HELPER::computeAnchors( SCH_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom )
|
||||
void EE_GRID_HELPER::computeAnchors( SCH_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom,
|
||||
bool aIncludeText )
|
||||
{
|
||||
switch( aItem->Type() )
|
||||
{
|
||||
case SCH_TEXT_T:
|
||||
case SCH_FIELD_T:
|
||||
{
|
||||
if( aIncludeText )
|
||||
addAnchor( aItem->GetPosition(), ORIGIN, aItem );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_SYMBOL_T:
|
||||
case SCH_SHEET_T:
|
||||
|
|
|
@ -74,8 +74,10 @@ private:
|
|||
* @param aItem The schematic item for which to compute the anchors
|
||||
* @param aRefPos The point for which to compute the anchors (if used by the symbol)
|
||||
* @param aFrom Is this for an anchor that is designating a source point (aFrom=true) or not
|
||||
* @param aIncludeText if true will compute anchors for text items
|
||||
*/
|
||||
void computeAnchors( SCH_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom = false );
|
||||
void computeAnchors( SCH_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom = false,
|
||||
bool aIncludeText = false );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -201,6 +201,12 @@ public:
|
|||
*/
|
||||
bool AreAllItemsIdentical() const;
|
||||
|
||||
/**
|
||||
* Checks if all items in the selection have a type in aList
|
||||
* @return False if any item in the selection has a type not included in aList
|
||||
*/
|
||||
bool OnlyContains( std::vector<KICAD_T> aList ) const;
|
||||
|
||||
protected:
|
||||
OPT<VECTOR2I> m_referencePoint;
|
||||
std::deque<EDA_ITEM*> m_items;
|
||||
|
|
Loading…
Reference in New Issue