Cleanup & performance enhancements.

This commit is contained in:
Jeff Young 2022-07-29 22:02:35 +01:00
parent d1ff8f4781
commit 6f49b57f9b
44 changed files with 170 additions and 197 deletions

View File

@ -58,7 +58,7 @@ void BOARD_ADAPTER::destroyLayers()
{
if( !m_layers_poly.empty() )
{
for( auto& poly : m_layers_poly )
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layers_poly )
delete poly.second;
m_layers_poly.clear();
@ -72,7 +72,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerHoleIdPolys.empty() )
{
for( auto& poly : m_layerHoleIdPolys )
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layerHoleIdPolys )
delete poly.second;
m_layerHoleIdPolys.clear();
@ -80,7 +80,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerHoleOdPolys.empty() )
{
for( auto& poly : m_layerHoleOdPolys )
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layerHoleOdPolys )
delete poly.second;
m_layerHoleOdPolys.clear();
@ -88,7 +88,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerMap.empty() )
{
for( auto& poly : m_layerMap )
for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& poly : m_layerMap )
delete poly.second;
m_layerMap.clear();
@ -102,7 +102,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerHoleMap.empty() )
{
for( auto& poly : m_layerHoleMap )
for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& poly : m_layerHoleMap )
delete poly.second;
m_layerHoleMap.clear();
@ -726,9 +726,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
auto layerPolyContainer = m_layers_poly.find( layer );
if( layerContainer != m_layerMap.end() )
{
addSolidAreasShapes( zone, layerContainer->second, layer );
}
if( m_Cfg->m_Render.opengl_copper_thickness
&& m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL
@ -1087,7 +1085,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( !m_layerHoleMap.empty() )
{
for( auto& hole : m_layerHoleMap )
for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& hole : m_layerHoleMap )
hole.second->BuildBVH();
}

View File

@ -126,7 +126,11 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
wxASSERT( m_3d_render_raytracing != nullptr );
wxASSERT( m_3d_render_opengl != nullptr );
auto busy_indicator_factory = []() { return std::make_unique<WX_BUSY_INDICATOR>(); };
auto busy_indicator_factory =
[]()
{
return std::make_unique<WX_BUSY_INDICATOR>();
};
m_3d_render_raytracing->SetBusyIndicatorFactory( busy_indicator_factory );
m_3d_render_opengl->SetBusyIndicatorFactory( busy_indicator_factory );

View File

@ -149,24 +149,25 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
{
const auto& mesh = a3DModel.m_Meshes[mesh_i];
const SMESH& mesh = a3DModel.m_Meshes[mesh_i];
// silently ignore meshes that have invalid material references or invalid geometry.
if( mesh.m_MaterialIdx >= m_materials.size()
|| mesh.m_Positions == nullptr
|| mesh.m_FaceIdx == nullptr
|| mesh.m_Normals == nullptr
|| mesh.m_FaceIdxSize == 0
|| mesh.m_VertexSize == 0 )
continue;
|| mesh.m_Positions == nullptr
|| mesh.m_FaceIdx == nullptr
|| mesh.m_Normals == nullptr
|| mesh.m_FaceIdxSize == 0
|| mesh.m_VertexSize == 0 )
{
continue;
}
auto& mesh_group = mesh_groups[mesh.m_MaterialIdx];
auto& material = m_materials[mesh.m_MaterialIdx];
MESH_GROUP& mesh_group = mesh_groups[mesh.m_MaterialIdx];
MATERIAL& material = m_materials[mesh.m_MaterialIdx];
if( material.IsTransparent()
&& m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
if( material.IsTransparent() && m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
m_have_transparent_meshes = true;
else
else
m_have_opaque_meshes = true;
const unsigned int vtx_offset = mesh_group.m_vertices.size();
@ -180,15 +181,14 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
{
m_meshes_bbox[mesh_i].Union( mesh.m_Positions[vtx_i] );
auto& vtx_out = mesh_group.m_vertices[vtx_offset + vtx_i];
VERTEX& vtx_out = mesh_group.m_vertices[vtx_offset + vtx_i];
vtx_out.m_pos = mesh.m_Positions[vtx_i];
vtx_out.m_nrm = glm::clamp( glm::vec4( mesh.m_Normals[vtx_i], 1.0f ) * 127.0f,
-127.0f, 127.0f );
vtx_out.m_tex_uv = mesh.m_Texcoords != nullptr
? mesh.m_Texcoords[vtx_i]
: glm::vec2 (0);
vtx_out.m_tex_uv = mesh.m_Texcoords != nullptr ? mesh.m_Texcoords[vtx_i]
: glm::vec2 (0);
if( mesh.m_Color != nullptr )
{
@ -299,7 +299,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
unsigned int total_vertex_count = 0;
unsigned int total_index_count = 0;
for( auto& mg : mesh_groups )
for( const MESH_GROUP& mg : mesh_groups )
{
total_vertex_count += mg.m_vertices.size();
total_index_count += mg.m_indices.size();
@ -327,8 +327,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
// temporary index buffer which will contain either GLushort or GLuint
// type indices. allocate with a bit of meadow at the end.
auto tmp_idx = std::make_unique<GLuint[]>(
( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
auto tmp_idx = std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
unsigned int prev_vtx_count = 0;
unsigned int idx_offset = 0;
@ -336,23 +335,22 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
for( unsigned int mg_i = 0; mg_i < mesh_groups.size (); ++mg_i )
{
auto& mg = mesh_groups[mg_i];
auto& mat = m_materials[mg_i];
MESH_GROUP& mg = mesh_groups[mg_i];
MATERIAL& mat = m_materials[mg_i];
uintptr_t tmp_idx_ptr = reinterpret_cast<uintptr_t>( tmp_idx.get() );
if( m_index_buffer_type == GL_UNSIGNED_SHORT )
{
auto idx_out = reinterpret_cast<GLushort*>(
reinterpret_cast<uintptr_t>( tmp_idx.get() ) + idx_offset );
GLushort* idx_out = reinterpret_cast<GLushort*>( tmp_idx_ptr + idx_offset );
for( auto idx : mg.m_indices )
for( GLuint idx : mg.m_indices )
*idx_out++ = static_cast<GLushort>( idx + prev_vtx_count );
}
else if( m_index_buffer_type == GL_UNSIGNED_INT )
{
auto idx_out = reinterpret_cast<GLuint*>(
reinterpret_cast<uintptr_t>( tmp_idx.get() ) + idx_offset );
GLuint* idx_out = reinterpret_cast<GLuint*>( tmp_idx_ptr + idx_offset );
for( auto idx : mg.m_indices )
for( GLuint idx : mg.m_indices )
*idx_out++ = static_cast<GLuint>( idx + prev_vtx_count );
}

View File

@ -531,7 +531,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
float layer_z_bot = 0.0f;
float layer_z_top = 0.0f;
for( const auto ii : outerMapHoles )
for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : outerMapHoles )
{
const PCB_LAYER_ID layer_id = ii.first;
const SHAPE_POLY_SET* poly = ii.second;
@ -543,7 +543,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
layer_z_top, layer_z_bot, false );
}
for( const auto ii : innerMapHoles )
for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : innerMapHoles )
{
const PCB_LAYER_ID layer_id = ii.first;
const SHAPE_POLY_SET* poly = ii.second;
@ -565,7 +565,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
for( const auto ii : m_boardAdapter.GetLayerMap() )
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& ii : m_boardAdapter.GetLayerMap() )
{
const PCB_LAYER_ID layer_id = ii.first;

View File

@ -556,9 +556,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
aStatusReporter->Report( _( "Load Raytracing: layers" ) );
// Add layers maps (except B_Mask and F_Mask)
for( auto entry : m_boardAdapter.GetLayerMap() )
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() )
{
PCB_LAYER_ID layer_id = entry.first;
const PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second;
// Only process layers that exist
@ -677,9 +677,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
const MATERIAL* materialLayer = &m_materials.m_SolderMask;
for( auto entry : m_boardAdapter.GetLayerMap() )
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() )
{
PCB_LAYER_ID layer_id = entry.first;
const PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second;
// Only process layers that exist

View File

@ -130,7 +130,7 @@ void ConvertPolygonToTriangles( const SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BA
for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
{
auto triPoly = aPolyList.TriangulatedPolygon( j );
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* triPoly = aPolyList.TriangulatedPolygon( j );
for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
{

View File

@ -77,12 +77,10 @@ void BITMAP_BASE::ImportData( BITMAP_BASE* aItem )
bool BITMAP_BASE::ReadImageFile( wxInputStream& aInStream )
{
auto new_image = std::make_unique<wxImage>();
std::unique_ptr<wxImage> new_image = std::make_unique<wxImage>();
if( !new_image->LoadFile( aInStream ) )
{
return false;
}
delete m_image;
m_image = new_image.release();

View File

@ -595,12 +595,13 @@ void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt )
int currentIdx = -1;
int delta = aEvt.ShiftDown() ? -1 : 1;
auto advance = [&]( int& idx )
{
// Wrap-around modulus
int size = m_tabOrder.size();
idx = ( ( idx + delta ) % size + size ) % size;
};
auto advance =
[&]( int& idx )
{
// Wrap-around modulus
int size = m_tabOrder.size();
idx = ( ( idx + delta ) % size + size ) % size;
};
for( size_t i = 0; i < m_tabOrder.size(); ++i )
{

View File

@ -149,7 +149,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
newSettings->SetName( themeName );
newSettings->SetReadOnly( false );
for( auto layer : m_validLayers )
for( int layer : m_validLayers )
newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) );
newSettings->SaveToFile( settingsMgr.GetPathForSettingsFile( newSettings ) );
@ -367,7 +367,7 @@ bool PANEL_COLOR_SETTINGS::saveCurrentTheme( bool aValidate )
selected->SetOverrideSchItemColors( m_optOverrideColors->GetValue() );
for( auto layer : m_validLayers )
for( int layer : m_validLayers )
selected->SetColor( layer, m_currentSettings->GetColor( layer ) );
settingsMgr.SaveColorSettings( selected, m_colorNamespace );

View File

@ -538,7 +538,7 @@ void DS_DRAW_ITEM_LIST::Print( const RENDER_SETTINGS* aSettings )
second_items.push_back( item );
}
for( auto item : second_items )
for( DS_DRAW_ITEM_BASE* item : second_items )
item->PrintWsItem( aSettings );
}

View File

@ -175,7 +175,7 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
{
delete m_socketServer;
for( auto socket : m_sockets )
for( wxSocketBase* socket : m_sockets )
{
socket->Shutdown();
socket->Destroy();

View File

@ -79,12 +79,14 @@ wxString NormalizePath( const wxFileName& aFilePath, const ENV_VAR_MAP* aEnvVars
if( aEnvVars )
{
for( auto& entry : *aEnvVars )
for( const std::pair<const wxString, ENV_VAR_ITEM>& entry : *aEnvVars )
{
// Don't bother normalizing paths that don't exist or the user cannot read.
if( !wxFileName::DirExists( entry.second.GetValue() )
|| !wxFileName::IsDirReadable( entry.second.GetValue() ) )
|| !wxFileName::IsDirReadable( entry.second.GetValue() ) )
{
continue;
}
envPath.SetPath( entry.second.GetValue() );
@ -177,7 +179,7 @@ wxString ResolveFile( const wxString& aFileName, const ENV_VAR_MAP* aEnvVars,
if( aEnvVars )
{
for( auto& entry : *aEnvVars )
for( const std::pair<const wxString, ENV_VAR_ITEM>& entry : *aEnvVars )
{
wxFileName fn( createFilePath( entry.second.GetValue(), aFileName ) );

View File

@ -47,7 +47,7 @@ static const ENV_VAR::ENV_VAR_LIST predefinedEnvVars = {
bool ENV_VAR::IsEnvVarImmutable( const wxString& aEnvVar )
{
for( const auto& s : predefinedEnvVars )
for( const wxString& s : predefinedEnvVars )
{
if( s == aEnvVar )
return true;

View File

@ -70,8 +70,8 @@ GRID_TRICKS::GRID_TRICKS( WX_GRID* aGrid ):
bool GRID_TRICKS::toggleCell( int aRow, int aCol, bool aPreserveSelection )
{
auto renderer = m_grid->GetCellRenderer( aRow, aCol );
bool isCheckbox = ( dynamic_cast<wxGridCellBoolRenderer*>( renderer ) != nullptr );
wxGridCellRenderer* renderer = m_grid->GetCellRenderer( aRow, aCol );
bool isCheckbox = ( dynamic_cast<wxGridCellBoolRenderer*>( renderer ) );
renderer->DecRef();
if( isCheckbox )

View File

@ -69,7 +69,7 @@ const BOX2I ORIGIN_VIEWITEM::ViewBBox() const
void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const
{
auto gal = aView->GetGAL();
GAL* gal = aView->GetGAL();
// Nothing to do if the target shouldn't be drawn at 0,0 and that's where the target is.
if( !m_drawAtZero && ( m_position.x == 0 ) && ( m_position.y == 0 ) )

View File

@ -198,7 +198,7 @@ const wxString PROJECT::GetSheetName( const KIID& aSheetID )
{
if( m_sheetNames.empty() )
{
for( auto pair : GetProjectFile().GetSheets() )
for( const std::pair<KIID, wxString>& pair : GetProjectFile().GetSheets() )
m_sheetNames[pair.first] = pair.second;
}
@ -214,13 +214,9 @@ void PROJECT::SetRString( RSTRING_T aIndex, const wxString& aString )
unsigned ndx = unsigned( aIndex );
if( ndx < arrayDim( m_rstrings ) )
{
m_rstrings[ndx] = aString;
}
else
{
wxASSERT( 0 ); // bad index
}
}
@ -247,9 +243,7 @@ PROJECT::_ELEM* PROJECT::GetElem( ELEM_T aIndex )
{
// This is virtual, so implement it out of line
if( unsigned( aIndex ) < arrayDim( m_elems ) )
{
return m_elems[aIndex];
}
return nullptr;
}

View File

@ -617,7 +617,7 @@ bool SETTINGS_MANAGER::GetPreviousVersionPaths( std::vector<wxString>* aPaths )
std::set<wxString> checkedPaths;
for( auto base_path : base_paths )
for( const wxFileName& base_path : base_paths )
{
if( checkedPaths.count( base_path.GetFullPath() ) )
continue;

View File

@ -202,7 +202,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
}
else if( !global.empty() )
{
for( auto act : global )
for( const TOOL_ACTION* act : global )
{
bool runAction = true;

View File

@ -60,7 +60,7 @@ ACTION_MENU::ACTION_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) :
ACTION_MENU::~ACTION_MENU()
{
// Set parent to NULL to prevent submenus from unregistering from a nonexistent object
for( auto menu : m_submenus )
for( ACTION_MENU* menu : m_submenus )
menu->SetParent( nullptr );
ACTION_MENU* parent = dynamic_cast<ACTION_MENU*>( GetParent() );

View File

@ -122,7 +122,7 @@ EDA_RECT SELECTION::GetBoundingBox() const
bool SELECTION::HasType( KICAD_T aType ) const
{
for( auto item : m_items )
for( const EDA_ITEM* item : m_items )
{
if( item->Type() == aType )
return true;
@ -136,7 +136,7 @@ size_t SELECTION::CountType( KICAD_T aType ) const
{
size_t count = 0;
for( EDA_ITEM* item : m_items )
for( const EDA_ITEM* item : m_items )
{
if( item->Type() == aType )
count++;
@ -150,7 +150,7 @@ const std::vector<KIGFX::VIEW_ITEM*> SELECTION::updateDrawList() const
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
for( EDA_ITEM* item : m_items )
items.push_back( item );
return items;

View File

@ -871,7 +871,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
m_menuCursor = m_viewControls->GetCursorPosition();
// Save all tools cursor settings, as they will be overridden
for( auto idState : m_toolIdIndex )
for( const std::pair<const TOOL_ID, TOOL_STATE*>& idState : m_toolIdIndex )
{
TOOL_STATE* s = idState.second;
const auto& vc = s->vcSettings;
@ -916,7 +916,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
m_menuOwner = -1;
// Restore cursor settings
for( auto const& cursorSetting : m_cursorSettings )
for( const std::pair<const TOOL_ID, OPT<VECTOR2D>>& cursorSetting : m_cursorSettings )
{
auto it = m_toolIdIndex.find( cursorSetting.first );
wxASSERT( it != m_toolIdIndex.end() );

View File

@ -158,7 +158,8 @@ int CVPCB_ASSOCIATION_TOOL::PasteAssoc( const TOOL_EVENT& aEvent )
// Assign the fpid to the selections
bool firstAssoc = true;
for( auto i : idx )
for( unsigned int i : idx )
{
m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, fpid ), firstAssoc );
firstAssoc = false;
@ -210,10 +211,9 @@ int CVPCB_ASSOCIATION_TOOL::Associate( const TOOL_EVENT& aEvent )
}
// Get all the components that are selected and associate them with the current footprint
std::vector<unsigned int> sel = m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS );
bool firstAssoc = true;
for( auto i : sel )
for( unsigned int i : m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ) )
{
CVPCB_ASSOCIATION newfp( i, fpid );
m_frame->AssociateFootprint( newfp, firstAssoc );
@ -237,12 +237,10 @@ int CVPCB_ASSOCIATION_TOOL::AutoAssociate( const TOOL_EVENT& aEvent )
int CVPCB_ASSOCIATION_TOOL::DeleteAssoc( const TOOL_EVENT& aEvent )
{
// Get all the components that are selected
std::vector<unsigned int> sel = m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS );
// Delete the association
// Delete all the selected components' associations
bool firstAssoc = true;
for( auto i : sel )
for( unsigned int i : m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ) )
{
m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, LIB_ID() ), firstAssoc );
firstAssoc = false;
@ -258,11 +256,10 @@ int CVPCB_ASSOCIATION_TOOL::DeleteAll( const TOOL_EVENT& aEvent )
{
// Remove all selections to avoid issues when setting the fpids
m_frame->SetSelectedComponent( -1, true );
std::vector<unsigned int> idx =
m_frame->GetComponentIndices( CVPCB_MAINFRAME::ALL_COMPONENTS );
bool firstAssoc = true;
for( auto i : idx )
for( unsigned int i : m_frame->GetComponentIndices( CVPCB_MAINFRAME::ALL_COMPONENTS ) )
{
m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, LIB_ID() ), firstAssoc );
firstAssoc = false;

View File

@ -832,7 +832,7 @@ void CONNECTION_GRAPH::resolveAllDrivers()
return 0;
// Special processing for some items
for( auto item : subgraph->m_items )
for( SCH_ITEM* item : subgraph->m_items )
{
switch( item->Type() )
{
@ -1237,7 +1237,7 @@ void CONNECTION_GRAPH::processSubGraphs()
wxString test_name = member->Name( true );
for( auto candidate : candidate_subgraphs )
for( CONNECTION_SUBGRAPH* candidate : candidate_subgraphs )
{
if( candidate->m_absorbed )
continue;
@ -2425,7 +2425,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu
SCH_ITEM* label = nullptr;
SCH_ITEM* port = nullptr;
for( auto item : aSubgraph->m_items )
for( SCH_ITEM* item : aSubgraph->m_items )
{
switch( item->Type() )
{

View File

@ -60,7 +60,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wx
{
SCH_SCREEN* screen = sheet.LastScreen();
for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
{
SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );

View File

@ -251,7 +251,7 @@ void DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable( REPORTER& aReporter )
for( screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
{
for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
{
symbol = dynamic_cast<SCH_SYMBOL*>( item );

View File

@ -990,7 +990,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
updateFileType = true;
tmpFn.SetExt( KiCadSchematicFileExtension );
for( auto item : screen->Items().OfType( SCH_SHEET_T ) )
for( EDA_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
wxFileName sheetFileName = sheet->GetFileName();

View File

@ -69,7 +69,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
SCH_SHEET_PATH sheet = sheetList[i];
// Process symbol attributes
for( auto item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
for( EDA_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
{
SCH_SYMBOL* symbol = findNextSymbol( item, &sheet );
@ -79,9 +79,10 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
CreatePinList( symbol, &sheet, true );
if( symbol->GetLibSymbolRef()
&& symbol->GetLibSymbolRef()->GetFPFilters().GetCount() != 0 )
cmpList.push_back( SCH_REFERENCE( symbol, symbol->GetLibSymbolRef().get(),
sheet ) );
&& symbol->GetLibSymbolRef()->GetFPFilters().GetCount() != 0 )
{
cmpList.push_back( SCH_REFERENCE( symbol, symbol->GetLibSymbolRef().get(), sheet ) );
}
footprint = symbol->GetFootprint( &sheet, true );
footprint.Replace( wxT( " " ), wxT( "_" ) );

View File

@ -535,7 +535,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
m_libraries.clear();
for( auto lcomp : m_libParts )
for( LIB_SYMBOL* lcomp : m_libParts )
{
wxString libNickname = lcomp->GetLibId().GetLibNickname();;

View File

@ -68,7 +68,7 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector<SCH_SYMBOL*>& aSymbol
// Get the full list
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
{
for( auto aItem : screen->Items().OfType( SCH_SYMBOL_T ) )
for( EDA_ITEM* aItem : screen->Items().OfType( SCH_SYMBOL_T ) )
aSymbols.push_back( static_cast<SCH_SYMBOL*>( aItem ) );
}
@ -685,7 +685,7 @@ void LEGACY_RESCUER::OpenRescueLibrary()
rescueLib->GetSymbols( symbols );
for( auto symbol : symbols )
for( LIB_SYMBOL* symbol : symbols )
{
// The LIB_SYMBOL copy constructor flattens derived symbols (formerly known as aliases).
m_rescue_lib->AddSymbol( new LIB_SYMBOL( *symbol, m_rescue_lib.get() ) );

View File

@ -93,7 +93,7 @@ void SCH_SEXPR_PLUGIN_CACHE::Save( const std::optional<bool>& aOpt )
formatter->Print( 0, "(kicad_symbol_lib (version %d) (generator kicad_symbol_editor)\n",
SEXPR_SYMBOL_LIB_FILE_VERSION );
for( auto parent : m_symbols )
for( const std::pair<const wxString, LIB_SYMBOL*>& parent : m_symbols )
{
// Save the root symbol first so alias can inherit from them.
if( parent.second->IsRoot() )
@ -101,7 +101,7 @@ void SCH_SEXPR_PLUGIN_CACHE::Save( const std::optional<bool>& aOpt )
SaveSymbol( parent.second, *formatter.get(), 1 );
// Save all of the aliases associated with the current root symbol.
for( auto alias : m_symbols )
for( const std::pair<const wxString, LIB_SYMBOL*>& alias : m_symbols )
{
if( !alias.second->IsAlias() )
continue;
@ -218,7 +218,7 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& a
return a.m_unit < b.m_unit;
} );
for( auto unit : units )
for( const LIB_SYMBOL_UNIT& unit : units )
{
// Add quotes and escape chars like ") to the UTF8 unitName string
name = aFormatter.Quotes( unitName );
@ -298,7 +298,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFOR
{
wxString tmp;
for( auto filter : fpFilters )
for( const wxString& filter : fpFilters )
{
// Spaces are not handled in fp filter names so escape spaces if any
wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE );

View File

@ -111,7 +111,7 @@ LIB_SYMBOL* SCH_LIB_PLUGIN_CACHE::removeSymbol( LIB_SYMBOL* aSymbol )
// the root symbol and make it the new root.
if( aSymbol->IsRoot() )
{
for( auto entry : m_symbols )
for( const std::pair<const wxString, LIB_SYMBOL*>& entry : m_symbols )
{
if( entry.second->IsAlias()
&& entry.second->GetParent().lock() == aSymbol->SharedPtr() )
@ -139,11 +139,13 @@ LIB_SYMBOL* SCH_LIB_PLUGIN_CACHE::removeSymbol( LIB_SYMBOL* aSymbol )
}
// Reparent the remaining aliases.
for( auto entry : m_symbols )
for( const std::pair<const wxString, LIB_SYMBOL*>& entry : m_symbols )
{
if( entry.second->IsAlias()
&& entry.second->GetParent().lock() == aSymbol->SharedPtr() )
&& entry.second->GetParent().lock() == aSymbol->SharedPtr() )
{
entry.second->SetParent( firstChild );
}
}
}
}

View File

@ -100,7 +100,7 @@ SCHEMATIC* SCH_SCREEN::Schematic() const
void SCH_SCREEN::clearLibSymbols()
{
for( auto libSymbol : m_libSymbols )
for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : m_libSymbols )
delete libSymbol.second;
m_libSymbols.clear();
@ -529,9 +529,9 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a
case SCH_SYMBOL_T:
{
auto symbol = static_cast<SCH_SYMBOL*>( item );
auto pins = symbol->GetPins( aSheet );
for( auto pin : pins )
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
for( SCH_PIN* pin : symbol->GetPins( aSheet ) )
{
if( pin->GetPosition() == aPosition )
{

View File

@ -723,14 +723,12 @@ bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList )
if( m_screen == aScreen )
return true;
for( auto item : m_screen->Items().OfType( SCH_SHEET_T ) )
for( EDA_ITEM* item : m_screen->Items().OfType( SCH_SHEET_T ) )
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
if( sheet->LocatePathOfScreen( aScreen, aList ) )
{
return true;
}
}
aList->pop_back();

View File

@ -154,7 +154,7 @@ void SCH_SHEET_PATH::Rehash()
{
m_current_hash = 0;
for( auto sheet : m_sheets )
for( SCH_SHEET* sheet : m_sheets )
boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
}

View File

@ -179,7 +179,7 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol )
void SCH_VIEW::ClearHiddenFlags()
{
for( auto item : *m_allItems )
for( VIEW_ITEM* item : *m_allItems )
Hide( item, false );
}

View File

@ -49,7 +49,6 @@
#include <origin_viewitem.h>
#include <pcb_edit_frame.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include <project.h>
#include <project/project_file.h> // LAST_PATH_TYPE
#include <tool/tool_manager.h>
@ -96,7 +95,6 @@ public:
Add( PCB_ACTIONS::drawSimilarZone );
}
protected:
ACTION_MENU* create() const override
{

View File

@ -73,13 +73,13 @@ int BOARD_REANNOTATE_TOOL::ReannotateDuplicatesInSelection()
}
int BOARD_REANNOTATE_TOOL::ReannotateDuplicates( const PCB_SELECTION& aSelectionToReannotate,
const std::vector<EDA_ITEM*>& aAdditionalFootprints )
const std::vector<EDA_ITEM*>& aAdditionalFootprints )
{
if( aSelectionToReannotate.Empty() )
return 0;
// 1. Build list of designators on the board & the additional footprints
FOOTPRINTS fpOnBoard = m_frame->GetBoard()->Footprints();
FOOTPRINTS fpOnBoard = m_frame->GetBoard()->Footprints();
std::multimap<wxString, KIID> usedDesignatorsMap;
for( EDA_ITEM* item : aAdditionalFootprints )

View File

@ -691,7 +691,6 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent )
FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
FOOTPRINT* footprint = nullptr;
PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer();
PCB_LAYER_ID copperLayer = F_Cu;
BOARD_ITEM_CONTAINER* parent = frame->GetModel();
if( fpEditor )
@ -738,12 +737,10 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent )
{
if( !IsCopperLayer( targetLayer ) )
{
copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
targetLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
if( copperLayer == UNDEFINED_LAYER ) // User canceled
if( targetLayer == UNDEFINED_LAYER ) // User canceled
return true;
targetLayer = copperLayer;
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2017 CERN
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -27,12 +27,8 @@
#include <pcb_edit_frame.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/tool_event_utils.h>
#include <tools/drawing_tool.h>
#include <board_commit.h>
#include <scoped_set_reset.h>
#include <bitmaps.h>
#include <painter.h>
#include <board.h>
#include <board_design_settings.h>
@ -48,9 +44,8 @@ using SCOPED_DRAW_MODE = SCOPED_SET_RESET<DRAWING_TOOL::MODE>;
static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*>> aContent,
wxPoint origin, PCB_LAYER_ID aLayer,
wxPoint* aTableSize,
bool aDrawFrame = true )
VECTOR2I origin, PCB_LAYER_ID aLayer,
VECTOR2I* aTableSize, bool aDrawFrame = true )
{
int i;
int j;
@ -58,7 +53,7 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
int nbCols = aContent.size();
int nbRows = 0;
for( auto col : aContent )
for( const std::vector<PCB_TEXT*>& col : aContent )
nbRows = std::max( nbRows, static_cast<int>( col.size() ) );
// Limit the number of cells
@ -176,8 +171,8 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
}
//Now add the text
i = 0;
wxPoint pos = wxPoint( origin.x + xmargin, origin.y + ymargin );
i = 0;
VECTOR2I pos( origin.x + xmargin, origin.y + ymargin );
for( std::vector<PCB_TEXT*>& col : aContent )
{
@ -190,7 +185,6 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
for( PCB_TEXT* cell : col )
{
if( j >= nbRows )
break;
@ -208,17 +202,18 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
}
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& aOrigin,
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const VECTOR2I& aOrigin,
PCB_LAYER_ID aLayer,
bool aDrawNow,
wxPoint* tableSize )
VECTOR2I* tableSize )
{
BOARD_COMMIT commit( m_frame );
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( m_frame->GetModel() );
std::vector<std::vector<PCB_TEXT*>> texts;
// Style : Header
std::unique_ptr<PCB_TEXT> headStyle =
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
std::unique_ptr<PCB_TEXT> headStyle = std::make_unique<PCB_TEXT>( footprint );
headStyle->SetLayer( Eco1_User );
headStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) );
headStyle->SetTextThickness( Millimeter2iu( 0.3 ) );
@ -229,8 +224,7 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
// Style : data
std::unique_ptr<PCB_TEXT> dataStyle =
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
std::unique_ptr<PCB_TEXT> dataStyle = std::make_unique<PCB_TEXT>( footprint );
dataStyle->SetLayer( Eco1_User );
dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) );
dataStyle->SetTextThickness( Millimeter2iu( 0.1 ) );
@ -317,7 +311,9 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
t->SetText( ly_name );
}
else
{
t->SetText( stackup_item->GetLayerName() );
}
colLayer.push_back( t );
@ -371,17 +367,17 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
}
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& aOrigin,
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& aOrigin,
PCB_LAYER_ID aLayer,
bool aDrawNow,
wxPoint* tableSize )
VECTOR2I* tableSize )
{
BOARD_COMMIT commit( m_frame );
std::vector<BOARD_ITEM*> objects;
BOARD_DESIGN_SETTINGS& settings = m_frame->GetBoard()->GetDesignSettings();
BOARD_STACKUP& stackup = settings.GetStackupDescriptor();
wxPoint cursorPos = aOrigin;
VECTOR2I cursorPos = aOrigin;
// Style : Section header
std::unique_ptr<PCB_TEXT> headStyle =
@ -530,7 +526,7 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint&
texts.push_back( colbreak );
texts.push_back( colLabel2 );
texts.push_back( colData2 );
wxPoint tableSize2 = wxPoint();
VECTOR2I tableSize2;
std::vector<BOARD_ITEM*> table = initTextTable( texts, cursorPos, Eco1_User, &tableSize2,
false );
@ -701,20 +697,16 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
{
wxPoint tableSize = wxPoint();
VECTOR2I tableSize;
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
layerSet = static_cast<LSET>( layerSet.set( Edge_Cuts ).set( Margin ) );
layerSet = static_cast<LSET>( layerSet.reset( F_Fab ).reset( B_Fab ) );
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
layerSet = static_cast<LSET>( layerSet.set( Edge_Cuts ).set( Margin ) );
layerSet = static_cast<LSET>( layerSet.reset( F_Fab ).reset( B_Fab ) );
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
PCB_LAYER_ID savedLayer = layer;
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
if( ( layerSet & LSET( layer ) ).count() ) // if layer is a forbidden layer
{
m_frame->SetActiveLayer( Cmts_User );
layer = Cmts_User;
}
std::vector<BOARD_ITEM*> table = DrawBoardCharacteristics( wxPoint( 0, 0 ),
m_frame->GetActiveLayer(), false,
@ -766,7 +758,7 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
items.push_back( static_cast<BOARD_ITEM*>( group ) );
if( InteractivePlaceWithPreview( aEvent, items, preview, &layerSet ) == -1 )
m_frame->SetActiveLayer( savedLayer );
m_frame->SetActiveLayer( layer );
else
m_frame->SetActiveLayer( table.front()->GetLayer() );
@ -776,11 +768,11 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent )
{
wxPoint tableSize = wxPoint();
VECTOR2I tableSize;
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
layerSet = static_cast<LSET>( layerSet.set( Edge_Cuts ).set( Margin ) );
layerSet = static_cast<LSET>( layerSet.reset( F_Fab ).reset( B_Fab ) );
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
layerSet = static_cast<LSET>( layerSet.set( Edge_Cuts ).set( Margin ) );
layerSet = static_cast<LSET>( layerSet.reset( F_Fab ).reset( B_Fab ) );
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
PCB_LAYER_ID savedLayer = layer;
@ -791,8 +783,9 @@ int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent )
layer = Cmts_User;
}
std::vector<BOARD_ITEM*> table = DrawSpecificationStackup(
wxPoint( 0, 0 ), m_frame->GetActiveLayer(), false, &tableSize );
std::vector<BOARD_ITEM*> table = DrawSpecificationStackup( VECTOR2I( 0, 0 ),
m_frame->GetActiveLayer(), false,
&tableSize );
std::vector<BOARD_ITEM*> preview;
std::vector<BOARD_ITEM*> items;

View File

@ -285,8 +285,7 @@ void DRAWING_TOOL::UpdateStatusBar() const
else
constrained = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" )
: wxT( "" ) );
m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) : wxT( "" ) );
}
}

View File

@ -86,13 +86,13 @@ public:
/**
*/
std::vector<BOARD_ITEM*> DrawBoardCharacteristics( const wxPoint& origin, PCB_LAYER_ID aLayer,
bool aDrawNow, wxPoint* tablesize );
std::vector<BOARD_ITEM*> DrawBoardCharacteristics( const VECTOR2I& origin, PCB_LAYER_ID aLayer,
bool aDrawNow, VECTOR2I* tablesize );
/**
*/
std::vector<BOARD_ITEM*> DrawSpecificationStackup( const wxPoint& origin, PCB_LAYER_ID aLayer,
bool aDrawNow, wxPoint* tablesize );
std::vector<BOARD_ITEM*> DrawSpecificationStackup( const VECTOR2I& origin, PCB_LAYER_ID aLayer,
bool aDrawNow, VECTOR2I* tablesize );
/**
*/

View File

@ -36,7 +36,6 @@
#include <drawing_sheet/ds_proxy_view_item.h>
#include <kiway.h>
#include <array_creator.h>
#include <pcbnew_settings.h>
#include <status_popup.h>
#include <tool/selection_conditions.h>
#include <tool/tool_manager.h>

View File

@ -594,8 +594,8 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
{
msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey() ) );}
KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey() ) );
}
else
{
msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),

View File

@ -33,7 +33,6 @@
#include <tools/pcb_selection_tool.h>
#include <tools/board_reannotate_tool.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <bitmaps.h>
#include <board_commit.h>
#include <board.h>
#include <board_design_settings.h>
@ -57,8 +56,6 @@
#include <properties.h>
#include <settings/color_settings.h>
#include <tool/tool_manager.h>
#include <footprint_viewer_frame.h>
#include <footprint_edit_frame.h>
#include <widgets/wx_progress_reporters.h>
#include <widgets/infobar.h>
#include <wx/hyperlink.h>
@ -171,7 +168,7 @@ int PCB_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
for( PCB_TRACK* track : board()->Tracks() )
{
if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
if( track->Type() == PCB_VIA_T )
view()->Update( track, KIGFX::REPAINT );
}
@ -587,11 +584,9 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
if( m_isFootprintEditor )
collector.Collect( board, GENERAL_COLLECTOR::FootprintItems,
(wxPoint) aPos, guide );
collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
else
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems,
(wxPoint) aPos, guide );
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
// Remove unselectable items
for( int i = collector.GetCount() - 1; i >= 0; --i )
@ -607,7 +602,6 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
if( m_pickerItem != item )
{
if( m_pickerItem )
selectionTool->UnbrightenItem( m_pickerItem );
@ -714,12 +708,12 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
return 0;
PASTE_MODE pasteMode = PASTE_MODE::KEEP_ANNOTATIONS;
PASTE_MODE mode = PASTE_MODE::KEEP_ANNOTATIONS;
const wxString defaultRef = wxT( "REF**" );
if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
{
DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode, defaultRef );
DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
if( dlg.ShowModal() == wxID_CANCEL )
return 0;
@ -803,18 +797,17 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
delete clipBoard;
placeBoardItems( pastedItems, true, true,
pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
}
else
{
if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS )
if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
{
for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
clipFootprint->SetReference( defaultRef );
}
placeBoardItems( clipBoard, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
placeBoardItems( clipBoard, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
m_frame->GetBoard()->BuildConnectivity();
m_frame->Compile_Ratsnest( true );
@ -835,14 +828,14 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
}
else
{
if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS )
if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
clipFootprint->SetReference( defaultRef );
clipFootprint->SetParent( board() );
pastedItems.push_back( clipFootprint );
}
placeBoardItems( pastedItems, true, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
break;
}
@ -1260,11 +1253,12 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
if( overlap.count() > 0
&& ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
{
constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b,
overlap.CuStack().front() );
PCB_LAYER_ID layer = overlap.CuStack().front();
std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( overlap.CuStack().front() ) );
std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( overlap.CuStack().front() ) );
constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
int actual_clearance = a_shape->GetClearance( b_shape.get() );