diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index a577c16eab..7231d98f52 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -238,11 +238,12 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( !track->IsOnLayer( layer ) ) continue; - // Skip vias annulus when not connected on this layer (if removing is enabled) - const PCB_VIA *via = dyn_cast< const PCB_VIA*>( track ); - - if( via && IsCopperLayer( layer ) && !via->FlashLayer( layer ) ) + // Skip vias annulus when not flashed on this layer + if( track->Type() == PCB_VIA_T + && !static_cast( track )->FlashLayer( layer ) ) + { continue; + } // Add object item to layer container createTrack( track, layerContainer ); @@ -431,11 +432,12 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( !track->IsOnLayer( layer ) ) continue; - // Skip vias annulus when not connected on this layer (if removing is enabled) - const PCB_VIA *via = dyn_cast( track ); - - if( via && !via->FlashLayer( layer ) && IsCopperLayer( layer ) ) + // Skip vias annulus when not flashed on this layer + if( track->Type() == PCB_VIA_T + && !static_cast( track )->FlashLayer( layer ) ) + { continue; + } // Add the track/via contour track->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE ); diff --git a/eeschema/sch_commit.cpp b/eeschema/sch_commit.cpp index c901066baa..9d7b9c773d 100644 --- a/eeschema/sch_commit.cpp +++ b/eeschema/sch_commit.cpp @@ -372,11 +372,13 @@ void SCH_COMMIT::Push( const wxString& aMessage, int aCommitFlags ) EDA_ITEM* SCH_COMMIT::parentObject( EDA_ITEM* aItem ) const { - if( SCH_SYMBOL* parentSymbol = dyn_cast( aItem->GetParent() ) ) - return parentSymbol; + EDA_ITEM* parent = aItem->GetParent(); - if( LIB_SYMBOL* parentSymbol = dyn_cast( aItem->GetParent() ) ) - return parentSymbol; + if( parent && parent->Type() == SCH_SYMBOL_T ) + return parent; + + if( parent && parent->Type() == LIB_SYMBOL_T ) + return parent; if( m_isLibEditor ) return static_cast( m_toolMgr->GetToolHolder() )->GetCurSymbol(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 32027af0b7..db318c192d 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1740,29 +1740,25 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL for( VECTOR2I& pt: pts ) { - for( SCH_ITEM* item : GetScreen()->Items().Overlapping(pt ) ) + for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) ) { - if( !item->IsConnectable() ) - continue; - - if( SCH_LINE* line = dyn_cast( item ) ) + if( item->Type() == SCH_LINE_T ) { - if( line->HitTest( pt ) ) - { + if( item->HitTest( pt ) ) changed_items.insert( item ); - continue; - } } - - if( SCH_SYMBOL* sym = dyn_cast( item ) ) + else if( item->Type() == SCH_SYMBOL_T ) { - std::vector pins = sym->GetPins(); - changed_items.insert( pins.begin(), pins.end() ); - continue; - } + SCH_SYMBOL* symbol = static_cast( item ); + std::vector pins = symbol->GetPins(); - if( item->IsConnected( pt ) ) - changed_items.insert( item ); + changed_items.insert( pins.begin(), pins.end() ); + } + else if( item->IsConnectable() ) + { + if( item->IsConnected( pt ) ) + changed_items.insert( item ); + } } } diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 391f41e2ca..866818b177 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -284,8 +284,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) if( status == UNDO_REDO::NEWITEM ) { // If we are removing the current sheet, get out first - if( SCH_SHEET* sheet = dyn_cast( eda_item ) ) + if( eda_item->Type() == SCH_SHEET_T ) { + SCH_SHEET* sheet = static_cast( eda_item ) ) + if( sheet->GetScreen() == GetScreen() ) GetToolManager()->RunAction( EE_ACTIONS::leaveSheet ); } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 26aeee5c25..73566099eb 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1371,7 +1371,7 @@ bool EE_SELECTION_TOOL::selectMultiple() [&]( SCH_ITEM* aChild ) { // Filter pins by unit - if( SCH_PIN* pin = dyn_cast( aChild ) ) + if( SCH_PIN* pin = dynamic_cast( aChild ) ) { int unit = pin->GetLibPin()->GetUnit(); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 0ffd19a493..fe809baf74 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2366,8 +2366,10 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) { - if( SCH_LINE* line = dyn_cast( item ) ) + if( item->Type() == SCH_LINE_T ) { + SCH_LINE* line = static_cast( item ); + if( !line->IsEndPoint( cursorPos ) ) lines.push_back( line ); } @@ -2535,21 +2537,23 @@ int SCH_EDIT_TOOL::SetAttribute( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) { - if( SCH_SYMBOL* sym = dyn_cast( item ) ) + if( item->Type() == SCH_SYMBOL_T ) { - commit.Modify( sym, m_frame->GetScreen() ); + SCH_SYMBOL* symbol = static_cast( item ); + + commit.Modify( symbol, m_frame->GetScreen() ); if( aEvent.IsAction( &EE_ACTIONS::setDNP ) ) - sym->SetDNP( true ); + symbol->SetDNP( true ); if( aEvent.IsAction( &EE_ACTIONS::setExcludeFromSimulation ) ) - sym->SetExcludeFromSim( true ); + symbol->SetExcludeFromSim( true ); if( aEvent.IsAction( &EE_ACTIONS::setExcludeFromBOM ) ) - sym->SetExcludedFromBOM( true ); + symbol->SetExcludedFromBOM( true ); if( aEvent.IsAction( &EE_ACTIONS::setExcludeFromBoard ) ) - sym->SetExcludedFromBoard( true ); + symbol->SetExcludedFromBoard( true ); } } @@ -2568,21 +2572,23 @@ int SCH_EDIT_TOOL::UnsetAttribute( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) { - if( SCH_SYMBOL* sym = dyn_cast( item ) ) + if( item->Type() == SCH_SYMBOL_T ) { - commit.Modify( sym, m_frame->GetScreen() ); + SCH_SYMBOL* symbol = static_cast( item ); + + commit.Modify( symbol, m_frame->GetScreen() ); if( aEvent.IsAction( &EE_ACTIONS::unsetDNP ) ) - sym->SetDNP( false ); + symbol->SetDNP( false ); if( aEvent.IsAction( &EE_ACTIONS::unsetExcludeFromSimulation ) ) - sym->SetExcludeFromSim( false ); + symbol->SetExcludeFromSim( false ); if( aEvent.IsAction( &EE_ACTIONS::unsetExcludeFromBOM ) ) - sym->SetExcludedFromBOM( false ); + symbol->SetExcludedFromBOM( false ); if( aEvent.IsAction( &EE_ACTIONS::unsetExcludeFromBoard ) ) - sym->SetExcludedFromBoard( false ); + symbol->SetExcludedFromBoard( false ); } } @@ -2601,21 +2607,23 @@ int SCH_EDIT_TOOL::ToggleAttribute( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) { - if( SCH_SYMBOL* sym = dyn_cast( item ) ) + if( item->Type() == SCH_SYMBOL_T ) { - commit.Modify( sym, m_frame->GetScreen() ); + SCH_SYMBOL* symbol = static_cast( item ); + + commit.Modify( symbol, m_frame->GetScreen() ); if( aEvent.IsAction( &EE_ACTIONS::toggleDNP ) ) - sym->SetDNP( !sym->GetDNP() ); + symbol->SetDNP( !symbol->GetDNP() ); if( aEvent.IsAction( &EE_ACTIONS::toggleExcludeFromSimulation ) ) - sym->SetExcludeFromSim( !sym->GetExcludeFromSim() ); + symbol->SetExcludeFromSim( !symbol->GetExcludeFromSim() ); if( aEvent.IsAction( &EE_ACTIONS::toggleExcludeFromBOM ) ) - sym->SetExcludedFromBOM( !sym->GetExcludedFromBOM() ); + symbol->SetExcludedFromBOM( !symbol->GetExcludedFromBOM() ); if( aEvent.IsAction( &EE_ACTIONS::toggleExcludeFromBoard ) ) - sym->SetExcludedFromBoard( !sym->GetExcludedFromBoard() ); + symbol->SetExcludedFromBoard( !symbol->GetExcludedFromBoard() ); } } diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 96a7b45546..ae38d61f58 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -1908,7 +1908,7 @@ std::tuple BOARD::GetTrackLength( const PCB_TRACK& aTrack ) if( !inPad ) length += segLen + segInPadLen; } - else if( PAD* pad = dyn_cast( item ) ) + else if( PAD* pad = dynamic_cast( item ) ) { package_length += pad->GetPadToDieLength(); } diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 545378c4c7..70f5b2722d 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -124,7 +124,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri clone = static_cast( item->Clone() ); // If it is only a footprint, clear the nets from the pads - if( PAD* pad = dyn_cast( clone ) ) + if( PAD* pad = dynamic_cast( clone ) ) pad->SetNetCode( 0 ); // Don't copy group membership information for the 1st level objects being copied diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index ff62634367..b31acf1d2d 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -1388,7 +1388,7 @@ int BOARD_EDITOR_CONTROL::ZoneDuplicate( const TOOL_EVENT& aEvent ) if( selection.Size() != 1 ) return 0; - ZONE* oldZone = dyn_cast( selection[0] ); + ZONE* oldZone = dynamic_cast( selection[0] ); if( !oldZone ) return 0;