From bd103c133d9d905dbeea1e5ba8c2a4a0088eeaac Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 3 Nov 2020 13:39:31 +0000 Subject: [PATCH] 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 --- .../dialog_global_edit_text_and_graphics.cpp | 38 +++++++++++++++++-- eeschema/sch_junction.cpp | 6 +-- eeschema/sch_junction.h | 4 +- eeschema/sch_painter.cpp | 2 +- eeschema/tools/sch_edit_tool.cpp | 2 - 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp index b6eb83b5b9..51f228f03a 100644 --- a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -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( aItem ); - auto sch_text = dynamic_cast( aItem ); - auto lineItem = dynamic_cast( aItem ); + EDA_TEXT* eda_text = dynamic_cast( aItem ); + SCH_TEXT* sch_text = dynamic_cast( aItem ); + SCH_LINE* lineItem = dynamic_cast( 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( 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 ) ) diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 5dbf3bf448..29ad4acceb 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -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( aPlotter->RenderSettings() ); - COLOR4D color = GetColor(); + COLOR4D color = GetJunctionColor(); if( color == COLOR4D::UNSPECIFIED ) color = settings->GetLayerColor( GetLayer() ); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index b1ab6fe8c1..54b9b10ba5 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -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; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 73bec80027..792dafa0fe 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -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( aItem )->GetColor(); + COLOR4D junctionColor = static_cast( aItem )->GetJunctionColor(); if( junctionColor != COLOR4D::UNSPECIFIED ) color = junctionColor; diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 968fd74265..98446e4bd5 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -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