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
This commit is contained in:
parent
70ffd971e3
commit
c8e8b71198
|
@ -330,6 +330,7 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
|
||||||
if( !std::isfinite( scale ) )
|
if( !std::isfinite( scale ) )
|
||||||
{
|
{
|
||||||
view->SetCenter( VECTOR2D( 0, 0 ) );
|
view->SetCenter( VECTOR2D( 0, 0 ) );
|
||||||
|
canvas->Refresh();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +359,7 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
|
||||||
|
|
||||||
view->SetScale( scale / margin_scale_factor );
|
view->SetScale( scale / margin_scale_factor );
|
||||||
view->SetCenter( bBox.Centre() );
|
view->SetCenter( bBox.Centre() );
|
||||||
|
canvas->Refresh();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -377,6 +379,7 @@ int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2D scrollbarSize = VECTOR2D( ToVECTOR2D( canvas->GetSize() - canvas->GetClientSize() ) );
|
VECTOR2D scrollbarSize = VECTOR2D( ToVECTOR2D( canvas->GetSize() - canvas->GetClientSize() ) );
|
||||||
VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
|
VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
|
||||||
getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
|
getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
|
||||||
|
canvas->Refresh();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -418,6 +421,8 @@ int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
|
||||||
getView()->SetScale( scale );
|
getView()->SetScale( scale );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->Refresh();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2733,8 +2733,9 @@ void SCH_PAINTER::draw( const SCH_LABEL* aLabel, int aLayer )
|
||||||
void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer )
|
void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer )
|
||||||
{
|
{
|
||||||
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
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() )
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
||||||
draw( &field, aLayer, false );
|
draw( &field, aLayer, false );
|
||||||
|
@ -2748,6 +2749,18 @@ void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer )
|
||||||
|
|
||||||
COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
|
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 )
|
if( m_schematic )
|
||||||
{
|
{
|
||||||
SCH_CONNECTION* conn = nullptr;
|
SCH_CONNECTION* conn = nullptr;
|
||||||
|
@ -2851,53 +2864,14 @@ void SCH_PAINTER::draw( const SCH_SHEET* aSheet, int aLayer )
|
||||||
{
|
{
|
||||||
for( const SCH_FIELD& field : aSheet->GetFields() )
|
for( const SCH_FIELD& field : aSheet->GetFields() )
|
||||||
draw( &field, aLayer, false );
|
draw( &field, aLayer, false );
|
||||||
|
|
||||||
|
for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
|
||||||
|
draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isFieldsLayer( aLayer ) )
|
if( isFieldsLayer( aLayer ) )
|
||||||
return;
|
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 pos = aSheet->GetPosition();
|
||||||
VECTOR2D size = aSheet->GetSize();
|
VECTOR2D size = aSheet->GetSize();
|
||||||
|
|
||||||
|
|
|
@ -1364,7 +1364,8 @@ void SCH_SCREEN::TestDanglingEnds( const SCH_SHEET_PATH* aPath,
|
||||||
{
|
{
|
||||||
std::vector<DANGLING_END_ITEM> endPoints;
|
std::vector<DANGLING_END_ITEM> endPoints;
|
||||||
|
|
||||||
for( SCH_ITEM* item : Items() )
|
auto testDanglingEnds =
|
||||||
|
[&]( SCH_ITEM* item )
|
||||||
{
|
{
|
||||||
if( item->IsConnectable() )
|
if( item->IsConnectable() )
|
||||||
{
|
{
|
||||||
|
@ -1379,6 +1380,12 @@ void SCH_SCREEN::TestDanglingEnds( const SCH_SHEET_PATH* aPath,
|
||||||
(*aChangedHandler)( item );
|
(*aChangedHandler)( item );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for( SCH_ITEM* item : Items() )
|
||||||
|
{
|
||||||
|
testDanglingEnds( item );
|
||||||
|
item->RunOnChildren( testDanglingEnds );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -647,14 +647,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool /* aManual */ )
|
||||||
|
|
||||||
void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
|
void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||||
{
|
{
|
||||||
aCount = 7;
|
aCount = 8;
|
||||||
aLayers[0] = LAYER_HIERLABEL;
|
aLayers[0] = LAYER_DANGLING; // Sheet pins are drawn by their parent sheet, so the
|
||||||
aLayers[1] = LAYER_SHEETNAME;
|
// parent needs to draw to LAYER_DANGLING
|
||||||
aLayers[2] = LAYER_SHEETFILENAME;
|
aLayers[1] = LAYER_HIERLABEL;
|
||||||
aLayers[3] = LAYER_SHEETFIELDS;
|
aLayers[2] = LAYER_SHEETNAME;
|
||||||
aLayers[4] = LAYER_SHEET;
|
aLayers[3] = LAYER_SHEETFILENAME;
|
||||||
aLayers[5] = LAYER_SHEET_BACKGROUND;
|
aLayers[4] = LAYER_SHEETFIELDS;
|
||||||
aLayers[6] = LAYER_SELECTION_SHADOWS;
|
aLayers[5] = LAYER_SHEET;
|
||||||
|
aLayers[6] = LAYER_SHEET_BACKGROUND;
|
||||||
|
aLayers[7] = LAYER_SELECTION_SHADOWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue