Commit df754ad5 authored by dickelbeck's avatar dickelbeck

AllAreModulesAndReturnSmallestIfSo()

parent bfa36f31
...@@ -4,6 +4,14 @@ Started 2007-June-11 ...@@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Sep-14 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
* controle.cpp, added Function AllAreModulesAndReturnSmallestIfSo() which is
called from PcbGeneralLocateAndDisplay()
2007-Sep-13 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Sep-13 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+ kicad + kicad
......
MAKEGTK = $(MAKE) -f makefile.gtk MAKEGTK = $(MAKE) -f makefile.gtk
KICAD_SUBDIRS = common 3d-viewer pcbnew eeschema eeschema/plugins cvpcb kicad gerbview KICAD_SUBDIRS = common 3d-viewer pcbnew #eeschema eeschema/plugins cvpcb kicad gerbview
KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview
KICAD_SUBDIRS_RES = internat modules template library KICAD_SUBDIRS_RES = internat modules template library
KICAD_SUBDIRS_HELP = help KICAD_SUBDIRS_HELP = help
......
...@@ -286,6 +286,47 @@ const char** BOARD_ITEM::MenuIcon() const ...@@ -286,6 +286,47 @@ const char** BOARD_ITEM::MenuIcon() const
} }
/**
* Function AllAreModulesAndReturnSmallestIfSo
* tests that all items in the collection are MODULEs and if so, returns the
* smallest MODULE.
* @return BOARD_ITEM* - The smallest or NULL.
*/
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
{
int count = aCollector->GetCount();
for( int i=0; i<count; ++i )
{
if( (*aCollector)[i]->Type() != TYPEMODULE )
return NULL;
}
// all are modules, now find smallest MODULE
int minDim = 0x7FFFFFFF;
int minNdx = 0;
for( int i=0; i<count; ++i )
{
MODULE* module = (MODULE*) (*aCollector)[i];
int lx = module->m_BoundaryBox.GetWidth();
int ly = module->m_BoundaryBox.GetHeight();
int lmin = MIN( lx, ly );
if( lmin <= minDim )
{
minDim = lmin;
minNdx = i;
}
}
return (*aCollector)[minNdx];
}
/***********************************************************************/ /***********************************************************************/
BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay() BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
...@@ -355,6 +396,13 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay() ...@@ -355,6 +396,13 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
item = (*m_Collector)[0]; item = (*m_Collector)[0];
SetCurItem( item ); SetCurItem( item );
} }
// if all are modules, find the smallest one amoung the primary choices
else if( (item = AllAreModulesAndReturnSmallestIfSo(m_Collector) ) != NULL )
{
SetCurItem( item );
}
else // show a popup menu else // show a popup menu
{ {
wxMenu itemMenu; wxMenu itemMenu;
......
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