Preload PCBnew find with selection when appropriate.
This commit is contained in:
parent
2bba277c5e
commit
476f1a7d4d
|
@ -96,6 +96,16 @@ DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME *aFrame ) :
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::Preload( const wxString& aFindString )
|
||||
{
|
||||
if( !aFindString.IsEmpty() )
|
||||
{
|
||||
m_searchCombo->SetValue( aFindString );
|
||||
m_searchCombo->SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::onTextEnter( wxCommandEvent& aEvent )
|
||||
{
|
||||
search( true );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2012 Marco Mattila <marcom99@gmail.com>
|
||||
* Copyright (C) 2006 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -42,6 +42,8 @@ class DIALOG_FIND : public DIALOG_FIND_BASE
|
|||
public:
|
||||
DIALOG_FIND( PCB_BASE_FRAME* aParent );
|
||||
|
||||
void Preload( const wxString& aFindString );
|
||||
|
||||
/**
|
||||
* Return the currently found item or nullptr in the case of no items found.
|
||||
*/
|
||||
|
|
|
@ -349,12 +349,18 @@ public:
|
|||
void CheckFootprintAttributes( const std::function<void( const wxString& )>& aErrorHandler );
|
||||
|
||||
/**
|
||||
* Run DRC checks on footprint's pads.
|
||||
* Run non-board-specific DRC checks on footprint's pads. These are the checks supported by
|
||||
* both the PCB DRC and the Footprint Editor Footprint Checker.
|
||||
*
|
||||
* @param aErrorHandler callback to handle the error messages generated
|
||||
*/
|
||||
void CheckPads( const std::function<void( const PAD*, int, const wxString& )>& aErrorHandler );
|
||||
|
||||
/**
|
||||
* Check for overlapping, different-numbered pads.
|
||||
*
|
||||
* @param aErrorHandler callback to handle the error messages generated
|
||||
*/
|
||||
void CheckOverlappingPads( const std::function<void( const PAD*, const PAD*,
|
||||
const VECTOR2I& )>& aErrorHandler );
|
||||
|
||||
|
|
|
@ -1455,6 +1455,39 @@ void PCB_EDIT_FRAME::ShowFindDialog()
|
|||
m_toolManager->GetTool<PCB_SELECTION_TOOL>(), _1 ) );
|
||||
}
|
||||
|
||||
wxString findString;
|
||||
|
||||
PCB_SELECTION& selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||
|
||||
if( selection.Size() == 1 )
|
||||
{
|
||||
EDA_ITEM* front = selection.Front();
|
||||
|
||||
switch( front->Type() )
|
||||
{
|
||||
case PCB_FOOTPRINT_T:
|
||||
findString = static_cast<FOOTPRINT*>( front )->GetValue();
|
||||
break;
|
||||
|
||||
case PCB_FP_TEXT_T:
|
||||
findString = static_cast<FP_TEXT*>( front )->GetShownText();
|
||||
break;
|
||||
|
||||
case PCB_TEXT_T:
|
||||
findString = static_cast<PCB_TEXT*>( front )->GetShownText();
|
||||
|
||||
if( findString.Contains( wxT( "\n" ) ) )
|
||||
findString = findString.Before( '\n' );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_findDialog->Preload( findString );
|
||||
|
||||
m_findDialog->Show( true );
|
||||
}
|
||||
|
||||
|
@ -1462,11 +1495,7 @@ void PCB_EDIT_FRAME::ShowFindDialog()
|
|||
void PCB_EDIT_FRAME::FindNext()
|
||||
{
|
||||
if( !m_findDialog )
|
||||
{
|
||||
m_findDialog = new DIALOG_FIND( this );
|
||||
m_findDialog->SetCallback( std::bind( &PCB_SELECTION_TOOL::FindItem,
|
||||
m_toolManager->GetTool<PCB_SELECTION_TOOL>(), _1 ) );
|
||||
}
|
||||
ShowFindDialog();
|
||||
|
||||
m_findDialog->FindNext();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,7 +32,6 @@
|
|||
#include <board.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <footprint_viewer_frame.h>
|
||||
#include <footprint_wizard_frame.h>
|
||||
#include <footprint.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/zone_filler_tool.h>
|
||||
|
@ -43,7 +42,8 @@
|
|||
FP_LIB_TABLE GFootprintTable;
|
||||
|
||||
|
||||
DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aParent ) : DIALOG_FIND_BASE( aParent )
|
||||
DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aParent ) :
|
||||
DIALOG_FIND_BASE( aParent )
|
||||
{
|
||||
// these members are initialized to avoid warnings about non initialized vars
|
||||
m_frame = aParent;
|
||||
|
|
Loading…
Reference in New Issue