TestDanglingEnds needs to test sheet pins as well.
Also fixes a bug where zooming doesn't get a redraw until mouse moves.
Also fixes a couple of bugs where dangling markers on SCH_SHEET_PINs
and SCH_HIERLABELs weren't getting drawn.
Also simplifies drawing algorithm by removing aesthetic offset (which
wasn't implemented when pin is drawn as part of selection VIEW_GROUP).
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15129
(cherry picked from commit c8e8b71198
)
This commit is contained in:
parent
fd049ef510
commit
f3dd5b73f8
|
@ -327,6 +327,7 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
|
|||
if( !std::isfinite( scale ) )
|
||||
{
|
||||
view->SetCenter( VECTOR2D( 0, 0 ) );
|
||||
canvas->Refresh();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -355,6 +356,7 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
|
|||
|
||||
view->SetScale( scale / margin_scale_factor );
|
||||
view->SetCenter( bBox.Centre() );
|
||||
canvas->Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -374,6 +376,7 @@ int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent )
|
|||
VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
|
||||
VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
|
||||
getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
|
||||
canvas->Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,6 +418,8 @@ int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
|
|||
getView()->SetScale( scale );
|
||||
}
|
||||
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2578,8 +2578,9 @@ void SCH_PAINTER::draw( const SCH_LABEL *aLabel, int aLayer )
|
|||
void SCH_PAINTER::draw( const SCH_HIERLABEL *aLabel, int aLayer )
|
||||
{
|
||||
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
||||
bool drawingDangling = aLayer == LAYER_DANGLING;
|
||||
|
||||
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
||||
if( !( drawingShadows || drawingDangling ) || eeconfig()->m_Selection.draw_selected_children )
|
||||
{
|
||||
for( const SCH_FIELD& field : aLabel->GetFields() )
|
||||
draw( &field, aLayer, false );
|
||||
|
@ -2593,6 +2594,18 @@ void SCH_PAINTER::draw( const SCH_HIERLABEL *aLabel, int aLayer )
|
|||
|
||||
COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
|
||||
|
||||
if( drawingDangling )
|
||||
{
|
||||
if( aLabel->IsDangling() )
|
||||
{
|
||||
drawDanglingSymbol( aLabel->GetTextPos(), color,
|
||||
schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE / 2 ), true,
|
||||
drawingShadows, aLabel->IsBrightened() );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_schematic )
|
||||
{
|
||||
SCH_CONNECTION* conn = nullptr;
|
||||
|
@ -2693,53 +2706,14 @@ void SCH_PAINTER::draw( const SCH_SHEET *aSheet, int aLayer )
|
|||
{
|
||||
for( const SCH_FIELD& field : aSheet->GetFields() )
|
||||
draw( &field, aLayer, false );
|
||||
|
||||
for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
|
||||
draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
|
||||
}
|
||||
|
||||
if( isFieldsLayer( aLayer ) )
|
||||
return;
|
||||
|
||||
if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
|
||||
{
|
||||
for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
|
||||
{
|
||||
if( drawingShadows )
|
||||
{
|
||||
if( ( aSheet->IsBrightened() || aSheet->IsSelected() )
|
||||
&& eeconfig()->m_Selection.draw_selected_children )
|
||||
{
|
||||
// fall through to draw
|
||||
}
|
||||
else if( sheetPin->IsBrightened() || sheetPin->IsSelected() )
|
||||
{
|
||||
// fall through to draw
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
|
||||
VECTOR2I initial_pos = sheetPin->GetTextPos();
|
||||
VECTOR2I offset_pos = initial_pos;
|
||||
|
||||
// For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
|
||||
switch( sheetPin->GetSide() )
|
||||
{
|
||||
case SHEET_SIDE::TOP: offset_pos.y += KiROUND( width / 2.0 ); break;
|
||||
case SHEET_SIDE::BOTTOM: offset_pos.y -= KiROUND( width / 2.0 ); break;
|
||||
case SHEET_SIDE::RIGHT: offset_pos.x -= KiROUND( width / 2.0 ); break;
|
||||
case SHEET_SIDE::LEFT: offset_pos.x += KiROUND( width / 2.0 ); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
sheetPin->SetTextPos( offset_pos );
|
||||
draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
|
||||
m_gal->DrawLine( offset_pos, initial_pos );
|
||||
sheetPin->SetTextPos( initial_pos );
|
||||
}
|
||||
}
|
||||
|
||||
VECTOR2D pos = aSheet->GetPosition();
|
||||
VECTOR2D size = aSheet->GetSize();
|
||||
|
||||
|
|
|
@ -1357,21 +1357,28 @@ void SCH_SCREEN::TestDanglingEnds( const SCH_SHEET_PATH* aPath,
|
|||
{
|
||||
std::vector<DANGLING_END_ITEM> endPoints;
|
||||
|
||||
auto testDanglingEnds =
|
||||
[&]( SCH_ITEM* item )
|
||||
{
|
||||
if( item->IsConnectable() )
|
||||
{
|
||||
endPoints.clear();
|
||||
|
||||
for( SCH_ITEM* overlapping : Items().Overlapping( item->GetBoundingBox() ) )
|
||||
overlapping->GetEndPoints( endPoints );
|
||||
|
||||
if( item->UpdateDanglingState( endPoints, aPath ) )
|
||||
{
|
||||
if( aChangedHandler )
|
||||
(*aChangedHandler)( item );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for( SCH_ITEM* item : Items() )
|
||||
{
|
||||
if( item->IsConnectable() )
|
||||
{
|
||||
endPoints.clear();
|
||||
|
||||
for( SCH_ITEM* overlapping : Items().Overlapping( item->GetBoundingBox() ) )
|
||||
overlapping->GetEndPoints( endPoints );
|
||||
|
||||
if( item->UpdateDanglingState( endPoints, aPath ) )
|
||||
{
|
||||
if( aChangedHandler )
|
||||
(*aChangedHandler)( item );
|
||||
}
|
||||
}
|
||||
testDanglingEnds( item );
|
||||
item->RunOnChildren( testDanglingEnds );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -648,14 +648,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool /* aManual */ )
|
|||
|
||||
void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 7;
|
||||
aLayers[0] = LAYER_HIERLABEL;
|
||||
aLayers[1] = LAYER_SHEETNAME;
|
||||
aLayers[2] = LAYER_SHEETFILENAME;
|
||||
aLayers[3] = LAYER_SHEETFIELDS;
|
||||
aLayers[4] = LAYER_SHEET;
|
||||
aLayers[5] = LAYER_SHEET_BACKGROUND;
|
||||
aLayers[6] = LAYER_SELECTION_SHADOWS;
|
||||
aCount = 8;
|
||||
aLayers[0] = LAYER_DANGLING; // Sheet pins are drawn by their parent sheet, so the
|
||||
// parent needs to draw to LAYER_DANGLING
|
||||
aLayers[1] = LAYER_HIERLABEL;
|
||||
aLayers[2] = LAYER_SHEETNAME;
|
||||
aLayers[3] = LAYER_SHEETFILENAME;
|
||||
aLayers[4] = LAYER_SHEETFIELDS;
|
||||
aLayers[5] = LAYER_SHEET;
|
||||
aLayers[6] = LAYER_SHEET_BACKGROUND;
|
||||
aLayers[7] = LAYER_SELECTION_SHADOWS;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue