Minor code cleaning.
This commit is contained in:
parent
9989145fb1
commit
35bc2efb61
|
@ -385,7 +385,7 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
|
||||||
#endif
|
#endif
|
||||||
if( aEvent.IsAction( &ACT_RouterOptions ) )
|
if( aEvent.IsAction( &ACT_RouterOptions ) )
|
||||||
{
|
{
|
||||||
DIALOG_PNS_SETTINGS settingsDlg( m_toolMgr->GetEditFrame(), m_router->Settings() );
|
DIALOG_PNS_SETTINGS settingsDlg( getEditFrame<PCB_EDIT_FRAME>(), m_router->Settings() );
|
||||||
|
|
||||||
if( settingsDlg.ShowModal() )
|
if( settingsDlg.ShowModal() )
|
||||||
m_router->ApplySettings();
|
m_router->ApplySettings();
|
||||||
|
@ -393,7 +393,7 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( aEvent.IsAction( &ACT_CustomTrackWidth ) )
|
else if( aEvent.IsAction( &ACT_CustomTrackWidth ) )
|
||||||
{
|
{
|
||||||
DIALOG_TRACK_VIA_SIZE sizeDlg( m_toolMgr->GetEditFrame(), m_router->Settings() );
|
DIALOG_TRACK_VIA_SIZE sizeDlg( getEditFrame<PCB_EDIT_FRAME>(), m_router->Settings() );
|
||||||
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>( PCB_T )->GetDesignSettings();
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>( PCB_T )->GetDesignSettings();
|
||||||
|
|
||||||
sizeDlg.ShowModal();
|
sizeDlg.ShowModal();
|
||||||
|
|
|
@ -93,7 +93,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY;
|
m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY;
|
||||||
|
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
PCB_EDIT_FRAME* editFrame = static_cast<PCB_EDIT_FRAME*>( m_toolMgr->GetEditFrame() );
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetSnapping( true );
|
controls->SetSnapping( true );
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
|
@ -208,7 +208,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
PCB_EDIT_FRAME* editFrame = static_cast<PCB_EDIT_FRAME*>( m_toolMgr->GetEditFrame() );
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
|
||||||
// Shall the selection be cleared at the end?
|
// Shall the selection be cleared at the end?
|
||||||
bool unselect = selection.Empty();
|
bool unselect = selection.Empty();
|
||||||
|
@ -224,7 +224,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
||||||
if( selection.Size() == 1 )
|
if( selection.Size() == 1 )
|
||||||
{
|
{
|
||||||
// Display properties dialog
|
// Display properties dialog
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) );
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );
|
||||||
|
|
||||||
// Check if user wants to edit pad or module properties
|
// Check if user wants to edit pad or module properties
|
||||||
if( item->Type() == PCB_MODULE_T )
|
if( item->Type() == PCB_MODULE_T )
|
||||||
|
@ -280,7 +280,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
||||||
int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
PCB_EDIT_FRAME* editFrame = static_cast<PCB_EDIT_FRAME*>( m_toolMgr->GetEditFrame() );
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
|
||||||
// Shall the selection be cleared at the end?
|
// Shall the selection be cleared at the end?
|
||||||
bool unselect = selection.Empty();
|
bool unselect = selection.Empty();
|
||||||
|
@ -302,7 +302,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
|
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( i ) );
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
|
||||||
|
|
||||||
item->Rotate( rotatePoint, editFrame->GetRotationAngle() );
|
item->Rotate( rotatePoint, editFrame->GetRotationAngle() );
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
||||||
int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
PCB_EDIT_FRAME* editFrame = static_cast<PCB_EDIT_FRAME*>( m_toolMgr->GetEditFrame() );
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
|
||||||
// Shall the selection be cleared at the end?
|
// Shall the selection be cleared at the end?
|
||||||
bool unselect = selection.Empty();
|
bool unselect = selection.Empty();
|
||||||
|
@ -356,7 +356,7 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
|
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( i ) );
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
|
||||||
|
|
||||||
item->Flip( flipPoint );
|
item->Flip( flipPoint );
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// Get a copy of the selected items set
|
// Get a copy of the selected items set
|
||||||
PICKED_ITEMS_LIST selectedItems = selection.items;
|
PICKED_ITEMS_LIST selectedItems = selection.items;
|
||||||
PCB_EDIT_FRAME* editFrame = static_cast<PCB_EDIT_FRAME*>( m_toolMgr->GetEditFrame() );
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
|
||||||
// As we are about to remove items, they have to be removed from the selection first
|
// As we are about to remove items, they have to be removed from the selection first
|
||||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear );
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear );
|
||||||
|
@ -412,10 +412,7 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// And now remove
|
// And now remove
|
||||||
for( unsigned int i = 0; i < selectedItems.GetCount(); ++i )
|
for( unsigned int i = 0; i < selectedItems.GetCount(); ++i )
|
||||||
{
|
remove( static_cast<BOARD_ITEM*>( selectedItems.GetPickedItem( i ) ) );
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selectedItems.GetPickedItem( i ) );
|
|
||||||
remove( item );
|
|
||||||
}
|
|
||||||
|
|
||||||
getModel<BOARD>( PCB_T )->GetRatsnest()->Recalculate();
|
getModel<BOARD>( PCB_T )->GetRatsnest()->Recalculate();
|
||||||
|
|
||||||
|
@ -491,7 +488,7 @@ void EDIT_TOOL::updateRatsnest( bool aRedraw )
|
||||||
ratsnest->ClearSimple();
|
ratsnest->ClearSimple();
|
||||||
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
|
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( i ) );
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
|
||||||
|
|
||||||
ratsnest->Update( item );
|
ratsnest->Update( item );
|
||||||
|
|
||||||
|
|
|
@ -658,7 +658,7 @@ bool SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
||||||
// Check if the point is located within any of the currently selected items bounding boxes
|
// Check if the point is located within any of the currently selected items bounding boxes
|
||||||
for( unsigned int i = 0; i < m_selection.items.GetCount(); ++i )
|
for( unsigned int i = 0; i < m_selection.items.GetCount(); ++i )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_selection.items.GetPickedItem( i ) );
|
BOARD_ITEM* item = m_selection.Item<BOARD_ITEM>( i );
|
||||||
BOX2I itemBox = item->ViewBBox();
|
BOX2I itemBox = item->ViewBBox();
|
||||||
itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
|
itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,13 @@ public:
|
||||||
return items.GetCount();
|
return items.GetCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Alias to make code shorter and clearer
|
||||||
|
template <typename T>
|
||||||
|
T* Item( unsigned int aIndex ) const
|
||||||
|
{
|
||||||
|
return static_cast<T*>( items.GetPickedItem( aIndex ) );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Clears both the VIEW_GROUP and set of selected items. Please note that it does not
|
/// Clears both the VIEW_GROUP and set of selected items. Please note that it does not
|
||||||
/// change properties of selected items (e.g. selection flag).
|
/// change properties of selected items (e.g. selection flag).
|
||||||
|
|
Loading…
Reference in New Issue