2007-08-23 04:28:46 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com
|
|
|
|
* Copyright (C) 2004-2007 Kicad Developers, see change_log.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
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
#include "collectors.h"
|
|
|
|
#include "pcbnew.h" // class BOARD
|
|
|
|
|
|
|
|
|
|
|
|
/* This module contains out of line member functions for classes given in
|
|
|
|
collectors.h. Those classes augment the functionality of class WinEDA_PcbFrame.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// see collectors.h
|
2007-08-30 22:20:52 +00:00
|
|
|
const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
|
2007-08-23 04:28:46 +00:00
|
|
|
TYPETEXTE,
|
|
|
|
TYPEDRAWSEGMENT,
|
|
|
|
TYPECOTATION,
|
|
|
|
TYPEVIA,
|
|
|
|
TYPETRACK,
|
|
|
|
TYPEPAD,
|
|
|
|
TYPETEXTEMODULE,
|
|
|
|
TYPEMODULE,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-09-06 04:34:03 +00:00
|
|
|
const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
|
|
|
|
TYPETEXTE,
|
|
|
|
TYPEDRAWSEGMENT,
|
|
|
|
TYPECOTATION,
|
|
|
|
TYPEVIA,
|
|
|
|
TYPETRACK,
|
|
|
|
// TYPEPAD, TYPEPAD and TYPETEXTEMODULE are handled in a subsearch
|
|
|
|
// TYPETEXTEMODULE,
|
|
|
|
TYPEMODULE,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
|
|
|
* Function Inspect
|
|
|
|
* is the examining function within the INSPECTOR which is passed to the
|
|
|
|
* Iterate function. Searches and collects all the objects that the old
|
|
|
|
* function PcbGeneralLocateAndDisplay() would find, except that it keeps all
|
|
|
|
* that it finds and does not do any displaying.
|
|
|
|
*
|
|
|
|
* @param testItem An EDA_BaseStruct to examine.
|
|
|
|
* @param notUsed The const void* testData.
|
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE;
|
|
|
|
*/
|
2007-08-30 22:20:52 +00:00
|
|
|
SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* notUsed )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
2007-09-05 14:52:28 +00:00
|
|
|
MODULE* module = NULL;
|
2007-08-24 03:40:04 +00:00
|
|
|
|
|
|
|
#if 1 // debugging
|
|
|
|
static int breakhere = 0;
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
|
|
|
case TYPEPAD:
|
2007-09-05 15:11:48 +00:00
|
|
|
{
|
|
|
|
MODULE* m = (MODULE*) item->GetParent();
|
|
|
|
if( m->GetReference() == wxT("Y2") )
|
|
|
|
{
|
|
|
|
breakhere++;
|
|
|
|
}
|
|
|
|
}
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPEVIA:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPETRACK:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPETEXTE:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPEDRAWSEGMENT:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPECOTATION:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPETEXTEMODULE:
|
2007-09-05 04:48:47 +00:00
|
|
|
{
|
|
|
|
TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
|
2007-09-01 12:00:30 +00:00
|
|
|
if( tm->m_Text == wxT("10uH") )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
|
|
|
breakhere++;
|
|
|
|
}
|
2007-09-05 04:48:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
case TYPEMODULE:
|
2007-09-05 04:48:47 +00:00
|
|
|
{
|
|
|
|
MODULE* m = (MODULE*) item;
|
|
|
|
if( m->GetReference() == wxT("C98") )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
|
|
|
breakhere++;
|
|
|
|
}
|
2007-09-05 04:48:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
default:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
#endif
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case TYPEPAD:
|
2007-09-05 14:52:28 +00:00
|
|
|
module = (MODULE*) item->GetParent();
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2007-09-05 14:52:28 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
case TYPEVIA:
|
|
|
|
break;
|
|
|
|
case TYPETRACK:
|
|
|
|
break;
|
|
|
|
case TYPETEXTE:
|
|
|
|
break;
|
|
|
|
case TYPEDRAWSEGMENT:
|
|
|
|
break;
|
|
|
|
case TYPECOTATION:
|
|
|
|
break;
|
2007-09-05 14:52:28 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
{
|
2007-09-05 14:52:28 +00:00
|
|
|
module = (MODULE*) item->GetParent();
|
|
|
|
|
2007-09-05 15:11:48 +00:00
|
|
|
if( m_Guide->IgnoreMTextsMarkedNoShow() && ((TEXTE_MODULE*)item)->m_NoShow )
|
2007-09-05 04:48:47 +00:00
|
|
|
goto exit;
|
2007-09-05 15:11:48 +00:00
|
|
|
|
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
if( m_Guide->IgnoreMTextsOnCopper() && module->GetLayer()==LAYER_CUIVRE_N )
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
if( m_Guide->IgnoreMTextsOnCmp() && module->GetLayer()==LAYER_CMP_N )
|
|
|
|
goto exit;
|
|
|
|
}
|
2007-09-05 04:48:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMODULE:
|
2007-09-05 14:52:28 +00:00
|
|
|
module = (MODULE*) item;
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
// common tests:
|
2007-09-05 14:52:28 +00:00
|
|
|
|
2007-09-05 15:11:48 +00:00
|
|
|
if( module ) // true from case TYPEPAD, TYPETEXTEMODULE, or TYPEMODULE
|
2007-09-05 14:52:28 +00:00
|
|
|
{
|
2007-09-05 15:11:48 +00:00
|
|
|
if( m_Guide->IgnoreModulesOnCu() && module->GetLayer()==LAYER_CUIVRE_N )
|
2007-09-05 14:52:28 +00:00
|
|
|
goto exit;
|
2007-09-05 15:11:48 +00:00
|
|
|
if( m_Guide->IgnoreModulesOnCmp() && module->GetLayer()==LAYER_CMP_N )
|
2007-09-05 14:52:28 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) || m_Guide->IgnorePreferredLayer() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
int layer = item->GetLayer();
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
if( m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
if( !m_Guide->IsLayerLocked(layer) || !m_Guide->IgnoreLockedLayers() )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
|
|
|
|
{
|
|
|
|
if( item->HitTest( m_RefPos ) )
|
|
|
|
{
|
|
|
|
Append( item );
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
if( m_Guide->IncludeSecondary() )
|
|
|
|
{
|
|
|
|
// for now, "secondary" means "tolerate any layer". It has
|
|
|
|
// no effect on other criteria, since there is a separate "ignore" control for
|
|
|
|
// those in the COLLECTORS_GUIDE
|
|
|
|
|
|
|
|
int layer = item->GetLayer();
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
if( m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
if( !m_Guide->IsLayerLocked(layer) || !m_Guide->IgnoreLockedLayers() )
|
|
|
|
{
|
|
|
|
if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
|
|
|
|
{
|
|
|
|
if( item->HitTest( m_RefPos ) )
|
|
|
|
{
|
|
|
|
Append2nd( item );
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return SEARCH_CONTINUE; // always when collecting
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
// see collectors.h
|
2007-09-06 04:34:03 +00:00
|
|
|
void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const wxPoint& aRefPos,
|
2007-09-05 04:48:47 +00:00
|
|
|
const COLLECTORS_GUIDE* aGuide )
|
2007-08-30 03:53:26 +00:00
|
|
|
{
|
|
|
|
Empty(); // empty the collection, primary criteria list
|
|
|
|
Empty2nd(); // empty the collection, secondary criteria list
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// remember guide, pass it to Inspect()
|
2007-09-05 04:48:47 +00:00
|
|
|
SetGuide( aGuide );
|
2007-08-30 03:53:26 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// remember where the snapshot was taken from and pass refPos to
|
|
|
|
// the Inspect() function.
|
2007-09-06 04:34:03 +00:00
|
|
|
SetRefPos( aRefPos );
|
2007-08-30 03:53:26 +00:00
|
|
|
|
2007-09-06 04:34:03 +00:00
|
|
|
// visit the board or module with the INSPECTOR (me).
|
2007-09-05 04:48:47 +00:00
|
|
|
aItem->Visit( this, // INSPECTOR* inspector
|
2007-08-30 03:53:26 +00:00
|
|
|
NULL, // const void* testData, not used here
|
|
|
|
m_ScanTypes);
|
|
|
|
|
|
|
|
SetTimeNow(); // when snapshot was taken
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// append 2nd list onto end of the first list
|
|
|
|
for( unsigned i=0; i<m_List2nd.size(); ++i )
|
|
|
|
Append( m_List2nd[i] );
|
2007-08-30 03:53:26 +00:00
|
|
|
|
|
|
|
Empty2nd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
//EOF
|