From 28f1209ce972100a6559577ee13fa723f4cc80f5 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Sat, 17 Feb 2018 11:36:41 +0100 Subject: [PATCH] Fixed invalid dynamic_cast in Align Tool Fixes: lp:1750107 * https://bugs.launchpad.net/kicad/+bug/1750107 --- pcbnew/tools/placement_tool.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index c01c7a2378..7dc9e6c44c 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -128,31 +128,37 @@ bool SortLeftmostX( const std::pair left, const std::pair return ( left.second.GetX() < right.second.GetX() ); } + bool SortRightmostX( const std::pair left, const std::pair right) { return ( left.second.GetRight() > right.second.GetRight() ); } + bool SortTopmostY( const std::pair left, const std::pair right) { return ( left.second.GetY() < right.second.GetY() ); } + bool SortCenterX( const std::pair left, const std::pair right) { return ( left.second.GetCenter().x < right.second.GetCenter().x ); } + bool SortCenterY( const std::pair left, const std::pair right) { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } + bool SortBottommostY( const std::pair left, const std::pair right) { return ( left.second.GetBottom() > right.second.GetBottom() ); } + ALIGNMENT_RECTS GetBoundingBoxes( const SELECTION &sel ) { const SELECTION& selection = sel; @@ -161,13 +167,15 @@ ALIGNMENT_RECTS GetBoundingBoxes( const SELECTION &sel ) for( auto item : selection ) { + BOARD_ITEM* boardItem = static_cast( item ); + if( item->Type() == PCB_MODULE_T ) { - rects.emplace_back( std::make_pair( dynamic_cast( item ), dynamic_cast( item )->GetFootprintRect() ) ); + rects.emplace_back( std::make_pair( boardItem, static_cast( item )->GetFootprintRect() ) ); } else { - rects.emplace_back( std::make_pair( dynamic_cast( item ), dynamic_cast( item )->GetBoundingBox() ) ); + rects.emplace_back( std::make_pair( boardItem, item->GetBoundingBox() ) ); } } return rects;