Repair is-selected logic in various global editors.

Fixes https://gitlab.com/kicad/code/kicad/issues/9090
This commit is contained in:
Jeff Young 2021-09-04 18:05:57 +01:00
parent 6960ac04d4
commit 6818539f6d
3 changed files with 55 additions and 23 deletions

View File

@ -95,7 +95,7 @@ protected:
bool TransferDataFromWindow() override;
void visitItem( const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem );
void processItem( const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem, SCH_ITEM* aParentItem );
void processItem( const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem );
};
@ -230,13 +230,12 @@ 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,
SCH_ITEM* aParentItem = nullptr )
SCH_ITEM* aItem )
{
if( m_selectedFilterOpt->GetValue() && !m_selection.Contains( aItem )
&& ( aParentItem == nullptr || !m_selection.Contains( aParentItem ) ) )
if( m_selectedFilterOpt->GetValue() )
{
return;
if( !aItem->IsSelected() && ( !aItem->GetParent() || !aItem->GetParent()->IsSelected() ) )
return;
}
EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem );
@ -358,10 +357,10 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
if( m_references->GetValue() )
processItem( aSheetPath, symbol->GetField( REFERENCE_FIELD ), aItem );
processItem( aSheetPath, symbol->GetField( REFERENCE_FIELD ) );
if( m_values->GetValue() )
processItem( aSheetPath, symbol->GetField( VALUE_FIELD ), aItem );
processItem( aSheetPath, symbol->GetField( VALUE_FIELD ) );
if( m_otherFields->GetValue() )
{
@ -373,7 +372,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty()
|| WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) )
{
processItem( aSheetPath, &field, aItem );
processItem( aSheetPath, &field );
}
}
}
@ -383,7 +382,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
if( m_sheetTitles->GetValue() )
processItem( aSheetPath, &sheet->GetFields()[SHEETNAME], aItem );
processItem( aSheetPath, &sheet->GetFields()[SHEETNAME] );
if( m_sheetFields->GetValue() )
{
@ -397,7 +396,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty()
|| WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) )
{
processItem( aSheetPath, &field, aItem );
processItem( aSheetPath, &field );
}
}
}

View File

@ -30,6 +30,7 @@
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <pcb_group.h>
#include <pcb_dimension.h>
#include <fp_shape.h>
#include <pcb_text.h>
@ -113,7 +114,7 @@ protected:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void visitItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem, FOOTPRINT* aParentItem );
void visitItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem );
void processItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem );
};
@ -348,12 +349,29 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B
}
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem,
FOOTPRINT* aParentItem = nullptr )
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem )
{
if( m_selectedItemsFilter->GetValue() && !m_selection.Contains( aItem )
&& ( aParentItem == nullptr || !m_selection.Contains( aParentItem ) ) )
return;
if( m_selectedItemsFilter->GetValue() )
{
BOARD_ITEM* candidate = aItem;
if( !candidate->IsSelected() )
{
if( candidate->GetParent() && candidate->GetParent()->Type() == PCB_FOOTPRINT_T )
candidate = candidate->GetParent();
}
if( !candidate->IsSelected() )
{
candidate = candidate->GetParentGroup();
while( candidate && !candidate->IsSelected() )
candidate = candidate->GetParentGroup();
if( !candidate )
return;
}
}
if( m_layerFilterOpt->GetValue() && m_layerFilter->GetLayerSelection() != UNDEFINED_LAYER )
{
@ -401,10 +419,10 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
for( FOOTPRINT* fp : m_parent->GetBoard()->Footprints() )
{
if( m_references->GetValue() )
visitItem( commit, &fp->Reference(), fp );
visitItem( commit, &fp->Reference() );
if( m_values->GetValue() )
visitItem( commit, &fp->Value(), fp );
visitItem( commit, &fp->Value() );
// Go through all other footprint items
for( BOARD_ITEM* boardItem : fp->GraphicalItems() )
@ -416,16 +434,16 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
const wxString text = dynamic_cast<EDA_TEXT*>( boardItem )->GetText();
if( m_references->GetValue() && text == wxT( "${REFERENCE}" ) )
visitItem( commit, boardItem, fp );
visitItem( commit, boardItem );
else if( m_values->GetValue() && text == wxT( "${VALUE}" ) )
visitItem( commit, boardItem, fp );
visitItem( commit, boardItem );
else if( m_otherFields->GetValue() )
visitItem( commit, boardItem, fp );
visitItem( commit, boardItem );
}
else if( boardItem->Type() == PCB_FP_SHAPE_T )
{
if( m_footprintGraphics->GetValue() )
visitItem( commit, boardItem, fp );
visitItem( commit, boardItem );
}
}
}

View File

@ -26,6 +26,7 @@
#include <board.h>
#include <board_design_settings.h>
#include <pcb_track.h>
#include <pcb_group.h>
#include <connectivity/connectivity_data.h>
#include <pcb_layer_box_selector.h>
#include <tool/tool_manager.h>
@ -327,6 +328,20 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem )
{
if( m_selectedItemsFilter->GetValue() )
{
if( !aItem->IsSelected() )
{
PCB_GROUP* group = aItem->GetParentGroup();
while( group && !group->IsSelected() )
group = group->GetParentGroup();
if( !group )
return;
}
}
if( m_selectedItemsFilter->GetValue() && !m_selection.Contains( aItem ) )
return;