Commit f0cd1476 authored by CHARRAS's avatar CHARRAS

pcbnew: use collector class to locate items in modedit, the footprint editor (thanks, Dick).

parent 5fc79254
......@@ -15,6 +15,10 @@ email address.
display frame
minor other changes
+ pcbnew:
Use collector class to locate items in modedit.
This is a big enhancement,
but a small work for me because Dick made all the work.
2007-Oct-26 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
......
......@@ -942,7 +942,7 @@ public:
virtual void HandleBlockPlace( wxDC* DC );
virtual int HandleBlockEnd( wxDC* DC );
BOARD_ITEM* ModeditLocateAndDisplay();
BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
/* Undo and redo functions */
public:
......
No preview for this file type
This diff is collapsed.
......@@ -69,6 +69,9 @@ WinEDA_BasePcbFrame::~WinEDA_BasePcbFrame( void )
/**************************************/
int WinEDA_BasePcbFrame::BestZoom( void )
/**************************************/
/**
* Return the "best" zoom, i.e. the zoom which shows the entire borad on screen
*/
{
int dx, dy, ii, jj;
int bestzoom;
......@@ -79,7 +82,6 @@ int WinEDA_BasePcbFrame::BestZoom( void )
m_Pcb->ComputeBoundaryBox();
/* calcul du zoom montrant tout le dessim */
dx = m_Pcb->m_BoundaryBox.GetWidth();
dy = m_Pcb->m_BoundaryBox.GetHeight();
......
This diff is collapsed.
......@@ -92,6 +92,14 @@ const KICAD_T GENERAL_COLLECTOR::PadsOrModules[] = {
EOT
};
const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems[] = {
TYPETEXTEMODULE,
TYPEEDGEMODULE,
TYPEPAD,
TYPEMODULE,
EOT
};
const KICAD_T GENERAL_COLLECTOR::Tracks[] = {
TYPETRACK,
......
......@@ -226,6 +226,11 @@ public:
*/
static const KICAD_T PadsOrModules[];
/**
* A scan list for MODULEs and their items (for Modedit)
*/
static const KICAD_T ModulesAndTheirItems[];
/**
* A scan list for only TRACKS
......
......@@ -17,29 +17,111 @@
#include "protos.h"
#include "id.h"
#include "collectors.h"
/*********************************************************************/
BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay()
/*********************************************************************/
/****************************************************************************/
BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
/****************************************************************************/
{
BOARD_ITEM* DrawStruct = GetCurItem();
BOARD_ITEM* item = GetCurItem();
MODULE* Module = m_Pcb->m_Modules;
if( Module == NULL )
return NULL;
DrawStruct = Locate_Edge_Module( Module, CURSEUR_OFF_GRILLE );
if( DrawStruct )
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
// Assign to scanList the proper item types desired based on tool type
// or hotkey that is in play.
const KICAD_T* scanList = NULL;
if( aHotKeyCode )
{
DrawStruct->Display_Infos( this );
// @todo: add switch here and add calls to PcbGeneralLocateAndDisplay( int aHotKeyCode )
// when searching is needed from a hotkey handler
}
else
DrawStruct = Locate( CURSEUR_OFF_GRILLE, -1 );
{
scanList = GENERAL_COLLECTOR::ModulesAndTheirItems;
}
m_Collector->Collect( m_Pcb, scanList, GetScreen()->RefPos( true ), guide );
/* Remove redundancies: when an item is found, we can remove the
* module from list
*/
if( m_Collector->GetCount() > 1 )
{
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{
item = (*m_Collector)[ii];
if( item->Type() != TYPEMODULE )
continue;
m_Collector->Remove( ii );
ii--;
}
}
if( m_Collector->GetCount() <= 1 )
{
item = (*m_Collector)[0];
SetCurItem( item );
}
else // we can't figure out which item user wants, do popup menu so user can choose
{
wxMenu itemMenu;
/* Give a title to the selection menu. This is also a cancel menu item */
wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__
wxFont bold_font(*wxNORMAL_FONT);
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
bold_font.SetStyle( wxFONTSTYLE_ITALIC);
item_title->SetFont(bold_font);
#endif
itemMenu.Append(item_title);
itemMenu.AppendSeparator();
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
for( int ii = 0; ii<limit; ++ii )
{
wxString text;
const char** xpm;
item = (*m_Collector)[ii];
text = item->MenuText( m_Pcb );
xpm = item->MenuIcon();
ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + ii, text, xpm );
}
// this menu's handler is void WinEDA_BasePcbFrame::ProcessItemSelection()
// and it calls SetCurItem() which in turn calls Display_Infos() on the item.
DrawPanel->m_AbortRequest = true; // changed in false if an item
PopupMenu( &itemMenu ); // m_AbortRequest = false if an item is selected
DrawPanel->MouseToCursorSchema();
return DrawStruct;
DrawPanel->m_IgnoreMouseEvents = FALSE;
// The function ProcessItemSelection() has set the current item, return it.
item = GetCurItem();
}
if( item )
{
item->Display_Infos( this );
}
return item;
}
/****************************************************************************/
void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
/****************************************************************************/
......
......@@ -74,6 +74,8 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = GetCurItem();
if( !DrawStruct || (DrawStruct->m_Flags == 0) )
{
if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
!wxGetKeyState(WXK_CONTROL) )
DrawStruct = ModeditLocateAndDisplay();
SetCurItem( DrawStruct );
}
......
......@@ -19,6 +19,9 @@
/* class WinEDA_ModuleEditFrame */
/********************************/
BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, wxFrame )
COMMON_EVENTS_DRAWFRAME EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START,
ID_POPUP_PCB_ITEM_SELECTION_END,
WinEDA_BasePcbFrame::ProcessItemSelection )
COMMON_EVENTS_DRAWFRAME EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow )
EVT_SIZE( WinEDA_ModuleEditFrame::OnSize )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment