Move from class INSPECTOR as the EDA_ITEM::Visit() callback interface to a std::function
callback. This improves conciseness and encourages use of Visit() due to the lower cost of entry in C++.
This commit is contained in:
parent
98ad5096b0
commit
c2b8a4ee43
|
@ -107,10 +107,10 @@ EDA_ITEM* EDA_ITEM::Clone() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart,
|
SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart,
|
||||||
INSPECTOR* inspector,
|
INSPECTOR inspector,
|
||||||
const void* testData,
|
void* testData,
|
||||||
const KICAD_T scanTypes[] )
|
const KICAD_T scanTypes[] )
|
||||||
{
|
{
|
||||||
EDA_ITEM* p = listStart;
|
EDA_ITEM* p = listStart;
|
||||||
|
|
||||||
|
@ -126,8 +126,7 @@ SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart,
|
||||||
|
|
||||||
// see base_struct.h
|
// see base_struct.h
|
||||||
// many classes inherit this method, be careful:
|
// many classes inherit this method, be careful:
|
||||||
SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||||
const KICAD_T scanTypes[] )
|
|
||||||
{
|
{
|
||||||
KICAD_T stype;
|
KICAD_T stype;
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR* inspector, const void* testData,
|
||||||
// If caller wants to inspect my type
|
// If caller wants to inspect my type
|
||||||
if( stype == Type() )
|
if( stype == Type() )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == inspector->Inspect( this, testData ) )
|
if( SEARCH_QUIT == inspector( this, testData ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -92,7 +92,7 @@ const KICAD_T LIB_COLLECTOR::RotatableItems[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT LIB_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
|
SEARCH_RESULT LIB_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
|
||||||
{
|
{
|
||||||
LIB_ITEM* item = (LIB_ITEM*) aItem;
|
LIB_ITEM* item = (LIB_ITEM*) aItem;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void LIB_COLLECTOR::Collect( LIB_ITEMS& aItems, const KICAD_T aFilterList[],
|
||||||
|
|
||||||
for( size_t i = 0; i < aItems.size(); i++ )
|
for( size_t i = 0; i < aItems.size(); i++ )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == aItems[i].Visit( this, NULL, m_ScanTypes ) )
|
if( SEARCH_QUIT == aItems[i].Visit( m_inspector, NULL, m_ScanTypes ) )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
* @return SEARCH_RESULT #SEARCH_QUIT if the iterator is to stop the scan,
|
* @return SEARCH_RESULT #SEARCH_QUIT if the iterator is to stop the scan,
|
||||||
* else #SEARCH_CONTINUE;
|
* else #SEARCH_CONTINUE;
|
||||||
*/
|
*/
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
|
SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Collect
|
* Function Collect
|
||||||
|
|
|
@ -93,7 +93,7 @@ class LIB_PIN : public LIB_ITEM
|
||||||
const TRANSFORM& aTransform );
|
const TRANSFORM& aTransform );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LIB_PIN( LIB_PART* aParent );
|
LIB_PIN( LIB_PART* aParent );
|
||||||
|
|
||||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ const KICAD_T SCH_COLLECTOR::OrientableItems[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
|
SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
||||||
{
|
{
|
||||||
if( aItem->Type() != LIB_PIN_T && !aItem->HitTest( m_RefPos ) )
|
if( aItem->Type() != LIB_PIN_T && !aItem->HitTest( m_RefPos ) )
|
||||||
return SEARCH_CONTINUE;
|
return SEARCH_CONTINUE;
|
||||||
|
@ -239,7 +239,7 @@ void SCH_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[],
|
||||||
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
||||||
SetRefPos( aPosition );
|
SetRefPos( aPosition );
|
||||||
|
|
||||||
EDA_ITEM::IterateForward( aItem, this, NULL, m_ScanTypes );
|
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ bool SCH_FIND_COLLECTOR::ReplaceItem( SCH_SHEET_PATH* aSheetPath )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
|
SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
||||||
{
|
{
|
||||||
wxPoint position;
|
wxPoint position;
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
|
||||||
if( aSheetPath )
|
if( aSheetPath )
|
||||||
{
|
{
|
||||||
m_sheetPath = aSheetPath;
|
m_sheetPath = aSheetPath;
|
||||||
EDA_ITEM::IterateForward( aSheetPath->LastDrawList(), this, NULL, m_ScanTypes );
|
EDA_ITEM::IterateForward( aSheetPath->LastDrawList(), m_inspector, NULL, m_ScanTypes );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -533,7 +533,7 @@ void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
|
||||||
for( unsigned i = 0; i < schematic.size(); i++ )
|
for( unsigned i = 0; i < schematic.size(); i++ )
|
||||||
{
|
{
|
||||||
m_sheetPath = &schematic[i];
|
m_sheetPath = &schematic[i];
|
||||||
EDA_ITEM::IterateForward( m_sheetPath->LastDrawList(), this, NULL, m_ScanTypes );
|
EDA_ITEM::IterateForward( m_sheetPath->LastDrawList(), m_inspector, NULL, m_ScanTypes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT SCH_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
|
SEARCH_RESULT SCH_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
|
||||||
{
|
{
|
||||||
// The Vist() function only visits the testItem if its type was in the
|
// The Vist() function only visits the testItem if its type was in the
|
||||||
// the scanList, so therefore we can collect anything given to us here.
|
// the scanList, so therefore we can collect anything given to us here.
|
||||||
|
@ -566,5 +566,5 @@ void SCH_TYPE_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[] )
|
||||||
|
|
||||||
SetScanTypes( aFilterList );
|
SetScanTypes( aFilterList );
|
||||||
|
|
||||||
EDA_ITEM::IterateForward( aItem, this, NULL, m_ScanTypes );
|
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
|
SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Collect
|
* Function Collect
|
||||||
|
@ -350,7 +350,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool ReplaceItem( SCH_SHEET_PATH* aSheetPath = NULL );
|
bool ReplaceItem( SCH_SHEET_PATH* aSheetPath = NULL );
|
||||||
|
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
|
SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the replace string without changing anything else.
|
* Update the replace string without changing anything else.
|
||||||
|
@ -392,7 +392,7 @@ public:
|
||||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||||
* else SCAN_CONTINUE;
|
* else SCAN_CONTINUE;
|
||||||
*/
|
*/
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, const void* testData );
|
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Collect
|
* Function Collect
|
||||||
|
|
|
@ -1812,7 +1812,7 @@ wxString SCH_COMPONENT::GetSelectMenuText() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData,
|
SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData,
|
||||||
const KICAD_T aFilterTypes[] )
|
const KICAD_T aFilterTypes[] )
|
||||||
{
|
{
|
||||||
KICAD_T stype;
|
KICAD_T stype;
|
||||||
|
@ -1822,7 +1822,7 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
|
||||||
// If caller wants to inspect component type or and component children types.
|
// If caller wants to inspect component type or and component children types.
|
||||||
if( stype == Type() )
|
if( stype == Type() )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( this, aTestData ) )
|
if( SEARCH_QUIT == aInspector( this, aTestData ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1832,23 +1832,23 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
|
||||||
// Test the bounding boxes of fields if they are visible and not empty.
|
// Test the bounding boxes of fields if they are visible and not empty.
|
||||||
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( ii ), (void*) this ) )
|
if( SEARCH_QUIT == aInspector( GetField( ii ), (void*) this ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCH_FIELD_LOCATE_REFERENCE_T:
|
case SCH_FIELD_LOCATE_REFERENCE_T:
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( REFERENCE ), (void*) this ) )
|
if( SEARCH_QUIT == aInspector( GetField( REFERENCE ), (void*) this ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCH_FIELD_LOCATE_VALUE_T:
|
case SCH_FIELD_LOCATE_VALUE_T:
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( VALUE ), (void*) this ) )
|
if( SEARCH_QUIT == aInspector( GetField( VALUE ), (void*) this ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCH_FIELD_LOCATE_FOOTPRINT_T:
|
case SCH_FIELD_LOCATE_FOOTPRINT_T:
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( FOOTPRINT ), (void*) this ) )
|
if( SEARCH_QUIT == aInspector( GetField( FOOTPRINT ), (void*) this ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1862,7 +1862,7 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
|
||||||
|
|
||||||
for( size_t i = 0; i < pins.size(); i++ )
|
for( size_t i = 0; i < pins.size(); i++ )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( pins[ i ], (void*) this ) )
|
if( SEARCH_QUIT == aInspector( pins[ i ], (void*) this ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,8 +512,7 @@ public:
|
||||||
|
|
||||||
void GetConnectionPoints( std::vector<wxPoint>& aPoints ) const;
|
void GetConnectionPoints( std::vector<wxPoint>& aPoints ) const;
|
||||||
|
|
||||||
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||||
const KICAD_T scanTypes[] );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetDrawItem().
|
* Function GetDrawItem().
|
||||||
|
|
|
@ -1042,8 +1042,7 @@ void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData,
|
SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICAD_T aFilterTypes[] )
|
||||||
const KICAD_T aFilterTypes[] )
|
|
||||||
{
|
{
|
||||||
KICAD_T stype;
|
KICAD_T stype;
|
||||||
|
|
||||||
|
@ -1052,7 +1051,7 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData,
|
||||||
// If caller wants to inspect my type
|
// If caller wants to inspect my type
|
||||||
if( stype == Type() )
|
if( stype == Type() )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( this, NULL ) )
|
if( SEARCH_QUIT == aInspector( this, NULL ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
}
|
}
|
||||||
else if( stype == SCH_SHEET_PIN_T )
|
else if( stype == SCH_SHEET_PIN_T )
|
||||||
|
@ -1060,7 +1059,7 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData,
|
||||||
// Test the sheet labels.
|
// Test the sheet labels.
|
||||||
for( size_t i = 0; i < m_pins.size(); i++ )
|
for( size_t i = 0; i < m_pins.size(); i++ )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == aInspector->Inspect( &m_pins[ i ], (void*) this ) )
|
if( SEARCH_QUIT == aInspector( &m_pins[ i ], this ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,8 +568,7 @@ public:
|
||||||
|
|
||||||
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const;
|
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const;
|
||||||
|
|
||||||
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||||
const KICAD_T scanTypes[] );
|
|
||||||
|
|
||||||
wxString GetSelectMenuText() const;
|
wxString GetSelectMenuText() const;
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <richio.h>
|
#include <richio.h>
|
||||||
#include <view/view_item.h>
|
#include <view/view_item.h>
|
||||||
#include <class_eda_rect.h>
|
#include <class_eda_rect.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
#include <iostream> // needed for Show()
|
#include <iostream> // needed for Show()
|
||||||
|
@ -83,35 +84,25 @@ class MSG_PANEL_ITEM;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class INSPECTOR
|
* Typedef INSPECTOR
|
||||||
* is an abstract class that is used to inspect and possibly collect the
|
* is used to inspect and possibly collect the
|
||||||
* (search) results of Iterating over a list or tree of KICAD_T objects.
|
* (search) results of Iterating over a list or tree of KICAD_T objects.
|
||||||
* Extend from this class and implement the Inspect function and provide for
|
* Provide an implementation as needed to inspect EDA_ITEMs visited via
|
||||||
* a way for the extension to collect the results of the search/scan data and
|
* the EDA_ITEM::Visit() and EDA_ITEM::IterateForward().
|
||||||
* provide them to the caller.
|
* <p>
|
||||||
|
* The lambda function is used within the EDA_ITEM::Iterate() function.
|
||||||
|
* It is used primarily for searching, but not limited to that. It can also
|
||||||
|
* collect or modify the scanned objects.
|
||||||
|
*
|
||||||
|
* @param aItem An EDA_ITEM to examine.
|
||||||
|
* @param aTestData is arbitrary data needed by the inspector to determine
|
||||||
|
* if the EDA_ITEM under test meets its match criteria.
|
||||||
|
* @return A #SEARCH_RESULT type #SEARCH_QUIT if the iterator function is to
|
||||||
|
* stop the scan, else #SEARCH_CONTINUE;
|
||||||
*/
|
*/
|
||||||
class INSPECTOR
|
typedef std::function< SEARCH_RESULT ( EDA_ITEM* aItem, void* aTestData ) > INSPECTOR_FUNC;
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~INSPECTOR()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
typedef const INSPECTOR_FUNC& INSPECTOR; /// std::function passed to nested users by ref, avoids copying std::function
|
||||||
/**
|
|
||||||
* Function Inspect
|
|
||||||
* is the examining function within the INSPECTOR which is passed to the
|
|
||||||
* EDA_ITEM::Iterate() function. It is used primarily for searching, but
|
|
||||||
* not limited to that. It can also collect or modify the scanned objects.
|
|
||||||
*
|
|
||||||
* @param aItem An EDA_ITEM to examine.
|
|
||||||
* @param aTestData is arbitrary data needed by the inspector to determine
|
|
||||||
* if the EDA_ITEM under test meets its match criteria.
|
|
||||||
* @return A #SEARCH_RESULT type #SEARCH_QUIT if the iterator function is to
|
|
||||||
* stop the scan, else #SEARCH_CONTINUE;
|
|
||||||
*/
|
|
||||||
virtual SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// These define are used for the .m_Flags and .m_UndoRedoStatus member of the
|
// These define are used for the .m_Flags and .m_UndoRedoStatus member of the
|
||||||
|
@ -359,10 +350,10 @@ public:
|
||||||
* @return SEARCH_RESULT SEARCH_QUIT if the called INSPECTOR returned
|
* @return SEARCH_RESULT SEARCH_QUIT if the called INSPECTOR returned
|
||||||
* SEARCH_QUIT, else SCAN_CONTINUE;
|
* SEARCH_QUIT, else SCAN_CONTINUE;
|
||||||
*/
|
*/
|
||||||
static SEARCH_RESULT IterateForward( EDA_ITEM* listStart,
|
static SEARCH_RESULT IterateForward( EDA_ITEM* listStart,
|
||||||
INSPECTOR* inspector,
|
INSPECTOR inspector,
|
||||||
const void* testData,
|
void* testData,
|
||||||
const KICAD_T scanTypes[] );
|
const KICAD_T scanTypes[] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Visit
|
* Function Visit
|
||||||
|
@ -378,8 +369,7 @@ public:
|
||||||
* @return SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan,
|
* @return SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan,
|
||||||
* else SCAN_CONTINUE, and determined by the inspector.
|
* else SCAN_CONTINUE, and determined by the inspector.
|
||||||
*/
|
*/
|
||||||
virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
virtual SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] );
|
||||||
const KICAD_T scanTypes[] );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetClass
|
* Function GetClass
|
||||||
|
|
|
@ -52,9 +52,11 @@ class EDA_ITEM;
|
||||||
* Later, after collection, the user can iterate through all the objects
|
* Later, after collection, the user can iterate through all the objects
|
||||||
* in the remembered collection using GetCount() and the [int] operator.
|
* in the remembered collection using GetCount() and the [int] operator.
|
||||||
*/
|
*/
|
||||||
class COLLECTOR : public INSPECTOR
|
class COLLECTOR
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
INSPECTOR_FUNC m_inspector;
|
||||||
|
|
||||||
/// Which object types to scan
|
/// Which object types to scan
|
||||||
const KICAD_T* m_ScanTypes;
|
const KICAD_T* m_ScanTypes;
|
||||||
|
|
||||||
|
@ -71,7 +73,9 @@ protected:
|
||||||
time_t m_TimeAtCollection;
|
time_t m_TimeAtCollection;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
COLLECTOR()
|
COLLECTOR() :
|
||||||
|
// Inspect() is virtual so calling it from a class common inspector preserves polymorphism.
|
||||||
|
m_inspector( [=] ( EDA_ITEM* aItem, void* aTestData ) { return Inspect( aItem, aTestData ); } )
|
||||||
{
|
{
|
||||||
m_ScanTypes = 0;
|
m_ScanTypes = 0;
|
||||||
m_TimeAtCollection = 0;
|
m_TimeAtCollection = 0;
|
||||||
|
@ -79,6 +83,8 @@ public:
|
||||||
|
|
||||||
virtual ~COLLECTOR() {}
|
virtual ~COLLECTOR() {}
|
||||||
|
|
||||||
|
virtual SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function IsValidIndex
|
* Function IsValidIndex
|
||||||
* tests if \a aIndex is with the limits of the list of collected items.
|
* tests if \a aIndex is with the limits of the list of collected items.
|
||||||
|
@ -276,8 +282,7 @@ public:
|
||||||
Empty(); // empty the collection
|
Empty(); // empty the collection
|
||||||
|
|
||||||
// visit the board with the INSPECTOR (me).
|
// visit the board with the INSPECTOR (me).
|
||||||
container->Visit( this, // INSPECTOR* inspector
|
container->Visit( inspector, &aRefPos,
|
||||||
NULL, // const void* testData,
|
|
||||||
m_ScanTypes);
|
m_ScanTypes);
|
||||||
SetTimeNow(); // when it was taken
|
SetTimeNow(); // when it was taken
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,21 +146,6 @@ void BOARD::SetPosition( const wxPoint& aPos )
|
||||||
|
|
||||||
void BOARD::Move( const wxPoint& aMoveVector ) // overload
|
void BOARD::Move( const wxPoint& aMoveVector ) // overload
|
||||||
{
|
{
|
||||||
// Implement 'interface INSPECTOR' which is only INSPECTOR::Inspect(),
|
|
||||||
// here it does the moving.
|
|
||||||
struct MOVER : public INSPECTOR
|
|
||||||
{
|
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* item, const void* data )
|
|
||||||
{
|
|
||||||
BOARD_ITEM* brd_item = (BOARD_ITEM*) item;
|
|
||||||
const wxPoint* vector = (const wxPoint*) data;
|
|
||||||
|
|
||||||
brd_item->Move( *vector );
|
|
||||||
|
|
||||||
return SEARCH_CONTINUE;
|
|
||||||
}
|
|
||||||
} inspector;
|
|
||||||
|
|
||||||
// @todo : anything like this elsewhere? maybe put into GENERAL_COLLECTOR class.
|
// @todo : anything like this elsewhere? maybe put into GENERAL_COLLECTOR class.
|
||||||
static const KICAD_T top_level_board_stuff[] = {
|
static const KICAD_T top_level_board_stuff[] = {
|
||||||
PCB_MARKER_T,
|
PCB_MARKER_T,
|
||||||
|
@ -177,20 +162,25 @@ void BOARD::Move( const wxPoint& aMoveVector ) // overload
|
||||||
EOT
|
EOT
|
||||||
};
|
};
|
||||||
|
|
||||||
// visit this BOARD with the above inspector, which moves all items.
|
INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
|
||||||
Visit( &inspector, &aMoveVector, top_level_board_stuff );
|
{
|
||||||
|
BOARD_ITEM* brd_item = (BOARD_ITEM*) item;
|
||||||
|
|
||||||
|
// aMoveVector was snapshotted, don't need "data".
|
||||||
|
brd_item->Move( aMoveVector );
|
||||||
|
|
||||||
|
return SEARCH_CONTINUE;
|
||||||
|
};
|
||||||
|
|
||||||
|
Visit( inspector, NULL, top_level_board_stuff );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerMask, TRACK_PTRS* aList )
|
void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACK_PTRS* aList )
|
||||||
{
|
{
|
||||||
TRACK* segment; // The current segment being analyzed.
|
LSET layer_set = aLayerSet;
|
||||||
TRACK* via; // The via identified, eventually destroy
|
|
||||||
TRACK* candidate; // The end segment to destroy (or NULL = segment)
|
|
||||||
int NbSegm;
|
|
||||||
LSET layer_set = aLayerMask;
|
|
||||||
|
|
||||||
if( !m_Track )
|
if( !m_Track ) // no tracks at all in board
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Set the BUSY flag of all connected segments, first search starting at
|
/* Set the BUSY flag of all connected segments, first search starting at
|
||||||
|
@ -218,7 +208,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerMask, TRAC
|
||||||
* is found we do not know at this time the number of connected items
|
* is found we do not know at this time the number of connected items
|
||||||
* and we do not know if this via is on the track or finish the track
|
* and we do not know if this via is on the track or finish the track
|
||||||
*/
|
*/
|
||||||
via = m_Track->GetVia( NULL, aPosition, layer_set );
|
TRACK* via = m_Track->GetVia( NULL, aPosition, layer_set );
|
||||||
|
|
||||||
if( via )
|
if( via )
|
||||||
{
|
{
|
||||||
|
@ -227,14 +217,15 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerMask, TRAC
|
||||||
aList->push_back( via );
|
aList->push_back( via );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we search all segments connected to point aPosition
|
int seg_count = 0;
|
||||||
* if only 1 segment: this segment is candidate
|
TRACK* candidate = NULL;
|
||||||
|
|
||||||
|
/* Search all segments connected to point aPosition.
|
||||||
|
* if only 1 segment at aPosition: then this segment is "candidate"
|
||||||
* if > 1 segment:
|
* if > 1 segment:
|
||||||
* end of track (more than 2 segment connected at this location)
|
* then end of "track" (because more than 2 segments are connected at aPosition)
|
||||||
*/
|
*/
|
||||||
segment = m_Track;
|
TRACK* segment = m_Track;
|
||||||
candidate = NULL;
|
|
||||||
NbSegm = 0;
|
|
||||||
|
|
||||||
while( ( segment = ::GetTrack( segment, NULL, aPosition, layer_set ) ) != NULL )
|
while( ( segment = ::GetTrack( segment, NULL, aPosition, layer_set ) ) != NULL )
|
||||||
{
|
{
|
||||||
|
@ -244,20 +235,18 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerMask, TRAC
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( segment == via ) // just previously found: skip it
|
if( segment == via ) // just previously found: skip it
|
||||||
{
|
{
|
||||||
segment = segment->Next();
|
segment = segment->Next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
NbSegm++;
|
if( ++seg_count == 1 ) // if first connected item: then segment is candidate
|
||||||
|
|
||||||
if( NbSegm == 1 ) // First time we found a connected item: segment is candidate
|
|
||||||
{
|
{
|
||||||
candidate = segment;
|
candidate = segment;
|
||||||
segment = segment->Next();
|
segment = segment->Next();
|
||||||
}
|
}
|
||||||
else // More than 1 segment connected -> this location is an end of the track
|
else // More than 1 segment connected -> location is end of track
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -502,15 +491,15 @@ LSET BOARD::GetVisibleLayers() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BOARD::SetEnabledLayers( LSET aLayerMask )
|
void BOARD::SetEnabledLayers( LSET aLayerSet )
|
||||||
{
|
{
|
||||||
m_designSettings.SetEnabledLayers( aLayerMask );
|
m_designSettings.SetEnabledLayers( aLayerSet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BOARD::SetVisibleLayers( LSET aLayerMask )
|
void BOARD::SetVisibleLayers( LSET aLayerSet )
|
||||||
{
|
{
|
||||||
m_designSettings.SetVisibleLayers( aLayerMask );
|
m_designSettings.SetVisibleLayers( aLayerSet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -793,7 +782,6 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_MODULE_T:
|
case PCB_MODULE_T:
|
||||||
|
@ -990,8 +978,7 @@ void BOARD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
||||||
|
|
||||||
|
|
||||||
// virtual, see pcbstruct.h
|
// virtual, see pcbstruct.h
|
||||||
SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||||
const KICAD_T scanTypes[] )
|
|
||||||
{
|
{
|
||||||
KICAD_T stype;
|
KICAD_T stype;
|
||||||
SEARCH_RESULT result = SEARCH_CONTINUE;
|
SEARCH_RESULT result = SEARCH_CONTINUE;
|
||||||
|
@ -1009,7 +996,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
|
||||||
switch( stype )
|
switch( stype )
|
||||||
{
|
{
|
||||||
case PCB_T:
|
case PCB_T:
|
||||||
result = inspector->Inspect( this, testData ); // inspect me
|
result = inspector( this, testData ); // inspect me
|
||||||
// skip over any types handled in the above call.
|
// skip over any types handled in the above call.
|
||||||
++p;
|
++p;
|
||||||
break;
|
break;
|
||||||
|
@ -1173,86 +1160,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* now using PcbGeneralLocateAndDisplay(), but this remains a useful example
|
|
||||||
* of how the INSPECTOR can be used in a lightweight way.
|
|
||||||
* // see pcbstruct.h
|
|
||||||
* BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, LAYER_NUM layer )
|
|
||||||
* {
|
|
||||||
* class PadOrModule : public INSPECTOR
|
|
||||||
* {
|
|
||||||
* public:
|
|
||||||
* BOARD_ITEM* found;
|
|
||||||
* LAYER_NUM layer;
|
|
||||||
* int layer_mask;
|
|
||||||
*
|
|
||||||
* PadOrModule( LAYER_NUM alayer ) :
|
|
||||||
* found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] )
|
|
||||||
* {}
|
|
||||||
*
|
|
||||||
* SEARCH_RESULT Inspect( EDA_ITEM* testItem, const void* testData
|
|
||||||
* )
|
|
||||||
* {
|
|
||||||
* BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
|
||||||
* const wxPoint& refPos = *(const wxPoint*) testData;
|
|
||||||
*
|
|
||||||
* if( item->Type() == PCB_PAD_T )
|
|
||||||
* {
|
|
||||||
* D_PAD* pad = (D_PAD*) item;
|
|
||||||
* if( pad->HitTest( refPos ) )
|
|
||||||
* {
|
|
||||||
* if( layer_mask & pad->GetLayerSet() )
|
|
||||||
* {
|
|
||||||
* found = item;
|
|
||||||
* return SEARCH_QUIT;
|
|
||||||
* }
|
|
||||||
* else if( !found )
|
|
||||||
* {
|
|
||||||
* MODULE* parent = (MODULE*) pad->m_Parent;
|
|
||||||
* if( IsModuleLayerVisible( parent->GetLayer() ) )
|
|
||||||
* found = item;
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* else if( item->Type() == PCB_MODULE_T )
|
|
||||||
* {
|
|
||||||
* MODULE* module = (MODULE*) item;
|
|
||||||
*
|
|
||||||
* // consider only visible modules
|
|
||||||
* if( IsModuleLayerVisible( module->GetLayer() ) )
|
|
||||||
* {
|
|
||||||
* if( module->HitTest( refPos ) )
|
|
||||||
* {
|
|
||||||
* if( layer == module->GetLayer() )
|
|
||||||
* {
|
|
||||||
* found = item;
|
|
||||||
* return SEARCH_QUIT;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // layer mismatch, save in case we don't find a
|
|
||||||
* // future layer match hit.
|
|
||||||
* if( !found )
|
|
||||||
* found = item;
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* return SEARCH_CONTINUE;
|
|
||||||
* }
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* PadOrModule inspector( layer );
|
|
||||||
*
|
|
||||||
* // search only for PADs first, then MODULES, and preferably a layer match
|
|
||||||
* static const KICAD_T scanTypes[] = { PCB_PAD_T, PCB_MODULE_T, EOT };
|
|
||||||
*
|
|
||||||
* // visit this BOARD with the above inspector
|
|
||||||
* Visit( &inspector, &refPos, scanTypes );
|
|
||||||
*
|
|
||||||
* return inspector.found;
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
|
NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
|
||||||
{
|
{
|
||||||
// the first valid netcode is 1 and the last is m_NetInfo.GetCount()-1.
|
// the first valid netcode is 1 and the last is m_NetInfo.GetCount()-1.
|
||||||
|
@ -1276,36 +1183,29 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
|
||||||
|
|
||||||
MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
|
MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
|
||||||
{
|
{
|
||||||
struct FINDER : public INSPECTOR
|
MODULE* found = nullptr;
|
||||||
{
|
|
||||||
MODULE* found;
|
|
||||||
|
|
||||||
FINDER() : found( 0 ) {}
|
|
||||||
|
|
||||||
// implement interface INSPECTOR
|
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* item, const void* data )
|
|
||||||
{
|
|
||||||
MODULE* module = (MODULE*) item;
|
|
||||||
const wxString& ref = *(const wxString*) data;
|
|
||||||
|
|
||||||
if( ref == module->GetReference() )
|
|
||||||
{
|
|
||||||
found = module;
|
|
||||||
return SEARCH_QUIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SEARCH_CONTINUE;
|
|
||||||
}
|
|
||||||
} inspector;
|
|
||||||
|
|
||||||
// search only for MODULES
|
// search only for MODULES
|
||||||
static const KICAD_T scanTypes[] = { PCB_MODULE_T, EOT };
|
static const KICAD_T scanTypes[] = { PCB_MODULE_T, EOT };
|
||||||
|
|
||||||
|
INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
|
||||||
|
{
|
||||||
|
MODULE* module = (MODULE*) item;
|
||||||
|
|
||||||
|
if( aReference == module->GetReference() )
|
||||||
|
{
|
||||||
|
found = module;
|
||||||
|
return SEARCH_QUIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SEARCH_CONTINUE;
|
||||||
|
};
|
||||||
|
|
||||||
// visit this BOARD with the above inspector
|
// visit this BOARD with the above inspector
|
||||||
BOARD* nonconstMe = (BOARD*) this;
|
BOARD* nonconstMe = (BOARD*) this;
|
||||||
nonconstMe->Visit( &inspector, &aReference, scanTypes );
|
nonconstMe->Visit( inspector, NULL, scanTypes );
|
||||||
|
|
||||||
return inspector.found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1321,17 +1221,7 @@ MODULE* BOARD::FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeSt
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 0 // case independent compare, why?
|
|
||||||
for( MODULE* module = m_Modules; module; module = module->Next() )
|
|
||||||
{
|
|
||||||
if( aRefOrTimeStamp.CmpNoCase( module->GetReference() ) == 0 )
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return FindModuleByReference( aRefOrTimeStamp );
|
return FindModuleByReference( aRefOrTimeStamp );
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1495,14 +1385,14 @@ VIA* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_ID aLayer) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerMask )
|
D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet )
|
||||||
{
|
{
|
||||||
if( !aLayerMask.any() )
|
if( !aLayerSet.any() )
|
||||||
aLayerMask = LSET::AllCuMask();
|
aLayerSet = LSET::AllCuMask();
|
||||||
|
|
||||||
for( MODULE* module = m_Modules; module; module = module->Next() )
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
D_PAD* pad = module->GetPad( aPosition, aLayerMask );
|
D_PAD* pad = module->GetPad( aPosition, aLayerSet );
|
||||||
|
|
||||||
if( pad )
|
if( pad )
|
||||||
return pad;
|
return pad;
|
||||||
|
@ -1516,11 +1406,11 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
|
||||||
{
|
{
|
||||||
const wxPoint& aPosition = aTrace->GetEndPoint( aEndPoint );
|
const wxPoint& aPosition = aTrace->GetEndPoint( aEndPoint );
|
||||||
|
|
||||||
LSET aLayerMask( aTrace->GetLayer() );
|
LSET lset( aTrace->GetLayer() );
|
||||||
|
|
||||||
for( MODULE* module = m_Modules; module; module = module->Next() )
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
D_PAD* pad = module->GetPad( aPosition, aLayerMask );
|
D_PAD* pad = module->GetPad( aPosition, lset );
|
||||||
|
|
||||||
if( pad )
|
if( pad )
|
||||||
return pad;
|
return pad;
|
||||||
|
@ -1530,7 +1420,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerMask )
|
D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerSet )
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<GetPadCount(); ++i )
|
for( unsigned i=0; i<GetPadCount(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -1540,7 +1430,7 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerMask )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Pad found, it must be on the correct layer
|
// Pad found, it must be on the correct layer
|
||||||
if( ( pad->GetLayerSet() & aLayerMask ).any() )
|
if( ( pad->GetLayerSet() & aLayerSet ).any() )
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1548,9 +1438,9 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerMask )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask )
|
D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerSet )
|
||||||
{
|
{
|
||||||
// Search the aPoint coordinates in aPadList
|
// Search aPadList for aPosition
|
||||||
// aPadList is sorted by X then Y values, and a fast binary search is used
|
// aPadList is sorted by X then Y values, and a fast binary search is used
|
||||||
int idxmax = aPadList.size()-1;
|
int idxmax = aPadList.size()-1;
|
||||||
|
|
||||||
|
@ -1572,7 +1462,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
|
||||||
if( pad->GetPosition() == aPosition ) // candidate found
|
if( pad->GetPosition() == aPosition ) // candidate found
|
||||||
{
|
{
|
||||||
// The pad must match the layer mask:
|
// The pad must match the layer mask:
|
||||||
if( ( aLayerMask & pad->GetLayerSet() ).any() )
|
if( ( aLayerSet & pad->GetLayerSet() ).any() )
|
||||||
return pad;
|
return pad;
|
||||||
|
|
||||||
// More than one pad can be at aPosition
|
// More than one pad can be at aPosition
|
||||||
|
@ -1586,7 +1476,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
|
||||||
if( pad->GetPosition() != aPosition )
|
if( pad->GetPosition() != aPosition )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( (aLayerMask & pad->GetLayerSet()) != 0 )
|
if( ( aLayerSet & pad->GetLayerSet() ).any() )
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
// search previous
|
// search previous
|
||||||
|
@ -1597,7 +1487,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
|
||||||
if( pad->GetPosition() != aPosition )
|
if( pad->GetPosition() != aPosition )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( (aLayerMask & pad->GetLayerSet()) != 0 )
|
if( ( aLayerSet & pad->GetLayerSet() ).any() )
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1605,9 +1495,9 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pad->GetPosition().x == aPosition.x ) // Must search considering Y coordinate
|
if( pad->GetPosition().x == aPosition.x ) // Must search considering Y coordinate
|
||||||
{
|
{
|
||||||
if(pad->GetPosition().y < aPosition.y) // Must search after this item
|
if( pad->GetPosition().y < aPosition.y ) // Must search after this item
|
||||||
{
|
{
|
||||||
idx += delta;
|
idx += delta;
|
||||||
|
|
||||||
|
@ -1684,16 +1574,17 @@ void BOARD::PadDelete( D_PAD* aPad )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TRACK* BOARD::GetTrack( TRACK* aTrace, const wxPoint& aPosition,
|
TRACK* BOARD::GetVisibleTrack( TRACK* aStartingTrace, const wxPoint& aPosition,
|
||||||
LSET aLayerMask ) const
|
LSET aLayerSet ) const
|
||||||
{
|
{
|
||||||
for( TRACK* track = aTrace; track; track = track->Next() )
|
for( TRACK* track = aStartingTrace; track; track = track->Next() )
|
||||||
{
|
{
|
||||||
LAYER_ID layer = track->GetLayer();
|
LAYER_ID layer = track->GetLayer();
|
||||||
|
|
||||||
if( track->GetState( BUSY | IS_DELETED ) )
|
if( track->GetState( BUSY | IS_DELETED ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// track's layer is not visible
|
||||||
if( m_designSettings.IsLayerVisible( layer ) == false )
|
if( m_designSettings.IsLayerVisible( layer ) == false )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1704,8 +1595,8 @@ TRACK* BOARD::GetTrack( TRACK* aTrace, const wxPoint& aPosition,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !aLayerMask[layer] )
|
if( !aLayerSet[layer] )
|
||||||
continue; // Segments on different layers.
|
continue; // track's layer is not in aLayerSet
|
||||||
|
|
||||||
if( track->HitTest( aPosition ) )
|
if( track->HitTest( aPosition ) )
|
||||||
return track;
|
return track;
|
||||||
|
@ -1737,11 +1628,12 @@ static void dump_tracks( const char* aName, const TRACK_PTRS& aList )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
double* aTraceLength, double* aPadToDieLength,
|
double* aTraceLength, double* aPadToDieLength,
|
||||||
bool aReorder )
|
bool aReorder )
|
||||||
{
|
{
|
||||||
int NbSegmBusy;
|
|
||||||
TRACK_PTRS trackList;
|
TRACK_PTRS trackList;
|
||||||
|
|
||||||
if( aCount )
|
if( aCount )
|
||||||
|
@ -1894,15 +1786,15 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
* the NbSegmBusy-1 next items (NbSegmBusy when including firstTrack)
|
* the NbSegmBusy-1 next items (NbSegmBusy when including firstTrack)
|
||||||
* are the flagged segments
|
* are the flagged segments
|
||||||
*/
|
*/
|
||||||
NbSegmBusy = 0;
|
int busy_count = 0;
|
||||||
TRACK* firstTrack;
|
TRACK* firstTrack;
|
||||||
|
|
||||||
for( firstTrack = m_Track; firstTrack; firstTrack = firstTrack->Next() )
|
for( firstTrack = m_Track; firstTrack; firstTrack = firstTrack->Next() )
|
||||||
{
|
{
|
||||||
// Search for the first flagged BUSY segments
|
// Search for the first flagged BUSY segments
|
||||||
if( firstTrack->GetState( BUSY ) )
|
if( firstTrack->GetState( BUSY ) )
|
||||||
{
|
{
|
||||||
NbSegmBusy = 1;
|
busy_count = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1919,7 +1811,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
wxASSERT( list );
|
wxASSERT( list );
|
||||||
|
|
||||||
/* Rearrange the chain starting at firstTrack
|
/* Rearrange the chain starting at firstTrack
|
||||||
* All others flagged items are moved from their position to the end
|
* All other BUSY flagged items are moved from their position to the end
|
||||||
* of the flagged list
|
* of the flagged list
|
||||||
*/
|
*/
|
||||||
TRACK* next;
|
TRACK* next;
|
||||||
|
@ -1930,7 +1822,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
|
|
||||||
if( track->GetState( BUSY ) ) // move it!
|
if( track->GetState( BUSY ) ) // move it!
|
||||||
{
|
{
|
||||||
NbSegmBusy++;
|
busy_count++;
|
||||||
track->UnLink();
|
track->UnLink();
|
||||||
list->Insert( track, firstTrack->Next() );
|
list->Insert( track, firstTrack->Next() );
|
||||||
|
|
||||||
|
@ -1943,13 +1835,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
// that are on each end of the track, if any
|
// that are on each end of the track, if any
|
||||||
if( track->GetState( BEGIN_ONPAD ) )
|
if( track->GetState( BEGIN_ONPAD ) )
|
||||||
{
|
{
|
||||||
D_PAD * pad = (D_PAD *) track->start;
|
D_PAD* pad = (D_PAD *) track->start;
|
||||||
lenPadToDie += (double) pad->GetPadToDieLength();
|
lenPadToDie += (double) pad->GetPadToDieLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( track->GetState( END_ONPAD ) )
|
if( track->GetState( END_ONPAD ) )
|
||||||
{
|
{
|
||||||
D_PAD * pad = (D_PAD *) track->end;
|
D_PAD* pad = (D_PAD *) track->end;
|
||||||
lenPadToDie += (double) pad->GetPadToDieLength();
|
lenPadToDie += (double) pad->GetPadToDieLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1958,13 +1850,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
}
|
}
|
||||||
else if( aTraceLength )
|
else if( aTraceLength )
|
||||||
{
|
{
|
||||||
NbSegmBusy = 0;
|
busy_count = 0;
|
||||||
|
|
||||||
for( TRACK* track = firstTrack; track; track = track->Next() )
|
for( TRACK* track = firstTrack; track; track = track->Next() )
|
||||||
{
|
{
|
||||||
if( track->GetState( BUSY ) )
|
if( track->GetState( BUSY ) )
|
||||||
{
|
{
|
||||||
NbSegmBusy++;
|
busy_count++;
|
||||||
track->SetState( BUSY, false );
|
track->SetState( BUSY, false );
|
||||||
full_len += track->GetLength();
|
full_len += track->GetLength();
|
||||||
|
|
||||||
|
@ -1973,19 +1865,19 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
// that are on each end of the track, if any
|
// that are on each end of the track, if any
|
||||||
if( track->GetState( BEGIN_ONPAD ) )
|
if( track->GetState( BEGIN_ONPAD ) )
|
||||||
{
|
{
|
||||||
D_PAD * pad = (D_PAD *) track->start;
|
D_PAD* pad = (D_PAD *) track->start;
|
||||||
lenPadToDie += (double) pad->GetPadToDieLength();
|
lenPadToDie += (double) pad->GetPadToDieLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( track->GetState( END_ONPAD ) )
|
if( track->GetState( END_ONPAD ) )
|
||||||
{
|
{
|
||||||
D_PAD * pad = (D_PAD *) track->end;
|
D_PAD* pad = (D_PAD *) track->end;
|
||||||
lenPadToDie += (double) pad->GetPadToDieLength();
|
lenPadToDie += (double) pad->GetPadToDieLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG( printf( "%s: NbSegmBusy:%d\n", __func__, NbSegmBusy ); )
|
DBG( printf( "%s: busy_count:%d\n", __func__, busy_count ); )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aTraceLength )
|
if( aTraceLength )
|
||||||
|
@ -1995,7 +1887,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||||
*aPadToDieLength = lenPadToDie;
|
*aPadToDieLength = lenPadToDie;
|
||||||
|
|
||||||
if( aCount )
|
if( aCount )
|
||||||
*aCount = NbSegmBusy;
|
*aCount = busy_count;
|
||||||
|
|
||||||
return firstTrack;
|
return firstTrack;
|
||||||
}
|
}
|
||||||
|
@ -2070,21 +1962,21 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_ID aActiveLayer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LSET aLayerMask )
|
BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LSET aLayerSet )
|
||||||
{
|
{
|
||||||
for( MODULE* module = m_Modules; module; module = module->Next() )
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
D_PAD* pad = module->GetPad( aPosition, aLayerMask );
|
D_PAD* pad = module->GetPad( aPosition, aLayerSet );
|
||||||
|
|
||||||
if( pad )
|
if( pad )
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No pad has been located so check for a segment of the trace.
|
// No pad has been located so check for a segment of the trace.
|
||||||
TRACK* segment = ::GetTrack( m_Track, NULL, aPosition, aLayerMask );
|
TRACK* segment = ::GetTrack( m_Track, NULL, aPosition, aLayerSet );
|
||||||
|
|
||||||
if( segment == NULL )
|
if( !segment )
|
||||||
segment = GetTrack( m_Track, aPosition, aLayerMask );
|
segment = GetVisibleTrack( m_Track, aPosition, aLayerSet );
|
||||||
|
|
||||||
return segment;
|
return segment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -909,8 +909,7 @@ public:
|
||||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||||
* else SCAN_CONTINUE, and determined by the inspector.
|
* else SCAN_CONTINUE, and determined by the inspector.
|
||||||
*/
|
*/
|
||||||
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||||
const KICAD_T scanTypes[] );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function FindModuleByReference
|
* Function FindModuleByReference
|
||||||
|
@ -1300,17 +1299,19 @@ public:
|
||||||
void GetSortedPadListByXthenYCoord( std::vector<D_PAD*>& aVector, int aNetCode = -1 );
|
void GetSortedPadListByXthenYCoord( std::vector<D_PAD*>& aVector, int aNetCode = -1 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetTrack
|
* Function GetVisibleTrack
|
||||||
* find the segment of \a aTrace at \a aPosition on \a aLayer if \a Layer is visible.
|
* finds the neighboring visible segment of \a aTrace at \a aPosition that is
|
||||||
|
* on a layer in \a aLayerSet.
|
||||||
* Traces that are flagged as deleted or busy are ignored.
|
* Traces that are flagged as deleted or busy are ignored.
|
||||||
*
|
*
|
||||||
* @param aTrace A pointer to the TRACK object to search.
|
* @param aStartingTrace is the first TRACK to test, testing continues to end of m_Track list from
|
||||||
|
* this starting point.
|
||||||
* @param aPosition A wxPoint object containing the position to test.
|
* @param aPosition A wxPoint object containing the position to test.
|
||||||
* @param aLayerMask A layer or layers to mask the hit test. Use -1 to ignore
|
* @param aLayerSet A set of layers; returned TRACK must be on one of these.
|
||||||
* layer mask.
|
* May pass a full set to request any layer.
|
||||||
* @return A TRACK object pointer if found otherwise NULL.
|
* @return A TRACK object pointer if found otherwise NULL.
|
||||||
*/
|
*/
|
||||||
TRACK* GetTrack( TRACK* aTrace, const wxPoint& aPosition, LSET aLayerMask ) const;
|
TRACK* GetVisibleTrack( TRACK* aStartingTrace, const wxPoint& aPosition, LSET aLayerSet ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function MarkTrace
|
* Function MarkTrace
|
||||||
|
|
|
@ -761,8 +761,7 @@ void MODULE::Add3DModel( S3D_MASTER* a3DModel )
|
||||||
|
|
||||||
|
|
||||||
// see class_module.h
|
// see class_module.h
|
||||||
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT MODULE::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||||
const KICAD_T scanTypes[] )
|
|
||||||
{
|
{
|
||||||
KICAD_T stype;
|
KICAD_T stype;
|
||||||
SEARCH_RESULT result = SEARCH_CONTINUE;
|
SEARCH_RESULT result = SEARCH_CONTINUE;
|
||||||
|
@ -780,7 +779,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
|
||||||
switch( stype )
|
switch( stype )
|
||||||
{
|
{
|
||||||
case PCB_MODULE_T:
|
case PCB_MODULE_T:
|
||||||
result = inspector->Inspect( this, testData ); // inspect me
|
result = inspector( this, testData ); // inspect me
|
||||||
++p;
|
++p;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -790,12 +789,12 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_MODULE_TEXT_T:
|
case PCB_MODULE_TEXT_T:
|
||||||
result = inspector->Inspect( m_Reference, testData );
|
result = inspector( m_Reference, testData );
|
||||||
|
|
||||||
if( result == SEARCH_QUIT )
|
if( result == SEARCH_QUIT )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result = inspector->Inspect( m_Value, testData );
|
result = inspector( m_Value, testData );
|
||||||
|
|
||||||
if( result == SEARCH_QUIT )
|
if( result == SEARCH_QUIT )
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -531,8 +531,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void Add3DModel( S3D_MASTER* a3DModel );
|
void Add3DModel( S3D_MASTER* a3DModel );
|
||||||
|
|
||||||
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||||
const KICAD_T scanTypes[] );
|
|
||||||
|
|
||||||
wxString GetClass() const
|
wxString GetClass() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,24 +68,24 @@ static bool ShowClearance( DISPLAY_OPTIONS* aDisplOpts, const TRACK* aTrack )
|
||||||
TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
|
TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
|
||||||
const wxPoint& aPosition, LSET aLayerMask )
|
const wxPoint& aPosition, LSET aLayerMask )
|
||||||
{
|
{
|
||||||
for( TRACK *PtSegm = aStartTrace; PtSegm != NULL; PtSegm = PtSegm->Next() )
|
for( TRACK* seg = aStartTrace; seg; seg = seg->Next() )
|
||||||
{
|
{
|
||||||
if( PtSegm->GetState( IS_DELETED | BUSY ) == 0 )
|
if( seg->GetState( IS_DELETED | BUSY ) == 0 )
|
||||||
{
|
{
|
||||||
if( aPosition == PtSegm->GetStart() )
|
if( aPosition == seg->GetStart() )
|
||||||
{
|
{
|
||||||
if( ( aLayerMask & PtSegm->GetLayerSet() ).any() )
|
if( ( aLayerMask & seg->GetLayerSet() ).any() )
|
||||||
return PtSegm;
|
return seg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aPosition == PtSegm->GetEnd() )
|
if( aPosition == seg->GetEnd() )
|
||||||
{
|
{
|
||||||
if( ( aLayerMask & PtSegm->GetLayerSet() ).any() )
|
if( ( aLayerMask & seg->GetLayerSet() ).any() )
|
||||||
return PtSegm;
|
return seg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( PtSegm == aEndTrace )
|
if( seg == aEndTrace )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,15 +363,14 @@ void VIA::Flip( const wxPoint& aCentre )
|
||||||
|
|
||||||
|
|
||||||
// see class_track.h
|
// see class_track.h
|
||||||
SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||||
const KICAD_T scanTypes[] )
|
|
||||||
{
|
{
|
||||||
KICAD_T stype = *scanTypes;
|
KICAD_T stype = *scanTypes;
|
||||||
|
|
||||||
// If caller wants to inspect my type
|
// If caller wants to inspect my type
|
||||||
if( stype == Type() )
|
if( stype == Type() )
|
||||||
{
|
{
|
||||||
if( SEARCH_QUIT == inspector->Inspect( this, testData ) )
|
if( SEARCH_QUIT == inspector( this, testData ) )
|
||||||
return SEARCH_QUIT;
|
return SEARCH_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,7 +1364,7 @@ TRACK* TRACK::GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoi
|
||||||
|
|
||||||
while( nextSegment || previousSegment )
|
while( nextSegment || previousSegment )
|
||||||
{
|
{
|
||||||
// Terminate the search in the direction if the netcode mismatches
|
// Terminate the search in the direction if the netcode mis-matches
|
||||||
if( aSameNetOnly )
|
if( aSameNetOnly )
|
||||||
{
|
{
|
||||||
if( nextSegment && (nextSegment->GetNetCode() != GetNetCode()) )
|
if( nextSegment && (nextSegment->GetNetCode() != GetNetCode()) )
|
||||||
|
|
|
@ -215,9 +215,7 @@ public:
|
||||||
*/
|
*/
|
||||||
wxString ShowWidth() const;
|
wxString ShowWidth() const;
|
||||||
|
|
||||||
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||||
const KICAD_T scanTypes[] );
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool HitTest( const wxPoint& aPosition ) const;
|
virtual bool HitTest( const wxPoint& aPosition ) const;
|
||||||
|
|
||||||
|
@ -250,7 +248,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetTrack
|
* Function GetTrack
|
||||||
* return the trace segment connected to the segment at \a aEndPoint from \a
|
* returns the trace segment connected to the segment at \a aEndPoint from \a
|
||||||
* aStartTrace to \a aEndTrace.
|
* aStartTrace to \a aEndTrace.
|
||||||
*
|
*
|
||||||
* @param aStartTrace A pointer to the TRACK object to begin searching.
|
* @param aStartTrace A pointer to the TRACK object to begin searching.
|
||||||
|
|
|
@ -148,11 +148,11 @@ const KICAD_T GENERAL_COLLECTOR::Zones[] = {
|
||||||
* that it finds and does not do any displaying.
|
* that it finds and does not do any displaying.
|
||||||
*
|
*
|
||||||
* @param testItem An EDA_ITEM to examine.
|
* @param testItem An EDA_ITEM to examine.
|
||||||
* @param testData The const void* testData, not used here.
|
* @param testData not used here.
|
||||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||||
* else SCAN_CONTINUE;
|
* else SCAN_CONTINUE;
|
||||||
*/
|
*/
|
||||||
SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testData )
|
SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
||||||
MODULE* module = NULL;
|
MODULE* module = NULL;
|
||||||
|
@ -459,10 +459,7 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
||||||
// the Inspect() function.
|
// the Inspect() function.
|
||||||
SetRefPos( aRefPos );
|
SetRefPos( aRefPos );
|
||||||
|
|
||||||
// visit the board or module with the INSPECTOR (me).
|
aItem->Visit( m_inspector, NULL, m_ScanTypes );
|
||||||
aItem->Visit( this, // INSPECTOR* inspector
|
|
||||||
NULL, // const void* testData, not used here
|
|
||||||
m_ScanTypes );
|
|
||||||
|
|
||||||
SetTimeNow(); // when snapshot was taken
|
SetTimeNow(); // when snapshot was taken
|
||||||
|
|
||||||
|
@ -478,7 +475,7 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
||||||
|
|
||||||
|
|
||||||
// see collectors.h
|
// see collectors.h
|
||||||
SEARCH_RESULT PCB_TYPE_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testData )
|
SEARCH_RESULT PCB_TYPE_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||||
{
|
{
|
||||||
// The Vist() function only visits the testItem if its type was in the
|
// The Vist() function only visits the testItem if its type was in the
|
||||||
// the scanList, so therefore we can collect anything given to us here.
|
// the scanList, so therefore we can collect anything given to us here.
|
||||||
|
@ -492,10 +489,5 @@ void PCB_TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[]
|
||||||
{
|
{
|
||||||
Empty(); // empty any existing collection
|
Empty(); // empty any existing collection
|
||||||
|
|
||||||
// visit the board with the INSPECTOR (me).
|
aBoard->Visit( m_inspector, NULL, aScanList );
|
||||||
aBoard->Visit( this, // INSPECTOR* inspector
|
|
||||||
NULL, // const void* testData,
|
|
||||||
aScanList );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//EOF
|
|
||||||
|
|
|
@ -337,14 +337,12 @@ public:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetPrimaryCount
|
* Function GetPrimaryCount
|
||||||
* @return int - The number if items which met the primary search criteria
|
* @return int - The number if items which met the primary search criteria
|
||||||
*/
|
*/
|
||||||
int GetPrimaryCount() { return m_PrimaryLength; }
|
int GetPrimaryCount() { return m_PrimaryLength; }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Inspect
|
* Function Inspect
|
||||||
* is the examining function within the INSPECTOR which is passed to the
|
* is the examining function within the INSPECTOR which is passed to the
|
||||||
|
@ -355,8 +353,7 @@ public:
|
||||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||||
* else SCAN_CONTINUE;
|
* else SCAN_CONTINUE;
|
||||||
*/
|
*/
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, const void* testData );
|
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Collect
|
* Function Collect
|
||||||
|
@ -595,7 +592,6 @@ public:
|
||||||
*/
|
*/
|
||||||
class PCB_TYPE_COLLECTOR : public COLLECTOR
|
class PCB_TYPE_COLLECTOR : public COLLECTOR
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -612,7 +608,6 @@ public:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Inspect
|
* Function Inspect
|
||||||
* is the examining function within the INSPECTOR which is passed to the
|
* is the examining function within the INSPECTOR which is passed to the
|
||||||
|
@ -623,8 +618,7 @@ public:
|
||||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||||
* else SCAN_CONTINUE;
|
* else SCAN_CONTINUE;
|
||||||
*/
|
*/
|
||||||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, const void* testData );
|
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Collect
|
* Function Collect
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
* @return the parent track or via of this connected point,
|
* @return the parent track or via of this connected point,
|
||||||
* or null if the parent is a pad
|
* or null if the parent is a pad
|
||||||
*/
|
*/
|
||||||
TRACK * GetTrack() const
|
TRACK* GetTrack() const
|
||||||
{
|
{
|
||||||
return m_item->Type() != PCB_PAD_T ? (TRACK*) m_item : NULL ;
|
return m_item->Type() != PCB_PAD_T ? (TRACK*) m_item : NULL ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,9 +214,9 @@ bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize,
|
||||||
|
|
||||||
if( !currTrack )
|
if( !currTrack )
|
||||||
{
|
{
|
||||||
LSET layer_mask( layer );
|
LSET layers( layer );
|
||||||
|
|
||||||
TRACK* track = m_Pcb->GetTrack( m_Pcb->m_Track, pos, layer_mask );
|
TRACK* track = m_Pcb->GetVisibleTrack( m_Pcb->m_Track, pos, layers );
|
||||||
|
|
||||||
if( !track || track->Type() != PCB_TRACE_T )
|
if( !track || track->Type() != PCB_TRACE_T )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue