mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Don't overflow int rebuilding selection rect (KICAD-E4J).
This commit is contained in:
parent
718b7e744a
commit
4137b9d31c
@ -2107,14 +2107,11 @@ bool SCH_SELECTION_TOOL::selectMultiple()
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
int width = area.GetEnd().x - area.GetOrigin().x;
|
||||
int height = area.GetEnd().y - area.GetOrigin().y;
|
||||
|
||||
/* Selection mode depends on direction of drag-selection:
|
||||
* Left > Right : Select objects that are fully enclosed by selection
|
||||
* Right > Left : Select objects that are crossed by selection
|
||||
*/
|
||||
bool isGreedy = width < 0;
|
||||
bool isGreedy = area.GetEnd().x < area.GetOrigin().x;
|
||||
|
||||
if( view->IsMirroredX() )
|
||||
isGreedy = !isGreedy;
|
||||
@ -2154,8 +2151,8 @@ bool SCH_SELECTION_TOOL::selectMultiple()
|
||||
|
||||
// Fetch items from the RTree that are in our area of interest
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
|
||||
BOX2I selectionBox = area.ViewBBox();
|
||||
view->Query( selectionBox, candidates );
|
||||
BOX2I selectionRect = area.ViewBBox();
|
||||
view->Query( selectionRect, candidates );
|
||||
|
||||
// Ensure candidates only have unique items
|
||||
std::set<SCH_ITEM*> uniqueCandidates;
|
||||
@ -2175,7 +2172,7 @@ bool SCH_SELECTION_TOOL::selectMultiple()
|
||||
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
|
||||
{
|
||||
// If the pin is within the selection box, add it as a candidate
|
||||
if( selectionBox.Intersects( pin->GetBoundingBox() ) )
|
||||
if( selectionRect.Intersects( pin->GetBoundingBox() ) )
|
||||
uniqueCandidates.insert( pin );
|
||||
}
|
||||
}
|
||||
@ -2184,15 +2181,12 @@ bool SCH_SELECTION_TOOL::selectMultiple()
|
||||
for( SCH_PIN* pin : symbol->GetPins() )
|
||||
{
|
||||
// If the pin is within the selection box, add it as a candidate
|
||||
if( selectionBox.Intersects( pin->GetBoundingBox() ) )
|
||||
if( selectionRect.Intersects( pin->GetBoundingBox() ) )
|
||||
uniqueCandidates.insert( pin );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Construct a BOX2I to determine SCH_ITEM selection
|
||||
BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
|
||||
|
||||
// Build lists of nearby items and their children
|
||||
SCH_COLLECTOR collector;
|
||||
SCH_COLLECTOR pinsCollector;
|
||||
|
@ -352,13 +352,11 @@ bool PL_SELECTION_TOOL::selectMultiple()
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
int width = area.GetEnd().x - area.GetOrigin().x;
|
||||
|
||||
/* Selection mode depends on direction of drag-selection:
|
||||
* Left > Right : Select objects that are fully enclosed by selection
|
||||
* Right > Left : Select objects that are crossed by selection
|
||||
*/
|
||||
bool windowSelection = width >= 0 ? true : false;
|
||||
bool windowSelection = area.GetEnd().x > area.GetOrigin().x;
|
||||
|
||||
m_frame->GetCanvas()->SetCurrentCursor( windowSelection ? KICURSOR::SELECT_WINDOW
|
||||
: KICURSOR::SELECT_LASSO );
|
||||
@ -393,13 +391,11 @@ bool PL_SELECTION_TOOL::selectMultiple()
|
||||
// End drawing the selection box
|
||||
view->SetVisible( &area, false );
|
||||
|
||||
int height = area.GetEnd().y - area.GetOrigin().y;
|
||||
|
||||
bool anyAdded = false;
|
||||
bool anySubtracted = false;
|
||||
|
||||
// Construct a BOX2I to determine EDA_ITEM selection
|
||||
BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
|
||||
BOX2I selectionRect( area.ViewBBox() );
|
||||
|
||||
selectionRect.Normalize();
|
||||
|
||||
|
@ -1066,13 +1066,11 @@ bool PCB_SELECTION_TOOL::selectMultiple()
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
int width = area.GetEnd().x - area.GetOrigin().x;
|
||||
|
||||
/* Selection mode depends on direction of drag-selection:
|
||||
* Left > Right : Select objects that are fully enclosed by selection
|
||||
* Right > Left : Select objects that are crossed by selection
|
||||
*/
|
||||
bool greedySelection = width >= 0 ? false : true;
|
||||
bool greedySelection = area.GetEnd().x < area.GetOrigin().x;
|
||||
|
||||
if( view->IsMirroredX() )
|
||||
greedySelection = !greedySelection;
|
||||
@ -1117,13 +1115,8 @@ bool PCB_SELECTION_TOOL::selectMultiple()
|
||||
view->SetVisible( &area, false );
|
||||
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
|
||||
BOX2I selectionBox = area.ViewBBox();
|
||||
view->Query( selectionBox, candidates ); // Get the list of nearby items
|
||||
|
||||
int height = area.GetEnd().y - area.GetOrigin().y;
|
||||
|
||||
// Construct a BOX2I to determine BOARD_ITEM selection
|
||||
BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
|
||||
BOX2I selectionRect = area.ViewBBox();
|
||||
view->Query( selectionRect, candidates ); // Get the list of nearby items
|
||||
|
||||
selectionRect.Normalize();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user