From f7ebf2af5e6710887f0bb51a6e5f6ab66ca8d38d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Wed, 22 Apr 2020 21:33:57 -0400 Subject: [PATCH] Add separate color setting for bus junctions Fix plotting and printing to use bus color when connectivity detects that the junction is on a bus. Fixes #4098 --- common/layer_id.cpp | 3 +++ common/settings/color_settings.cpp | 1 + eeschema/connection_graph.cpp | 11 ++++++++++- eeschema/sch_junction.cpp | 14 ++++++-------- eeschema/sch_junction.h | 2 +- eeschema/sch_painter.cpp | 8 +------- eeschema/sch_view.h | 2 +- include/layers_id_colors_and_visibility.h | 1 + 8 files changed, 24 insertions(+), 18 deletions(-) diff --git a/common/layer_id.cpp b/common/layer_id.cpp index 08869497ab..9a1a3bc877 100644 --- a/common/layer_id.cpp +++ b/common/layer_id.cpp @@ -31,6 +31,9 @@ wxString LayerName( SCH_LAYER_ID aLayer ) case LAYER_BUS: return _( "Bus" ); + case LAYER_BUS_JUNCTION: + return _( "Bus Junction" ); + case LAYER_JUNCTION: return _( "Junction" ); diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index b08b64908e..d74e534566 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -65,6 +65,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) ); CLR( "schematic.brightened", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) ); CLR( "schematic.bus", LAYER_BUS, COLOR4D( BLUE ) ); + CLR( "schematic.bus_junction", LAYER_BUS_JUNCTION, COLOR4D( BLUE ) ); CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) ); CLR( "schematic.component_outline", LAYER_DEVICE, COLOR4D( RED ) ); CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) ); diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 8b87bcb375..b0464fc135 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -543,7 +543,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet, } // Bus-to-bus entries are treated just like bus wires - if( connected_item->Type() == SCH_BUS_BUS_ENTRY_T ) + else if( connected_item->Type() == SCH_BUS_BUS_ENTRY_T ) { if( connection_vec.size() < 2 ) { @@ -565,6 +565,15 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet, } } + // Change junctions to be on bus junction layer if they are touching a bus + else if( connected_item->Type() == SCH_JUNCTION_T ) + { + SCH_SCREEN* screen = aSheet.LastScreen(); + SCH_LINE* bus = screen->GetBus( it.first ); + + connected_item->SetLayer( bus ? LAYER_BUS_JUNCTION : LAYER_JUNCTION ); + } + for( auto test_it = primary_it + 1; test_it != connection_vec.end(); test_it++ ) { auto test_item = *test_it; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 1d696d6692..3f548db1dc 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -50,11 +50,11 @@ int SCH_JUNCTION::GetSymbolSize() } -SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : +SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos, SCH_LAYER_ID aLayer ) : SCH_ITEM( NULL, SCH_JUNCTION_T ) { - m_pos = pos; - m_Layer = LAYER_JUNCTION; + m_pos = pos; + m_Layer = aLayer; } @@ -77,7 +77,7 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem ) void SCH_JUNCTION::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 2; - aLayers[0] = LAYER_JUNCTION; + aLayers[0] = m_Layer; aLayers[1] = LAYER_SELECTION_SHADOWS; } @@ -95,10 +95,8 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const void SCH_JUNCTION::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) { - wxDC* DC = aSettings->GetPrintDC(); - SCH_CONNECTION* conn = Connection( *g_CurrentSheet ); - bool isBus = conn && conn->IsBus(); - COLOR4D color = aSettings->GetLayerColor( isBus ? LAYER_BUS : m_Layer ); + wxDC* DC = aSettings->GetPrintDC(); + COLOR4D color = aSettings->GetLayerColor( GetLayer() ); GRFilledCircle( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, GetSymbolSize() / 2, 0, color, color ); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index e449ea0eb2..c85e52d119 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -37,7 +37,7 @@ public: static int g_SymbolSize; // diameter of the junction graphic symbol public: - SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) ); + SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ), SCH_LAYER_ID aLayer = LAYER_JUNCTION ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 6209e0659c..cd8ffdb132 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1160,13 +1160,7 @@ void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer ) if( drawingShadows && !aJct->IsSelected() ) return; - COLOR4D color; - auto conn = aJct->Connection( *g_CurrentSheet ); - - if( conn && conn->IsBus() ) - color = getRenderColor( aJct, LAYER_BUS, drawingShadows ); - else - color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows ); + COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows ); m_gal->SetIsStroke( drawingShadows ); m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) ); diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index d8eb15636e..c60063f596 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -46,7 +46,7 @@ static const LAYER_NUM SCH_LAYER_ORDER[] = LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY, LAYER_ERC_ERR, LAYER_ERC_WARN, LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS, - LAYER_JUNCTION, LAYER_NOCONNECT, + LAYER_BUS_JUNCTION, LAYER_JUNCTION, LAYER_NOCONNECT, LAYER_HIERLABEL, LAYER_WIRE, LAYER_BUS, LAYER_DEVICE, diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 7cffb070a1..1652a46f61 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -270,6 +270,7 @@ enum SCH_LAYER_ID: int LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, LAYER_SCHEMATIC_WORKSHEET, + LAYER_BUS_JUNCTION, SCH_LAYER_ID_END };