Don't save junction colours when they're inherited.

Also fixes Edit Text & Graphics Properties to be able to clear
colours from junctions.

Fixes https://gitlab.com/kicad/code/kicad/issues/6018
This commit is contained in:
Jeff Young 2020-11-03 13:39:31 +00:00
parent 6a3c868db5
commit bd103c133d
5 changed files with 42 additions and 10 deletions

View File

@ -28,6 +28,7 @@
#include <sch_connection.h>
#include <sch_edit_frame.h>
#include <sch_line.h>
#include <sch_junction.h>
#include <sch_sheet.h>
#include <schematic.h>
#include <advanced_config.h>
@ -110,6 +111,11 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_
m_lineStyle->Append( DEFAULT_STYLE );
m_lineStyle->Append( INDETERMINATE_ACTION );
m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
m_colorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
m_bgColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
m_bgColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
m_sdbSizerButtonsOK->SetDefault();
FinishDialogSettings();
@ -216,9 +222,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::OnUpdateUI( wxUpdateUIEvent& )
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aSheetPath,
SCH_ITEM* aItem )
{
auto eda_text = dynamic_cast<EDA_TEXT*>( aItem );
auto sch_text = dynamic_cast<SCH_TEXT*>( aItem );
auto lineItem = dynamic_cast<SCH_LINE*>( aItem );
EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem );
SCH_TEXT* sch_text = dynamic_cast<SCH_TEXT*>( aItem );
SCH_LINE* lineItem = dynamic_cast<SCH_LINE*>( aItem );
m_parent->SaveCopyInUndoList( aSheetPath.LastScreen(), aItem, UNDO_REDO::CHANGED, m_hasChange );
@ -418,6 +424,32 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
}
}
}
else if( aItem->Type() == SCH_JUNCTION_T )
{
SCH_JUNCTION* junction = static_cast<SCH_JUNCTION*>( aItem );
for( SCH_ITEM* item : junction->ConnectedItems( aSheetPath ) )
{
if( item->GetLayer() == LAYER_BUS )
{
if( m_buses->GetValue() && m_setColor->GetValue() )
{
junction->SetColor( m_colorSwatch->GetSwatchColor() );
m_hasChange = true;
}
break;
}
else if( item->GetLayer() == LAYER_WIRE )
{
if( m_wires->GetValue() && m_setColor->GetValue() )
{
junction->SetColor( m_colorSwatch->GetSwatchColor() );
m_hasChange = true;
}
break;
}
}
}
else if( m_wires->GetValue() && aItem->IsType( wireTypes ) )
processItem( aSheetPath, aItem );
else if( m_buses->GetValue() && aItem->IsType( busTypes ) )

View File

@ -96,7 +96,7 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const
void SCH_JUNCTION::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = GetColor();
COLOR4D color = GetJunctionColor();
if( color == COLOR4D::UNSPECIFIED )
color = aSettings->GetLayerColor( GetLayer() );
@ -155,7 +155,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) const
#endif
COLOR4D SCH_JUNCTION::GetColor() const
COLOR4D SCH_JUNCTION::GetJunctionColor() const
{
if( m_color != COLOR4D::UNSPECIFIED )
return m_color;
@ -226,7 +226,7 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const
void SCH_JUNCTION::Plot( PLOTTER* aPlotter )
{
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
COLOR4D color = GetColor();
COLOR4D color = GetJunctionColor();
if( color == COLOR4D::UNSPECIFIED )
color = settings->GetLayerColor( GetLayer() );

View File

@ -100,7 +100,9 @@ public:
int GetDiameter() const;
void SetDiameter( int aDiameter ) { m_diameter = aDiameter; }
COLOR4D GetColor() const;
COLOR4D GetJunctionColor() const;
COLOR4D GetColor() const { return m_color; }
void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;

View File

@ -280,7 +280,7 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
}
else if( aItem->Type() == SCH_JUNCTION_T )
{
COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetColor();
COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetJunctionColor();
if( junctionColor != COLOR4D::UNSPECIFIED )
color = junctionColor;

View File

@ -277,8 +277,6 @@ bool SCH_EDIT_TOOL::Init()
auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
auto singleComponentCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_COMPONENT_T );
auto wireSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T );
auto busSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T );
auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
//
// Add edit actions to the move tool menu