A bunch of fixes to Eeschema Find/Replace.

This commit is contained in:
Jeff Young 2020-04-18 12:04:52 +01:00
parent 56c31e65f6
commit d7d1cb6f78
10 changed files with 176 additions and 61 deletions

View File

@ -164,7 +164,10 @@ int EDA_TEXT::GetEffectiveTextPenWidth() const
bool EDA_TEXT::Replace( wxFindReplaceData& aSearchData )
{
return EDA_ITEM::Replace( aSearchData, m_text );
bool retval = EDA_ITEM::Replace( aSearchData, m_text );
m_shown_text = UnescapeString( m_text );
return retval;
}

View File

@ -34,7 +34,8 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, wxFindReplaceData* aD
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | aStyle ),
m_frame( aParent ),
m_editorControl( m_frame->GetToolManager()->GetTool<SCH_EDITOR_CONTROL>() ),
m_findReplaceData( aData )
m_findReplaceData( aData ),
m_findDirty( true )
{
wxASSERT_MSG( m_findReplaceData, wxT( "can't create find dialog without data" ) );
@ -95,8 +96,19 @@ void DIALOG_SCH_FIND::OnClose( wxCloseEvent& aEvent )
{
// Notify the SCH_EDIT_FRAME
m_frame->OnFindDialogClose();
// Notify the controller
m_editorControl->UpdateFind( ACTIONS::updateFind.MakeEvent() );
m_findDirty = true;
}
void DIALOG_SCH_FIND::OnIdle( wxIdleEvent& aEvent )
{
if( m_findDirty )
{
m_editorControl->UpdateFind( ACTIONS::updateFind.MakeEvent() );
m_findDirty = false;
}
}
@ -133,11 +145,55 @@ void DIALOG_SCH_FIND::OnChar( wxKeyEvent& aEvent )
void DIALOG_SCH_FIND::OnSearchForText( wxCommandEvent& aEvent )
{
m_findReplaceData->SetFindString( m_comboFind->GetValue() );
m_findDirty = true;
}
void DIALOG_SCH_FIND::OnSearchForSelect( wxCommandEvent& aEvent )
{
m_findReplaceData->SetFindString( m_comboFind->GetValue() );
// Move the search string to the top of the list if it isn't already there.
if( aEvent.GetSelection() != 0 )
{
wxString tmp = m_comboFind->GetValue();
m_comboFind->Delete( aEvent.GetSelection() );
m_comboFind->Insert( tmp, 0 );
m_comboFind->SetSelection( 0 );
}
m_editorControl->UpdateFind( ACTIONS::updateFind.MakeEvent() );
}
void DIALOG_SCH_FIND::OnTextEnter( wxCommandEvent& aEvent )
void DIALOG_SCH_FIND::OnReplaceWithText( wxCommandEvent& aEvent )
{
m_findReplaceData->SetReplaceString( m_comboReplace->GetValue() );
}
void DIALOG_SCH_FIND::OnReplaceWithSelect( wxCommandEvent& aEvent )
{
m_findReplaceData->SetReplaceString( m_comboReplace->GetValue() );
// Move the replace string to the top of the list if it isn't already there.
if( aEvent.GetSelection() != 0 )
{
wxString tmp = m_comboReplace->GetValue();
m_comboReplace->Delete( aEvent.GetSelection() );
m_comboReplace->Insert( tmp, 0 );
m_comboReplace->SetSelection( 0 );
}
}
void DIALOG_SCH_FIND::OnSearchForEnter( wxCommandEvent& aEvent )
{
OnFind( aEvent );
}
void DIALOG_SCH_FIND::OnReplaceWithEnter( wxCommandEvent& aEvent )
{
OnFind( aEvent );
}
@ -172,7 +228,7 @@ void DIALOG_SCH_FIND::OnOptions( wxCommandEvent& aEvent )
flags |= FR_REPLACE_REFERENCES;
m_findReplaceData->SetFlags( flags );
m_editorControl->UpdateFind( ACTIONS::updateFind.MakeEvent() );
m_findDirty = true;
}
@ -215,9 +271,9 @@ void DIALOG_SCH_FIND::OnReplace( wxCommandEvent& aEvent )
}
if( aEvent.GetId() == wxID_REPLACE )
m_editorControl->FindNext( ACTIONS::replaceAndFindNext.MakeEvent());
m_editorControl->ReplaceAndFindNext( ACTIONS::replaceAndFindNext.MakeEvent());
else if( aEvent.GetId() == wxID_REPLACE_ALL )
m_editorControl->FindNext( ACTIONS::replaceAll.MakeEvent());
m_editorControl->ReplaceAll( ACTIONS::replaceAll.MakeEvent());
}

View File

@ -50,12 +50,16 @@ protected:
// Handlers for DIALOG_SCH_FIND_BASE events.
void OnClose( wxCloseEvent& aEvent ) override;
void OnCancel( wxCommandEvent& aEvent ) override;
void OnSearchForSelect( wxCommandEvent& aEvent ) override;
void OnSearchForText( wxCommandEvent& aEvent ) override;
void OnTextEnter( wxCommandEvent& event ) override;
void OnSearchForEnter( wxCommandEvent& event ) override;
void OnReplaceWithSelect( wxCommandEvent& aEvent ) override;
void OnReplaceWithText( wxCommandEvent& aEvent ) override;
void OnReplaceWithEnter( wxCommandEvent& event ) override;
void OnOptions( wxCommandEvent& event ) override;
void OnUpdateReplaceUI( wxUpdateUIEvent& aEvent ) override;
void OnUpdateReplaceAllUI( wxUpdateUIEvent& aEvent ) override;
void OnIdle( wxIdleEvent& event ) override;
void OnChar( wxKeyEvent& aEvent );
void OnFind( wxCommandEvent& aEvent ) override;
void OnReplace( wxCommandEvent& aEvent ) override;
@ -63,6 +67,7 @@ protected:
SCH_EDIT_FRAME* m_frame;
SCH_EDITOR_CONTROL* m_editorControl;
wxFindReplaceData* m_findReplaceData;
bool m_findDirty;
DECLARE_NO_COPY_CLASS( DIALOG_SCH_FIND )

View File

@ -89,16 +89,16 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con
m_checkWildcardMatch = new wxCheckBox( this, wxID_ANY, _("Wildcards"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer2->Add( m_checkWildcardMatch, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_checkAllFields = new wxCheckBox( this, wxID_ANY, _("Search user-defined fields"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer2->Add( m_checkAllFields, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkAllPins = new wxCheckBox( this, wxID_ANY, _("Search pin &names and numbers"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer2->Add( m_checkAllPins, wxGBPosition( 2, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
gbSizer2->Add( m_checkAllPins, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkAllFields = new wxCheckBox( this, wxID_ANY, _("Search hidden fields"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer2->Add( m_checkAllFields, wxGBPosition( 2, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkCurrentSheetOnly = new wxCheckBox( this, wxID_ANY, _("Search the current &sheet only"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer2->Add( m_checkCurrentSheetOnly, wxGBPosition( 3, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkReplaceReferences = new wxCheckBox( this, wxID_ANY, _("Replace componen&t reference designators"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkReplaceReferences = new wxCheckBox( this, wxID_ANY, _("Replace matches in reference designators"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkReplaceReferences->Hide();
gbSizer2->Add( m_checkReplaceReferences, wxGBPosition( 4, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
@ -145,16 +145,20 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_FIND_BASE::OnClose ) );
this->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_SCH_FIND_BASE::OnIdle ) );
m_comboFind->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnSearchForSelect ), NULL, this );
m_comboFind->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnSearchForText ), NULL, this );
m_comboFind->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnTextEnter ), NULL, this );
m_comboFind->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnSearchForEnter ), NULL, this );
m_comboFind->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateDrcUI ), NULL, this );
m_comboReplace->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnTextEnter ), NULL, this );
m_comboReplace->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplaceWithSelect ), NULL, this );
m_comboReplace->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplaceWithText ), NULL, this );
m_comboReplace->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplaceWithEnter ), NULL, this );
m_comboReplace->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateDrcUI ), NULL, this );
m_checkMatchCase->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkWholeWord->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkWildcardMatch->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkAllFields->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkAllPins->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkAllFields->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkCurrentSheetOnly->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_buttonFind->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnFind ), NULL, this );
m_buttonReplace->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplace ), NULL, this );
@ -168,16 +172,20 @@ DIALOG_SCH_FIND_BASE::~DIALOG_SCH_FIND_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_FIND_BASE::OnClose ) );
this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_SCH_FIND_BASE::OnIdle ) );
m_comboFind->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnSearchForSelect ), NULL, this );
m_comboFind->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnSearchForText ), NULL, this );
m_comboFind->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnTextEnter ), NULL, this );
m_comboFind->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnSearchForEnter ), NULL, this );
m_comboFind->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateDrcUI ), NULL, this );
m_comboReplace->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnTextEnter ), NULL, this );
m_comboReplace->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplaceWithSelect ), NULL, this );
m_comboReplace->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplaceWithText ), NULL, this );
m_comboReplace->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplaceWithEnter ), NULL, this );
m_comboReplace->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateDrcUI ), NULL, this );
m_checkMatchCase->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkWholeWord->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkWildcardMatch->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkAllFields->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkAllPins->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkAllFields->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_checkCurrentSheetOnly->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnOptions ), NULL, this );
m_buttonFind->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnFind ), NULL, this );
m_buttonReplace->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplace ), NULL, this );

View File

@ -54,6 +54,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnClose">OnClose</event>
<event name="OnIdle">OnIdle</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">mainSizer</property>
@ -217,8 +218,9 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCombobox">OnSearchForSelect</event>
<event name="OnText">OnSearchForText</event>
<event name="OnTextEnter">OnTextEnter</event>
<event name="OnTextEnter">OnSearchForEnter</event>
<event name="OnUpdateUI">OnUpdateDrcUI</event>
</object>
</object>
@ -346,7 +348,9 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">OnTextEnter</event>
<event name="OnCombobox">OnReplaceWithSelect</event>
<event name="OnText">OnReplaceWithText</event>
<event name="OnTextEnter">OnReplaceWithEnter</event>
<event name="OnUpdateUI">OnUpdateDrcUI</event>
</object>
</object>
@ -807,7 +811,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Search user-defined fields</property>
<property name="label">Search pin &amp;names and numbers</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -815,7 +819,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkAllFields</property>
<property name="name">m_checkAllPins</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -875,7 +879,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Search pin &amp;names and numbers</property>
<property name="label">Search hidden fields</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -883,7 +887,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkAllPins</property>
<property name="name">m_checkAllFields</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1011,7 +1015,7 @@
<property name="gripper">0</property>
<property name="hidden">1</property>
<property name="id">wxID_ANY</property>
<property name="label">Replace componen&amp;t reference designators</property>
<property name="label">Replace matches in reference designators</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>

View File

@ -49,8 +49,8 @@ class DIALOG_SCH_FIND_BASE : public DIALOG_SHIM
wxCheckBox* m_checkMatchCase;
wxCheckBox* m_checkWholeWord;
wxCheckBox* m_checkWildcardMatch;
wxCheckBox* m_checkAllFields;
wxCheckBox* m_checkAllPins;
wxCheckBox* m_checkAllFields;
wxCheckBox* m_checkCurrentSheetOnly;
wxCheckBox* m_checkReplaceReferences;
wxButton* m_buttonFind;
@ -60,9 +60,14 @@ class DIALOG_SCH_FIND_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnIdle( wxIdleEvent& event ) { event.Skip(); }
virtual void OnSearchForSelect( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSearchForText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTextEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSearchForEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateDrcUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnReplaceWithSelect( wxCommandEvent& event ) { event.Skip(); }
virtual void OnReplaceWithText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnReplaceWithEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOptions( wxCommandEvent& event ) { event.Skip(); }
virtual void OnFind( wxCommandEvent& event ) { event.Skip(); }
virtual void OnReplace( wxCommandEvent& event ) { event.Skip(); }

View File

@ -139,12 +139,12 @@ int SCH_FIELD::GetPenWidth() const
void SCH_FIELD::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( m_forceVisible ? LAYER_HIDDEN : m_Layer );
COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_Layer );
int orient;
wxPoint textpos;
int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
if( ( !IsVisible() && !m_forceVisible) || IsVoid() )
if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
return;
// Calculate the text orientation according to the component orientation.
@ -274,20 +274,20 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
{
wxString text = GetShownText();
int flags = aSearchData.GetFlags();
bool searchUserDefinedFields = flags & FR_SEARCH_ALL_FIELDS;
bool searchHiddenFields = flags & FR_SEARCH_ALL_FIELDS;
bool searchAndReplace = flags & FR_SEARCH_REPLACE;
bool replaceReferences = flags & FR_REPLACE_REFERENCES;
wxLogTrace( traceFindItem, wxT( " child item " )
+ GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
if( !IsVisible() && !searchHiddenFields )
return false;
if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
if( !searchUserDefinedFields && m_id >= MANDATORY_FIELDS )
return false;
if( searchAndReplace && m_id == REFERENCE && !replaceReferences )
return false;
@ -301,11 +301,6 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
text << LIB_PART::SubReference( parentComponent->GetUnit() );
}
}
else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
{
if( !searchUserDefinedFields && m_id >= SHEET_MANDATORY_FIELDS )
return false;
}
return SCH_ITEM::Matches( text, aSearchData );
}
@ -340,7 +335,7 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
{
bool isReplaced = false;
if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T && m_id == REFERENCE )
if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );

View File

@ -1430,7 +1430,7 @@ void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
if( !aField->IsVisible() )
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
{
if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );

View File

@ -154,28 +154,56 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
{
wxFindReplaceData* data = m_frame->GetFindReplaceData();
auto visit = [&] ( EDA_ITEM* aItem )
{
if( data && aItem->Matches( *data, nullptr ) )
{
aItem->SetForceVisible( true );
m_selectionTool->BrightenItem( aItem );
}
else if( aItem->IsBrightened() )
{
aItem->SetForceVisible( false );
m_selectionTool->UnbrightenItem( aItem );
}
};
if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
|| aEvent.IsAction( &ACTIONS::updateFind ) )
{
m_selectionTool->ClearSelection();
for( auto item : m_frame->GetScreen()->Items() )
for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
{
if( data && item->Matches( *data, nullptr ) )
m_selectionTool->BrightenItem( item );
else if( item->IsBrightened() )
m_selectionTool->UnbrightenItem( item );
visit( item );
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
for( SCH_FIELD& field : cmp->GetFields() )
visit( &field );
for( SCH_PIN* pin : cmp->GetSchPins() )
visit( pin );
}
else if( item->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
for( SCH_FIELD& field : sheet->GetFields() )
visit( &field );
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
visit( pin );
}
}
}
else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
{
for( EDA_ITEM* item : m_selectionTool->GetSelection() )
{
if( data && item->Matches( *data, nullptr ) )
m_selectionTool->BrightenItem( item );
else if( item->IsBrightened() )
m_selectionTool->UnbrightenItem( item );
}
visit( item );
}
getView()->UpdateItems();
@ -366,7 +394,12 @@ int SCH_EDITOR_CONTROL::ReplaceAndFindNext( const TOOL_EVENT& aEvent )
if( item && item->Matches( *data, nullptr ) )
{
item->Replace( *data, g_CurrentSheet );
if( item->Replace( *data, g_CurrentSheet ) )
{
m_frame->RefreshItem( item );
m_frame->OnModify();
}
FindNext( ACTIONS::findNext.MakeEvent() );
}
@ -386,12 +419,16 @@ int SCH_EDITOR_CONTROL::ReplaceAll( const TOOL_EVENT& aEvent )
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
{
//TODO(snh): Fix ReplaceAll
// screen->ForEachItem() for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
// item = nextMatch( screen, item, data ) )
// {
// item->Replace( *data, schematic.FindSheetForScreen( screen ) );
// }
for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item; )
{
if( item->Replace( *data, schematic.FindSheetForScreen( screen ) ) )
{
m_frame->RefreshItem( item );
m_frame->OnModify();
}
item = nextMatch( screen, dynamic_cast<SCH_ITEM*>( item ), data );
}
}
return 0;

View File

@ -62,7 +62,7 @@ enum FIND_REPLACE_FLAGS
{
// The last wxFindReplaceFlag enum is wxFR_MATCHCASE = 0x4.
FR_CURRENT_SHEET_ONLY = wxFR_MATCHCASE << 1, // Search the current sheet only.
FR_SEARCH_ALL_FIELDS = wxFR_MATCHCASE << 2, // Search user fields as well as ref and value.
FR_SEARCH_ALL_FIELDS = wxFR_MATCHCASE << 2, // Search hidden fields too.
FR_SEARCH_ALL_PINS = wxFR_MATCHCASE << 3, // Search pin name and number.
FR_MATCH_WILDCARD = wxFR_MATCHCASE << 4, // Use simple wild card matching (* & ?).
FR_SEARCH_WRAP = wxFR_MATCHCASE << 5, // Wrap around the start or end of search.
@ -289,6 +289,8 @@ public:
*/
void SetForceVisible( bool aEnable ) { m_forceVisible = aEnable; }
bool IsForceVisible() const { return m_forceVisible; }
/**
* Function GetMsgPanelInfo
* populates \a aList of #MSG_PANEL_ITEM objects with it's internal state for display