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
This commit is contained in:
Jon Evans 2020-04-22 21:33:57 -04:00
parent b1ac504fcd
commit f7ebf2af5e
8 changed files with 24 additions and 18 deletions

View File

@ -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" );

View File

@ -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 ) );

View File

@ -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;

View File

@ -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 );

View File

@ -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.

View File

@ -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 ) );

View File

@ -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,

View File

@ -270,6 +270,7 @@ enum SCH_LAYER_ID: int
LAYER_HIDDEN,
LAYER_SELECTION_SHADOWS,
LAYER_SCHEMATIC_WORKSHEET,
LAYER_BUS_JUNCTION,
SCH_LAYER_ID_END
};