Formatting.

This commit is contained in:
Jeff Young 2021-09-13 17:18:58 +01:00
parent fdfecf5932
commit 32e23d993e
6 changed files with 189 additions and 193 deletions

View File

@ -179,9 +179,8 @@ BOARD_EDITOR_CONTROL::BOARD_EDITOR_CONTROL() :
m_inPlaceFootprint( false ),
m_inPlaceTarget( false )
{
m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>(
KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
}
@ -206,19 +205,19 @@ void BOARD_EDITOR_CONTROL::Reset( RESET_REASON aReason )
bool BOARD_EDITOR_CONTROL::Init()
{
auto activeToolCondition =
[ this ] ( const SELECTION& aSel )
[this]( const SELECTION& aSel )
{
return ( !m_frame->ToolStackIsEmpty() );
};
auto inactiveStateCondition =
[ this ] ( const SELECTION& aSel )
[this]( const SELECTION& aSel )
{
return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
};
auto placeModuleCondition =
[ this ] ( const SELECTION& aSel )
[this]( const SELECTION& aSel )
{
return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
};
@ -274,13 +273,14 @@ bool BOARD_EDITOR_CONTROL::Init()
// Functor to say if the PCB_EDIT_FRAME is in a given mode
// Capture the tool pointer and tool mode by value
auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
{
return [=]( const SELECTION& sel )
{
return drawingTool->GetDrawingMode() == aMode;
};
};
auto toolActiveFunctor =
[=]( DRAWING_TOOL::MODE aMode )
{
return [=]( const SELECTION& sel )
{
return drawingTool->GetDrawingMode() == aMode;
};
};
menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
}
@ -333,8 +333,8 @@ int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
undoCmd.PushItem( wrapper );
m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
DIALOG_PAGES_SETTINGS dlg( m_frame, IU_PER_MILS,
wxSize( MAX_PAGE_SIZE_PCBNEW_MILS, MAX_PAGE_SIZE_PCBNEW_MILS ) );
DIALOG_PAGES_SETTINGS dlg( m_frame, IU_PER_MILS, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS,
MAX_PAGE_SIZE_PCBNEW_MILS ) );
dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
if( dlg.ShowModal() != wxID_OK )
@ -412,7 +412,9 @@ int BOARD_EDITOR_CONTROL::ExportSpecctraDSN( const TOOL_EVENT& aEvent )
fn.SetExt( SpecctraDsnFileExtension );
}
else
{
fn = fullFileName;
}
fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
SpecctraDsnFileExtension, SpecctraDsnFileWildcard(),
@ -968,7 +970,9 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::refreshPreview );
}
else if( !aEvent.IsReactivate() )
{
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
}
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -1323,9 +1327,7 @@ static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE*>& aOriginZones,
}
for( unsigned int i = 1; i < aOriginZones.size(); i++ )
{
aCommit.Remove( aOriginZones[i] );
}
aMergedZones.push_back( aOriginZones[0] );
@ -1351,7 +1353,7 @@ int BOARD_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
ZONE* firstZone = nullptr;
std::vector<ZONE*> toMerge, merged;
for( auto item : selection )
for( EDA_ITEM* item : selection )
{
ZONE* curr_area = dynamic_cast<ZONE*>( item );
@ -1387,7 +1389,7 @@ int BOARD_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
{
commit.Push( "Merge zones" );
for( auto item : merged )
for( EDA_ITEM* item : merged )
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, item );
}

View File

@ -96,14 +96,14 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
// First, we determine what the height/Width should be for every cell
i = 0;
for( auto col : aContent )
for( const std::vector<PCB_TEXT*>& col : aContent )
{
j = 0;
if( i >= nbCols )
break;
for( auto cell : col )
for( const PCB_TEXT* cell : col )
{
if( j >= nbRows )
@ -179,7 +179,7 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
i = 0;
wxPoint pos = wxPoint( origin.x + xmargin, origin.y + ymargin );
for( auto col : aContent )
for( std::vector<PCB_TEXT*>& col : aContent )
{
j = 0;
@ -188,7 +188,7 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
pos.y = origin.y + ymargin;
for( auto cell : col )
for( PCB_TEXT* cell : col )
{
if( j >= nbRows )
@ -208,10 +208,12 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
}
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup(
const wxPoint& aOrigin, PCB_LAYER_ID aLayer, bool aDrawNow, wxPoint* tableSize )
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& aOrigin,
PCB_LAYER_ID aLayer,
bool aDrawNow,
wxPoint* tableSize )
{
BOARD_COMMIT commit( m_frame );
BOARD_COMMIT commit( m_frame );
std::vector<std::vector<PCB_TEXT*>> texts;
// Style : Header
@ -237,11 +239,11 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup(
dataStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
//Get Layer names
BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
BOARD_STACKUP& stackup = dsnSettings.GetStackupDescriptor();
BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
BOARD_STACKUP& stackup = dsnSettings.GetStackupDescriptor();
stackup.SynchronizeWithBoard( &dsnSettings );
std::vector<BOARD_STACKUP_ITEM*> layers = stackup.GetList();
std::vector<BOARD_STACKUP_ITEM*> layers = stackup.GetList();
std::vector<PCB_TEXT*> colLayer;
std::vector<PCB_TEXT*> colType;
@ -298,13 +300,9 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup(
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
if( layers.at( i )->GetLayerName().IsEmpty() )
{
t->SetText( m_frame->GetBoard()->GetLayerName( layers.at( i )->GetBrdLayerId() ) );
}
else
{
t->SetText( layers.at( i )->GetLayerName() );
}
colLayer.push_back( t );
@ -348,7 +346,7 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup(
if( aDrawNow )
{
for( auto item : table )
for( BOARD_ITEM* item : table )
commit.Add( item );
commit.Push( _( "Insert board stackup table" ) );
@ -358,10 +356,12 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup(
}
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics(
const wxPoint& aOrigin, PCB_LAYER_ID aLayer, bool aDrawNow, wxPoint* tableSize )
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& aOrigin,
PCB_LAYER_ID aLayer,
bool aDrawNow,
wxPoint* tableSize )
{
BOARD_COMMIT commit( m_frame );
BOARD_COMMIT commit( m_frame );
std::vector<BOARD_ITEM*> objects;
BOARD_DESIGN_SETTINGS& settings = m_frame->GetBoard()->GetDesignSettings();
BOARD_STACKUP& stackup = settings.GetStackupDescriptor();
@ -404,7 +404,7 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics(
std::vector<PCB_TEXT*> colbreak;
std::vector<PCB_TEXT*> colLabel2;
std::vector<PCB_TEXT*> colData2;
wxString text = wxString( "" );
wxString text = wxString( "" );
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
t->SetText( _( "Copper Layer Count: " ) );
@ -502,7 +502,7 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics(
std::vector<BOARD_ITEM*> table = initTextTable( texts, cursorPos, Eco1_User, &tableSize2,
false );
for( auto item : table )
for( BOARD_ITEM* item : table )
objects.push_back( item );
if( aDrawNow )
@ -555,7 +555,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
view()->ClearPreview();
view()->InitPreview();
for( auto item : aPreview )
for( BOARD_ITEM* item : aPreview )
{
item->Move( wxCursorPosition - wxPreviousCursorPosition );
view()->AddToPreview( item );
@ -614,13 +614,12 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
{
if( aLayers != nullptr )
{
PCB_LAYER_ID targetLayer = frame()->SelectOneLayer(
PCB_LAYER_ID::PCB_LAYER_ID_COUNT,
*aLayers, wxGetMousePosition() );
PCB_LAYER_ID destLayer = frame()->SelectOneLayer( PCB_LAYER_ID::PCB_LAYER_ID_COUNT,
*aLayers, wxGetMousePosition() );
view()->ClearPreview();
if( targetLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
if( destLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
{
// The user did not pick any layer.
m_frame->PopTool( tool );
@ -628,27 +627,21 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
break;
}
for( auto item : aItems )
for( BOARD_ITEM* item : aItems )
{
if( item->Type() == PCB_GROUP_T )
{
static_cast<PCB_GROUP*>( item )->SetLayerRecursive( targetLayer, 200 );
}
static_cast<PCB_GROUP*>( item )->SetLayerRecursive( destLayer, 200 );
else
{
item->SetLayer( targetLayer );
}
item->SetLayer( destLayer );
}
}
for( auto item : aItems )
for( BOARD_ITEM* item : aItems )
{
item->Move( wxCursorPosition );
if( item->Type() == PCB_GROUP_T )
{
static_cast<PCB_GROUP*>( item )->AddChildrenToCommit( commit );
}
commit.Add( item );
}
@ -691,8 +684,9 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
layer = Cmts_User;
}
std::vector<BOARD_ITEM*> table = DrawBoardCharacteristics(
wxPoint( 0, 0 ), m_frame->GetActiveLayer(), false, &tableSize );
std::vector<BOARD_ITEM*> table = DrawBoardCharacteristics( wxPoint( 0, 0 ),
m_frame->GetActiveLayer(), false,
&tableSize );
std::vector<BOARD_ITEM*> preview;
std::vector<BOARD_ITEM*> items;
@ -808,7 +802,7 @@ int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent )
PCB_GROUP* group = new PCB_GROUP( m_board );
group->SetName("group-boardStackUp");
for( auto item : table )
for( BOARD_ITEM* item : table )
group->AddItem( item );
items.push_back( static_cast<BOARD_ITEM*>( group ) );

View File

@ -92,7 +92,9 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
currentMode = false;
}
else
{
wxFAIL_MSG( "ExchangeFootprints: unexpected action" );
}
// invoke the exchange dialog process
{

View File

@ -99,14 +99,14 @@ bool GROUP_TOOL::Init()
// Find the selection tool, so they can cooperate
m_selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
auto groupMenu = std::make_shared<GROUP_CONTEXT_MENU>();
std::shared_ptr<GROUP_CONTEXT_MENU> groupMenu = std::make_shared<GROUP_CONTEXT_MENU>();
groupMenu->SetTool( this );
// Add the group control menus to relevant other tools
if( m_selectionTool )
{
auto& toolMenu = m_selectionTool->GetToolMenu();
auto& menu = toolMenu.GetMenu();
TOOL_MENU& toolMenu = m_selectionTool->GetToolMenu();
CONDITIONAL_MENU& menu = toolMenu.GetMenu();
toolMenu.AddSubMenu( groupMenu );
@ -148,50 +148,50 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
statusPopup.SetText( _( "Click on new member..." ) );
picker->SetClickHandler(
[&]( const VECTOR2D& aPoint ) -> bool
{
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
const PCB_SELECTION& sel = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector,
PCB_SELECTION_TOOL* sTool )
{
} );
if( sel.Empty() )
return true; // still looking for an item
statusPopup.Hide();
if( m_propertiesDialog )
[&]( const VECTOR2D& aPoint ) -> bool
{
m_propertiesDialog->DoAddMember( sel.Front() );
m_propertiesDialog->Show( true );
}
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
return false; // got our item; don't need any more
} );
const PCB_SELECTION& sel = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector,
PCB_SELECTION_TOOL* sTool )
{
} );
if( sel.Empty() )
return true; // still looking for an item
statusPopup.Hide();
if( m_propertiesDialog )
{
m_propertiesDialog->DoAddMember( sel.Front() );
m_propertiesDialog->Show( true );
}
return false; // got our item; don't need any more
} );
picker->SetMotionHandler(
[&] ( const VECTOR2D& aPos )
{
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
} );
[&] ( const VECTOR2D& aPos )
{
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
} );
picker->SetCancelHandler(
[&]()
{
if( m_propertiesDialog )
m_propertiesDialog->Show( true );
[&]()
{
if( m_propertiesDialog )
m_propertiesDialog->Show( true );
statusPopup.Hide();
} );
statusPopup.Hide();
} );
picker->SetFinalizeHandler(
[&]( const int& aFinalState )
{
done = true;
} );
[&]( const int& aFinalState )
{
done = true;
} );
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
statusPopup.Popup();

View File

@ -77,16 +77,17 @@ bool PAD_TOOL::Init()
SELECTION_CONDITION singlePadSel = SELECTION_CONDITIONS::Count( 1 ) &&
SELECTION_CONDITIONS::OnlyType( PCB_PAD_T );
auto explodeCondition = [&]( const SELECTION& aSel )
{
return m_editPad == niluuid
&& aSel.Size() == 1 && aSel[0]->Type() == PCB_PAD_T;
};
auto explodeCondition =
[&]( const SELECTION& aSel )
{
return m_editPad == niluuid && aSel.Size() == 1 && aSel[0]->Type() == PCB_PAD_T;
};
auto recombineCondition = [&]( const SELECTION& aSel )
{
return m_editPad != niluuid;
};
auto recombineCondition =
[&]( const SELECTION& aSel )
{
return m_editPad != niluuid;
};
menu.AddSeparator( 400 );
@ -118,7 +119,6 @@ bool PAD_TOOL::Init()
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
return true;
}

View File

@ -130,7 +130,7 @@ int PCB_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
Flip( opts.m_DisplayPcbTrackFill );
m_frame->SetDisplayOptions( opts );
for( auto track : board()->Tracks() )
for( PCB_TRACK* track : board()->Tracks() )
{
if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
view()->Update( track, KIGFX::REPAINT );
@ -152,7 +152,7 @@ int PCB_CONTROL::ToggleRatsnest( const TOOL_EVENT& aEvent )
Flip( opts.m_ShowGlobalRatsnest );
m_frame->SetDisplayOptions( opts );
getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
opts.m_ShowGlobalRatsnest );
opts.m_ShowGlobalRatsnest );
}
else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
@ -175,7 +175,7 @@ int PCB_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
Flip( opts.m_DisplayViaFill );
m_frame->SetDisplayOptions( opts );
for( auto track : board()->Tracks() )
for( PCB_TRACK* track : board()->Tracks() )
{
if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
view()->Update( track, KIGFX::REPAINT );
@ -301,17 +301,9 @@ int PCB_CONTROL::HighContrastModeCycle( const TOOL_EVENT& aEvent )
switch( opts.m_ContrastModeDisplay )
{
case HIGH_CONTRAST_MODE::NORMAL:
opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED;
break;
case HIGH_CONTRAST_MODE::DIMMED:
opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN;
break;
case HIGH_CONTRAST_MODE::HIDDEN:
opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
break;
case HIGH_CONTRAST_MODE::NORMAL: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED; break;
case HIGH_CONTRAST_MODE::DIMMED: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN; break;
case HIGH_CONTRAST_MODE::HIDDEN: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL; break;
}
m_frame->SetDisplayOptions( opts );
@ -367,8 +359,10 @@ int PCB_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
while( startLayer != --layer )
{
if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
&& brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
&& brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
{
break;
}
if( layer <= F_Cu )
layer = B_Cu + 1;
@ -405,10 +399,9 @@ int PCB_CONTROL::LayerToggle( const TOOL_EVENT& aEvent )
int PCB_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
{
auto settings = m_frame->GetColorSettings();
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
COLOR_SETTINGS* settings = m_frame->GetColorSettings();
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
{
@ -426,7 +419,9 @@ int PCB_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->OnLayerAlphaChanged();
}
else
{
wxBell();
}
return 0;
}
@ -434,10 +429,9 @@ int PCB_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
int PCB_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
{
auto settings = m_frame->GetColorSettings();
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
COLOR_SETTINGS* settings = m_frame->GetColorSettings();
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
{
@ -499,12 +493,12 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
Activate();
picker->SetClickHandler(
[this] ( const VECTOR2D& pt ) -> bool
{
m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
return false; // drill origin is a one-shot; don't continue with tool
} );
[this]( const VECTOR2D& pt ) -> bool
{
m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
return false; // drill origin is a one-shot; don't continue with tool
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
}
@ -541,82 +535,82 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
picker->SetCursor( KICURSOR::REMOVE );
picker->SetClickHandler(
[this] ( const VECTOR2D& aPosition ) -> bool
{
if( m_pickerItem )
[this]( const VECTOR2D& aPosition ) -> bool
{
if( m_pickerItem && m_pickerItem->IsLocked() )
if( m_pickerItem )
{
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
m_statusPopup->SetText( _( "Item locked." ) );
m_statusPopup->PopupFor( 2000 );
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
return true;
if( m_pickerItem && m_pickerItem->IsLocked() )
{
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
m_statusPopup->SetText( _( "Item locked." ) );
m_statusPopup->PopupFor( 2000 );
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
return true;
}
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
selectionTool->UnbrightenItem( m_pickerItem );
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
m_toolMgr->RunAction( ACTIONS::doDelete, true );
m_pickerItem = nullptr;
}
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
selectionTool->UnbrightenItem( m_pickerItem );
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
m_toolMgr->RunAction( ACTIONS::doDelete, true );
m_pickerItem = nullptr;
}
return true;
} );
return true;
} );
picker->SetMotionHandler(
[this] ( const VECTOR2D& aPos )
{
BOARD* board = m_frame->GetBoard();
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
GENERAL_COLLECTOR collector;
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
if( m_isFootprintEditor )
collector.Collect( board, GENERAL_COLLECTOR::FootprintItems,
(wxPoint) aPos, guide );
else
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems,
(wxPoint) aPos, guide );
// Remove unselectable items
for( int i = collector.GetCount() - 1; i >= 0; --i )
[this]( const VECTOR2D& aPos )
{
if( !selectionTool->Selectable( collector[ i ] ) )
collector.Remove( i );
}
BOARD* board = m_frame->GetBoard();
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
GENERAL_COLLECTOR collector;
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
if( collector.GetCount() > 1 )
selectionTool->GuessSelectionCandidates( collector, aPos );
if( m_isFootprintEditor )
collector.Collect( board, GENERAL_COLLECTOR::FootprintItems,
(wxPoint) aPos, guide );
else
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems,
(wxPoint) aPos, guide );
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
// Remove unselectable items
for( int i = collector.GetCount() - 1; i >= 0; --i )
{
if( !selectionTool->Selectable( collector[ i ] ) )
collector.Remove( i );
}
if( m_pickerItem != item )
{
if( collector.GetCount() > 1 )
selectionTool->GuessSelectionCandidates( collector, aPos );
if( m_pickerItem )
selectionTool->UnbrightenItem( m_pickerItem );
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
m_pickerItem = item;
if( m_pickerItem != item )
{
if( m_pickerItem )
selectionTool->BrightenItem( m_pickerItem );
}
} );
if( m_pickerItem )
selectionTool->UnbrightenItem( m_pickerItem );
m_pickerItem = item;
if( m_pickerItem )
selectionTool->BrightenItem( m_pickerItem );
}
} );
picker->SetFinalizeHandler(
[this] ( const int& aFinalState )
{
if( m_pickerItem )
m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
[this]( const int& aFinalState )
{
if( m_pickerItem )
m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
m_statusPopup.reset();
m_statusPopup.reset();
// Ensure the cursor gets changed&updated
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->GetCanvas()->Refresh();
} );
// Ensure the cursor gets changed&updated
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->GetCanvas()->Refresh();
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
@ -901,10 +895,14 @@ static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget,
aList.pop_back();
}
else
{
obj = nullptr;
}
}
else
{
obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
}
}
}