diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index 2117bbbac2..d2fe414d14 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -25,6 +25,7 @@ #include <string_utils.h> #include <board_commit.h> #include <pcb_edit_frame.h> +#include <footprint_edit_frame.h> #include <pcb_layer_box_selector.h> #include <pcbnew.h> #include <board.h> @@ -37,6 +38,7 @@ #include <widgets/unit_binder.h> #include <tool/tool_manager.h> #include <tools/global_edit_tool.h> +#include <tools/footprint_editor_control.h> #include <dialog_global_edit_text_and_graphics_base.h> @@ -81,9 +83,10 @@ static bool g_filterSelected = false; class DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS : public DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE { - PCB_EDIT_FRAME* m_parent; + PCB_BASE_EDIT_FRAME* m_parent; BOARD_DESIGN_SETTINGS* m_brdSettings; PCB_SELECTION m_selection; + bool m_isBoardEditor; UNIT_BINDER m_lineWidth; UNIT_BINDER m_textWidth; @@ -91,7 +94,7 @@ class DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS : public DIALOG_GLOBAL_EDIT_TEXT_AND_ UNIT_BINDER m_thickness; public: - DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_EDIT_FRAME* parent ); + DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_BASE_EDIT_FRAME* parent ); ~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS() override; protected: @@ -119,7 +122,7 @@ protected: }; -DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_EDIT_FRAME* parent ) : +DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_BASE_EDIT_FRAME* parent ) : DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE( parent ), m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits ), m_textWidth( parent, m_SizeXlabel, m_SizeXCtrl, m_SizeXunit ), @@ -128,6 +131,21 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_ { m_parent = parent; m_brdSettings = &m_parent->GetDesignSettings(); + m_isBoardEditor = dynamic_cast<PCB_EDIT_FRAME*>( m_parent ) != nullptr; + + if( !m_isBoardEditor ) + { + m_otherFields->SetLabel( _( "Other text items" ) ); + m_footprintGraphics->SetLabel( _( "Graphic items" ) ); + + m_boardText->Show( false ); + m_boardGraphics->Show( false ); + + m_referenceFilterOpt->Show( false ); + m_referenceFilter->Show( false ); + m_footprintFilterOpt->Show( false ); + m_footprintFilter->Show( false ); + } m_layerFilter->SetBoardFrame( m_parent ); m_layerFilter->SetLayersHotkeys( false ); @@ -153,15 +171,24 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS() g_modifyValues = m_values->GetValue(); g_modifyOtherFields = m_otherFields->GetValue(); g_modifyFootprintGraphics = m_footprintGraphics->GetValue(); - g_modifyBoardText = m_boardText->GetValue(); - g_modifyBoardGraphics = m_boardGraphics->GetValue(); + + if( m_isBoardEditor ) + { + g_modifyBoardText = m_boardText->GetValue(); + g_modifyBoardGraphics = m_boardGraphics->GetValue(); + } g_filterByLayer = m_layerFilterOpt->GetValue(); g_layerFilter = m_layerFilter->GetLayerSelection(); - g_filterByReference = m_referenceFilterOpt->GetValue(); - g_referenceFilter = m_referenceFilter->GetValue(); - g_filterByFootprint = m_footprintFilterOpt->GetValue(); - g_footprintFilter = m_footprintFilter->GetValue(); + + if( m_isBoardEditor ) + { + g_filterByReference = m_referenceFilterOpt->GetValue(); + g_referenceFilter = m_referenceFilter->GetValue(); + g_filterByFootprint = m_footprintFilterOpt->GetValue(); + g_footprintFilter = m_footprintFilter->GetValue(); + } + g_filterSelected = m_selectedItemsFilter->GetValue(); } @@ -175,17 +202,25 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow() m_values->SetValue( g_modifyValues ); m_otherFields->SetValue( g_modifyOtherFields ); m_footprintGraphics->SetValue( g_modifyFootprintGraphics ); - m_boardText->SetValue( g_modifyBoardText ); - m_boardGraphics->SetValue( g_modifyBoardGraphics ); + + if( m_isBoardEditor ) + { + m_boardText->SetValue( g_modifyBoardText ); + m_boardGraphics->SetValue( g_modifyBoardGraphics ); + } if( m_layerFilter->SetLayerSelection( g_layerFilter ) != wxNOT_FOUND ) m_layerFilterOpt->SetValue( g_filterByLayer ); - // SetValue() generates events, ChangeValue() does not - m_referenceFilter->ChangeValue( g_referenceFilter ); - m_referenceFilterOpt->SetValue( g_filterByReference ); - m_footprintFilter->ChangeValue( g_footprintFilter ); - m_footprintFilterOpt->SetValue( g_filterByFootprint ); + if( m_isBoardEditor ) + { + // SetValue() generates events, ChangeValue() does not + m_referenceFilter->ChangeValue( g_referenceFilter ); + m_referenceFilterOpt->SetValue( g_filterByReference ); + m_footprintFilter->ChangeValue( g_footprintFilter ); + m_footprintFilterOpt->SetValue( g_filterByFootprint ); + } + m_selectedItemsFilter->SetValue( g_filterSelected ); m_lineWidth.SetValue( INDETERMINATE_ACTION ); @@ -387,26 +422,29 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOA return; } - if( m_referenceFilterOpt->GetValue() && !m_referenceFilter->GetValue().IsEmpty() ) + if( m_isBoardEditor ) { - FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParent() ); - - if( fp ) + if( m_referenceFilterOpt->GetValue() && !m_referenceFilter->GetValue().IsEmpty() ) { - if( !WildCompareString( m_referenceFilter->GetValue(), fp->GetReference(), false ) ) - return; + FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParent() ); + + if( fp ) + { + if( !WildCompareString( m_referenceFilter->GetValue(), fp->GetReference(), false ) ) + return; + } } + + if( m_footprintFilterOpt->GetValue() && !m_footprintFilter->GetValue().IsEmpty() ) + { + FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParent() ); + + if( fp ) + { + if( !WildCompareString( m_footprintFilter->GetValue(), fp->GetFPID().Format(), false ) ) + return; + } } - - if( m_footprintFilterOpt->GetValue() && !m_footprintFilter->GetValue().IsEmpty() ) - { - FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParent() ); - - if( fp ) - { - if( !WildCompareString( m_footprintFilter->GetValue(), fp->GetFPID().Format(), false ) ) - return; - } } processItem( aCommit, aItem ); @@ -456,20 +494,23 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() } } - // Go through the PCB text & graphic items - for( BOARD_ITEM* boardItem : m_parent->GetBoard()->Drawings() ) + if( m_isBoardEditor ) { - KICAD_T itemType = boardItem->Type(); + // Go through the PCB text & graphic items + for( BOARD_ITEM* boardItem : m_parent->GetBoard()->Drawings() ) + { + KICAD_T itemType = boardItem->Type(); - if( itemType == PCB_TEXT_T ) - { - if( m_boardText->GetValue() ) - visitItem( commit, boardItem ); - } - else if( itemType == PCB_SHAPE_T || BaseType( itemType ) == PCB_DIMENSION_T ) - { - if( m_boardGraphics->GetValue() ) - visitItem( commit, boardItem ); + if( itemType == PCB_TEXT_T ) + { + if( m_boardText->GetValue() ) + visitItem( commit, boardItem ); + } + else if( itemType == PCB_SHAPE_T || BaseType( itemType ) == PCB_DIMENSION_T ) + { + if( m_boardGraphics->GetValue() ) + visitItem( commit, boardItem ); + } } } @@ -490,3 +531,13 @@ int GLOBAL_EDIT_TOOL::EditTextAndGraphics( const TOOL_EVENT& aEvent ) } +int FOOTPRINT_EDITOR_CONTROL::EditTextAndGraphics( const TOOL_EVENT& aEvent ) +{ + FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>(); + DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS dlg( editFrame ); + + dlg.ShowModal(); + return 0; +} + + diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 0a4c317a65..ea8aec71bb 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -1095,10 +1095,6 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) ); mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) ); - mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( cond.HasItems() ) ); - mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( cond.HasItems() ) ); - - auto highContrastCond = [this]( const SELECTION& ) { @@ -1130,10 +1126,14 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) ); mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) ); - mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) ); - mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) ); mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) ); + mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) ); + mgr->SetConditions( PCB_ACTIONS::editTextAndGraphics, ENABLE( haveFootprintCond ) ); + mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( haveFootprintCond ) ); + mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( haveFootprintCond ) ); + mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) ); + // Only enable a tool if the part is edtable #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \ diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 7fef7fd9ac..e68bf39b09 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -110,6 +110,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() editMenu->Add( ACTIONS::selectAll ); editMenu->AppendSeparator(); + editMenu->Add( PCB_ACTIONS::editTextAndGraphics ); editMenu->Add( PCB_ACTIONS::defaultPadProperties ); diff --git a/pcbnew/tools/footprint_editor_control.cpp b/pcbnew/tools/footprint_editor_control.cpp index 1d6b879ffc..3ccc3af1a1 100644 --- a/pcbnew/tools/footprint_editor_control.cpp +++ b/pcbnew/tools/footprint_editor_control.cpp @@ -616,6 +616,7 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions() Go( &FOOTPRINT_EDITOR_CONTROL::ImportFootprint, PCB_ACTIONS::importFootprint.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ExportFootprint, PCB_ACTIONS::exportFootprint.MakeEvent() ); + Go( &FOOTPRINT_EDITOR_CONTROL::EditTextAndGraphics, PCB_ACTIONS::editTextAndGraphics.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::CleanupGraphics, PCB_ACTIONS::cleanupGraphics.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::CheckFootprint, PCB_ACTIONS::checkFootprint.MakeEvent() ); diff --git a/pcbnew/tools/footprint_editor_control.h b/pcbnew/tools/footprint_editor_control.h index efbb9b4788..a32aa9b4aa 100644 --- a/pcbnew/tools/footprint_editor_control.h +++ b/pcbnew/tools/footprint_editor_control.h @@ -68,11 +68,12 @@ public: int ToggleLayersManager( const TOOL_EVENT& aEvent ); int Properties( const TOOL_EVENT& aEvent ); - int CleanupGraphics( const TOOL_EVENT& aEvent ); + int EditTextAndGraphics( const TOOL_EVENT& aEvent ); int CheckFootprint( const TOOL_EVENT& aEvent ); void DestroyCheckerDialog(); + int CleanupGraphics( const TOOL_EVENT& aEvent ); int RepairFootprint( const TOOL_EVENT& aEvent ); /**