2007-08-09 21:15:08 +00:00
|
|
|
/***************************************************/
|
|
|
|
/* PCBNEW - Gestion des Recherches (fonction Find) */
|
|
|
|
/***************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
/* Fichier find.cpp */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/*
|
2007-08-09 21:15:08 +00:00
|
|
|
* Affichage et modifications des parametres de travail de PcbNew
|
|
|
|
* Parametres = dimensions des via, pistes, isolements, options...
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
#include "find.h"
|
|
|
|
|
2007-12-06 07:35:26 +00:00
|
|
|
/*Local Variables */
|
2007-05-06 16:03:28 +00:00
|
|
|
static wxString s_OldStringFound;
|
2007-08-09 21:15:08 +00:00
|
|
|
static int s_ItemCount, s_MarkerCount;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2007-08-09 21:15:08 +00:00
|
|
|
void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos );
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************/
|
2007-08-09 21:15:08 +00:00
|
|
|
void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
PCB_SCREEN* screen = m_Parent->GetScreen();
|
|
|
|
wxPoint locate_pos;
|
|
|
|
wxString msg;
|
|
|
|
bool FindMarker = FALSE;
|
2007-10-03 19:45:32 +00:00
|
|
|
BOARD_ITEM* foundItem = 0;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
switch( event.GetId() )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
case ID_FIND_ITEM:
|
|
|
|
s_ItemCount = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FIND_MARKER:
|
|
|
|
s_MarkerCount = 0;
|
2007-10-03 19:45:32 +00:00
|
|
|
// fall thru
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
case ID_FIND_NEXT_MARKER:
|
|
|
|
FindMarker = TRUE;
|
|
|
|
break;
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s_OldStringFound = m_NewText->GetValue();
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y );
|
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
if( FindMarker )
|
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
MARKER* marker = m_Parent->m_Pcb->GetMARKER( s_MarkerCount++ );
|
|
|
|
if( marker )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
foundItem = marker;
|
2007-12-01 03:42:52 +00:00
|
|
|
locate_pos = marker->GetPosition();
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
else
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
int StartCount = 0;
|
|
|
|
for( MODULE* module = m_Parent->m_Pcb->m_Modules; module; module = module->Next() )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), FALSE ) )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
StartCount++;
|
|
|
|
if( StartCount > s_ItemCount )
|
|
|
|
{
|
2007-10-03 19:45:32 +00:00
|
|
|
foundItem = module;
|
2007-12-01 03:42:52 +00:00
|
|
|
locate_pos = module->GetPosition();
|
2007-08-09 21:15:08 +00:00
|
|
|
s_ItemCount++;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
2007-10-03 19:45:32 +00:00
|
|
|
if( WildCompareString( s_OldStringFound, module->m_Value->m_Text.GetData(), FALSE ) )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
StartCount++;
|
|
|
|
if( StartCount > s_ItemCount )
|
|
|
|
{
|
2007-10-03 19:45:32 +00:00
|
|
|
foundItem = module;
|
|
|
|
locate_pos = module->m_Pos;
|
2007-08-09 21:15:08 +00:00
|
|
|
s_ItemCount++;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-10-03 19:45:32 +00:00
|
|
|
if( foundItem )
|
|
|
|
{
|
|
|
|
m_Parent->SetCurItem( foundItem );
|
|
|
|
|
|
|
|
if( FindMarker )
|
|
|
|
msg = _( "Marker found" );
|
|
|
|
else
|
2007-12-04 07:04:53 +00:00
|
|
|
msg.Printf( _( "<%s> Found" ), s_OldStringFound.GetData() );
|
2007-10-03 19:45:32 +00:00
|
|
|
|
2007-12-04 07:04:53 +00:00
|
|
|
m_Parent->Affiche_Message( msg );
|
|
|
|
|
|
|
|
m_Parent->CursorGoto( locate_pos );
|
2007-10-03 19:45:32 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
EndModal( 1 );
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
m_Parent->Affiche_Message( wxEmptyString );
|
2007-10-03 19:45:32 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
if( FindMarker )
|
|
|
|
msg = _( "Marker not found" );
|
|
|
|
else
|
|
|
|
msg.Printf( _( "<%s> Not Found" ), s_OldStringFound.GetData() );
|
2007-10-03 19:45:32 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
DisplayError( this, msg, 10 );
|
|
|
|
EndModal( 0 );
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbFindFrame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_PcbFindFrame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_PcbFindFrame event table entries
|
2007-08-09 21:15:08 +00:00
|
|
|
EVT_BUTTON( ID_FIND_ITEM, WinEDA_PcbFindFrame::OnFindItemClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
EVT_BUTTON( ID_FIND_NEXT_ITEM, WinEDA_PcbFindFrame::OnFindNextItemClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
EVT_BUTTON( ID_FIND_MARKER, WinEDA_PcbFindFrame::OnFindMarkerClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
EVT_BUTTON( ID_FIND_NEXT_MARKER, WinEDA_PcbFindFrame::OnFindNextMarkerClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@end WinEDA_PcbFindFrame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame constructors
|
|
|
|
*/
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
WinEDA_PcbFindFrame::WinEDA_PcbFindFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( WinEDA_BasePcbFrame* parent,
|
|
|
|
wxDC* DC,
|
|
|
|
const wxPoint& pos,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-06-20 00:33:23 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_DC = DC;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
Create( parent, id, caption, pos, size, style );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
m_NewText->SetFocus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame creator
|
|
|
|
*/
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
bool WinEDA_PcbFindFrame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
////@begin WinEDA_PcbFindFrame member initialisation
|
|
|
|
m_NewText = NULL;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_PcbFindFrame creation
|
2007-08-09 21:15:08 +00:00
|
|
|
SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
|
2007-05-06 16:03:28 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2007-08-09 21:15:08 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
Centre();
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame creation
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_PcbFindFrame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::CreateControls()
|
2007-08-09 21:15:08 +00:00
|
|
|
{
|
|
|
|
SetFont( *g_DialogFont );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@begin WinEDA_PcbFindFrame content construction
|
|
|
|
// Generated by DialogBlocks, 04/03/2006 14:04:20 (unregistered)
|
|
|
|
|
|
|
|
WinEDA_PcbFindFrame* itemDialog1 = this;
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemDialog1->SetSizer( itemBoxSizer2 );
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC,
|
|
|
|
_(
|
|
|
|
"Item to find:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer2->Add( itemStaticText3,
|
|
|
|
0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(
|
|
|
|
"" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer2->Add( m_NewText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer5,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer6 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer5->Add( itemBoxSizer6, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton7 = new wxButton( itemDialog1, ID_FIND_ITEM, _(
|
|
|
|
"Find Item" ), wxDefaultPosition, wxDefaultSize, 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
itemButton7->SetDefault();
|
2007-08-09 21:15:08 +00:00
|
|
|
itemButton7->SetForegroundColour( wxColour( 102, 0, 0 ) );
|
|
|
|
itemBoxSizer6->Add( itemButton7, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton8 = new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _(
|
|
|
|
"Find Next Item" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemButton8->SetForegroundColour( wxColour( 111, 0, 0 ) );
|
|
|
|
itemBoxSizer6->Add( itemButton8, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer5->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton10 = new wxButton( itemDialog1, ID_FIND_MARKER, _(
|
|
|
|
"Find Marker" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemButton10->SetForegroundColour( wxColour( 0, 0, 255 ) );
|
|
|
|
itemBoxSizer9->Add( itemButton10, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton11 = new wxButton( itemDialog1, ID_FIND_NEXT_MARKER, _(
|
|
|
|
"Find Next Marker" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
itemButton11->SetForegroundColour( wxColour( 0, 0, 255 ) );
|
|
|
|
itemBoxSizer9->Add( itemButton11, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@end WinEDA_PcbFindFrame content construction
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_PcbFindFrame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_PcbFindFrame bitmap retrieval
|
2007-08-09 21:15:08 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullBitmap;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_PcbFindFrame icon retrieval
|
2007-08-09 21:15:08 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullIcon;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame icon retrieval
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_ITEM
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindItemClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_ITEM
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindNextItemClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_MARKER
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindMarkerClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_MARKER
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindNextMarkerClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|